示例#1
0
        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));
        }
示例#2
0
 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>();
 }
示例#3
0
        /// <summary>
        /// Returns a copy of this IndexToValueTable
        /// </summary>
        /// <returns>copy of this IndexToValueTable</returns>
        public IndexToValueTable <T> Copy()
        {
            IndexToValueTable <T> copy = new IndexToValueTable <T>();

            foreach (Range <T> range in this._list)
            {
                copy._list.Add(range.Copy());
            }
            return(copy);
        }
示例#4
0
        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));
            }
        }
示例#5
0
 public DataGridSelectedItemsCollection(DataGrid owningGrid)
 {
     this.OwningGrid          = owningGrid;
     this._selectedItemsTable = new IndexToValueTable <bool>();
 }