http://www.gissky.net- GIS空间站

我要投稿 投稿指南 RSS订阅 网站资讯通告:
搜索: 您现在的位置: GIS空间站 >> 技术专栏 >> ArcGIS >> ArcObjects开发 >> 正文

AO在线上画注记

作者:未知    文章来源:未知    点击数:    更新时间:2007-9-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

Tags:AO 线 注记  
责任编辑:wzj3sstudio
  • 上一篇文章:
  • 下一篇文章:
  • 相关文章列表
    没有相关文章
    关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 中国地图