public IEnumerable <SelectionRange> GetIntersectedColumnRanges(SelectionCellRange range) { return((from match in this.IndexOfOverlap(range) let current = m_unsortedRanges[match].Value let intersection = current.CellRange.Intersect(range) select intersection.ColumnRange).ToList()); }
public bool Contains(SelectionCellRange range) { if ((m_unsortedRanges.Count <= 0) || (SelectedCellsStorage.IsEmpty(range))) { return(false); } return(this.Contains(new SelectionCellRangeWithItems(range.ItemRange, null, range.ColumnRange))); }
public override bool Equals(object obj) { if (!(obj is SelectionCellRange)) { return(false); } SelectionCellRange selectionRange = ( SelectionCellRange )obj; return((selectionRange.m_itemRange == m_itemRange) && (selectionRange.m_columnRange == m_columnRange)); }
private IEnumerable <int> IndexOfOverlap(SelectionCellRange target) { if ((m_sortedRanges.Count <= 0) || SelectedCellsStorage.IsEmpty(target)) { yield break; } var comparer = new ItemRangeComparer(target.ItemRange); var index = this.FindIndex(comparer); if (index < 0) { yield break; } while (index > 0) { if (comparer.Compare(m_sortedRanges[index - 1]) != 0) { break; } index--; } for (int i = index; i < m_sortedRanges.Count; i++) { var wrapper = m_sortedRanges[i]; if (comparer.Compare(wrapper) != 0) { break; } var currentRangeWithItems = wrapper.Value; var overlap = target.Intersect(currentRangeWithItems.CellRange); if (!SelectedCellsStorage.IsEmpty(overlap)) { yield return(wrapper.Index); } } }
public SelectionCellRange Intersect(SelectionCellRange range) { SelectionCellRange cellRangeIntersection = SelectionCellRange.Empty; SelectionRange itemRange = range.ItemRange; SelectionRange itemRangeIntersection = m_itemRange.Intersect(itemRange); if (itemRangeIntersection.IsEmpty) { return(SelectionCellRange.Empty); } SelectionRange columnRange = range.ColumnRange; SelectionRange columnRangeIntersection = m_columnRange.Intersect(columnRange); if (columnRangeIntersection.IsEmpty) { return(SelectionCellRange.Empty); } return(new SelectionCellRange(itemRangeIntersection, columnRangeIntersection)); }
public SelectionCellRange[] Exclude(SelectionCellRange cellRangeToExclude) { if (cellRangeToExclude.IsEmpty) { return new SelectionCellRange[] { this } } ; SelectionCellRange cellRangeIntersection = this.Intersect(cellRangeToExclude); if (cellRangeIntersection.IsEmpty) { return new SelectionCellRange[] { this } } ; SelectionRange[] itemRanges = m_itemRange.Exclude(cellRangeToExclude.ItemRange); SelectionRange[] columnRanges = m_columnRange.Exclude(cellRangeToExclude.ColumnRange); SelectionCellRange[] cellRanges = new SelectionCellRange[itemRanges.Length + columnRanges.Length]; int index = 0; foreach (SelectionRange itemRange in itemRanges) { cellRanges[index] = new SelectionCellRange(itemRange, m_columnRange); index++; } foreach (SelectionRange columnRange in columnRanges) { cellRanges[index] = new SelectionCellRange(cellRangeIntersection.ItemRange, columnRange); index++; } Debug.Assert(index == cellRanges.Length); return(cellRanges); }
private static bool IsEmpty(SelectionCellRange range) { return((range.ItemRange.IsEmpty) || (range.ColumnRange.IsEmpty)); }
public IEnumerable <SelectionCellRangeWithItems> GetIntersectedCellRangesWithItems(SelectionCellRange range) { return((from match in this.IndexOfOverlap(range) let current = m_unsortedRanges[match].Value let intersection = current.CellRange.Intersect(range) select new SelectionCellRangeWithItems( intersection.ItemRange, current.ItemRangeWithItems.GetItems(intersection.ItemRange), intersection.ColumnRange)).ToList()); }