Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles _
MyBase.MouseDown
m_X = e.X
m_Y = e.Y
m_Drawing = True
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles _
MyBase.MouseMove
Dim i As Integer
Dim angle As Double
Dim dx1 As Integer
Dim dy1 As Integer
Dim dx2 As Integer
Dim dy2 As Integer
Dim x1 As Integer
Dim y1 As Integer
Dim x2 As Integer
Dim y2 As Integer
If Not m_Drawing Then Exit Sub
Dim gr As Graphics = Me.CreateGraphics()
gr.DrawLine(Pens.Black, m_X, m_Y, e.X, e.Y)
Select Case m_CurrentStyle
Case "Reflection X"
gr.DrawLine(Pens.Black, 2 * m_Cx - m_X, m_Y, 2 _
* m_Cx - e.X, e.Y)
Case "Reflection Y"
gr.DrawLine(Pens.Black, m_X, 2 * m_Cy - m_Y, _
e.X, 2 * m_Cy - e.Y)
Case "Reflection XY"
gr.DrawLine(Pens.Black, 2 * m_Cx - m_X, m_Y, 2 _
* m_Cx - e.X, e.Y)
gr.DrawLine(Pens.Black, m_X, 2 * m_Cy - m_Y, _
e.X, 2 * m_Cy - e.Y)
gr.DrawLine(Pens.Black, 2 * m_Cx - m_X, 2 * _
m_Cy - m_Y, 2 * m_Cx - e.X, 2 * m_Cy - e.Y)
Case "Rotation 2"
dx1 = m_X - m_Cx
dy1 = m_Y - m_Cy
dx2 = e.X - m_Cx
dy2 = e.Y - m_Cy
gr.DrawLine(Pens.Black, m_Cx - dx1, m_Cy - dy1, _
m_Cx - dx2, m_Cy - dy2)
Case "Rotation 4"
dx1 = m_X - m_Cx
dy1 = m_Y - m_Cy
dx2 = e.X - m_Cx
dy2 = e.Y - m_Cy
gr.DrawLine(Pens.Black, m_Cx - dx1, m_Cy - dy1, _
m_Cx - dx2, m_Cy - dy2)
gr.DrawLine(Pens.Black, m_Cx - dy1, m_Cy + dx1, _
m_Cx - dy2, m_Cy + dx2)
gr.DrawLine(Pens.Black, m_Cx + dy1, m_Cy - dx1, _
m_Cx + dy2, m_Cy - dx2)
Case "Rotation 8"
x1 = m_X
y1 = m_Y
x2 = e.X
y2 = e.Y
For i = 1 To 8
gr.DrawLine(Pens.Black, x1, y1, x2, y2)
RotatePointAround(m_Cx, m_Cy, PI / 4, x1, _
y1)
RotatePointAround(m_Cx, m_Cy, PI / 4, x2, _
y2)
Next i
Case "Rotation Other"
x1 = m_X
y1 = m_Y
x2 = e.X
y2 = e.Y
For i = 1 To CInt((2 * PI) / m_Angle)
gr.DrawLine(Pens.Black, x1, y1, x2, y2)
RotatePointAround(m_Cx, m_Cy, m_Angle, x1, _
y1)
RotatePointAround(m_Cx, m_Cy, m_Angle, x2, _
y2)
Next i
End Select
m_X = e.X
m_Y = e.Y
End Sub
Private Sub Form1_MouseUp(ByVal sender As Object, ByVal e _
As System.Windows.Forms.MouseEventArgs) Handles _
MyBase.MouseUp
m_Drawing = False
End Sub
|