Private Sub AddBalloonCallout(ByVal activeView As IActiveView)
Dim pTextElement As ITextElement
Dim pElement As IElement
Dim pPoint As IPoint
Dim pCallout As ICallout
Dim pTextSymbol As IFormattedTextSymbol
Dim pGraphicsContainer As IGraphicsContainer
Dim midX As Double, midY As Double
'Create a new text element
pTextElement = New TextElement
pElement = CType(pTextElement, IElement) 'QI
pTextElement.Text = "Text callout" & vbCrLf & "In the middle of the screen"
'Position the new element on the active view's center point
midX = (activeView.Extent.XMax + activeView.Extent.XMin) / 2
midY = (activeView.Extent.YMax + activeView.Extent.YMin) / 2
pPoint = New Point
pPoint.PutCoords(midX, midY)
pElement.Geometry = pPoint
'Set the text element symbology to a default balloon callout
pTextSymbol = New TextSymbol
pCallout = New BalloonCallout
pTextSymbol.Background = CType(pCallout, ITextBackground)
'Use this formula to get a callout anchor point location
pPoint.PutCoords(midX - activeView.Extent.Width / 4, midY + activeView.Extent.Width / 20)
pCallout.AnchorPoint = pPoint
pTextElement.Symbol = pTextSymbol
'Add the element to the active view, either the focus Map or PageLayout
pGraphicsContainer = CType(activeView, IGraphicsContainer)
pGraphicsContainer.AddElement(pElement, 0)
pElement.Activate(activeView.ScreenDisplay)
'Flag the area of the new element for refreshing
activeView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, pElement, Nothing)
End Sub
Saturday, September 11, 2010
Balloon Callout i ArcGIS Engine.
Anpassat ett exempel i VBA dokumentationen "How to add balloon callout" så att den fungerar i ArcGIS Engine. Inga stora förändringar krävdes utan det räckte med att byta ut så att ActiveView inte hämtas via MxDocument utan MapControl. Bryter man dessutom ut ActiveView till att vara en inparameter så fungerar dessutom exemplet i både desktop och engine.
Friday, September 10, 2010
Skapat en kodsnutt för att fånga när ett lager till i ArcGIS Engine.
Skapat en kodsnutt för att fånga när ett lager läggs till i karta, samt ser till att det lager som ligger överst alltid ligger kvar överst i ArcGIS Engine.
Private activeViewEvents As ESRI.ArcGIS.Carto.IActiveViewEvents_Event
Private m_ActiveViewEventsItemAdded As ESRI.ArcGIS.Carto.IActiveViewEvents_ItemAddedEventHandler
Private Sub AddEventListenerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AddEventListenerToolStripMenuItem.Click
activeViewEvents = CType(axMapControl1.ActiveView.FocusMap, ESRI.ArcGIS.Carto.IActiveViewEvents_Event)
m_ActiveViewEventsItemAdded = New ESRI.ArcGIS.Carto.IActiveViewEvents_ItemAddedEventHandler(AddressOf OnActiveViewEventsItemAdded)
AddHandler CType(axMapControl1.ActiveView.FocusMap, ESRI.ArcGIS.Carto.IActiveViewEvents_Event).ItemAdded, m_ActiveViewEventsItemAdded
End Sub
Private Sub OnActiveViewEventsItemAdded()
'makes layer(1) always on top.
axMapControl1.ActiveView.FocusMap.MoveLayer(axMapControl1.ActiveView.FocusMap.Layer(0), 1)
End Sub
Subscribe to:
Posts (Atom)