public void RefreshLayerFieldComboBox() { try { LayerFieldComboBox.ClearItems(); QueuedTask.Run(() => { var LayerName = LayerComboBox.SelectedItem.ToString(); // Get all the fields from the selected item in LayerComboBox // Get the layer in the ComboBox selection var QALayer = MapView.Active.Map.FindLayers(LayerName).FirstOrDefault() as FeatureLayer; if (QALayer == null) { return; } var FieldsList = QALayer.GetTable().GetDefinition().GetFields(); // as string // bool hasItems = false; // Keep empty, as selection of an item populates the values combobox foreach (var fld in FieldsList) { var fldNameString = fld.Name; if (fldNameString != "Shape") { LayerFieldComboBox.AddItem(new ComboBoxItem(fldNameString)); } } LayerFieldComboBox.Text = "Choose..."; // Zoom to either the selected features, or the extent of all layers in the map var featureLayers = MapView.Active.Map.Layers.OfType <FeatureLayer>().Where((featurelayer) => featurelayer.Name == LayerComboBox.SelectedItem.ToString()); if (QALayer.SelectionCount == 0) { QALayerSelection = QALayer.Select(); // select all features } else { QALayerSelection = QALayer.GetSelection(); // get current selection } //Selection QASelection = QALayer.GetSelection(); var selectionSet = QALayerSelection.GetObjectIDs(); if (QALayerSelection.GetCount() > 0) { MapView.Active.ZoomTo(QALayer, selectionSet, TimeSpan.FromSeconds(0)); MapView.Active.ZoomOutFixed(TimeSpan.FromSeconds(0)); } else { MapView.Active.ZoomTo(QALayer); } }); } catch (Exception ex) { MessageBox.Show("Error in RefreshLayerFieldComboBox: " + ex.ToString(), "Error"); } }
public void ResetTab() { if (!_deferredRefreshOfLayerList) { if (Project.Current.HasEdits) { MessageBox.Show("You have ended your current review session. You have unsaved edits."); } // clear the comboboxes EditNoteComboBox.ClearItems(); LayerFieldComboBox.ClearItems(); QAFieldComboBox.ClearItems(); FieldValueComboBox.ClearItems(); // reset states to deactivated FrameworkApplication.State.Deactivate("active_state_1"); FrameworkApplication.State.Deactivate("active_state_2"); FrameworkApplication.State.Deactivate("active_state_3"); } }