Ejemplo n.º 1
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));
            }
        }
Ejemplo n.º 2
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));
                }
            }
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Merges given range with one of the intersecting range in m_ranges
 /// if no intersecting ranges is found, then rangeToMerge is
 /// added to m_ranges
 /// </summary>
 /// <param name="rangeToMerge"></param>
 /// <returns></returns>
 private GridRange MergeRecursive(GridRange rangeToMerge)
 {
     for (int i = 0; i < m_ranges.Count; i++)
     {
         GridRange range = m_ranges[i];
         if (range.IntersectsWith(rangeToMerge))
         {
             m_ranges.Remove(range);
             return(MergeByRow(rangeToMerge, range));
         }
     }
     m_ranges.Add(rangeToMerge);
     return(GridRange.Empty);
 }
Ejemplo n.º 5
0
 private bool RemoveRangeRecursive(GridRange rangeToRemove)
 {
     rangeToRemove = NormalizeRange(rangeToRemove);
     for (int i = 0; i < m_ranges.Count; i++)
     {
         GridRange range = m_ranges[i];
         if (range.IntersectsWith(rangeToRemove) == false)
         {
             continue;
         }
         GridRange intersection = range.Intersect(rangeToRemove);
         m_ranges.Remove(range);
         RangeRegion excludedRanges = range.Exclude(intersection);
         InternalAdd(excludedRanges);
         return(true);
     }
     return(false);
 }