internal SelectionChangedEventArgs GetSelectionChangedEventArgs() { List <object> addedSelectedItems = new List <object>(); List <object> removedSelectedItems = new List <object>(); // Compare the old selected indexes with the current selection to determine which items // have been added and removed since the last time this method was called foreach (int newSlot in _selectedSlotsTable.GetIndexes()) { object newItem = this.OwningGrid.DataConnection.GetDataItem(this.OwningGrid.RowIndexFromSlot(newSlot)); if (_oldSelectedSlotsTable.Contains(newSlot)) { _oldSelectedSlotsTable.RemoveValue(newSlot); _oldSelectedItemsCache.Remove(newItem); } else { addedSelectedItems.Add(newItem); } } foreach (object oldItem in _oldSelectedItemsCache) { removedSelectedItems.Add(oldItem); } // The current selection becomes the old selection _oldSelectedSlotsTable = _selectedSlotsTable.Copy(); _oldSelectedItemsCache = new List <object>(_selectedItemsCache); return(new SelectionChangedEventArgs(removedSelectedItems, addedSelectedItems)); }
public DataGridSelectedItemsCollection(DataGrid owningGrid) { this.OwningGrid = owningGrid; _oldSelectedItemsCache = new List <object>(); _oldSelectedSlotsTable = new IndexToValueTable <bool>(); _selectedItemsCache = new List <object>(); _selectedSlotsTable = new IndexToValueTable <bool>(); }
public DataGridSelectedItemsCollection(DataGrid owningGrid) { this.OwningGrid = owningGrid; this._oldSelectedItemsCache = new List<object>(); this._oldSelectedSlotsTable = new IndexToValueTable<bool>(); this._selectedItemsCache = new List<object>(); this._selectedSlotsTable = new IndexToValueTable<bool>(); }
public WrapLayout(IHierarchyAdapter adapter, double defaultItemLength, double defaultItemOppositeLength) { this.DefaultItemLength = defaultItemLength; this.DefaultItemOppositeLength = defaultItemOppositeLength; this.hierarchyAdapter = adapter; this.averageItemLength = this.DefaultItemLength; this.LayoutStrategies.Add(new ItemsLayoutStrategy()); this.groupHeadersTable = new IndexToValueTable <GroupInfo>(); }
public CompactLayout(IHierarchyAdapter adapter, double defaultItemLength) { if (adapter == null) { throw new ArgumentNullException("adapter", "Adapter cannot be null."); } this.DefaultItemLength = defaultItemLength; this.hierarchyAdapter = adapter; this.averageItemLength = defaultItemLength; this.collapsedSlotsTable = new IndexToValueTable <bool>(); this.groupHeadersTable = new IndexToValueTable <GroupInfo>(); this.LayoutStrategies.Add(new ItemsLayoutStrategy()); }
public LayoutRenderInfoState(IndexToValueTable <bool> collapsedSlots) { this.collapsedSlots = collapsedSlots; }
public SelectedItemsEnumerator(DataGrid owningGrid, IndexToValueTable<bool> selectedItemsTable) { Debug.Assert(owningGrid != null); Debug.Assert(selectedItemsTable != null); this.OwningGrid = owningGrid; this._rowIndexesEnumerator = selectedItemsTable.GetIndexesEnumerator(); }
public DataGridSelectedItemsCollection(DataGrid owningGrid) { this.OwningGrid = owningGrid; this._selectedItemsTable = new IndexToValueTable<bool>(); }
internal SelectionChangedEventArgs GetSelectionChangedEventArgs() { List<object> addedSelectedItems = new List<object>(); List<object> removedSelectedItems = new List<object>(); // Compare the old selected indexes with the current selection to determine which items // have been added and removed since the last time this method was called foreach (int newSlot in this._selectedSlotsTable.GetIndexes()) { object newItem = this.OwningGrid.DataConnection.GetDataItem(this.OwningGrid.RowIndexFromSlot(newSlot)); if (this._oldSelectedSlotsTable.Contains(newSlot)) { this._oldSelectedSlotsTable.RemoveValue(newSlot); this._oldSelectedItemsCache.Remove(newItem); } else { addedSelectedItems.Add(newItem); } } foreach (object oldItem in this._oldSelectedItemsCache) { removedSelectedItems.Add(oldItem); } // The current selection becomes the old selection this._oldSelectedSlotsTable = this._selectedSlotsTable.Copy(); this._oldSelectedItemsCache = new List<object>(this._selectedItemsCache); return new SelectionChangedEventArgs(removedSelectedItems, addedSelectedItems); }
public DataGrid() { this.TabNavigation = KeyboardNavigationMode.Once; this.KeyDown += new KeyEventHandler(DataGrid_KeyDown); this.KeyUp += new KeyEventHandler(DataGrid_KeyUp); this.GotFocus += new RoutedEventHandler(DataGrid_GotFocus); this.LostFocus += new RoutedEventHandler(DataGrid_LostFocus); this.IsEnabledChanged += new DependencyPropertyChangedEventHandler(DataGrid_IsEnabledChanged); this._loadedRows = new List<DataGridRow>(); this._lostFocusActions = new Queue<Action>(); this._selectedItems = new DataGridSelectedItemsCollection(this); this._rowGroupHeaderStyles = new ObservableCollection<Style>(); this._rowGroupHeaderStyles.CollectionChanged += RowGroupHeaderStyles_CollectionChanged; this._rowGroupHeaderStylesOld = new List<Style>(); this.RowGroupHeadersTable = new IndexToValueTable<DataGridRowGroupInfo>(); this._validationItems = new Dictionary<INotifyDataErrorInfo, string>(); this._validationResults = new List<ValidationResult>(); this._bindingValidationResults = new List<ValidationResult>(); this._propertyValidationResults = new List<ValidationResult>(); this._indeiValidationResults = new List<ValidationResult>(); this.DisplayData = new DataGridDisplayData(this); this.ColumnsInternal = CreateColumnsInstance(); this.RowHeightEstimate = DATAGRID_defaultRowHeight; this.RowDetailsHeightEstimate = 0; this._rowHeaderDesiredWidth = 0; this.DataConnection = new DataGridDataConnection(this); this._showDetailsTable = new IndexToValueTable<Visibility>(); this._collapsedSlotsTable = new IndexToValueTable<Visibility>(); this.AnchorSlot = -1; this._lastEstimatedRow = -1; this._editingColumnIndex = -1; this._mouseOverRowIndex = null; this.CurrentCellCoordinates = new DataGridCellCoordinates(-1, -1); this.RowGroupHeaderHeightEstimate = DATAGRID_defaultRowHeight; DefaultStyleKey = typeof(DataGrid); }
public DataGrid() { TabNavigation = KeyboardNavigationMode.Once; KeyDown += DataGrid_KeyDown; KeyUp += DataGrid_KeyUp; GotFocus += DataGrid_GotFocus; LostFocus += DataGrid_LostFocus; IsEnabledChanged += DataGrid_IsEnabledChanged; _loadedRows = new List<DataGridRow>(); _selectedItems = new DataGridSelectedItemsCollection(this); _rowGroupHeaderStyles = new ObservableCollection<Style>(); _rowGroupHeaderStyles.CollectionChanged += RowGroupHeaderStyles_CollectionChanged; _rowGroupHeaderStylesOld = new List<Style>(); RowGroupHeadersTable = new IndexToValueTable<DataGridRowGroupInfo>(); _validationResults = new List<ValidationResult>(); DisplayData = new DataGridDisplayData(this); ColumnsInternal = CreateColumnsInstance(); RowHeightEstimate = DATAGRID_defaultRowHeight; RowDetailsHeightEstimate = 0; _rowHeaderDesiredWidth = 0; DataConnection = new DataGridDataConnection(this); _showDetailsTable = new IndexToValueTable<Visibility>(); _collapsedSlotsTable = new IndexToValueTable<Visibility>(); AnchorSlot = -1; _lastEstimatedRow = -1; _editingColumnIndex = -1; _mouseOverRowIndex = null; CurrentCellCoordinates = new DataGridCellCoordinates(-1, -1); RowGroupHeaderHeightEstimate = DATAGRID_defaultRowHeight; DefaultStyleKey = typeof(DataGrid); }
public DataGrid() { this.TabNavigation = KeyboardNavigationMode.Once; this.IsTabStop = true; this.KeyDown += new KeyEventHandler(DataGrid_KeyDown); this.KeyUp += new KeyEventHandler(DataGrid_KeyUp); this.GotFocus += new RoutedEventHandler(DataGrid_GotFocus); this.LostFocus += new RoutedEventHandler(DataGrid_LostFocus); this.SetValueNoCallback(GridlinesVisibilityProperty, DataGridGridlines.All); this._prefetchedRows = new List<DataGridRow>(); this._preparedRows = new List<DataGridRow>(); this._recyclableRows = new List<DataGridRow>(); this._editingBoundCells = new List<DataGridCell>(2); this.SelectedItemsInternal = new DataGridSelectedItemsCollection(this); this.ColumnsInternal = CreateColumnsInstance(); this.SetValueNoCallback(ColumnWidthProperty, DATAGRID_defaultColumnWidth); this.DisplayData = new DataGridDisplayData(); this.SetValueNoCallback(RowHeightProperty, DATAGRID_defaultRowHeight); this._minColumnWidth = DATAGRID_defaultMinColumnWidth; this._minRowHeight = DataGridRow.DATAGRIDROW_minMinHeight; this.DataConnection = new DataGridDataConnection(this); this._editingRowLocation = DataGridEditingRowLocation.Inline; this._newRowLocation = DataGridNewRowLocation.Inline; this._showDetailsTable = new IndexToValueTable<Visibility>(); this.SetValueNoCallback(RowDetailsVisibilityProperty, DATAGRID_defaultRowDetailsVisibility); this.AnchorRowIndex = -1; this._editingColumnIndex = -1; this._mouseOverRowIndex = null; this.CurrentCellCoordinates = new DataGridCellCoordinates(-1, -1); this.SetValueNoCallback(HeadersVisibilityProperty, DATAGRID_defaultHeadersVisibility); this.SetValueNoCallback(HorizontalScrollBarVisibilityProperty, DATAGRID_defaultHorizontalScrollBarVisibility); this.SetValueNoCallback(VerticalScrollBarVisibilityProperty, DATAGRID_defaultVerticalScrollBarVisibility); this.SetValueNoCallback(ColumnHeadersHeightProperty, DATAGRID_defaultColumnHeadersHeight); this.SetValueNoCallback(RowHeadersWidthProperty, DATAGRID_defaultRowHeadersWidth); this.SetValueNoCallback(SelectionModeProperty, DATAGRID_defaultSelectionMode); // this.CanUserResizeColumns = DATAGRID_defaultCanUserResizeColumns; }
private static IEnumerable<object> GetSelectedItems(DataGrid owningGrid, IndexToValueTable<bool> selectedItemsTable) { Debug.Assert(owningGrid != null); Debug.Assert(owningGrid.DataConnection != null); Debug.Assert(selectedItemsTable != null); DataGridDataConnection dataConnection = owningGrid.DataConnection; foreach (int rowIndex in selectedItemsTable.GetIndexes()) { Debug.Assert(rowIndex > -1); yield return dataConnection.GetDataItem(rowIndex); } }
public DataGrid() { this.TabNavigation = KeyboardNavigationMode.Once; this.KeyDown += new KeyEventHandler(DataGrid_KeyDown); this.KeyUp += new KeyEventHandler(DataGrid_KeyUp); this.GotFocus += new RoutedEventHandler(DataGrid_GotFocus); this.LostFocus += new RoutedEventHandler(DataGrid_LostFocus); this._loadedRows = new List<DataGridRow>(); this._editingBoundCells = new List<DataGridCell>(2); this._selectedItems = new DataGridSelectedItemsCollection(this); this.SetValueNoCallback(SelectedIndexProperty, -1); this.DisplayData = new DataGridDisplayData(); this.ColumnsInternal = CreateColumnsInstance(); this.SetValueNoCallback(ColumnWidthProperty, DataGridLength.Auto); this.SetValueNoCallback(MaxColumnWidthProperty, DATAGRID_defaultMaxColumnWidth); this.SetValueNoCallback(MinColumnWidthProperty, DATAGRID_defaultMinColumnWidth); this.SetValueNoCallback(RowHeightProperty, double.NaN); this.RowHeightEstimate = DATAGRID_defaultRowHeight; this.RowDetailsHeightEstimate = 0; this._rowHeaderDesiredWidth = 0; this.DataConnection = new DataGridDataConnection(this); //this._newRowLocation = DataGridNewRowLocation.Inline; this._showDetailsTable = new IndexToValueTable<Visibility>(); this.AnchorRowIndex = -1; this._lastEstimatedRow = -1; this._editingColumnIndex = -1; this._mouseOverRowIndex = null; this.CurrentCellCoordinates = new DataGridCellCoordinates(-1, -1); this.SetValueNoCallback(RowHeaderWidthProperty, double.NaN); this.SetValueNoCallback(ColumnHeaderHeightProperty, double.NaN); this._addedSelectedItems = new List<object>(); this._removedSelectedItems = new List<object>(); DefaultStyleKey = typeof(DataGrid); }