Public Class Form1
    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

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

    '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.
    Friend WithEvents canvas As WroxPaint.PaintCanvas
    Friend WithEvents paletteColor As WroxPaint.ColorPalette
    Friend WithEvents mnuMain As System.Windows.Forms.MainMenu
    Friend WithEvents mnuTools As System.Windows.Forms.MenuItem
    Friend WithEvents mnuToolsCircle As System.Windows.Forms.MenuItem
    Friend WithEvents mnuToolsHollowCircle As System.Windows.Forms.MenuItem
    Friend WithEvents dlgOpenBackground As System.Windows.Forms.OpenFileDialog
    Friend WithEvents mnuFile As System.Windows.Forms.MenuItem
    Friend WithEvents mnuFileOpenBackground As System.Windows.Forms.MenuItem
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.canvas = New WroxPaint.PaintCanvas()
        Me.paletteColor = New WroxPaint.ColorPalette()
        Me.mnuMain = New System.Windows.Forms.MainMenu()
        Me.mnuFile = New System.Windows.Forms.MenuItem()
        Me.mnuFileOpenBackground = New System.Windows.Forms.MenuItem()
        Me.mnuTools = New System.Windows.Forms.MenuItem()
        Me.mnuToolsCircle = New System.Windows.Forms.MenuItem()
        Me.mnuToolsHollowCircle = New System.Windows.Forms.MenuItem()
        Me.dlgOpenBackground = New System.Windows.Forms.OpenFileDialog()
        Me.SuspendLayout()
        '
        'canvas
        '
        Me.canvas.Anchor = (((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
                    Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right)
        Me.canvas.BackColor = System.Drawing.Color.White
        Me.canvas.Location = New System.Drawing.Point(4, -4)
        Me.canvas.Name = "canvas"
        Me.canvas.Size = New System.Drawing.Size(684, 356)
        Me.canvas.TabIndex = 0
        '
        'paletteColor
        '
        Me.paletteColor.Anchor = ((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left) _
                    Or System.Windows.Forms.AnchorStyles.Right)
        Me.paletteColor.AutoScroll = True
        Me.paletteColor.Location = New System.Drawing.Point(0, 356)
        Me.paletteColor.Name = "paletteColor"
        Me.paletteColor.Size = New System.Drawing.Size(688, 24)
        Me.paletteColor.TabIndex = 1
        '
        'mnuMain
        '
        Me.mnuMain.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.mnuTools})
        '
        'mnuFile
        '
        Me.mnuFile.Index = 0
        Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFileOpenBackground})
        Me.mnuFile.Text = "&File"
        '
        'mnuFileOpenBackground
        '
        Me.mnuFileOpenBackground.Index = 0
        Me.mnuFileOpenBackground.Text = "Open &Background Image"
        '
        'mnuTools
        '
        Me.mnuTools.Index = 1
        Me.mnuTools.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuToolsCircle, Me.mnuToolsHollowCircle})
        Me.mnuTools.Text = "&Tools"
        '
        'mnuToolsCircle
        '
        Me.mnuToolsCircle.Checked = True
        Me.mnuToolsCircle.Index = 0
        Me.mnuToolsCircle.Text = "&Circle"
        '
        'mnuToolsHollowCircle
        '
        Me.mnuToolsHollowCircle.Index = 1
        Me.mnuToolsHollowCircle.Text = "&Hollow Circle"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(688, 377)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.paletteColor, Me.canvas})
        Me.Menu = Me.mnuMain
        Me.Name = "Form1"
        Me.Text = "WroxPaint"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub paletteColor_LeftClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles paletteColor.LeftClick
        canvas.GraphicLeftColor = paletteColor.LeftColor
    End Sub

    Private Sub paletteColor_RightClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles paletteColor.RightClick
        canvas.GraphicRightColor = paletteColor.RightColor
    End Sub

    Private Sub mnuToolsCircle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuToolsCircle.Click
        ' set the tool...
        canvas.GraphicTool = PaintCanvas.GraphicTools.CirclePen

        ' update the menu...
        UpdateMenu()
    End Sub

    Private Sub mnuToolsHollowCircle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuToolsHollowCircle.Click
        ' set the tool...
        canvas.GraphicTool = PaintCanvas.GraphicTools.HollowCirclePen

        ' update the menu...
        UpdateMenu()

    End Sub

    ' UpdateMenu - update the menu...
    Private Function UpdateMenu()

        ' go through the menu items updating the check...
        If canvas.GraphicTool = PaintCanvas.GraphicTools.CirclePen Then
            mnuToolsCircle.Checked = True
        Else
            mnuToolsCircle.Checked = False
        End If
        If canvas.GraphicTool = PaintCanvas.GraphicTools.HollowCirclePen Then
            mnuToolsHollowCircle.Checked = True
        Else
            mnuToolsHollowCircle.Checked = False
        End If

    End Function

    Private Sub mnuFileOpenBackground_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuFileOpenBackground.Click
        OpenBackgroundImage()
    End Sub

    Public Sub OpenBackgroundImage()

        ' open the dialog...
        If dlgOpenBackground.ShowDialog() = DialogResult.OK Then

            ' create a new image that references the file...
            Dim backgroundImage As Image = _
               Image.FromFile(dlgOpenBackground.FileName)

            ' set the background...
            canvas.BackgroundImage = backgroundImage

        End If

    End Sub

End Class
