I have a printing issue that I need help to resolve and a printing question. First, the question:
- What implications/limitations do I impose on myself (as programmer) and what must my program’s users endure by my setting GoView.ShowsNegativeCoordinates to false? I understand that users cannot specify negative coordinates, but what does that mean?
Now, for my printing issue…
- Currently, my program has a palette containing objects that users may drag out onto the canvas. One of those objects is a text box sub-classed from GoText. The text box displays a rectangle around the text with a margin (i.e., whitespace) between the text and the rectangle. I override GoText’s Paint and ExpandPaintBounds methods to draw an 4 pixel margin around the text before drawing the rectangle.
When a text box is printed using the goview.print method, the text’s margins are not equal on all sides (i.e., not 4 pixels). Specifically, it appears that the right and bottom margins increase substantially. For example, an 8 point font string “Text Box” will print with a 16-20 pixel margin both at the end of the text string and below the text string
(even though I’ve specified an 4 pixel margin all the way around the text). At larger point sizes, the right and bottom margins become quite large, causing the print to span pages, due to so much white space at the end of and below the text. Any idea what might be causing this issue? Below, I’m including the code for my overridden Paint and ExpandPaintBounds methods:
Public Overrides Sub Paint(ByVal g As System.Drawing.Graphics, ByVal view As Northwoods.Go.GoView) If Not (Me.HasBorder) Then MyBase.Paint(g, view) Return End If If (PaintGreek(g, view)) Then Return End If Dim r As RectangleF = Me.Bounds Dim borderpen As Pen = New Pen(Me.TextColor) Dim backgroundBrush As New SolidBrush(Me.BackgroundColor) GoShape.DrawRectangle(g, view, borderpen, backgroundBrush, r.X - 4, r.Y - 4, r.Width + 8, r.Height + 8) borderpen.Dispose() MyBase.Paint(g, view) End Sub Public Overrides Function ExpandPaintBounds(ByVal rect As System.Drawing.RectangleF, ByVal view As Northwoods.Go.GoView) As System.Drawing.RectangleF If Not (Me.HasBorder) Then Return MyBase.ExpandPaintBounds(rect, view) End If Dim r As RectangleF = MyBase.ExpandPaintBounds(rect, view) r.X -= 4 r.Width += 8 r.Y -= 4 r.Height += 8 Return r End Function
Thanks a lot for your help.