Intersect() public method

Returns the intersection between the 2 Range. If one of the range is empty then the return is empty.
public Intersect ( Range p_Range ) : Range
p_Range Range
return Range
Beispiel #1
0
        /// <summary>
        /// Returns a non contiguous range of cells of the intersection between the current range and the specified range.
        /// </summary>
        /// <param name="p_Range"></param>
        /// <returns></returns>
        public virtual RangeRegion Intersect(Range p_Range)
        {
            RangeRegion range = new RangeRegion();

            if (p_Range.IsEmpty() == false && IsEmpty() == false)
            {
                //Range
                for (int i = 0; i < m_RangeCollection.Count; i++)
                {
                    Range intersectRange = p_Range.Intersect(m_RangeCollection[i]);
                    if (intersectRange.IsEmpty() == false)
                    {
                        range.m_RangeCollection.Add(intersectRange);
                    }
                }
            }

            return(range);
        }
Beispiel #2
0
        public Range FindDestinationRange(GridVirtual destinationGrid, Position dropDestination)
        {
            if (dropDestination.IsEmpty())
            {
                return(Range.Empty);
            }

            Position destinationStart = new Position(dropDestination.Row + (mSourceRange.Start.Row - mStartDragPosition.Row),
                                                     dropDestination.Column + (mSourceRange.Start.Column - mStartDragPosition.Column));

            destinationStart = Position.Max(destinationStart, new Position(0, 0));

            Range destination = mSourceRange;

            destination.MoveTo(destinationStart);

            destination = destination.Intersect(destinationGrid.CompleteRange);

            return(destination);
        }
Beispiel #3
0
        /// <summary>
        /// Returns a non contiguous range of cells of the intersection between the current range and the specified range.
        /// </summary>
        /// <param name="p_Range"></param>
        /// <returns></returns>
        public virtual RangeRegion Intersect(Range p_Range)
        {
            RangeRegion range = new RangeRegion();

            if (p_Range.IsEmpty() == false && IsEmpty() == false)
            {
                //Range
                for (int i = 0; i < m_RangeCollection.Count; i++)
                {
                    Range intersectRange = p_Range.Intersect(m_RangeCollection[i]);
                    if (intersectRange.IsEmpty() == false)
                        range.m_RangeCollection.Add(intersectRange);
                }
            }

            return range;
        }