About the ArcGIS Network Analyst extension Engine application Sample
[C#]
frmLoadLocations.cs
using System;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.NetworkAnalyst;
using System.Windows.Forms;
using System.Collections.Generic;
// This form allows users to load locations from another point feature layer into the selected NALayer and active category.
namespace NAEngine
{
public class frmLoadLocations : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lblInputData;
private System.Windows.Forms.CheckBox chkUseSelection;
private System.Windows.Forms.Button btnCancel;
private System.Windows.Forms.Button btnOK;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
private System.Windows.Forms.ComboBox cboInputData;
bool m_okClicked;
System.Collections.IList m_listDisplayTable;
public frmLoadLocations()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.cboInputData = new System.Windows.Forms.ComboBox();
this.lblInputData = new System.Windows.Forms.Label();
this.chkUseSelection = new System.Windows.Forms.CheckBox();
this.btnCancel = new System.Windows.Forms.Button();
this.btnOK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// cboInputData
//
this.cboInputData.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cboInputData.Location = new System.Drawing.Point(82, 9);
this.cboInputData.Name = "cboInputData";
this.cboInputData.Size = new System.Drawing.Size(381, 21);
this.cboInputData.TabIndex = 0;
this.cboInputData.SelectedIndexChanged += new System.EventHandler(this.cboInputData_SelectedIndexChanged);
//
// lblInputData
//
this.lblInputData.Location = new System.Drawing.Point(12, 12);
this.lblInputData.Name = "lblInputData";
this.lblInputData.Size = new System.Drawing.Size(64, 24);
this.lblInputData.TabIndex = 1;
this.lblInputData.Text = "Input Data";
//
// chkUseSelection
//
this.chkUseSelection.Location = new System.Drawing.Point(15, 39);
this.chkUseSelection.Name = "chkUseSelection";
this.chkUseSelection.Size = new System.Drawing.Size(419, 16);
this.chkUseSelection.TabIndex = 2;
this.chkUseSelection.Text = "Use Selection";
//
// btnCancel
//
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnCancel.Location = new System.Drawing.Point(351, 61);
this.btnCancel.Name = "btnCancel";
this.btnCancel.Size = new System.Drawing.Size(112, 32);
this.btnCancel.TabIndex = 6;
this.btnCancel.Text = "&Cancel";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
// btnOK
//
this.btnOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnOK.Location = new System.Drawing.Point(223, 61);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(112, 32);
this.btnOK.TabIndex = 5;
this.btnOK.Text = "&OK";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
// frmLoadLocations
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(479, 100);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.chkUseSelection);
this.Controls.Add(this.lblInputData);
this.Controls.Add(this.cboInputData);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Name = "frmLoadLocations";
this.ShowInTaskbar = false;
this.Text = "Load Locations";
this.ResumeLayout(false);
}
#endregion
public bool ShowModal(IMapControl3 mapControl, IEngineNetworkAnalystEnvironment naEnv)
{
// Initialize variables
m_okClicked = false;
m_listDisplayTable = new System.Collections.ArrayList();
var activeCategory = naEnv.NAWindow.ActiveCategory as IEngineNAWindowCategory2;
if (activeCategory == null)
return false;
IDataLayer dataLayer = activeCategory.DataLayer;
if (dataLayer == null)
return false;
// Set up the title of this dialog
String dataLayerName = GetDataLayerName(dataLayer);
if (dataLayerName.Length == 0)
return false;
this.Text = "Load Items into " + dataLayerName;
// Make sure the combo box lists only the appropriate possible input data layers
PopulateInputDataComboBox(mapControl, dataLayer);
//Select the first display table from the list
if (cboInputData.Items.Count > 0)
cboInputData.SelectedIndex = 0;
// Show the window
this.ShowDialog();
// If we selected a layer and clicked OK, load the locations
if (m_okClicked && (cboInputData.SelectedIndex >= 0))
{
try
{
// Get a cursor on the source display table (either though the selection set or table)
// Use IDisplayTable because it accounts for joins, querydefs, etc.
// IDisplayTable is implemented by FeatureLayers and StandaloneTables.
//
IDisplayTable displayTable = m_listDisplayTable[cboInputData.SelectedIndex] as IDisplayTable;
ICursor cursor;
if (chkUseSelection.Checked)
{
ISelectionSet selSet;
selSet = displayTable.DisplaySelectionSet;
selSet.Search(null, false, out cursor);
}
else
cursor = displayTable.SearchDisplayTable(null, false);
// Get the NAContext from the active analysis layer
INAContext naContext = naEnv.NAWindow.ActiveAnalysis.Context;
// Get the dataset for the active NAClass
IDataset naDataset = activeCategory.NAClass as IDataset;
// Setup NAClassLoader and Load Locations
INAClassLoader2 naClassLoader = new NAClassLoader() as INAClassLoader2;
naClassLoader.Initialize(naContext, naDataset.Name, cursor);
// Avoid loading network locations onto non-traversable portions of elements
INALocator3 locator = naContext.Locator as INALocator3;
locator.ExcludeRestrictedElements = true;
locator.CacheRestrictedElements(naContext);
int rowsIn = 0;
int rowsLocated = 0;
naClassLoader.Load(cursor, null, ref rowsIn, ref rowsLocated);
// Let the user know if some of the rows failed to locate
if (rowsIn != rowsLocated)
MessageBox.Show("Out of " + rowsIn + " + rows, " + rowsLocated + " rows were located",
"Loading locations", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception e)
{
MessageBox.Show(e.Message, "Loading locations failure", MessageBoxButtons.OK, MessageBoxIcon.Error );
}
return true;
}
return false;
}
private String GetDataLayerName(IDataLayer dataLayer)
{
var pFeatureLayer = dataLayer as IFeatureLayer;
var pStandaloneTable = dataLayer as IStandaloneTable;
var pLayer = dataLayer as ILayer;
if (pFeatureLayer != null && pLayer.Valid)
return pLayer.Name;
else if (pStandaloneTable != null)
return pStandaloneTable.Name;
return "";
}
private esriGeometryType GetDataLayerGeometryType(IDataLayer dataLayer)
{
var pFeatureLayer = dataLayer as IFeatureLayer;
var pLayer = dataLayer as ILayer;
if (pFeatureLayer != null && pLayer.Valid)
{
IFeatureClass pFeatureClass = pFeatureLayer.FeatureClass;
if (pFeatureClass != null)
return pFeatureClass.ShapeType;
}
return esriGeometryType.esriGeometryNull;
}
private void PopulateInputDataComboBox(IMapControl3 mapControl, IDataLayer dataLayer)
{
esriGeometryType targetGeoType = GetDataLayerGeometryType(dataLayer);
IEnumLayer sourceLayers = null;
ILayer sourceLayer = null;
IDisplayTable sourceDisplayTable = null;
UID searchInterfaceUID = new UID();
if (targetGeoType != esriGeometryType.esriGeometryNull)
{
// Only include layers that are of type IFeatureLayer
searchInterfaceUID.Value = typeof(IFeatureLayer).GUID.ToString("B");
sourceLayers = mapControl.Map.get_Layers(searchInterfaceUID, true);
// iterate over all of the feature layers
sourceLayer = sourceLayers.Next();
while (sourceLayer != null)
{
// Verify that the layer is a feature layer and a display table
IFeatureLayer sourceFeatureLayer = sourceLayer as IFeatureLayer;
sourceDisplayTable = sourceLayer as IDisplayTable;
if ((sourceFeatureLayer != null) && (sourceDisplayTable != null))
{
// Make sure that the geometry of the feature layer matches the geometry
// of the class into which we are loading
IFeatureClass sourceFeatureClass = sourceFeatureLayer.FeatureClass;
esriGeometryType sourceGeoType = sourceFeatureClass.ShapeType;
if ((sourceGeoType == targetGeoType) ||
(targetGeoType == esriGeometryType.esriGeometryPoint && sourceGeoType == esriGeometryType.esriGeometryMultipoint))
{
// Add the layer name to the combobox and the layer to the list
cboInputData.Items.Add(sourceLayer.Name);
m_listDisplayTable.Add(sourceDisplayTable);
}
}
sourceLayer = sourceLayers.Next();
}
}
// The layer being loaded into has no geometry type
else
{
// Find all of the standalone table that are not part of an NALayer
IStandaloneTableCollection sourceStandaloneTables = mapControl.Map as IStandaloneTableCollection;
IStandaloneTable sourceStandaloneTable = null;
sourceDisplayTable = null;
int count = 0;
if (sourceStandaloneTables != null)
count = sourceStandaloneTables.StandaloneTableCount;
for (int i = 0; i < count; ++i)
{
sourceStandaloneTable = sourceStandaloneTables.get_StandaloneTable(i);
sourceDisplayTable = sourceStandaloneTable as IDisplayTable;
if ((sourceStandaloneTable != null) && (sourceDisplayTable != null))
{
// Add the table name to the combobox and the layer to the list
cboInputData.Items.Add(sourceStandaloneTable.Name);
m_listDisplayTable.Add(sourceDisplayTable);
}
}
// Find all of the standalone tables that are part of an NALayer
searchInterfaceUID.Value = typeof(INALayer).GUID.ToString("B");
sourceLayers = mapControl.Map.get_Layers(searchInterfaceUID, true);
sourceLayer = sourceLayers.Next();
while (sourceLayer != null)
{
INALayer sourceNALayer = sourceLayer as INALayer;
if (sourceNALayer != null)
{
sourceStandaloneTables = sourceNALayer as IStandaloneTableCollection;
sourceStandaloneTable = null;
sourceDisplayTable = null;
count = 0;
if (sourceStandaloneTables != null)
count = sourceStandaloneTables.StandaloneTableCount;
for (int i = 0; i < count; ++i)
{
sourceStandaloneTable = sourceStandaloneTables.get_StandaloneTable(i);
sourceDisplayTable = sourceStandaloneTable as IDisplayTable;
if ((sourceStandaloneTable != null) && (sourceDisplayTable != null))
{
// Add the table name to the combobox and the layer to the list
cboInputData.Items.Add(sourceStandaloneTable.Name);
m_listDisplayTable.Add(sourceDisplayTable);
}
}
}
sourceLayer = sourceLayers.Next();
}
}
}
private void btnOK_Click(object sender, System.EventArgs e)
{
m_okClicked = true;
this.Close();
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
m_okClicked = false;
this.Close();
}
private void cboInputData_SelectedIndexChanged(object sender, System.EventArgs e)
{
// Set the chkUseSelectedFeatures control based on if anything is selected or not
if (cboInputData.SelectedIndex >= 0)
{
IDisplayTable displayTable = m_listDisplayTable[cboInputData.SelectedIndex] as IDisplayTable;
chkUseSelection.Checked = (displayTable.DisplaySelectionSet.Count > 0);
chkUseSelection.Enabled = (displayTable.DisplaySelectionSet.Count > 0);
}
}
}
}
[Visual Basic .NET]
frmLoadLocations.vb
Imports Microsoft.VisualBasic
Imports System
Imports ESRI.ArcGIS.Carto
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.Geometry
Imports ESRI.ArcGIS.NetworkAnalyst
Imports System.Windows.Forms
Imports System.Collections.Generic
' This form allows users to load locations from another point feature layer into the selected NALayer and active category.
Namespace NAEngine
Public Class frmLoadLocations : Inherits System.Windows.Forms.Form
Private lblInputData As System.Windows.Forms.Label
Private chkUseSelection As System.Windows.Forms.CheckBox
Private WithEvents btnCancel As System.Windows.Forms.Button
Private WithEvents btnOK As System.Windows.Forms.Button
''' <summary>
''' Required designer variable.
''' </summary>
Private components As System.ComponentModel.Container = Nothing
Private WithEvents cboInputData As System.Windows.Forms.ComboBox
Private m_okClicked As Boolean
Private m_listDisplayTable As System.Collections.IList
Public Sub New()
'
' Required for Windows Form Designer support
'
InitializeComponent()
End Sub
''' <summary>
''' Clean up any resources being used.
''' </summary>
Protected Overrides Overloads Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not components Is Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#Region "Windows Form Designer generated code"
''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()
Me.cboInputData = New System.Windows.Forms.ComboBox()
Me.lblInputData = New System.Windows.Forms.Label()
Me.chkUseSelection = New System.Windows.Forms.CheckBox()
Me.btnCancel = New System.Windows.Forms.Button()
Me.btnOK = New System.Windows.Forms.Button()
Me.SuspendLayout()
'
' cboInputData
'
Me.cboInputData.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.cboInputData.Location = New System.Drawing.Point(82, 9)
Me.cboInputData.Name = "cboInputData"
Me.cboInputData.Size = New System.Drawing.Size(381, 21)
Me.cboInputData.TabIndex = 0
' Me.cboInputData.SelectedIndexChanged += New System.EventHandler(Me.cboInputData_SelectedIndexChanged);
'
' lblInputData
'
Me.lblInputData.Location = New System.Drawing.Point(12, 12)
Me.lblInputData.Name = "lblInputData"
Me.lblInputData.Size = New System.Drawing.Size(64, 24)
Me.lblInputData.TabIndex = 1
Me.lblInputData.Text = "Input Data"
'
' chkUseSelection
'
Me.chkUseSelection.Location = New System.Drawing.Point(15, 39)
Me.chkUseSelection.Name = "chkUseSelection"
Me.chkUseSelection.Size = New System.Drawing.Size(419, 16)
Me.chkUseSelection.TabIndex = 2
Me.chkUseSelection.Text = "Use Selection"
'
' btnCancel
'
Me.btnCancel.Anchor = (CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
Me.btnCancel.Location = New System.Drawing.Point(351, 61)
Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(112, 32)
Me.btnCancel.TabIndex = 6
Me.btnCancel.Text = "&Cancel"
' Me.btnCancel.Click += New System.EventHandler(Me.btnCancel_Click);
'
' btnOK
'
Me.btnOK.Anchor = (CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles))
Me.btnOK.Location = New System.Drawing.Point(223, 61)
Me.btnOK.Name = "btnOK"
Me.btnOK.Size = New System.Drawing.Size(112, 32)
Me.btnOK.TabIndex = 5
Me.btnOK.Text = "&OK"
' Me.btnOK.Click += New System.EventHandler(Me.btnOK_Click);
'
' frmLoadLocations
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(479, 100)
Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnOK)
Me.Controls.Add(Me.chkUseSelection)
Me.Controls.Add(Me.lblInputData)
Me.Controls.Add(Me.cboInputData)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Name = "frmLoadLocations"
Me.ShowInTaskbar = False
Me.Text = "Load Locations"
Me.ResumeLayout(False)
End Sub
#End Region
Public Function ShowModal(ByVal mapControl As IMapControl3, ByVal naEnv As IEngineNetworkAnalystEnvironment) As Boolean
' Initialize variables
m_okClicked = False
m_listDisplayTable = New System.Collections.ArrayList()
Dim activeCategory As IEngineNAWindowCategory2 = TryCast(naEnv.NAWindow.ActiveCategory, IEngineNAWindowCategory2)
If activeCategory Is Nothing Then
Return False
End If
Dim dataLayer As IDataLayer = activeCategory.DataLayer
If dataLayer Is Nothing Then
Return False
End If
' Set up the title of this dialog
Dim dataLayerName As String = GetDataLayerName(dataLayer)
If dataLayerName.Length = 0 Then
Return False
End If
Me.Text = "Load Items into " & dataLayerName
' Make sure the combo box lists only the appropriate possible input data layers
PopulateInputDataComboBox(mapControl, dataLayer)
'Select the first display table from the list
If cboInputData.Items.Count > 0 Then
cboInputData.SelectedIndex = 0
End If
' Show the window
Me.ShowDialog()
' If we selected a layer and clicked OK, load the locations
If m_okClicked AndAlso (cboInputData.SelectedIndex >= 0) Then
Try
' Get a cursor on the source display table (either though the selection set or table)
' Use IDisplayTable because it accounts for joins, querydefs, etc.
' IDisplayTable is implemented by FeatureLayers and StandaloneTables.
'
Dim displayTable As IDisplayTable = TryCast(m_listDisplayTable(cboInputData.SelectedIndex), IDisplayTable)
Dim cursor As ICursor = Nothing
If chkUseSelection.Checked Then
Dim selSet As ISelectionSet
selSet = displayTable.DisplaySelectionSet
selSet.Search(Nothing, False, cursor)
Else
cursor = displayTable.SearchDisplayTable(Nothing, False)
End If
' Get the NAContext from the active analysis layer
Dim naContext As INAContext = naEnv.NAWindow.ActiveAnalysis.Context
' Get the dataset for the active NAClass
Dim naDataset As IDataset = TryCast(activeCategory.NAClass, IDataset)
' Setup NAClassLoader and Load Locations
Dim naClassLoader As INAClassLoader2 = TryCast(New NAClassLoader(), INAClassLoader2)
naClassLoader.Initialize(naContext, naDataset.Name, cursor)
' Avoid loading network locations onto non-traversable portions of elements
Dim locator As INALocator3 = TryCast(naContext.Locator, INALocator3)
locator.ExcludeRestrictedElements = True
locator.CacheRestrictedElements(naContext)
Dim rowsIn As Integer = 0
Dim rowsLocated As Integer = 0
naClassLoader.Load(cursor, Nothing, rowsIn, rowsLocated)
' Let the user know if some of the rows failed to locate
If rowsIn <> rowsLocated Then
MessageBox.Show("Out of " & rowsIn & " + rows, " & rowsLocated & " rows were located", "Loading locations", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
Catch e As Exception
MessageBox.Show(e.Message, "Loading locations failure", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Return True
End If
Return False
End Function
Private Function GetDataLayerName(ByVal dataLayer As IDataLayer) As String
Dim pFeatureLayer As IFeatureLayer = TryCast(dataLayer, IFeatureLayer)
Dim pStandaloneTable As IStandaloneTable = TryCast(dataLayer, IStandaloneTable)
Dim pLayer As ILayer = TryCast(dataLayer, ILayer)
If Not pFeatureLayer Is Nothing AndAlso pLayer.Valid Then
Return pLayer.Name
ElseIf Not pStandaloneTable Is Nothing Then
Return pStandaloneTable.Name
End If
Return ""
End Function
Private Function GetDataLayerGeometryType(ByVal dataLayer As IDataLayer) As esriGeometryType
Dim pFeatureLayer As IFeatureLayer = TryCast(dataLayer, IFeatureLayer)
Dim pLayer As ILayer = TryCast(dataLayer, ILayer)
If Not pFeatureLayer Is Nothing AndAlso pLayer.Valid Then
Dim pFeatureClass As IFeatureClass = pFeatureLayer.FeatureClass
If Not pFeatureClass Is Nothing Then
Return pFeatureClass.ShapeType
End If
End If
Return esriGeometryType.esriGeometryNull
End Function
Private Sub PopulateInputDataComboBox(ByVal mapControl As IMapControl3, ByVal dataLayer As IDataLayer)
Dim targetGeoType As esriGeometryType = GetDataLayerGeometryType(dataLayer)
Dim sourceLayers As IEnumLayer = Nothing
Dim sourceLayer As ILayer = Nothing
Dim sourceDisplayTable As IDisplayTable = Nothing
Dim searchInterfaceUID As UID = New UID()
If targetGeoType <> esriGeometryType.esriGeometryNull Then
' Only include layers that are of type IFeatureLayer
searchInterfaceUID.Value = GetType(IFeatureLayer).GUID.ToString("B")
sourceLayers = mapControl.Map.Layers(searchInterfaceUID, True)
' iterate over all of the feature layers
sourceLayer = sourceLayers.Next()
Do While Not sourceLayer Is Nothing
' Verify that the layer is a feature layer and a display table
Dim sourceFeatureLayer As IFeatureLayer = TryCast(sourceLayer, IFeatureLayer)
sourceDisplayTable = TryCast(sourceLayer, IDisplayTable)
If (Not sourceFeatureLayer Is Nothing) AndAlso (Not sourceDisplayTable Is Nothing) Then
' Make sure that the geometry of the feature layer matches the geometry
' of the class into which we are loading
Dim sourceFeatureClass As IFeatureClass = sourceFeatureLayer.FeatureClass
Dim sourceGeoType As esriGeometryType = sourceFeatureClass.ShapeType
If (sourceGeoType = targetGeoType) OrElse (targetGeoType = esriGeometryType.esriGeometryPoint AndAlso sourceGeoType = esriGeometryType.esriGeometryMultipoint) Then
' Add the layer name to the combobox and the layer to the list
cboInputData.Items.Add(sourceLayer.Name)
m_listDisplayTable.Add(sourceDisplayTable)
End If
End If
sourceLayer = sourceLayers.Next()
Loop
' The layer being loaded into has no geometry type
Else
' Find all of the standalone table that are not part of an NALayer
Dim sourceStandaloneTables As IStandaloneTableCollection = TryCast(mapControl.Map, IStandaloneTableCollection)
Dim sourceStandaloneTable As IStandaloneTable = Nothing
sourceDisplayTable = Nothing
Dim count As Integer = 0
If Not sourceStandaloneTables Is Nothing Then
count = sourceStandaloneTables.StandaloneTableCount
End If
Dim i As Integer = 0
Do While i < count
sourceStandaloneTable = sourceStandaloneTables.StandaloneTable(i)
sourceDisplayTable = TryCast(sourceStandaloneTable, IDisplayTable)
If (Not sourceStandaloneTable Is Nothing) AndAlso (Not sourceDisplayTable Is Nothing) Then
' Add the table name to the combobox and the layer to the list
cboInputData.Items.Add(sourceStandaloneTable.Name)
m_listDisplayTable.Add(sourceDisplayTable)
End If
i += 1
Loop
' Find all of the standalone tables that are part of an NALayer
searchInterfaceUID.Value = GetType(INALayer).GUID.ToString("B")
sourceLayers = mapControl.Map.Layers(searchInterfaceUID, True)
sourceLayer = sourceLayers.Next()
Do While Not sourceLayer Is Nothing
Dim sourceNALayer As INALayer = TryCast(sourceLayer, INALayer)
If Not sourceNALayer Is Nothing Then
sourceStandaloneTables = TryCast(sourceNALayer, IStandaloneTableCollection)
sourceStandaloneTable = Nothing
sourceDisplayTable = Nothing
count = 0
If Not sourceStandaloneTables Is Nothing Then
count = sourceStandaloneTables.StandaloneTableCount
End If
i = 0
Do While i < count
sourceStandaloneTable = sourceStandaloneTables.StandaloneTable(i)
sourceDisplayTable = TryCast(sourceStandaloneTable, IDisplayTable)
If (Not sourceStandaloneTable Is Nothing) AndAlso (Not sourceDisplayTable Is Nothing) Then
' Add the table name to the combobox and the layer to the list
cboInputData.Items.Add(sourceStandaloneTable.Name)
m_listDisplayTable.Add(sourceDisplayTable)
End If
i += 1
Loop
End If
sourceLayer = sourceLayers.Next()
Loop
End If
End Sub
Private Sub btnOK_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnOK.Click
m_okClicked = True
Me.Close()
End Sub
Private Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnCancel.Click
m_okClicked = False
Me.Close()
End Sub
Private Sub cboInputData_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboInputData.SelectedIndexChanged
' Set the chkUseSelectedFeatures control based on if anything is selected or not
If cboInputData.SelectedIndex >= 0 Then
Dim displayTable As IDisplayTable = TryCast(m_listDisplayTable(cboInputData.SelectedIndex), IDisplayTable)
chkUseSelection.Checked = (displayTable.DisplaySelectionSet.Count > 0)
chkUseSelection.Enabled = (displayTable.DisplaySelectionSet.Count > 0)
End If
End Sub
End Class
End Namespace