如何在PageLayout中添加点元素

将该实现过程写在控件的OnMouseDown事件下

Private Sub AxPageLayoutControl1_OnMouseDown(ByVal sender As Object, ByVal e As ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnMouseDownEvent) Handles AxPageLayoutControl1.OnMouseDown
        Dim pPageLayout As IPageLayout
        Dim pActiveView As IActiveView
        pPageLayout = Me.AxPageLayoutControl1.PageLayout
        '获取控件的PageLayout对象
        pActiveView = pPageLayout
        '新建一个点Point
        Dim pPt As IPoint
        pPt = New Point
        pPt.PutCoords(e.pageX, e.pageY)
        '产生一个Maker元素
        Dim pMarkerElement As IMarkerElement
        pMarkerElement = New MarkerElement
        '产生修饰Marker元素的symbol
        Dim pMarkerSymbol As ISimpleMarkerSymbol
        pMarkerSymbol = New SimpleMarkerSymbol
        '设置符号的颜色
        pMarkerSymbol.Color = getRGB(11, 200, 145)
        '设置符号大小
        pMarkerSymbol.Size = 2
        '设置符号类型
        pMarkerSymbol.Style = esriSimpleMarkerStyle.esriSMSDiamond

        Dim pElement As IElement
        pElement = pMarkerElement
        'QI,得到IElement接口对象,用于设置元素的Geometry
        pElement.Geometry = pPt
        pMarkerElement.Symbol = pMarkerSymbol

        Dim pGraphicsContainer As IGraphicsContainer
        pGraphicsContainer = pPageLayout
        '将元素添加到pPageLayout中
        pGraphicsContainer.AddElement(pMarkerElement, 0)
        pActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, Nothing, Nothing)
    End Sub
    Public Function getRGB(ByVal r As Integer, ByVal g As Integer, ByVal b As Integer) As IRgbColor
        Dim color As IRgbColor
        color = New RgbColor
        With color
            .Red = r
            .Green = g
            .Blue = b
        End With
        Return color
    End Function
End Class 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值