Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim Width As Integer
Dim Height As Integer
Dim Ratio As Decimal
If ListBox1.SelectedIndex > -1 Then
If RadioButton1.Checked = True Then 'ZOOM 100%
Height = PictureArray(ListBox1.SelectedIndex).Height
Width = PictureArray(ListBox1.SelectedIndex).Width
PictureBox1.Height = PictureArray(ListBox1.SelectedIndex).Height
PictureBox1.Width = PictureArray(ListBox1.SelectedIndex).Width
Else 'ZOOM to Fit into Panel2
PictureBox1.Height = Panel2.Height
PictureBox1.Width = Panel2.Width
Ratio = PictureArray(ListBox1.SelectedIndex).width / PictureArray(ListBox1.SelectedIndex).height
If Ratio < (PictureBox1.Width / PictureBox1.Height) Then
Height = PictureBox1.Height
Width = PictureBox1.Width * Ratio
Else
Height = PictureBox1.Height / Ratio
Width = PictureBox1.Width
End If
End If
PictureBox1.Image = PictureArray(ListBox1.SelectedIndex).GetThumbnailImage(Width, Height, Nothing, Nothing)
PictureBox1.Tag = ListBox1.SelectedIndex
End If
End Sub