If you are in the Paint event you can draw lines quite easily with g.drawline
Getting the Separator right solved the left margin.
Now the problem is the right side. If I remove padding then it right on the 20 unit inside, and if not it like 30 inside like the last image I posted. It also doesn’t matter if it’s padding*2 or not, as it is always 30 in.
g.DrawText(DisplayTextArea.Text, kMargin + padding , kMargin + padding , printwidth - padding )
I also tried subtracting padding from printwidth and got the same result.
Var printwidth as integer = g.width - leftmargin - rightmargin//- padding
Sorry. I just noticed the next word would push it over the edge.
Thank You, Tim H &
I got the rectangle around text to work. The code following is for the Paint Event in the DrawingCanvas control of the example CanvasDrawString project. I added in 3 DrawLines so I could tell where the borders are. I eliminated leftmargin, rightmargin, and Y1 in favor of the constant kMargin. I also figured out where TextAscent should be.
// clear the whole canvas
g.ClearRectangle(0, 0, DrawingCanvas.Width, DrawingCanvas.Height)
g.FontName = "Arial"
g.FontSize = 20
g.DrawingColor = Color.TextColor
Const kMargin = 20
Var w As Integer//width
Var h As Integer//height
Var padding as integer = 5
Var dcBox As DesktopUIControl = me
g.DrawLine( 0, 0, dcBox.Width, 0 )//Top
g.DrawLine( 0, 0, 0, dcBox.Height )//Left
g.DrawLine( dcBox.Width-1, 0, dcBox.Width-1, dcBox.Height )//Right
Var printWidth as integer = g.width - kMargin - kMargin - padding*2
// set the bold, italic, and underline properties
g.Bold = BoldCheck.Value
g.Underline = UnderlineCheck.Value
g.Italic = ItalicCheck.Value
w = min( printWidth, g.TextWidth(DisplayTextArea.Text) ) + padding*2
h = g.TextHeight(DisplayTextArea.Text, printWidth) + padding*2
g.DrawText( DisplayTextArea.Text, kMargin + padding , kMargin + padding + g.FontAscent , printWidth )
g.DrawRectangle( kMargin, kMargin, w, h )
Return