Public Class Draw

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        myp.NewDoc()
        myp.NewPage()
        Dim mypen1 As New Pen(Color.Blue)
        Dim mypen2 As New Pen(Color.Red, 5)
        Dim mybrush1 As New SolidBrush(Color.Green)
        Dim mybrush2 As New System.Drawing.Drawing2D.LinearGradientBrush(New PointF(0, 0), New PointF(myp.PaperPrintWidth, myp.PaperPrintHeight), Color.Blue, Color.Red)
        Dim mypen3 As New Pen(mybrush2)
        mypen2.StartCap = Drawing2D.LineCap.ArrowAnchor
        myp.DrawLine(mypen1, 0, 0, myp.PaperPrintWidth / 2, 0)
        myp.DrawLine(mypen2, 0, 50, myp.PaperPrintWidth / 2, 50)
        myp.DrawLine(mypen3, 0, 150, myp.PaperPrintWidth / 2, 150)
        myp.EndDoc()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        myp.NewDoc()
        myp.NewPage()
        Dim mypen1 As New Pen(Color.Blue)
        Dim mypen2 As New Pen(Color.Red, 5)
        Dim mybrush1 As New SolidBrush(Color.Green)
        Dim mybrush2 As New System.Drawing.Drawing2D.LinearGradientBrush(New PointF(0, 0), New PointF(myp.PaperPrintWidth, myp.PaperPrintHeight), Color.Blue, Color.Red)
        Dim mypen3 As New Pen(mybrush2)
        mypen2.StartCap = Drawing2D.LineCap.ArrowAnchor
        myp.DrawRectangle(mypen1, 0, 0, myp.PaperPrintWidth / 2, myp.PaperPrintHeight / 6)
        myp.DrawFillRectangle(mybrush2, 0, myp.PaperPrintHeight / 5, myp.PaperPrintWidth / 2, myp.PaperPrintHeight / 4)
        myp.EndDoc()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        '画路径
        Dim mypath As New System.Drawing.Drawing2D.GraphicsPath()
        mypath = New System.Drawing.Drawing2D.GraphicsPath()
        Dim mybrush2 As New System.Drawing.Drawing2D.LinearGradientBrush(New PointF(0, 0), New PointF(myp.PaperPrintWidth, myp.PaperPrintHeight), Color.Blue, Color.Red)
        Dim mypen3 As New Pen(mybrush2)
        Dim mymatrix As New System.Drawing.Drawing2D.Matrix()
        mymatrix.RotateAt(45, New PointF(100 + 200 / 2, 150 + 500 / 2)) '旋转45度
        mypath.AddRectangle(New Rectangle(100, 150, 200, 500))
        mypath.AddLine(0, 80, 300, 80)
        mypath.Transform(mymatrix)
        mypath.AddEllipse(New RectangleF(100, 100, 200, 300))
        mypath.AddLine(0, 180, 300, 180)
   
        myp.NewDoc()
        myp.NewPage()
        myp.DrawPath(mypath, mypen3)
        myp.EndDoc()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        '画路径
        Dim mypath As New System.Drawing.Drawing2D.GraphicsPath()
        mypath = New System.Drawing.Drawing2D.GraphicsPath()
        Dim mybrush2 As New System.Drawing.Drawing2D.LinearGradientBrush(New PointF(0, 0), New PointF(myp.PaperPrintWidth, myp.PaperPrintHeight), Color.Blue, Color.Red)
        Dim mypen3 As New Pen(mybrush2)
        Dim mymatrix As New System.Drawing.Drawing2D.Matrix()
        mymatrix.RotateAt(45, New PointF(100 + 200 / 2, 150 + 500 / 2)) '旋转45度
        mypath.AddRectangle(New Rectangle(100, 150, 200, 500))
        mypath.AddLine(0, 80, 300, 80)
        mypath.Transform(mymatrix)
        mypath.AddEllipse(New RectangleF(100, 100, 200, 300))
        mypath.AddLine(0, 180, 300, 180)

        myp.NewDoc()
        myp.NewPage()
        myp.DrawFillPath(mypath, mybrush2, Drawing2D.LinearGradientMode.Horizontal)
        myp.EndDoc()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim mypen1 As New Pen(Color.Blue)
        Dim point1 As New PointF(50.0F, 50.0F)
        Dim point2 As New PointF(100.0F, 25.0F)
        Dim point3 As New PointF(200.0F, 5.0F)
        Dim point4 As New PointF(250.0F, 50.0F)
        Dim point5 As New PointF(300.0F, 100.0F)
        Dim point6 As New PointF(350.0F, 200.0F)
        Dim point7 As New PointF(250.0F, 250.0F)
        Dim curvePoints As PointF() = {point1, point2, point3, point4, _
        point5, point6, point7}

        myp.NewDoc()
        myp.NewPage()

        Dim offset As Integer = 2
        Dim numSegments As Integer = 4
        Dim tension As Single = 1.0F
        myp.DrawCurve(mypen1, curvePoints, offset, numSegments, tension)
        myp.EndDoc()
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Dim blackPen As New Pen(Color.Black, 3)
        Dim point1 As New PointF(50.0F, 50.0F)
        Dim point2 As New PointF(100.0F, 25.0F)
        Dim point3 As New PointF(200.0F, 5.0F)
        Dim point4 As New PointF(250.0F, 50.0F)
        Dim point5 As New PointF(300.0F, 100.0F)
        Dim point6 As New PointF(350.0F, 200.0F)
        Dim point7 As New PointF(250.0F, 250.0F)
        Dim curvePoints As PointF() = {point1, point2, point3, point4, point5, point6, point7}
        myp.NewDoc()
        myp.NewPage()
        myp.DrawPolygon(blackPen, curvePoints)
        myp.EndDoc()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Dim blackPen As New Pen(Color.Black, 3)

        Dim start As New PointF(100.0F, 100.0F)
        Dim control1 As New PointF(200.0F, 10.0F)
        Dim control2 As New PointF(350.0F, 50.0F)
        Dim end1 As New PointF(500.0F, 100.0F)
        Dim control3 As New PointF(600.0F, 150.0F)
        Dim control4 As New PointF(650.0F, 250.0F)
        Dim end2 As New PointF(500.0F, 300.0F)
        Dim bezierPoints As PointF() = {start, control1, control2, end1, control3, control4, end2}

        myp.NewDoc()
        myp.NewPage()
        myp.DrawBeziers(blackPen, bezierPoints)
        myp.EndDoc()
    End Sub
End Class