/// <summary> /// When filter source changes the view and record text needs to be updated. /// </summary> private static void OnFilterSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FeatureDataGrid grid = d as FeatureDataGrid; grid.ApplyFilter(); grid.UpdateRecordsText(); }
private static void OnSelectedGraphicCountPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FeatureDataGrid grid = d as FeatureDataGrid; int oldValue = (int)e.OldValue; int newValue = (int)e.NewValue; // if they are different update the status bar text to reflect changes if (oldValue != newValue) { grid.UpdateRecordsText(); } if (grid.GraphicsLayer == null) { return; } IEnumerable <Graphic> gridSelected = grid.SelectedItems.Cast <Graphic>();; var addedSelections = grid.GraphicsLayer.SelectedGraphics.Except(gridSelected).ToList(); IEnumerable <Graphic> layerSelected = grid.GraphicsLayer.SelectedGraphics; var removedSelections = gridSelected.Except(grid.GraphicsLayer.SelectedGraphics).ToList(); foreach (var add in addedSelections) { grid.SelectedItems.Add(add); } foreach (var remove in removedSelections) { grid.SelectedItems.Remove(remove); } }
private static void OnTotalGraphicCountPropetyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FeatureDataGrid grid = d as FeatureDataGrid; int oldValue = (int)e.OldValue; int newValue = (int)e.NewValue; // if they are different update the status bar text to reflect changes if (oldValue != newValue) { grid.UpdateRecordsText(); } }
private static void OnGraphicsLayerPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { FeatureDataGrid grid = d as FeatureDataGrid; GraphicsLayer oldValue = e.OldValue as GraphicsLayer; GraphicsLayer newValue = e.NewValue as GraphicsLayer; if (oldValue != null) { if (grid.featureLayer != null) { grid.featureLayer.UpdateCompleted -= grid.FeatureLayer_UpdateCompleted; grid.featureLayer = null; // clear out reference to old feature layer if it exists } oldValue.PropertyChanged -= grid.GraphicsLayer_PropertyChanged; BindingOperations.ClearBinding(grid, FeatureDataGrid.TotalGraphicCountProperty); BindingOperations.ClearBinding(grid, FeatureDataGrid.SelectedGraphicCountProperty); if (!oldValue.IsInitialized) { oldValue.Initialized -= grid.GraphicsLayer_Initialized; } } if (newValue != null) { // if new layer is feature layer set private member if (newValue is FeatureLayer) { grid.featureLayer = newValue as FeatureLayer; grid.OutFields = grid.featureLayer.OutFields.ToString(); grid.featureLayer.UpdateCompleted += grid.FeatureLayer_UpdateCompleted; } else { grid.GraphicCollection = newValue.Graphics; } if (newValue.IsInitialized) { newValue.PropertyChanged += grid.GraphicsLayer_PropertyChanged; grid.SetItemsSource(newValue.Graphics); // Set the ItemsSource grid.BindToTotalGraphicsCount(); // Add total graphic count binding. grid.BindToSelectedGraphicsCount(); // Add selected graphic count binding. } else { // Wait for initialize event to fire before configuring feature data grid newValue.Initialized += grid.GraphicsLayer_Initialized; } } grid.UpdateRecordsText(); // Update the status bar text. grid.SetSubmitButtonVisibility(); // Enable/Disable submit button option. grid.SetDeleteSelectedRowsMenuButtonEnableState(); // Enable/Disable delete option. }