Imports System.Drawing.Drawing2D

 

Public Class Form1

    Private Sub drawLine()

        Dim startPt As New Point(50, 30)

        Dim endPt As New Point(550, 230)

        Dim myGraphics As Graphics = Me.CreateGraphics()

        Dim myPen As New Pen(Color.Blue, 6)

        myPen.DashStyle = DashStyle.Dot

        myGraphics.DrawLine(myPen, startPt, endPt)

    End Sub

    Private Sub drawEllipse()

        Dim myGraphics As Graphics = Me.CreateGraphics()

        Dim myRectangle As New Rectangle(20, 20, 550, 200)

        Dim myPenEllipse As New Pen(Color.Red, 6)

        Dim foreColor As Color

        foreColor = Color.Cornsilk

        Dim myLinearGradientBrush As New LinearGradientBrush( _

        myRectangle, Color.DarkViolet, Color.Coral, LinearGradientMode.Horizontal)

        myGraphics.FillEllipse(myLinearGradientBrush, 20, 20, 550, 200)

    End Sub

    Private Sub drawPolygon()

        Dim myGraphics As Graphics = Me.CreateGraphics()

        Dim myPenPolygon As New Pen(Color.Goldenrod, 2)

        Dim myPointArray As Point() = _

   {New Point(20, 30), New Point(550, 60), New Point(450, 150), New Point(50, 175)}

        myGraphics.DrawPolygon(myPenPolygon, myPointArray)

    End Sub

    Private Sub drawBezier()

        Me.Refresh()

        Dim myGraphics As Graphics = Me.CreateGraphics()

        Dim myPen As New Pen(Color.Crimson, 6)

        myGraphics.DrawBezier(myPen, 25, 25, 300, 175, 550, 50, 450, 150)

 

    End Sub

    Private Sub drawPath()

        Dim myGraphicsPath As New GraphicsPath()

        Me.Refresh()

        Dim myGraphics As Graphics = Me.CreateGraphics()

        Dim myPointArray2 As Point() = { _

           New Point(30, 30), _

           New Point(40, 40), _

           New Point(90, 30)}

 

        Dim myFontFamily As New FontFamily("Calligraph421 BT")

        Dim myPointF As New PointF(50, 20)

        Dim myStringFormat As New StringFormat()

        Dim myPenPath As New Pen(Color.DarkViolet, 1)

 

        myGraphicsPath.AddArc(50, 50, 80, 50, -90, 180)

        myGraphicsPath.StartFigure()

        myGraphicsPath.AddCurve(myPointArray2)

        myGraphicsPath.AddString("Visual Basic .NET", myFontFamily, _

           0, 60, myPointF, myStringFormat)

        myGraphicsPath.AddPie(230, 10, 40, 40, 40, 110)

        myGraphics.DrawPath(myPenPath, myGraphicsPath)

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Me.Refresh()

        drawLine()

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Me.Refresh()

        drawEllipse()

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        Me.Refresh()

        drawPolygon()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Refresh()

        drawBezier()

    End Sub

 

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

        Me.Refresh()

        drawPath()

    End Sub

 

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

        Me.Refresh()

    End Sub

 

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

        Me.Close()

    End Sub

End Class