I am not good at English, so hope you can understand my problem .
I want to ask why I need to add If mPoints.Count > 1 in the following program,?If I del this command,the program cannot be run.
And How can I draw the ellipse by more than one ? Now , I can only draw one ellipse and then stop.
Thx
Dim mPen As Pen = New Pen(Color.DarkBlue)
Dim mBrush As SolidBrush = New SolidBrush(Color.DarkBlue)
Dim z As Integer
Private mPoints As ArrayList = New ArrayList
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim graphicsObject As Graphics = e.Graphics
If mPoints.Count > 1 Then
Dim pointArray() As Point = mPoints.ToArray(mPoints(0).GetType())
If rd_points.Checked Then
graphicsObject.DrawEllipse(mPen, pointArray(z).X, pointArray(z).Y, 10, 10)
End If
End If
End Sub
Private Sub Panel1_mousedown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
mPoints.Add(New Point(e.X, e.Y))
Panel1.Invalidate()
End Sub
Private Sub cmd_clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_clear.Click
mPoints = New ArrayList
End Sub
Private Sub cmd_changecolor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_changecolor.Click
Dim colorBox As ColorDialog = New ColorDialog
Dim result As DialogResult = colorBox.ShowDialog()
If result = DialogResult.Cancel Then
Return
End If
mPen.Color = colorBox.Color
mBrush.Color = colorBox.Color
Panel1.Invalidate()
End Sub
Private Sub rd_fillpoints_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rd_fillpoints.CheckedChanged
Panel1.Invalidate()
End Sub
I want to ask why I need to add If mPoints.Count > 1 in the following program,?If I del this command,the program cannot be run.
And How can I draw the ellipse by more than one ? Now , I can only draw one ellipse and then stop.
Thx
Dim mPen As Pen = New Pen(Color.DarkBlue)
Dim mBrush As SolidBrush = New SolidBrush(Color.DarkBlue)
Dim z As Integer
Private mPoints As ArrayList = New ArrayList
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
Dim graphicsObject As Graphics = e.Graphics
If mPoints.Count > 1 Then
Dim pointArray() As Point = mPoints.ToArray(mPoints(0).GetType())
If rd_points.Checked Then
graphicsObject.DrawEllipse(mPen, pointArray(z).X, pointArray(z).Y, 10, 10)
End If
End If
End Sub
Private Sub Panel1_mousedown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown
mPoints.Add(New Point(e.X, e.Y))
Panel1.Invalidate()
End Sub
Private Sub cmd_clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_clear.Click
mPoints = New ArrayList
End Sub
Private Sub cmd_changecolor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmd_changecolor.Click
Dim colorBox As ColorDialog = New ColorDialog
Dim result As DialogResult = colorBox.ShowDialog()
If result = DialogResult.Cancel Then
Return
End If
mPen.Color = colorBox.Color
mBrush.Color = colorBox.Color
Panel1.Invalidate()
End Sub
Private Sub rd_fillpoints_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles rd_fillpoints.CheckedChanged
Panel1.Invalidate()
End Sub