ArcObjects Library Reference  

RoutingToolbar

About the StreetMap routing Sample

[C#]

RoutingToolbar.cs

using System;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.CATIDs;


namespace RoutingSample
{

	[Guid("802B4297-9F7E-438d-B8A8-CB62C9658301"),
	ComVisible(true),
	ClassInterface(ClassInterfaceType.None),
	ProgId("RoutingSample.RoutingToolbar")]
	public class RoutingToolbar : ESRI.ArcGIS.SystemUI.IToolBarDef
	{

	#region COM Registration Function(s)

		[ComRegisterFunction(), ComVisibleAttribute(false)]
		public static void RegisterFunction(Type registerType)
		{
			// Required for ArcGIS Component Category Registrar support
			ArcGISCategoryRegistration(registerType);
		}

		[ComUnregisterFunction(), ComVisibleAttribute(false)]
		public static void UnregisterFunction(Type registerType)
		{
			// Required for ArcGIS Component Category Registrar support
			ArcGISCategoryUnregistration(registerType);
		}

	#region ArcGIS Component Category Registrar generated code
		/// <summary>
		/// Required method for ArcGIS Component Category registration -
		/// Do not modify the contents of this method with the code editor.
		/// </summary>
		private static void ArcGISCategoryRegistration(Type registerType)
		{
			string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
			MxCommandBars.Register(regKey);

		}
		/// <summary>
		/// Required method for ArcGIS Component Category unregistration -
		/// Do not modify the contents of this method with the code editor.
		/// </summary>
		private static void ArcGISCategoryUnregistration(Type registerType)
		{
			string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
			MxCommandBars.Unregister(regKey);
		}

	#endregion
	#endregion

	#region Public Methods + Properties

		// A creatable COM class must have a Public Sub New() 
		// with no parameters, otherwise, the class will not be 
		// registered in the COM registry and cannot be created 
		// via CreateObject.
		public RoutingToolbar() : base()
		{
		}

		public string Caption
		{
			get
			{
				return "Routing Sample";
			}
		}

		public void GetItemInfo(int pos, ESRI.ArcGIS.SystemUI.IItemDef itemDef)
		{
			if (pos == 0)
			{
				itemDef.ID = "RoutingSample.RoutingCommand";
				itemDef.Group = false;
			}
		}

		public int ItemCount
		{
			get
			{
				return 1;
			}
		}

		public string Name
		{
			get
			{
				return "RoutingSampleCSharpCommand";
			}
		}

	#endregion

	}



} //end of root namespace
[Visual Basic .NET]

RoutingToolbar.vb

Imports ESRI.ArcGIS.ADF.CATIDs

Imports System.Runtime.InteropServices

<ComClass(RoutingToolbar.ClassId, RoutingToolbar.InterfaceId, RoutingToolbar.EventsId), _
 ProgId("RoutingSample.RoutingToolbar")> _
Public Class RoutingToolbar
	Implements ESRI.ArcGIS.SystemUI.IToolBarDef

#Region "COM GUIDs"
	' These  GUIDs provide the COM identity for this class 
	' and its COM interfaces. If you change them, existing 
	' clients will no longer be able to access the class.
	Public Const ClassId As String = "6052656e-3835-4713-81d0-a5ca5ff4c3ef"
	Public Const InterfaceId As String = "12a04071-5783-4fd4-9782-c6898dbd47b6"
	Public Const EventsId As String = "6ba5b87e-0930-4840-85f1-3214f3f808e9"
#End Region

#Region "COM Registration Function(s)"

	<ComRegisterFunction(), ComVisibleAttribute(False)> _
	Public Shared Sub RegisterFunction(ByVal registerType As Type)
		' Required for ArcGIS Component Category Registrar support
		ArcGISCategoryRegistration(registerType)
	End Sub

	<ComUnregisterFunction(), ComVisibleAttribute(False)> _
	Public Shared Sub UnregisterFunction(ByVal registerType As Type)
		' Required for ArcGIS Component Category Registrar support
		ArcGISCategoryUnregistration(registerType)
	End Sub

#Region "ArcGIS Component Category Registrar generated code"
	''' <summary>
	''' Required method for ArcGIS Component Category registration -
	''' Do not modify the contents of this method with the code editor.
	''' </summary>
	Private Shared Sub ArcGISCategoryRegistration(ByVal registerType As Type)
		Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
		MxCommandBars.Register(regKey)

	End Sub
	''' <summary>
	''' Required method for ArcGIS Component Category unregistration -
	''' Do not modify the contents of this method with the code editor.
	''' </summary>
	Private Shared Sub ArcGISCategoryUnregistration(ByVal registerType As Type)
		Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
		MxCommandBars.Unregister(regKey)
	End Sub

#End Region
#End Region

#Region "Public Methods and Properties"

	' A creatable COM class must have a Public Sub New() 
	' with no parameters, otherwise, the class will not be 
	' registered in the COM registry and cannot be created 
	' via CreateObject.
	Public Sub New()
		MyBase.New()
	End Sub

	Public ReadOnly Property Caption() As String Implements ESRI.ArcGIS.SystemUI.IToolBarDef.Caption
		Get
			Return "Routing Sample"
		End Get
	End Property

	Public Sub GetItemInfo(ByVal pos As Integer, ByVal itemDef As ESRI.ArcGIS.SystemUI.IItemDef) Implements ESRI.ArcGIS.SystemUI.IToolBarDef.GetItemInfo
		If pos = 0 Then
			itemDef.ID = "RoutingSample.RoutingCommand"
			itemDef.Group = False
		End If
	End Sub

	Public ReadOnly Property ItemCount() As Integer Implements ESRI.ArcGIS.SystemUI.IToolBarDef.ItemCount
		Get
			Return 1
		End Get
	End Property

	Public ReadOnly Property Name() As String Implements ESRI.ArcGIS.SystemUI.IToolBarDef.Name
		Get
			Return "RoutingSampleVBNetCommand"
		End Get
	End Property

#End Region

End Class