|
|
|
|

AO在线上画注记

Imports ESRI.ArcGIS.GeometryImports ESRI.ArcGIS.CartoImports ESRI.ArcGIS.MapControlImports ESRI.ArcGIS.DisplayOnAfterDraw:Dim pTextSymbol As ITextSymbol = New TextSymbolDim pFont As stdole.StdFontpFont = New stdole.StdFontpFont.Name = "A...

作者:未知来源:未知|2007年09月19日
Imports ESRI.ARCGIS.Geometry
Imports ESRI.ARCGIS.Carto
Imports ESRI.ARCGIS.MapControl
Imports ESRI.ARCGIS.Display

OnAfterDraw:

Dim pTextSymbol As ITextSymbol = New TextSymbol
Dim pFont As stdole.StdFont
pFont = New stdole.StdFont
pFont.Name = "Arial"
pFont.Bold = True
pFont.Size = 16
pTextSymbol.Font = pFont
pTextSymbol.HorizontalAlignment = esriTextHorizontalAlignment.esriTHAFull

Dim rgbcolor As IRgbColor = New RgbColor
rgbcolor.RGB = RGB(0, 0, 255)
pTextSymbol.Color = rgbcolor

Dim pTextPath As ITextPath
Dim pSimpleTextSymbol As ISimpleTextSymbol
'Create a text path and grab hold of the ITextPath interface
pTextPath = New BezierTextPath 'to spline the text
pSimpleTextSymbol = pTextSymbol 'Grab hold of the ISimpleTextSymbol interface through the ITextSymbol interface
pSimpleTextSymbol.TextPath = pTextPath 'Set the text path of the simple text symbol
'Draw the line object and spline the user text around the line
m_Line = rotatezj(m_Line) '文字位置的自适应调整
AxMapControl1.DrawText(m_Line, "ssfsfsfsfsfsf", pTextSymbol)

'当线的起点位于终点的右侧时,线将以相反方向重新绘制,确保文字自动显示在线的上方
Private Function rotatezj(ByVal line As Polyline) As Polyline
Try
Dim ilinetmp As IPolyline
Dim linetmp As Polyline = New Polyline
Dim pt0x, pt0y, pt1x, pt1y As Double
Dim pt0, pt1 As IPoint

If line Is Nothing Then Return line : Exit Try
If line.PointCount < 2 Then Return line : Exit Try

pt0 = line.Point(0)
pt1 = line.Point(line.PointCount - 1)
AxMapControl1.FromMapPoint(pt0, pt0x, pt0y)
AxMapControl1.FromMapPoint(pt1, pt1x, pt1y)

If pt0x < pt1x Then Return line : Exit Function
ilinetmp = linetmp
If pt0x > pt1x Then '需要转换
linetmp = New Polyline
Dim length As Integer = line.PointCount
For i As Integer = length - 1 To 0 Step -1
linetmp.AddPoint(line.Point(i))
Next
End If
Return linetmp
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function

上一篇:AO的Display对象简介

下一篇:ArcSDE批处理安装文件