Public Shared Function SetScale(ByVal g As Graphics, ByVal gWidth As Single, ByVal gHeight As Single, _
ByVal Left As Double, ByVal Right As Double, ByVal Top As Double, ByVal Bottom As Double) As Double
g.ResetTransform()
' Scale so the viewport's width and height
' map to the Graphics object's width and height.
g.ScaleTransform(gWidth / (Right - Left), gHeight / (Bottom - Top))
' Translate (left_x, top_y) to the Graphics
' object's origin.
g.TranslateTransform(-Left, -Top)
'return the scale factor
m_ScaleFactor = (gWidth / (Right - Left))
Return m_ScaleFactor
End Function
Public Sub PlotText(ByRef g As Graphics, ByVal Label As String, ByVal Pos As PointF, _
ByVal Bearing As Single, ByVal TextLoc As TextLocationType)
Dim TextPos As PointF
Dim TextSize As SizeF = g.MeasureString(Label, LabelFont)
Dim MyFontFamily As New FontFamily(LabelFont.Name)
Dim MyGP As GraphicsPath
Dim Angle As Double
Dim NegTextWidth As Double = TextSize.Width * -1
Dim NegTextHeight As Double = TextSize.Height * -1
Dim OldSmoothingMode As SmoothingMode = g.SmoothingMode
Bearing = CorrectBearing(Bearing)
If LabelFont.Size < 5 Then Exit Sub
Angle = AngleToBearing(Bearing * DEGTORAD, vbRadOrDegsType.vbABTRadians) * m_RADTODEG
MyGP = New GraphicsPath(FillMode.Winding)
g.SmoothingMode = SmoothingMode.HighQuality
Dim MyRM As New Matrix(1, 0, 0, -1, 0, TextPos.Y * 2)
MyGP.AddString(Label, MyFontFamily, FontStyle.Regular, LabelFont.Size, TextPos, StringFormat.GenericDefault)
MyRM.RotateAt(-Angle, TextPos)
MyGP.Transform(MyRM)
g.FillPath(New SolidBrush(m_FontColour), MyGP)
g.SmoothingMode = OldSmoothingMode
End Sub