我想画第一个旋转的图形,而第二个旋转的图形。当我运行下面的代码时,它没有显示第一个数字,但旋转了第二个数字。重置无效。我需要保持数字顺序不变。
Private Sub Form17_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
Dim x, y As Integer
e.Graphics.SmoothingMode = SmoothingMode.HighQuality
'Figure 1
Dim Mx As Matrix = New Matrix()
x = 59 : y = 25
Mx.RotateAt(90, New Point(x, y), MatrixOrder.Append)
e.Graphics.Transform = Mx
e.Graphics.DrawEllipse(New Pen(Color.Green, 1), New Rectangle(x + 3, y - 5, 10, 10))
e.Graphics.DrawLine(New Pen(Color.Green, 1), x, y - 2, x + 13, y - 2)
e.Graphics.DrawLine(New Pen(Color.Green, 1), x, y + 2, x + 13, y + 2)
e.Graphics.DrawLine(New Pen(Color.Green, 1), x + 8, y - 5, x + 8, y + 5)
Mx.Reset()
'Figura 2
e.Graphics.DrawEllipse(New Pen(Color.Blue, 1), New Rectangle(x + 3, y - 5, 10, 10))
e.Graphics.DrawLine(New Pen(Color.Blue, 1), x, y - 2, x + 13, y - 2)
e.Graphics.DrawLine(New Pen(Color.Blue, 1), x, y + 2, x + 13, y + 2)
e.Graphics.DrawLine(New Pen(Color.Blue, 1), x + 8, y - 5, x + 8, y + 5)
End Sub
怎么了?
这两个数字相互重叠。重置后重新分配矩阵:
Mx.Reset()
e.Graphics.Transform = Mx ' <========