public void SelectTracedDevices() { // ----------------------------------------------- // Following section of code causes cable, splice // and device features to be selected on the map // using the IFeatureSelection & ISelectionSet // interfaces // ----------------------------------------------- // Remove any previous trace results. _hookHelper.FocusMap.ClearSelection(); Dictionary <string, List <int> > deviceOidLists = new Dictionary <string, List <int> >(); // First get set of OIDs that were traced. foreach (IRow traceItem in this._traceResults) { ESRI.ArcGIS.Geodatabase.IDataset dataset = traceItem.Table as ESRI.ArcGIS.Geodatabase.IDataset; string className = GdbUtils.ParseTableName(dataset); if (ConfigUtil.IsDeviceClassName(className)) { List <int> deviceOids = null; if (deviceOidLists.ContainsKey(className)) { deviceOids = deviceOidLists[className]; } else { deviceOids = new List <int>(); deviceOidLists[className] = deviceOids; } deviceOids.Add(traceItem.OID); } } // Do the actual selections foreach (KeyValuePair <string, List <int> > deviceOidPair in deviceOidLists) { ESRI.ArcGIS.Carto.IFeatureSelection deviceFtSelection = _hookHelper.FindFeatureLayer(deviceOidPair.Key) as ESRI.ArcGIS.Carto.IFeatureSelection; if (null != deviceFtSelection) { ESRI.ArcGIS.Geodatabase.ISelectionSet deviceSelectionSet = deviceFtSelection.SelectionSet; List <int> deviceOidList = deviceOidPair.Value; if (null != deviceSelectionSet && 0 < deviceOidList.Count) { int[] oidList = deviceOidList.ToArray(); deviceSelectionSet.AddList(deviceOidList.Count, ref oidList[0]); } } else { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", deviceOidPair.Key + " not found.", "Layer removed from TOC?"); } } }
protected override void editor_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { ESRI.ArcGIS.Geodatabase.IFeature feature = obj as ESRI.ArcGIS.Geodatabase.IFeature; if (null != feature && null != feature.Class) { ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)feature.Class; string tableName = GdbUtils.ParseTableName(dataset); if (ConfigUtil.IsDeviceClassName(tableName)) { if (InputPorts != Int32.MinValue && OutputPorts != Int32.MinValue) { try { ConfigureDevice(feature, InputPorts, OutputPorts, true); } catch (Exception ex) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Failed to configure device.", ex.Message); string message = "Failed to configure device:" + System.Environment.NewLine + ex.Message; MessageBox.Show(message, "Configure Device", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { AbortOperation(); _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Port counts are not set.", "Please specify a valid configuration of port settings."); string message = "Port counts are not set." + System.Environment.NewLine + "Please specify a valid configuration of port settings."; MessageBox.Show(message, "Configure Device", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
protected override void editor_OnCreateFeature(ESRI.ArcGIS.Geodatabase.IObject obj) { // Check for bad inputs ESRI.ArcGIS.Geodatabase.IFeature feature = obj as ESRI.ArcGIS.Geodatabase.IFeature; if (feature == null || feature.Class == null) { return; } // Work out type of feature ESRI.ArcGIS.Geodatabase.IDataset dataset = (ESRI.ArcGIS.Geodatabase.IDataset)feature.Class; string tableName = GdbUtils.ParseTableName(dataset); // ----------------------------- // Fiber // ----------------------------- if (0 == string.Compare(ConfigUtil.FiberCableFtClassName, tableName, true)) { try { //FiberCableConfiguration cf = // ConfigUtil.FiberCableConfigurationFromDisplayName(listView1.SelectedItems[0].Text); if (_fiberConfig != null) { ConfigureCable(feature, _fiberConfig, true); } } catch (Exception ex) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Failed to configure cable.", ex.Message); string message = "Failed to configure cable:" + System.Environment.NewLine + ex.Message; MessageBox.Show(message, "Configure Fiber Cable", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
/// <summary> /// Attempts to open a given feature workspace as a /// telecom workspace. Various checks are done to see /// if this location is valid for editing. /// /// Any existing valid workspaces are closed. /// /// Raises ValidWorkspaceSelected event if workspace is valid. /// </summary> /// <param name="wksp">The telecom workspace to be opened.</param> /// <returns>True if workspace was successfully opened, otherwise False</returns> public bool OpenWorkspace(IFeatureWorkspace wksp) { // If current workspace is valid and open the close it first. if (_currentWorkspace != null && _workspaceIsValid) { CloseCurrentWorkspace(); } // Assume workspace is valid until we can prove invalid. // _currentWorkspace used in some utility functions so // make sure this is set before checking validity. _currentWorkspace = wksp; _workspaceIsValid = true; try { if (WorkspaceIsValid(wksp)) { _workspaceIsValid = true; if (this.ValidWorkspaceSelected != null) { ValidWorkspaceSelected(this, null); } } else { _currentWorkspace = null; _workspaceIsValid = false; } } catch (Exception e) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Open Workspace", e.Message); } return(_workspaceIsValid); }
void _wkspHelper_WorkspaceSelected(object sender, EventArgs e) { _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Workspace Selected", "Clearing hook helper layer cache"); _featureLayerCache.Clear(); }
public FiberEditorExtension() { try { // -------------------------------------- // Initialize log window with log helper // -------------------------------------- _logHelper = LogHelper.Instance(); TelecomToolsLogWindow.AddinImpl winImpl = AddIn.FromID<TelecomToolsLogWindow.AddinImpl>( ThisAddIn.IDs.Esri_Telecom_Tools_Windows_TelecomToolsLogWindow); TelecomToolsLogWindow logWindow = winImpl.UI; logWindow.InitLog(_logHelper); // -------------------- // Build a hook helper // -------------------- _hookHelper = HookHelperExt.Instance(this.Hook); // ------------------------------------------- // Initialize telecom workspace helper. // // Listen to ActiveViewChanged event. // // If this happens the focus map more than // likely changed. Since the tools go after // layers in the TOC we probably need to close // the current telecom workspace since // editing etc could not longer be done. // Should add code to ask for saving changes. // ------------------------------------------- _wkspHelper = TelecomWorkspaceHelper.Instance(); _wkspHelper.ActiveViewChanged += new EventHandler(_wkspHelper_ActiveViewChanged); // ------------------------------------------- // Build helpers that actually do all object // creation work for special feature types // ------------------------------------------- _fiberCableHelper = new FiberCableConfigHelper(_hookHelper, ArcMap.Editor as IEditor3); _fiberDeviceHelper = new FiberDeviceConfigHelper(_hookHelper, ArcMap.Editor as IEditor3); // -------------------------------------------- // Splice and Connection helpers // -------------------------------------------- _spliceHelper = new FiberSpliceHelper(_hookHelper, ArcMap.Editor as IEditor3); _connectionHelper = new FiberDeviceConnectionHelper(_hookHelper, ArcMap.Editor as IEditor3); _logHelper.addLogEntry(DateTime.Now.ToString(), "INFO", "Telecom Extension Constructed."); } catch (Exception ex) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "General error.", ex.ToString()); } }