public void Visit(DataGridContext sourceContext, int startSourceDataItemIndex, int endSourceDataItemIndex, ref bool stopVisit)
        {
            SelectionManager selectionChangerManager = sourceContext.DataGridControl.SelectionChangerManager;

            if (m_selectedColumns != null)
            {
                int columnCount = sourceContext.Columns.Count;

                if (columnCount == 0)
                {
                    return;
                }

                SelectionRange contextColumnMaxRange = new SelectionRange(0, columnCount - 1);

                for (int i = 0; i < m_selectedColumns.Length; i++)
                {
                    SelectionRange selectionRange             = m_selectedColumns[i];
                    SelectionRange intersectionSelectionRange = selectionRange.Intersect(contextColumnMaxRange);

                    if (intersectionSelectionRange.IsEmpty)
                    {
                        continue;
                    }

#if DEBUG
                    string action = (m_unselect) ? "Removing" : "Adding";
                    Debug.WriteLine("Selection : " + action + " cell : (" + startSourceDataItemIndex.ToString() + " - " + endSourceDataItemIndex.ToString() + ") - ("
                                    + intersectionSelectionRange.StartIndex.ToString() + " - " + intersectionSelectionRange.EndIndex.ToString() + ")");
#endif

                    var cellRange = new SelectionCellRangeWithItems(new SelectionRange(startSourceDataItemIndex, endSourceDataItemIndex), null, intersectionSelectionRange);

                    if (m_unselect)
                    {
                        selectionChangerManager.UnselectCells(sourceContext, cellRange);
                    }
                    else
                    {
                        selectionChangerManager.SelectCells(sourceContext, cellRange);
                    }
                }
            }
            else
            {
#if DEBUG
                string action = (m_unselect) ? "Removing" : "Adding";
                Debug.WriteLine("Selection : " + action + " Adding item : " + startSourceDataItemIndex.ToString() + " - " + endSourceDataItemIndex.ToString());
#endif
                var itemRange = new SelectionRangeWithItems(new SelectionRange(startSourceDataItemIndex, endSourceDataItemIndex), null);

                if (m_unselect)
                {
                    selectionChangerManager.UnselectItems(sourceContext, itemRange);
                }
                else
                {
                    selectionChangerManager.SelectItems(sourceContext, itemRange);
                }
            }
        }
Esempio n. 2
0
 internal SelectionCellRangeWithItemsWrapper(SelectionCellRangeWithItems value, int index)
 {
     m_value = value;
     m_index = index;
 }