Option Explicit On 
Option Strict On

Public Class frmPlayground
  Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

  Public Sub New()
    MyBase.New()

    'This call is required by the Windows Form Designer.
    InitializeComponent()

    'Add any initialization after the InitializeComponent() call

  End Sub

  'Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
    If disposing Then
      If Not (components Is Nothing) Then
        components.Dispose()
      End If
    End If
    MyBase.Dispose(disposing)
  End Sub
  Friend WithEvents picNormal As System.Windows.Forms.PictureBox
  Friend WithEvents Label1 As System.Windows.Forms.Label
  Friend WithEvents picCenter As System.Windows.Forms.PictureBox
  Friend WithEvents Label2 As System.Windows.Forms.Label
  Friend WithEvents picStretch As System.Windows.Forms.PictureBox
  Friend WithEvents Label3 As System.Windows.Forms.Label
  Friend WithEvents picAuto As System.Windows.Forms.PictureBox
  Friend WithEvents Label4 As System.Windows.Forms.Label
  Friend WithEvents btnImage As System.Windows.Forms.Button
  Friend WithEvents dlgOpen As System.Windows.Forms.OpenFileDialog
  Friend WithEvents Label5 As System.Windows.Forms.Label
  Friend WithEvents lblSize As System.Windows.Forms.Label

  'Required by the Windows Form Designer
  Private components As System.ComponentModel.Container

  'NOTE: The following procedure is required by the Windows Form Designer
  'It can be modified using the Windows Form Designer.  
  'Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
    Me.Label1 = New System.Windows.Forms.Label()
    Me.Label2 = New System.Windows.Forms.Label()
    Me.Label3 = New System.Windows.Forms.Label()
    Me.picCenter = New System.Windows.Forms.PictureBox()
    Me.btnImage = New System.Windows.Forms.Button()
    Me.picNormal = New System.Windows.Forms.PictureBox()
    Me.picStretch = New System.Windows.Forms.PictureBox()
    Me.picAuto = New System.Windows.Forms.PictureBox()
    Me.dlgOpen = New System.Windows.Forms.OpenFileDialog()
    Me.Label4 = New System.Windows.Forms.Label()
    Me.Label5 = New System.Windows.Forms.Label()
    Me.lblSize = New System.Windows.Forms.Label()
    Me.SuspendLayout()
    '
    'Label1
    '
    Me.Label1.Location = New System.Drawing.Point(8, 8)
    Me.Label1.Name = "Label1"
    Me.Label1.Size = New System.Drawing.Size(88, 24)
    Me.Label1.TabIndex = 1
    Me.Label1.Text = "Normal:"
    '
    'Label2
    '
    Me.Label2.Location = New System.Drawing.Point(144, 8)
    Me.Label2.Name = "Label2"
    Me.Label2.Size = New System.Drawing.Size(88, 24)
    Me.Label2.TabIndex = 1
    Me.Label2.Text = "CenterImage:"
    '
    'Label3
    '
    Me.Label3.Location = New System.Drawing.Point(280, 8)
    Me.Label3.Name = "Label3"
    Me.Label3.Size = New System.Drawing.Size(88, 24)
    Me.Label3.TabIndex = 1
    Me.Label3.Text = "StretchImage:"
    '
    'picCenter
    '
    Me.picCenter.BackColor = System.Drawing.Color.White
    Me.picCenter.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    Me.picCenter.Location = New System.Drawing.Point(144, 24)
    Me.picCenter.Name = "picCenter"
    Me.picCenter.Size = New System.Drawing.Size(130, 138)
    Me.picCenter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage
    Me.picCenter.TabIndex = 0
    Me.picCenter.TabStop = False
    '
    'btnImage
    '
    Me.btnImage.Location = New System.Drawing.Point(296, 176)
    Me.btnImage.Name = "btnImage"
    Me.btnImage.Size = New System.Drawing.Size(104, 23)
    Me.btnImage.TabIndex = 2
    Me.btnImage.Text = "&Select Image"
    '
    'picNormal
    '
    Me.picNormal.BackColor = System.Drawing.Color.White
    Me.picNormal.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    Me.picNormal.Location = New System.Drawing.Point(8, 24)
    Me.picNormal.Name = "picNormal"
    Me.picNormal.Size = New System.Drawing.Size(128, 136)
    Me.picNormal.TabIndex = 0
    Me.picNormal.TabStop = False
    '
    'picStretch
    '
    Me.picStretch.BackColor = System.Drawing.Color.White
    Me.picStretch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    Me.picStretch.Location = New System.Drawing.Point(280, 24)
    Me.picStretch.Name = "picStretch"
    Me.picStretch.Size = New System.Drawing.Size(130, 138)
    Me.picStretch.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
    Me.picStretch.TabIndex = 0
    Me.picStretch.TabStop = False
    '
    'picAuto
    '
    Me.picAuto.BackColor = System.Drawing.Color.White
    Me.picAuto.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
    Me.picAuto.Location = New System.Drawing.Point(416, 24)
    Me.picAuto.Name = "picAuto"
    Me.picAuto.Size = New System.Drawing.Size(128, 136)
    Me.picAuto.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize
    Me.picAuto.TabIndex = 0
    Me.picAuto.TabStop = False
    '
    'dlgOpen
    '
    Me.dlgOpen.Filter = "Bitmaps (*.bmp)|*.bmp|Icons (*.ico)|*.ico|Metafiles (*.wmf)|*.wmf|JPEG (*.jpg)|*." & _
    "jpg|GIF (*.gif)|*.gif"
    Me.dlgOpen.Title = "Open Image File"
    '
    'Label4
    '
    Me.Label4.Location = New System.Drawing.Point(416, 8)
    Me.Label4.Name = "Label4"
    Me.Label4.Size = New System.Drawing.Size(88, 24)
    Me.Label4.TabIndex = 1
    Me.Label4.Text = "AutoSize:"
    '
    'Label5
    '
    Me.Label5.Location = New System.Drawing.Point(8, 176)
    Me.Label5.Name = "Label5"
    Me.Label5.Size = New System.Drawing.Size(80, 24)
    Me.Label5.TabIndex = 3
    Me.Label5.Text = "Size:"
    Me.Label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
    '
    'lblSize
    '
    Me.lblSize.BackColor = System.Drawing.Color.White
    Me.lblSize.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
    Me.lblSize.Location = New System.Drawing.Point(48, 176)
    Me.lblSize.Name = "lblSize"
    Me.lblSize.Size = New System.Drawing.Size(184, 24)
    Me.lblSize.TabIndex = 4
    Me.lblSize.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
    '
    'frmPlayground
    '
    Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
    Me.ClientSize = New System.Drawing.Size(552, 213)
    Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.lblSize, Me.Label5, Me.btnImage, Me.picAuto, Me.Label4, Me.picStretch, Me.Label3, Me.picCenter, Me.Label2, Me.picNormal, Me.Label1})
    Me.Name = "frmPlayground"
    Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
    Me.Text = "Picture Box Playground"
    Me.ResumeLayout(False)

  End Sub

#End Region
  Dim WSave As Integer, HSave As Integer
  Private Sub frmPlayground_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
    'start form in upper left corner
    Me.Left = 0
    Me.Top = 0
    'save form width/height for initialization
    WSave = Me.Width
    HSave = Me.Height
  End Sub


  Private Sub btnImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnImage.Click
    'reset autosize picture box and form to initial size
    picAuto.Width = picNormal.Width
    picAuto.Height = picNormal.Height
    Me.Width = WSave
    Me.Height = HSave
    'display open dialog box
    If dlgOpen.ShowDialog = DialogResult.OK Then
      picNormal.Image = Image.FromFile(dlgOpen.FileName)
      picCenter.Image = Image.FromFile(dlgOpen.FileName)
      picStretch.Image = Image.FromFile(dlgOpen.FileName)
      picAuto.Image = Image.FromFile(dlgOpen.FileName)
      lblSize.Text = Str(picAuto.Width) + " pixels x" + Str(picAuto.Height) + " pixels"
    End If
  End Sub
End Class
