ArcObjects Library Reference  


About the Custom selection extension Sample



using System;
using System.Collections.Generic;
using System.Text;

namespace SelectionSample
  public class ZoomToLayerMultiItem : ESRI.ArcGIS.Desktop.AddIns.MultiItem
    protected override void OnClick(Item item)
      ESRI.ArcGIS.Carto.ILayer layer = item.Tag as ESRI.ArcGIS.Carto.ILayer;
      ESRI.ArcGIS.Geometry.IEnvelope env = layer.AreaOfInterest;
      ArcMap.Document.ActiveView.Extent = env;

    protected override void OnPopup(ItemCollection items)
      ESRI.ArcGIS.Carto.IMap map = ArcMap.Document.FocusMap;
      for (int i = 0; i < map.LayerCount; i++)
        ESRI.ArcGIS.Carto.ILayer layer = map.get_Layer(i);
        Item item = new Item();
        item.Caption = layer.Name;
        item.Enabled = layer.Visible;
        item.Message = layer.Name;
        item.Tag = layer;

[Visual Basic .NET]


Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.Text

Imports My

Namespace SelectionSample
  Public Class ZoomToLayerMultiItem
	  Inherits ESRI.ArcGIS.Desktop.AddIns.MultiItem
	Protected Overrides Sub OnClick(ByVal item As Item)
	  Dim layer As ESRI.ArcGIS.Carto.ILayer = TryCast(item.Tag, ESRI.ArcGIS.Carto.ILayer)
	  Dim env As ESRI.ArcGIS.Geometry.IEnvelope = layer.AreaOfInterest
	  ArcMap.Document.ActiveView.Extent = env
	End Sub

	Protected Overrides Sub OnPopup(ByVal items As ItemCollection)
	  Dim map As ESRI.ArcGIS.Carto.IMap = ArcMap.Document.FocusMap
	  For i As Integer = 0 To map.LayerCount - 1
		Dim layer As ESRI.ArcGIS.Carto.ILayer = map.Layer(i)
		Dim item As New Item()
		item.Caption = layer.Name
		item.Enabled = layer.Visible
		item.Message = layer.Name
		item.Tag = layer
	  Next i
	End Sub
  End Class
End Namespace