public void Add(SelectionCellRangeWithItems rangeWithItems)
        {
            Debug.Assert(m_unsortedRanges.All(r => r.Value.CellRange.Intersect(rangeWithItems.CellRange).IsEmpty), "Part of this range is already selected");

            var itemRangeWithItems = rangeWithItems.ItemRangeWithItems;

            SelectedItemsStorage.UpdateSelectionRangeWithItemsFromAdd(m_dataGridContext, itemRangeWithItems, ref itemRangeWithItems);

            var newRangeWithItems = new SelectionCellRangeWithItems(itemRangeWithItems.Range, itemRangeWithItems.Items, rangeWithItems.ColumnRange);

            this.Insert(this.Count, newRangeWithItems, true);
        }
Example #2
0
        public object Clone()
        {
            var copy = new SelectedItemsStorage(m_dataGridContext);

            for (int i = 0; i < m_unsortedRanges.Count; i++)
            {
                copy.Insert(i, m_unsortedRanges[i].Value, false);
            }

            copy.m_itemsCount = m_itemsCount;

            return(copy);
        }
Example #3
0
 internal SelectionInfo(
     DataGridContext dataGridContext,
     SelectedItemsStorage removedItems,
     SelectedItemsStorage addedItems,
     SelectedCellsStorage removedCells,
     SelectedCellsStorage addedCells)
 {
     this.DataGridContext   = dataGridContext;
     this.AddedItems        = new ReadOnlyCollection <object>(new SelectionItemCollection(addedItems));
     this.RemovedItems      = new ReadOnlyCollection <object>(new SelectionItemCollection(removedItems));
     this.AddedItemRanges   = new ReadOnlyCollection <SelectionRange>(new SelectionItemRangeCollection(addedItems));
     this.RemovedItemRanges = new ReadOnlyCollection <SelectionRange>(new SelectionItemRangeCollection(removedItems));
     this.AddedCellRanges   = new ReadOnlyCollection <SelectionCellRange>(new SelectionCellRangeCollection(addedCells));
     this.RemovedCellRanges = new ReadOnlyCollection <SelectionCellRange>(new SelectionCellRangeCollection(removedCells));
 }
Example #4
0
        public void Add(SelectionRangeWithItems rangeWithItems)
        {
            Debug.Assert(!this.Contains(rangeWithItems.Range));

            m_itemsCount += rangeWithItems.Length;

            if (this.Count > 0)
            {
                var lastIndex          = this.Count - 1;
                var lastRangeWithItems = this[lastIndex];
                var lastRange          = lastRangeWithItems.Range;

                if ((lastRange.EndIndex + 1) == rangeWithItems.Range.StartIndex)
                {
                    Debug.Assert(rangeWithItems.Range.EndIndex > lastRange.EndIndex);

                    SelectedItemsStorage.UpdateSelectionRangeWithItemsFromAdd(m_dataGridContext, rangeWithItems, ref lastRangeWithItems);

                    this[lastIndex] = lastRangeWithItems;
                    return;
                }
                else if ((lastRange.EndIndex - 1) == rangeWithItems.Range.StartIndex)
                {
                    Debug.Assert(rangeWithItems.Range.EndIndex < lastRange.EndIndex);

                    SelectedItemsStorage.UpdateSelectionRangeWithItemsFromAdd(m_dataGridContext, rangeWithItems, ref lastRangeWithItems);

                    this[lastIndex] = lastRangeWithItems;
                    return;
                }
            }

            SelectedItemsStorage.UpdateSelectionRangeWithItemsFromAdd(m_dataGridContext, rangeWithItems, ref rangeWithItems);

            this.Insert(this.Count, rangeWithItems, true);
        }
Example #5
0
        public void Visit(DataGridContext sourceContext, ref bool stopVisit)
        {
            object[]       items;
            CollectionView itemsCollection = sourceContext.Items;
            int            count           = itemsCollection.Count;

            if (count == 0)
            {
                return;
            }

            if (sourceContext.ItemsSourceCollection is DataGridVirtualizingCollectionViewBase)
            {
                items = null;
            }
            else
            {
                items = new object[count];

                for (int i = 0; i < count; i++)
                {
                    items[i] = itemsCollection.GetItemAt(i);
                }
            }

            SelectionRange itemRange = new SelectionRange(0, count - 1);

            if (sourceContext.DataGridControl.SelectionUnit == SelectionUnit.Row)
            {
                sourceContext.DataGridControl.SelectionChangerManager.SelectItems(
                    sourceContext,
                    new SelectionRangeWithItems(itemRange, items));
            }
            else
            {
                HashedLinkedList <ColumnBase> columnsByVisiblePosition = sourceContext.ColumnsByVisiblePosition;
                SelectedItemsStorage          selectedColumnStore      = new SelectedItemsStorage(null);
                SelectionRange fullColumnRange = new SelectionRange(0, columnsByVisiblePosition.Count - 1);
                selectedColumnStore.Add(new SelectionRangeWithItems(fullColumnRange, null));
                int index = 0;

                foreach (ColumnBase column in columnsByVisiblePosition)
                {
                    if (!column.Visible)
                    {
                        selectedColumnStore.Remove(new SelectionRangeWithItems(new SelectionRange(index), null));
                    }

                    index++;
                }

                int columnRangeCount = selectedColumnStore.Count;

                for (int i = 0; i < columnRangeCount; i++)
                {
                    sourceContext.DataGridControl.SelectionChangerManager.SelectCells(
                        sourceContext,
                        new SelectionCellRangeWithItems(itemRange, items, selectedColumnStore[i].Range));
                }
            }
        }
 public SelectionItemCollection(SelectedItemsStorage list)
 {
     m_list = list;
 }