Hi,
I'm really new to graphics and I've struggled with this problem for weeks, and desperately need help.
I'm attempting to write a routine where I can place from one to six rectangles on a page, add drawings, dimensions etc into each rectangle, and print out the result.
The co-ordinates for the data in the rectangles are contained in a number of SQL tables.
One critical aspect to be considered is that the contents to be placed in a rectangle, must be able to be placed in any one of the six rectangles. With one set of data, this is not dificult, using TransformTranslate, however, as soon as I try to add a second rectagle and data, I keep getting a "Parameter is not valid" message. This message applies to ether the rectangle, or Transformation co-ordinates, or anything which has co-ordinates, whichever is first up in the code.
I've experimented with GraphicPaths, Regions, Containers and have not had any success. I am guessing the problem may be related to the Origin of the co-ordinates, but can't find any way to reset x=0 y = 0. If that is possible. And I really don't know if that could solve the problem.
My guess seems to be incorrect. I believe the following lines will reset the Origin to 0,0. and tried it without success.
e.ResetTransform()
e.TranslateTransform(0, 0)
I've posted a little of my code below. For a number of reasons, the Select Case works from the highest number, back to 1.
If I dont try to add data to the rectangles, all the rectangles perform as I want, showing up on the screen and printing OK. Add data, and it handles one lot correctly, then hits me with the error message.
Code:
Dim blackPen As New Pen(Color.Black, 2)
_dwgNo = _totalDrawings
Select Case _totalDrawings
Case Is = 1
' Draw rectangle in correct position
e.DrawRectangle(blackPen, 25, 140, 340, 275)
' Use TranslateTransform to place drawings etc in correct rectangle
Dim z1 As Single = 10 '_across
Dim d1 As Single = 100 '_down
e.TranslateTransform(z1, d1)
' Select drawing and dimensions co-ordinates, and text from tables and add to rectangle
If _dwgNo = 1 Then
DrawDetails(e)
End If
Case Is = 2
e.DrawRectangle(blackPen, 380, 140, 340, 275)
Dim z2 As Single = 355 '_across
Dim d2 As Single = 100 '_down
e.TranslateTransform(z2, d2)
' Select drawing and dimensions co-ordinates, and text from tables and add to rectangle
If _dwgNo = 2 Then
DrawDetails(e)
End If
Case Is = 3
e.DrawRectangle(blackPen, 735, 140, 340, 275)
Dim z3 As Single = 710 '_across
Dim d3 As Single = 100 '_down
e.TranslateTransform(z3, d3)
If _dwgNo = 3 Then
DrawDetails(e)
End If
Hope someone can help me, to preserve what sanity I still have. Any ideas or advice will be most welcome.
Tailor