splaisance
Programmer
I am having a problem drawing custom button shapes at specified locations in my application. The app has a grid of 24 concentric circles. Then a set of rectangles (or button shapes) are to be drawn onto this grid but they need to be drawn at an angle. Here is the code I am using in the paint event:
oG.TranslateTransform(pnlGrid.Width / 2, pnlGrid.Height / 2)
*For Each wABtn In clsBtn
'Move the origin to the bottom right corner of button
oG.TranslateTransform(wABtn.gSize.Width, wABtn.gSize.Height)
'Rotate the graphics by mydegrees
oG.RotateTransform(45)
'Get a fresh array of original corner points of button
* pts = wABtn.gPts
'Transform array to match transformation done on graphics object
* oG.TransformPoints(CoordinateSpace.Page, CoordinateSpace.World, pts)
'Update bounds of button w/newly transformed corner(points)
* wABtn.gBounds = New GraphicsPath(pts,mRectanglePathPoints)
'Close the bounding rectangle
* wABtn.gBounds.CloseAllFigures()
'Use ControlPaint to render 3D button image w/ state
*ControlPaint.DrawButton(oG, myRect.X, myRect.Y, hldWidth, hldHeight, wABtn.State)
*Next
'Reset transformation so drawing resumes on normal coordinate space
*oG.ResetTransform()
'Draw bounds of each button
* For i As Integer = 0 To (clsBtn.Count - 1)
* oG.DrawPath(Pens.Aqua, clsBtn.Item(i).gBounds)
* Next
Definitions at top of form are:
Private mRectanglePathPoints As Byte() = New Byte() {PathPointType.Start, PathPointType.Line, PathPointType.Line, PathPointType.Line}
Dim clsBtn As ArrayList
Private oG As Graphics
Dim wABtn As myButton
Where myButton is a class which determines each item's location, size, button pressed state, bounds (which is defined as a GraphicsPath), and other data.
When I only have the statements which are starred (*) run then I get the correct button outline, but the buttons are drawn 'regular' as in to say not on an angle or anything. Yet when I use all of the above code, neither the outlines nor the buttons are in the correct places.
Can anyone help me figure out what is going wrong?
oG.TranslateTransform(pnlGrid.Width / 2, pnlGrid.Height / 2)
*For Each wABtn In clsBtn
'Move the origin to the bottom right corner of button
oG.TranslateTransform(wABtn.gSize.Width, wABtn.gSize.Height)
'Rotate the graphics by mydegrees
oG.RotateTransform(45)
'Get a fresh array of original corner points of button
* pts = wABtn.gPts
'Transform array to match transformation done on graphics object
* oG.TransformPoints(CoordinateSpace.Page, CoordinateSpace.World, pts)
'Update bounds of button w/newly transformed corner(points)
* wABtn.gBounds = New GraphicsPath(pts,mRectanglePathPoints)
'Close the bounding rectangle
* wABtn.gBounds.CloseAllFigures()
'Use ControlPaint to render 3D button image w/ state
*ControlPaint.DrawButton(oG, myRect.X, myRect.Y, hldWidth, hldHeight, wABtn.State)
*Next
'Reset transformation so drawing resumes on normal coordinate space
*oG.ResetTransform()
'Draw bounds of each button
* For i As Integer = 0 To (clsBtn.Count - 1)
* oG.DrawPath(Pens.Aqua, clsBtn.Item(i).gBounds)
* Next
Definitions at top of form are:
Private mRectanglePathPoints As Byte() = New Byte() {PathPointType.Start, PathPointType.Line, PathPointType.Line, PathPointType.Line}
Dim clsBtn As ArrayList
Private oG As Graphics
Dim wABtn As myButton
Where myButton is a class which determines each item's location, size, button pressed state, bounds (which is defined as a GraphicsPath), and other data.
When I only have the statements which are starred (*) run then I get the correct button outline, but the buttons are drawn 'regular' as in to say not on an angle or anything. Yet when I use all of the above code, neither the outlines nor the buttons are in the correct places.
Can anyone help me figure out what is going wrong?