Пример #1
0
        internal override void VerifyRowRange(GridRange rowRange)
        {
            if (GridRange.IntersectsWith(rowRange))
            {
                throw new InvalidOperationException(DiagnosticMessages.BlockBinding_IntersectsWithRowRange(Ordinal));
            }

            if (!Template.Orientation.HasValue)
            {
                throw new InvalidOperationException(DiagnosticMessages.BlockBinding_NullOrientation);
            }

            var orientation = Template.Orientation.GetValueOrDefault();

            if (orientation == Orientation.Horizontal)
            {
                if (!rowRange.Contains(GridRange.Left) || !rowRange.Contains(GridRange.Right))
                {
                    throw new InvalidOperationException(DiagnosticMessages.BlockBinding_OutOfHorizontalRowRange(Ordinal));
                }
            }
            else
            {
                Debug.Assert(orientation == Orientation.Vertical);
                if (!rowRange.Contains(GridRange.Top) || !rowRange.Contains(GridRange.Bottom))
                {
                    throw new InvalidOperationException(DiagnosticMessages.BlockBinding_OutOfVerticalRowRange(Ordinal));
                }
            }
        }
Пример #2
0
        internal override void VerifyRowRange(GridRange rowRange)
        {
            if (GridRange.IntersectsWith(rowRange))
            {
                throw new InvalidOperationException(DiagnosticMessages.ScalarBinding_IntersectsWithRowRange(Ordinal));
            }

            if (!RepeatsWhenFlow)
            {
                return;
            }

            if (Template.Flowable(Orientation.Horizontal))
            {
                if (!rowRange.Contains(GridRange.Left) || !rowRange.Contains(GridRange.Right))
                {
                    throw new InvalidOperationException(DiagnosticMessages.ScalarBinding_OutOfHorizontalRowRange(Ordinal));
                }
            }
            else if (Template.Flowable(Orientation.Vertical))
            {
                if (!rowRange.Contains(GridRange.Top) || !rowRange.Contains(GridRange.Bottom))
                {
                    throw new InvalidOperationException(DiagnosticMessages.ScalarBinding_OutOfVerticalRowRange(Ordinal));
                }
            }
            else
            {
                throw new InvalidOperationException(DiagnosticMessages.ScalarBinding_FlowRepeatableNotAllowedByTemplate(Ordinal));
            }
        }
Пример #3
0
        public bool Remove(GridRange range)
        {
            // if the item is not contained in this quad, there's a problem
            if (!m_bounds.Contains(range))
            {
                throw new ArgumentException("range is out of the bounds of this quadtree node");
            }

            // for each subnode:
            // if the node contains the item, add the item to that node and return
            // this recurses into the node that is just large enough to fit this item
            foreach (QuadTreeNode node in m_nodes)
            {
                if (node.Bounds.Contains(range))
                {
                    return(node.Remove(range));
                }
            }

            for (int i = 0; i < Contents.Count; i++)
            {
                if (Contents[i].Equals(range))
                {
                    Contents.RemoveAt(i);
                    return(true);
                }
            }
            return(false);
        }
Пример #4
0
 internal sealed override void VerifyRowRange(GridRange rowRange)
 {
     if (!rowRange.Contains(GridRange))
     {
         throw new InvalidOperationException(DiagnosticMessages.RowBinding_OutOfRowRange(Ordinal));
     }
 }
Пример #5
0
        /// <summary>
        /// Query the QuadTree for items that are in the given area
        /// </summary>
        /// <returns></returns>
        public List <GridRange> QueryInternal(GridRange queryArea, bool stopOnFirst)
        {
            // create a list of the items that are found
            List <GridRange> results = new List <GridRange>();

            // this quad contains items that are not entirely contained by
            // it's four sub-quads. Iterate through the items in this quad
            // to see if they intersect.
            foreach (var item in this.Contents)
            {
                if (queryArea.IntersectsWith(item))
                {
                    results.Add(item);
                    if (stopOnFirst == true)
                    {
                        return(results);
                    }
                }
            }

            foreach (QuadTreeNode node in m_nodes)
            {
                if (node.IsEmpty)
                {
                    continue;
                }

                // Case 1: search area completely contained by sub-quad
                // if a node completely contains the query area, go down that branch
                // and skip the remaining nodes (break this loop)
                if (node.Bounds.Contains(queryArea))
                {
                    results.AddRange(node.QueryInternal(queryArea, stopOnFirst));
                    break;
                }

                // Case 2: Sub-quad completely contained by search area
                // if the query area completely contains a sub-quad,
                // just add all the contents of that quad and it's children
                // to the result set. You need to continue the loop to test
                // the other quads
                if (queryArea.Contains(node.Bounds))
                {
                    results.AddRange(node.SubTreeContents);
                    continue;
                }

                // Case 3: search area intersects with sub-quad
                // traverse into this quad, continue the loop to search other
                // quads
                if (node.Bounds.IntersectsWith(queryArea))
                {
                    results.AddRange(node.QueryInternal(queryArea, stopOnFirst));
                }
            }


            return(results);
        }
Пример #6
0
        public override void Draw(RangePaintEventArgs e)
        {
            RangeRegion region = mSelection.GetSelectionRegion();

            if (region.IsEmpty())
            {
                return;
            }

            // get visible range for scrollable area
            GridRange visibleScrollabeRange = mSelection.Grid.RangeAtAreaExpanded(CellPositionType.Scrollable);


            System.Drawing.Brush brush = e.GraphicsCache.BrushsCache.GetBrush(mSelection.BackColor);

            CellContext focusContext = new CellContext(e.Grid, mSelection.ActivePosition);
            // get focus rectangle
            // clipped to visible range
            GridRange focusClippedRange = visibleScrollabeRange.Intersect(new GridRange(mSelection.ActivePosition, mSelection.ActivePosition));

            System.Drawing.Rectangle focusRect = e.Grid.PositionToRectangle(focusClippedRange.Start);

            //Draw each selection range
            foreach (GridRange rangeToLoop in region)
            {
                // intersect given range with visible range
                // this way we ensure we don't loop through thousands
                // of rows to calculate rectToDraw
                GridRange rng = visibleScrollabeRange.Intersect(rangeToLoop);


                System.Drawing.Rectangle rectToDraw = e.Grid.RangeToRectangle(rng);
                if (rectToDraw == System.Drawing.Rectangle.Empty)
                {
                    continue;
                }

                System.Drawing.Region regionToDraw = new System.Drawing.Region(rectToDraw);

                if (rectToDraw.IntersectsWith(focusRect))
                {
                    regionToDraw.Exclude(focusRect);
                }

                e.GraphicsCache.Graphics.FillRegion(brush, regionToDraw);

                //Draw the border only if there isn't a editing cell
                // and is the range that contains the focus or there is a single range
                if (rng.Contains(mSelection.ActivePosition) || region.Count == 1)
                {
                    if (focusContext.IsEditing() == false)
                    {
                        mSelection.Border.Draw(e.GraphicsCache, rectToDraw);
                    }
                }
            }

            //Draw Focus
            System.Drawing.Brush brushFocus = e.GraphicsCache.BrushsCache.GetBrush(mSelection.FocusBackColor);
            e.GraphicsCache.Graphics.FillRectangle(brushFocus, focusRect);
        }