Public Class drawexpression

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

    Private Sub myp_PrintDocument() Handles myp.PrintDocument
        myp.NewPage()
        Dim ss As String
        ss = ".NET轻松打印控件5.3版新增了表达式绘图打印功能（ExpressiongDrawer组件），可以很方便对单变量（变量固定为x）表达式进行绘图，功能强大，使用方便"
        myp.DrawText(ss, New Font("宋体", 13))

        myp.NewRow(myp.LastDrawTextHeight)
        Dim myexpress As New VBprinter.ExpressionDrawer()
        Dim mycolor(0 To 100) As Color
        For i As Integer = 0 To 100
            mycolor(i) = Color.Black
        Next
        mycolor(0) = Color.Red
        mycolor(1) = Color.Green
        mycolor(2) = Color.Blue
        mycolor(3) = Color.Yellow
        mycolor(4) = Color.Black

        For i As Integer = 0 To ListBox1.Items.Count - 1

            myexpress.AddExpression(ListBox1.Items(i), mycolor(i))

        Next
        If CheckBox1.Checked = True Then
            myexpress.Grids = True
        Else
            myexpress.Grids = False
        End If
        If CheckBox2.Checked = True Then
            myexpress.GraphMode = VBprinter.GraphMode.Polar
        Else
            myexpress.GraphMode = VBprinter.GraphMode.Rectangular
        End If
        myexpress.PenWidth = NumericUpDown1.Value
        myexpress.ExpressionTextFont = New Font("黑体", 13)
        Dim myrect As New RectangleF(0, myp.Currenty, myp.PaperPrintWidth, myp.PaperPrintWidth)
        myp.DrawExpression(myexpress, myrect)
        myexpress.Dispose()
        myp.NewRow(myrect.Height)
        myp.DrawText("打印完表达式后，可以再接下去打印其他东西", New Font("黑体", 18), 1)
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        If ListBox1.SelectedIndex >= 0 Then
            ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If Trim(TextBox1.Text) <> "" Then
            ListBox1.Items.Add(TextBox1.Text)
            TextBox1.Text = ""
        End If
    End Sub

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
        TextBox1.Text = ListBox1.SelectedItem
    End Sub

    
End Class