Hi guys
I have run into a problem with rotation and resizing of a
rectangle. I am rotating around the x and y axis of the rectangle. When I
stretch the rectangle using the left handle the x and y is moved. This causes
the rectangle to move around the screen because the rotation point keeps changing.
I somehow need to rotate around a fixed point that will not be affected by
resizing at a rotation. I am just not sure what to do here. Any suggestions
would be really appreciated!
The code I am using to draw the rectangle is very straightforward.
<code>
Public Overrides Sub Draw(ByVal g As Graphics)
Me.Rectangle = Geometry.GetNormalizedRectanlge(Me.Rectangle)
Dim container As GraphicsContainer = g.BeginContainer()
' If object is being rotated
If Me.Rotation <> 0 Then
Dim m As Matrix = New Matrix
m.RotateAt(Me.Rotation, New PointF(Me.RotationPoint.X,
Me.RotationPoint.Y), MatrixOrder.Append)
g.Transform = m
End If
Select Case Me.FillType
Case FillType.OneColour
g.FillRectangle(New SolidBrush(Me.FillColour), Me.Rectangle)
Case FillType.TwoColour
Dim brush As New LinearGradientBrush(Me.Rectangle, Me.FillColour,
Me.FillColour2, Me.SelectedLinearGradientMode)
g.FillRectangle(brush, Me.Rectangle)
End Select
Dim pen As New pen(Me.LineColour, Me.LineWeight)
g.DrawRectangle(pen, Me.Rectangle)
pen.Dispose()
g.EndContainer(container)
End Sub
</code>