ArcObjects Library Reference  

cmdNALayerProperties

About the Network Analyst Engine application Sample

[C#]

cmdNALayerProperties.cs

using System.Windows.Forms;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.NetworkAnalyst;
using ESRI.ArcGIS.Controls;


// This command brings up the property pages for the NALayer.

namespace NAEngine
{
	[Guid("04B67C95-96DD-4afe-AF62-942255ACBA71")]
	[ClassInterface(ClassInterfaceType.None)]
	[ProgId("NAEngine.NALayerProperties")]
	public sealed class cmdNALayerProperties : BaseCommand
	{
		private IMapControl3 m_mapControl;

		public cmdNALayerProperties()
		{
			base.m_caption = "Properties...";
		}

		public override void OnClick()
		{
			// Show the Property Page form for the NALayer

			// Get the NALayer that was right-clicked on in the table of contents
			// m_MapControl.CustomProperty was set in frmMain.axTOCControl1_OnMouseDown
			INALayer naLayer = (INALayer)m_mapControl.CustomProperty;
			frmNALayerProperties props = new frmNALayerProperties();
			if (props.ShowModal(naLayer))
			{
				// Notify the ActiveView that the contents have changed so the TOC and NAWindow know to refresh themselves.
				m_mapControl.ActiveView.ContentsChanged();
			}
		}

		public override void OnCreate(object hook)
		{
			m_mapControl = (IMapControl3)hook;
		}
	}
}

[Visual Basic .NET]

cmdNALayerProperties.vb

Imports Microsoft.VisualBasic
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
Imports ESRI.ArcGIS.ADF.BaseClasses
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.NetworkAnalyst
Imports ESRI.ArcGIS.Controls


' This command brings up the property pages for the NALayer.

Namespace NAEngine
	<Guid("FC17F05F-D614-40d4-B5B7-071FB7062D99"), ClassInterface(ClassInterfaceType.None), ProgId("NAEngine.NALayerProperties")> _
 Public NotInheritable Class NALayerProperties : Inherits BaseCommand
		Private m_mapControl As IMapControl3

		Public Sub New()
			MyBase.m_caption = "Properties..."
		End Sub

		Public Overloads Overrides Sub OnClick()
			' Show the Property Page form for the NALayer

			' Get the NALayer that was right-clicked on in the table of contents
			' m_MapControl.CustomProperty was set in frmMain.axTOCControl1_OnMouseDown
			Dim naLayer As INALayer = CType(m_mapControl.CustomProperty, INALayer)
			Dim props As frmNALayerProperties = New frmNALayerProperties()
			If props.ShowModal(naLayer) Then
				' Notify the ActiveView that the contents have changed so the TOC and NAWindow know to refresh themselves.
				m_mapControl.ActiveView.ContentsChanged()
			End If
		End Sub

		Public Overloads Overrides Sub OnCreate(ByVal hook As Object)
			m_mapControl = CType(hook, IMapControl3)
		End Sub
	End Class
End Namespace