• pagelayoutControl中添加图元(VB)


    添加文本,图例,图形比例尺,文字比例尺

    Private Sub insertText_Click()

      Dim pActiveView As IActiveView

      Dim pGraphicsContainer As IGraphicsContainer

      Dim pTextElement As ITextElement, pTextSymbol As ITextSymbol, pColor As IColor

      Dim pElement As IElement, pEnvelope As IEnvelope

      Set pActiveView = pPageLayoutControl.ActiveView

      Set pGraphicsContainer = pPageLayoutControl.PageLayout

      Set pEnvelope = New Envelope

      pEnvelope.PutCoords 0, 0, 20.4, 50.4

      Set pTextElement = New TextElement

      Set pElement = pTextElement

      pElement.Geometry = pEnvelope

      pTextElement.Text = "My Map"

      Set pTextSymbol = New TextSymbol

      Set pColor = New RgbColor

      pColor.RGB = &H8000&

      pTextSymbol.Color = pColor

      pTextSymbol.size = 40

      pTextElement.Symbol = pTextSymbol

      pGraphicsContainer.AddElement pTextElement, 0

      pPageLayoutControl.ActiveView.PartialRefresh esriViewGraphics, Nothing, Nothing

    End Sub

    Private Sub insertLegend_Click()

      Dim pUid As UID, pEnvelope As IEnvelope, pMapSurround As IMapSurround

      Dim m_GraphicsContainer  As IGraphicsContainer, m_MapFrame As IMapFrame

      Dim m_MapSurroundFrame As IMapSurroundFrame, m_Element As IElement, m_TrackCancel As ITrackCancel

      Set pUid = New UID

      pUid.value = "esriCarto.legend"

      Set pEnvelope = New Envelope

      pEnvelope.PutCoords 1, 1, 3.4, 2.4

      Set m_GraphicsContainer = pPageLayoutControl.PageLayout

      Set m_MapFrame = m_GraphicsContainer.FindFrame(pPageLayoutControl.ActiveView.FocusMap)

      Set m_MapSurroundFrame = m_MapFrame.CreateSurroundFrame(pUid, pMapSurround)

      Set m_MapSurroundFrame.MapFrame = m_MapFrame

      m_MapSurroundFrame.MapSurround.name = "legend"

      Set m_Element = m_MapSurroundFrame

      m_Element.Geometry = pEnvelope

      m_Element.Activate pPageLayoutControl.ActiveView.screenDisplay

      Set m_TrackCancel = New CancelTracker

      m_Element.Draw pPageLayoutControl.ActiveView.screenDisplay, m_TrackCancel

      m_GraphicsContainer.AddElement m_Element, 0

      m_Element.Geometry = pEnvelope

      pPageLayoutControl.ActiveView.PartialRefresh esriViewDrawPhase.esriViewGraphics, Nothing, Nothing

    End Sub

    Private Sub insertScalebar_Click()

      Dim pEnvelope As IEnvelope, pMapSurround As IMapSurround

      Dim pStyleGalleryItem As IStyleGalleryItem

      Set pEnvelope = New Envelope

      pEnvelope.PutCoords 1, 1, 3.4, 2.4

      Set pStyleGalleryItem = bgFrmShowElementStyle.getItem(esriStyleClassScaleBars)

      Set pMapSurround = CreateMapSurround(pPageLayoutControl.PageLayout, _

                          pPageLayoutControl.ActiveView.FocusMap, _

                          "ScaleBar", pEnvelope, pPageLayoutControl.ActiveView, pStyleGalleryItem)

      pPageLayoutControl.ActiveView.PartialRefresh esriViewDrawPhase.esriViewGraphics, Nothing, Nothing

    End Sub

    Private Sub insertNorth_Click()

      Dim pEnvelope As IEnvelope, pMapSurround As IMapSurround

      Dim pStyleGalleryItem As IStyleGalleryItem

      Set pEnvelope = New Envelope

      pEnvelope.PutCoords 0.2, 0.2, 3, 3

      Set pStyleGalleryItem = bgFrmShowElementStyle.getItem(esriStyleClassNorthArrows)

      Set pMapSurround = CreateMapSurround(pPageLayoutControl.PageLayout, _

                           pPageLayoutControl.ActiveView.FocusMap, _

                           "NorthArrow", pEnvelope, pPageLayoutControl.ActiveView, pStyleGalleryItem)

      pPageLayoutControl.ActiveView.PartialRefresh esriViewDrawPhase.esriViewGraphics, Nothing, _ Nothing

    End Sub

    Private Sub insertScaleText_Click()

      Dim pEnvelope As IEnvelope, pMapSurround As IMapSurround

      dim pStyleGalleryItem As IStyleGalleryItem

      Set pEnvelope = New Envelope

      pEnvelope.PutCoords 1, 1, 3.4, 2.4

      Set pStyleGalleryItem = bgFrmShowElementStyle.getItem(esriStyleClassScaleTexts)

      Set pMapSurround = CreateMapSurround(pPageLayoutControl.PageLayout, _

                            pPageLayoutControl.ActiveView.FocusMap, _

                            "ScaleText", pEnvelope, pPageLayoutControl.ActiveView, pStyleGalleryItem)

      pPageLayoutControl.ActiveView.PartialRefresh esriViewDrawPhase.esriViewGraphics, Nothing, Nothing

    End Sub

    Private Function CreateMapSurround(m_PageLayout As IPageLayout, m_Map As IMap, _

                              name As String, m_Envelope As IEnvelope, m_ActiveView As IActiveView, _

                              m_styleGalleryItem As IStyleGalleryItem) As IMapSurround

      Dim m_GraphicsContainer  As IGraphicsContainer, m_MapFrame As IMapFrame

      Dim m_MapSurroundFrame As IMapSurroundFrame, m_Element As IElement

      dim m_TrackCancel As ITrackCancel

      Set m_GraphicsContainer = m_PageLayout

      Set m_MapFrame = m_GraphicsContainer.FindFrame(m_Map)

      Set m_MapSurroundFrame = New MapSurroundFrame

      Set m_MapSurroundFrame.MapFrame = m_MapFrame

      Set m_MapSurroundFrame.MapSurround = m_styleGalleryItem.Item

      m_MapSurroundFrame.MapSurround.name = name

      Set m_Element = m_MapSurroundFrame

      m_Element.Geometry = m_Envelope

      m_Element.Activate m_ActiveView.screenDisplay

      Set m_TrackCancel = New CancelTracker

      m_Element.Draw m_ActiveView.screenDisplay, m_TrackCancel

      m_GraphicsContainer.AddElement m_Element, 0

      m_Element.Geometry = m_Envelope

  • 相关阅读:
    Andrew Ng机器学习 五:Regularized Linear Regression and Bias v.s. Variance
    cadence时各种焊盘层的定义
    cadence 关于PCB封装的设计
    candence 关于焊盘的描述
    cadence 关于DRC设置
    cadence的关于封装层叠
    cadence 学习
    stm32的一些参数
    无刷电机的FOC理解
    wait()、notify、notifyAll()的使用
  • 原文地址:https://www.cnblogs.com/bluemaplestudio/p/1675164.html
Copyright © 2020-2023  润新知