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

No comments: