private void clearLocationsToolStripMenuItem_Click(object sender, EventArgs e) { IMapControl3 mapControl = (IMapControl3)axMapControl1.Object; IEngineNetworkAnalystHelper naHelper = m_naEnv as IEngineNetworkAnalystHelper; IEngineNAWindow naWindow = m_naWindow; INALayer naLayer = naWindow.ActiveAnalysis; naHelper.DeleteAllNetworkLocations(); mapControl.Refresh(esriViewDrawPhase.esriViewGeography, naLayer, mapControl.Extent); }
public override void OnClick() { IEngineNetworkAnalystEnvironment naEnv = new EngineNetworkAnalystEnvironmentClass(); IEngineNetworkAnalystHelper naHelper = naEnv as IEngineNetworkAnalystHelper; IEngineNAWindow naWindow = naEnv.NAWindow; // Get the NALayer and corresponding NAContext of the layer 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; INAContext naContext = naLayer.Context; // Set the active Analysis layer if (naWindow.ActiveAnalysis != naLayer) { naWindow.ActiveAnalysis = naLayer; } // Remember what the current category is IEngineNAWindowCategory currentCategory = naWindow.ActiveCategory; // Loop through deleting all the items from all the categories INamedSet naClasses = naContext.NAClasses; for (int i = 0; i < naClasses.Count; i++) { IEngineNAWindowCategory category = naWindow.get_CategoryByNAClassName(naClasses.get_Name(i)); naWindow.ActiveCategory = category; naHelper.DeleteAllNetworkLocations(); } //Reset to the original category naWindow.ActiveCategory = currentCategory; m_mapControl.Refresh(esriViewDrawPhase.esriViewGeography, naLayer, m_mapControl.Extent); }