コード例 #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 _selectedSlotsTable.GetIndexes())
            {
                object newItem = OwningGrid.DataConnection.GetDataItem(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(DataGrid.SelectionChangedEvent, removedSelectedItems, addedSelectedItems)
            {
                Source = OwningGrid
            });
        }
コード例 #2
0
 internal void SelectSlot(int slot, bool select)
 {
     if (OwningGrid.RowGroupHeadersTable.Contains(slot))
     {
         return;
     }
     if (select)
     {
         if (!_selectedSlotsTable.Contains(slot))
         {
             _selectedItemsCache.Add(OwningGrid.DataConnection.GetDataItem(OwningGrid.RowIndexFromSlot(slot)));
         }
         _selectedSlotsTable.AddValue(slot, true);
     }
     else
     {
         if (_selectedSlotsTable.Contains(slot))
         {
             _selectedItemsCache.Remove(OwningGrid.DataConnection.GetDataItem(OwningGrid.RowIndexFromSlot(slot)));
         }
         _selectedSlotsTable.RemoveValue(slot);
     }
 }