/// <summary> /// Update the dropdowns of features on the UI /// </summary> /// <param name="helper">Helper class</param> private void PopulateDropDowns(FiberDeviceConnectionHelper helper) { // Clear the existing choices cboFrom.Items.Clear(); cboTo.Items.Clear(); lblAvailableFrom.Text = ""; lblAvailableTo.Text = ""; // Get the features and the display index for use when creating the wrapper ESRI.ArcGIS.Carto.IFeatureLayer ftLayer = _hookHelper.FindFeatureLayer(ConfigUtil.FiberCableFtClassName); int displayIdx = ftLayer.FeatureClass.FindField(ftLayer.DisplayField); // Get the selected features List <ESRI.ArcGIS.Geodatabase.IFeature> selectedFts = _hookHelper.GetSelectedFeatures(ftLayer); // Add each of the fiber features to the drop down for (int ftIdx = 0; ftIdx < selectedFts.Count; ftIdx++) { FiberCableWrapper w = new FiberCableWrapper(selectedFts[ftIdx], displayIdx); cboFrom.Items.Add(w); } // Now do that same thing for each of the device feature classes string[] deviceClassNames = ConfigUtil.DeviceFeatureClassNames; for (int deviceClassIdx = 0; deviceClassIdx < deviceClassNames.Length; deviceClassIdx++) { string ftClassName = deviceClassNames[deviceClassIdx]; // Get the features and the display index for use when creating the wrapper ftLayer = _hookHelper.FindFeatureLayer(ftClassName); if (ftLayer != null) // what if layer removed from map { selectedFts = _hookHelper.GetSelectedFeatures(ftLayer); displayIdx = ftLayer.FeatureClass.FindField(ftLayer.DisplayField); for (int ftIdx = 0; ftIdx < selectedFts.Count; ftIdx++) { DeviceWrapper w = new DeviceWrapper(selectedFts[ftIdx], displayIdx); cboFrom.Items.Add(w); } } } // Preselect the first choice if (0 < cboFrom.Items.Count) { cboFrom.SelectedItem = cboFrom.Items[0]; } }
/// <summary> /// Load the drop down of selected splice closures /// </summary> /// <param name="helper">SpliceEditorHelper</param> private void PopulateSpliceClosures(FiberSpliceHelper helper) { try { // Clear anything that is dependent on what we are about to load ClearGrid(); cboCableA.Items.Clear(); cboCableB.Items.Clear(); cboSpliceClosure.Items.Clear(); lblAvailableA.Text = ""; lblAvailableB.Text = ""; // Find the layer ESRI.ArcGIS.Carto.IFeatureLayer ftLayer = _hookHelper.FindFeatureLayer(ConfigUtil.SpliceClosureFtClassName); if (ftLayer == null) { ArcMap.Application.StatusBar.set_Message(0, "Telecom Tools error occurred. Check log for details."); _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Could not find Feature Layer:.", ConfigUtil.SpliceClosureFtClassName); return; } int displayIdx = ftLayer.FeatureClass.FindField(ftLayer.DisplayField); // Get the selection on this layer List <ESRI.ArcGIS.Geodatabase.IFeature> selectedSplices = _hookHelper.GetSelectedFeatures(ftLayer); for (int i = 0; i < selectedSplices.Count; i++) { SpliceClosureWrapper w = new SpliceClosureWrapper(selectedSplices[i], displayIdx); cboSpliceClosure.Items.Add(w); } if (0 < cboSpliceClosure.Items.Count) { cboSpliceClosure.SelectedItem = cboSpliceClosure.Items[0]; } } catch (Exception e) { _logHelper.addLogEntry(DateTime.Now.ToString(), "ERROR", "Splice Connection Window (PopulateSpliceClosures): ", e.Message); } }