'******************************************************************************** ' class_Text '******************************************************************************** Const PI = 3.14159265358979 Const P360 = PI * 2 Const P180 = PI Private Type My_ArcObjects IMxApplication As IMxApplication IScreenDisplay As IScreenDisplay IMxDocument As IMxDocument IActiveView As IActiveView IFontDisp As IFontDisp ITextsymbol As ITextsymbol IMap As IMap End Type Private Type My_Text Point As IPoint Just As String Text As String Angle As Double BaseScale As Double Size As Long End Type Dim P As My_Text Dim A As My_ArcObjects '========================================================================== ' Class_Initilize '========================================================================== Private Sub Class_Initialize() Set A.IMxDocument = ThisDocument Set A.IMxApplication = Application Set P.Point = New Point P.Just = "LL" P.Angle = 0 P.Text = "" P.Size = 12 P.BaseScale = 0 Set A.IFontDisp = New StdFont A.IFontDisp.name = "Arial" ' some value is required A.IFontDisp.Size = P.Size ' any value is required here Set A.ITextsymbol = New textSymbol A.ITextsymbol.Font = A.IFontDisp A.ITextsymbol.Size = P.Size A.ITextsymbol.Angle = P.Angle * 180 / PI A.ITextsymbol.RightToLeft = False A.ITextsymbol.VerticalAlignment = Me.VAlign() A.ITextsymbol.HorizontalAlignment = Me.Align() End Sub '========================================================================== ' Align '========================================================================== Public Property Get Align() As Variant Align = esriTextHorizontalAlignment.esriTHALeft If (Mid(P.Just, 2, 1) = "C") Then Align = esriTextHorizontalAlignment.esriTHACenter If (Mid(P.Just, 2, 1) = "R") Then Align = esriTextHorizontalAlignment.esriTHARight End Property '========================================================================== ' VAlign '========================================================================== Public Property Get VAlign() As Variant VAlign = esriTextVerticalAlignment.esriTVABaseline If (Mid(P.Just, 1, 1) = "C") Then VAlign = esriTextVerticalAlignment.esriTVACenter If (Mid(P.Just, 1, 1) = "T") Then VAlign = esriTextVerticalAlignment.esriTVATop End Property '========================================================================== ' Just '========================================================================== Public Property Get Just() As Variant Just = P.Just End Property Public Property Let Just(ByVal Value As Variant) Dim Temp P.Just = "LL" Temp = UCase(Trim(Value)) If (Temp = "LL") Then P.Just = "LL" If (Temp = "LC") Then P.Just = "LC" If (Temp = "LR") Then P.Just = "LR" If (Temp = "CL") Then P.Just = "CL" If (Temp = "CC") Then P.Just = "CC" If (Temp = "CR") Then P.Just = "CR" If (Temp = "UL") Then P.Just = "UL" If (Temp = "UC") Then P.Just = "UC" If (Temp = "UR") Then P.Just = "UR" A.ITextsymbol.VerticalAlignment = Me.VAlign() A.ITextsymbol.HorizontalAlignment = Me.Align() End Property '========================================================================== ' Point (Map Point) '========================================================================== Public Property Get Point() As IPoint Set Point = P.Point End Property Public Property Let Point(ByVal Value As IPoint) Set P.Point = Value End Property '========================================================================== ' SPoint (Screen Point) '========================================================================== Public Property Get SPoint() As IPoint Set A.IScreenDisplay = A.IMxDocument.ActiveView Set SPoint = A.IScreenDisplay.DisplayTransformation.ToMapPoint(P.Point.x, P.Point.y) End Property Public Property Let SPoint(ByVal Value As IPoint) Set A.IScreenDisplay = A.IMxDocument.ActiveView Set P.Point = A.IScreenDisplay.DisplayTransformation.FromMapPoint(Value.x, Value.y) End Property '========================================================================== ' Text '========================================================================== Public Property Get Text() As Variant Text = P.Text End Property Public Property Let Text(ByVal Value As Variant) P.Text = Value End Property '========================================================================== ' DrawScreen '========================================================================== Function DrawScreen() Dim MapScale As Double Dim Scl As Double Set A.IActiveView = A.IMxDocument.FocusMap Set A.IScreenDisplay = A.IActiveView.ScreenDisplay Set A.IMap = A.IActiveView.FocusMap If (P.BaseScale > 0) Then MapScale = A.IMap.MapScale Scl = MapScale / P.BaseScale A.ITextsymbol.Size = P.Size * Scl End If A.IScreenDisplay.StartDrawing A.IScreenDisplay.hDC, esriNoScreenCache A.IScreenDisplay.SetSymbol A.ITextsymbol A.IScreenDisplay.drawText P.Point, P.Text A.IScreenDisplay.FinishDrawing A.ITextsymbol.VerticalAlignment = Me.VAlign() A.ITextsymbol.HorizontalAlignment = Me.Align() End Function '========================================================================== ' Angle (Degrees) '========================================================================== Public Property Get Angle() As Variant Angle = P.Angle / 180 * PI End Property Public Property Let Angle(ByVal Value As Variant) P.Angle = Value A.ITextsymbol.Angle = P.Angle / PI * 180 End Property '========================================================================== ' BaseScale '========================================================================== Public Property Get BaseScale() As Variant BaseScale = P.BaseScale End Property Public Property Let BaseScale(ByVal Value As Variant) P.BaseScale = Value End Property '========================================================================== ' Size '========================================================================== Public Property Get Size() As Variant Size = P.Size End Property Public Property Let Size(ByVal Value As Variant) P.Size = Value End Property