Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows フォーム デザイナで生成されたコード "

    Public Sub New()
        MyBase.New()

        ' この呼び出しは Windows フォーム デザイナで必要です。
        InitializeComponent()

        ' InitializeComponent() 呼び出しの後に初期化を追加します。

    End Sub

    ' Form は、コンポーネント一覧に後処理を実行するために dispose をオーバーライドします。
    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

    ' Windows フォーム デザイナで必要です。
    Private components As System.ComponentModel.IContainer

    ' メモ : 以下のプロシージャは、Windows フォーム デザイナで必要です。
    'Windows フォーム デザイナを使って変更してください。  
    ' コード エディタを使って変更しないでください。
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents Button4 As System.Windows.Forms.Button
    Friend WithEvents Button5 As System.Windows.Forms.Button
    Friend WithEvents PictureBox2 As System.Windows.Forms.PictureBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.PictureBox1 = New System.Windows.Forms.PictureBox
        Me.Button1 = New System.Windows.Forms.Button
        Me.Button2 = New System.Windows.Forms.Button
        Me.Button3 = New System.Windows.Forms.Button
        Me.Button4 = New System.Windows.Forms.Button
        Me.Button5 = New System.Windows.Forms.Button
        Me.PictureBox2 = New System.Windows.Forms.PictureBox
        Me.SuspendLayout()
        '
        'PictureBox1
        '
        Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.PictureBox1.Location = New System.Drawing.Point(16, 8)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(504, 288)
        Me.PictureBox1.TabIndex = 0
        Me.PictureBox1.TabStop = False
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(24, 336)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(88, 40)
        Me.Button1.TabIndex = 1
        Me.Button1.Text = "枠線のみ"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(136, 336)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(88, 40)
        Me.Button2.TabIndex = 2
        Me.Button2.Text = "単色塗りつぶし"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(240, 336)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(80, 40)
        Me.Button3.TabIndex = 3
        Me.Button3.Text = "パターン塗りつぶし"
        '
        'Button4
        '
        Me.Button4.Location = New System.Drawing.Point(344, 336)
        Me.Button4.Name = "Button4"
        Me.Button4.Size = New System.Drawing.Size(80, 40)
        Me.Button4.TabIndex = 4
        Me.Button4.Text = "グラデーション塗りつぶし"
        '
        'Button5
        '
        Me.Button5.Location = New System.Drawing.Point(440, 336)
        Me.Button5.Name = "Button5"
        Me.Button5.Size = New System.Drawing.Size(96, 40)
        Me.Button5.TabIndex = 5
        Me.Button5.Text = "テクスチャ塗りつぶし"
        '
        'PictureBox2
        '
        Me.PictureBox2.Image = CType(resources.GetObject("PictureBox2.Image"), System.Drawing.Image)
        Me.PictureBox2.Location = New System.Drawing.Point(536, 208)
        Me.PictureBox2.Name = "PictureBox2"
        Me.PictureBox2.Size = New System.Drawing.Size(88, 72)
        Me.PictureBox2.TabIndex = 6
        Me.PictureBox2.TabStop = False
        Me.PictureBox2.Visible = False
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)
        Me.ClientSize = New System.Drawing.Size(552, 397)
        Me.Controls.Add(Me.PictureBox2)
        Me.Controls.Add(Me.Button5)
        Me.Controls.Add(Me.Button4)
        Me.Controls.Add(Me.Button3)
        Me.Controls.Add(Me.Button2)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.PictureBox1)
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim Pos As Byte
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Pos = 1
        Me.PictureBox1.Refresh()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Pos = 2
        Me.PictureBox1.Refresh()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Pos = 3
        Me.PictureBox1.Refresh()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Pos = 4
        Me.PictureBox1.Refresh()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Pos = 5
        Me.PictureBox1.Refresh()
    End Sub

    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
        Select Case Pos
            Case 1
                RectDraw(e)
            Case 2
                SolidRect(e)
            Case 3
                HatchRect(e)
            Case 4
                GradRect(e)
            Case 5
                TextureString(e)
        End Select

        Dim ret As Byte
        Select Case ret
            Case 1 To 100

            Case 1, 3, 5, 7, 9

            Case Is >= 100, Is <= 200

        End Select
    End Sub

    Private Sub RectDraw(ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim Newpen As New Pen(Color.Blue, 3)
        Dim Rect As New Rectangle(10, 10, 200, 200)

        e.Graphics.DrawRectangle(Newpen, Rect)
    End Sub

    Private Sub SolidRect(ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim Newpen As New Pen(Color.GreenYellow, 3)
        Dim Newbrush As New SolidBrush(Color.Plum)
        Dim Rect As New Rectangle(10, 10, 200, 200)

        e.Graphics.FillRectangle(Newbrush, Rect)
        e.Graphics.DrawRectangle(Newpen, Rect)
    End Sub

    Private Sub HatchRect(ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim Newpen As New Pen(Color.White, 3)
        Dim Rect As New Rectangle(10, 10, 200, 200)
        Dim Hbrush As New Drawing2D.HatchBrush( _
                                    Drawing2D.HatchStyle.Cross, _
                                    Color.HotPink, _
                                    Color.Indigo)

        e.Graphics.FillRectangle(Hbrush, Rect)
        e.Graphics.DrawRectangle(Newpen, Rect)

    End Sub

    Private Sub GradRect(ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim Newpen As New Pen(Color.Black)
        Dim Rect As New Rectangle(10, 10, 200, 200)
        Dim Gradbrush As New Drawing2D.LinearGradientBrush( _
                                       Rect, _
                                       Color.Blue, _
                                       Color.Cyan, _
                                       Drawing2D.LinearGradientMode.Vertical)

        Dim ShadowRect As New Rectangle(16, 16, 200, 200)
        Dim Shadowbrush As New SolidBrush(Color.DimGray)

        e.Graphics.FillRectangle(Shadowbrush, ShadowRect)
        e.Graphics.FillRectangle(Gradbrush, Rect)
        e.Graphics.DrawRectangle(Newpen, Rect)
    End Sub

    Private Sub TextureString(ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim fnt As New Font("arial", 70)
        Dim Img As New Bitmap("c:\花.bmp")
        Dim Texbrush As New TextureBrush(Img)

        e.Graphics.DrawString("Hello", fnt, Texbrush, 250, 10)
    End Sub

    Private Sub TextureString2(ByVal e As System.Windows.Forms.PaintEventArgs)
        Dim Rect As New Rectangle(10, 10, 200, 200)
        Dim fnt As New Font("arial", 70)
        Dim Img As Bitmap = Me.PictureBox2.Image
        Dim Texbrush As New TextureBrush(Img)

        e.Graphics.FillEllipse(Texbrush, Rect)
        e.Graphics.DrawString("Hello", fnt, Texbrush, 250, 10)
    End Sub
End Class
