示例#1
0
 private Rect AdjustPosition(AnchorPanel.ArrangeGrid arrangeGrid, AnchoredElement anchoredElement, Rect position)
 {
     if (!this.CollisionDetectionEnabled || !AnchorPanel.GetRepositionOverlapped(anchoredElement.UIElement) || !AnchorPanel.CheckPositionForCollision(arrangeGrid, anchoredElement, position))
         return position;
     Rect rect;
     if (anchoredElement.ContentPosition == ContentPositions.InsideEnd || anchoredElement.ContentPosition == ContentPositions.InsideCenter || (anchoredElement.ContentPosition == ContentPositions.InsideBase || anchoredElement.ContentPosition == ContentPositions.OutsideBase) || anchoredElement.ContentPosition == ContentPositions.OutsideEnd)
     {
         rect = this.AdjustAnchorRectPosition(arrangeGrid, anchoredElement, position);
         if (rect == position)
             rect = this.AdjustAnchoredPosition(arrangeGrid, anchoredElement, position);
     }
     else
     {
         rect = this.AdjustAnchoredPosition(arrangeGrid, anchoredElement, position);
         if (rect == position)
             rect = this.AdjustAnchorRectPosition(arrangeGrid, anchoredElement, position);
     }
     bool hideOverlapped = AnchorPanel.GetHideOverlapped(anchoredElement.UIElement);
     if (rect == position && hideOverlapped)
         rect = new Rect(double.MinValue, double.MinValue, 0.0, 0.0);
     return rect;
 }
示例#2
0
 private Rect AdjustAnchorRectPosition(AnchorPanel.ArrangeGrid arrangeGrid, AnchoredElement anchoredElement, Rect position)
 {
     if (!anchoredElement.AnchorRect.IsEmpty && ValueHelper.CanGraph(anchoredElement.AnchorRect.X) && (ValueHelper.CanGraph(anchoredElement.AnchorRect.Y) && ValueHelper.CanGraph(anchoredElement.AnchorRect.Right)) && ValueHelper.CanGraph(anchoredElement.AnchorRect.Left))
     {
         ContentPositions[] contentPositionsArray;
         switch (anchoredElement.ContentPosition)
         {
             case ContentPositions.InsideEnd:
                 contentPositionsArray = new ContentPositions[5]
                 {
       ContentPositions.InsideEnd,
       ContentPositions.InsideCenter,
       ContentPositions.InsideBase,
       ContentPositions.OutsideEnd,
       ContentPositions.OutsideBase
                 };
                 break;
             case ContentPositions.OutsideBase:
                 contentPositionsArray = new ContentPositions[5]
                 {
       ContentPositions.OutsideBase,
       ContentPositions.InsideBase,
       ContentPositions.InsideCenter,
       ContentPositions.InsideEnd,
       ContentPositions.OutsideEnd
                 };
                 break;
             case ContentPositions.OutsideEnd:
                 contentPositionsArray = new ContentPositions[5]
                 {
       ContentPositions.OutsideEnd,
       ContentPositions.InsideEnd,
       ContentPositions.InsideCenter,
       ContentPositions.InsideBase,
       ContentPositions.OutsideBase
                 };
                 break;
             case ContentPositions.InsideCenter:
                 contentPositionsArray = new ContentPositions[5]
                 {
       ContentPositions.InsideCenter,
       ContentPositions.InsideEnd,
       ContentPositions.InsideBase,
       ContentPositions.OutsideEnd,
       ContentPositions.OutsideBase
                 };
                 break;
             case ContentPositions.InsideBase:
                 contentPositionsArray = new ContentPositions[5]
                 {
       ContentPositions.InsideBase,
       ContentPositions.InsideCenter,
       ContentPositions.InsideEnd,
       ContentPositions.OutsideBase,
       ContentPositions.OutsideEnd
                 };
                 break;
             default:
                 contentPositionsArray = new ContentPositions[6]
                 {
       anchoredElement.ContentPosition,
       ContentPositions.TopCenter,
       ContentPositions.BottomCenter,
       ContentPositions.MiddleRight,
       ContentPositions.MiddleLeft,
       ContentPositions.MiddleCenter
                 };
                 break;
         }
         if (contentPositionsArray != null)
         {
             Size desiredSize = AnchorPanel.GetDesiredSize(anchoredElement.UIElement);
             for (int index = 0; index < contentPositionsArray.Length; ++index)
             {
                 if ((anchoredElement.ValidContentPositions & contentPositionsArray[index]) == contentPositionsArray[index])
                 {
                     double val1 = anchoredElement.MaximumMovingDistance;
                     double num1 = Math.Max(anchoredElement.MinimumMovingDistance, anchoredElement.AnchorMargin);
                     bool flag = false;
                     switch (contentPositionsArray[index])
                     {
                         case ContentPositions.InsideCenter:
                             num1 = anchoredElement.MinimumMovingDistance;
                             flag = true;
                             val1 = anchoredElement.AnchorRectOrientation == RectOrientation.LeftRight || anchoredElement.AnchorRectOrientation == RectOrientation.RightLeft ? (anchoredElement.AnchorRect.Width - desiredSize.Width) / 2.0 : (anchoredElement.AnchorRect.Height - AnchorPanel.GetDesiredSize(anchoredElement.UIElement).Height) / 2.0;
                             break;
                         case ContentPositions.InsideBase:
                         case ContentPositions.InsideEnd:
                             val1 = anchoredElement.AnchorRectOrientation == RectOrientation.LeftRight || anchoredElement.AnchorRectOrientation == RectOrientation.RightLeft ? anchoredElement.AnchorRect.Width - AnchorPanel.GetDesiredSize(anchoredElement.UIElement).Width : anchoredElement.AnchorRect.Height - AnchorPanel.GetDesiredSize(anchoredElement.UIElement).Height;
                             break;
                     }
                     double num2 = Math.Min(val1, anchoredElement.MaximumMovingDistance);
                     double offset = num1;
                     while (DoubleHelper.LessOrEqualWithPrecision(offset, num2))
                     {
                         Rect position1 = AnchorPanel.CalculateContentPosition(anchoredElement, contentPositionsArray[index], desiredSize, offset);
                         if (!AnchorPanel.CheckPositionForCollision(arrangeGrid, anchoredElement, position1))
                         {
                             anchoredElement.Offset = offset;
                             anchoredElement.ContentPosition = contentPositionsArray[index];
                             return position1;
                         }
                         if (flag)
                         {
                             Rect position2 = AnchorPanel.CalculateContentPosition(anchoredElement, contentPositionsArray[index], desiredSize, -offset);
                             if (!AnchorPanel.CheckPositionForCollision(arrangeGrid, anchoredElement, position2))
                             {
                                 anchoredElement.Offset = offset;
                                 anchoredElement.ContentPosition = contentPositionsArray[index];
                                 return position2;
                             }
                         }
                         offset += this.MovingStep;
                     }
                 }
             }
         }
     }
     return position;
 }
示例#3
0
 private static void InvalidateAnchorPanel(AnchorPanel panel)
 {
     if (panel == null)
         return;
     panel.Invalidate();
 }
示例#4
0
 private Rect AdjustAnchoredPosition(AnchorPanel.ArrangeGrid arrangeGrid, AnchoredElement anchoredElement, Rect position)
 {
     if (ValueHelper.CanGraph(anchoredElement.AnchorPoint.X) && ValueHelper.CanGraph(anchoredElement.AnchorPoint.Y))
     {
         ContentPositions[] contentPositionsArray = new ContentPositions[9]
         {
       ContentPositions.BottomCenter,
       ContentPositions.TopCenter,
       ContentPositions.MiddleRight,
       ContentPositions.MiddleLeft,
       ContentPositions.BottomRight,
       ContentPositions.BottomLeft,
       ContentPositions.TopRight,
       ContentPositions.TopLeft,
       ContentPositions.MiddleCenter
         };
         Size desiredSize = AnchorPanel.GetDesiredSize(anchoredElement.UIElement);
         double offset = Math.Max(anchoredElement.MinimumMovingDistance, anchoredElement.AnchorMargin);
         while (DoubleHelper.LessOrEqualWithPrecision(offset, anchoredElement.MaximumMovingDistance))
         {
             for (int index = 0; index < contentPositionsArray.Length; ++index)
             {
                 if ((contentPositionsArray[index] != ContentPositions.MiddleCenter || offset == anchoredElement.MinimumMovingDistance) && (anchoredElement.ValidContentPositions & contentPositionsArray[index]) == contentPositionsArray[index])
                 {
                     Rect position1 = AnchorPanel.CalculateContentPosition(anchoredElement, contentPositionsArray[index], desiredSize, offset);
                     if (!AnchorPanel.CheckPositionForCollision(arrangeGrid, anchoredElement, position1))
                     {
                         anchoredElement.Offset = offset;
                         anchoredElement.ContentPosition = contentPositionsArray[index];
                         return position1;
                     }
                 }
             }
             offset += this.MovingStep;
         }
     }
     return position;
 }
示例#5
0
 private static bool CheckPositionForCollision(AnchorPanel.ArrangeGrid arrangeGrid, AnchoredElement anchoredElement, Rect position)
 {
     if (arrangeGrid.HasConflict(position))
         return true;
     Rect rect = RectExtensions.Expand(new Rect(new Point(0.0, 0.0), anchoredElement.ArrangeSize), 5.0, 3.0);
     switch (anchoredElement.OutsidePlacement)
     {
         case OutsidePlacement.Disallowed:
             rect.Intersect(position);
             if (!DoubleHelper.LessWithPrecision(rect.Width, position.Width))
                 return DoubleHelper.LessWithPrecision(rect.Height, position.Height);
             return true;
         case OutsidePlacement.Partial:
             rect.Intersect(position);
             if (!DoubleHelper.LessWithPrecision(rect.Width, position.Width / 2.0))
                 return DoubleHelper.LessWithPrecision(rect.Height, position.Height / 2.0);
             return true;
         default:
             return false;
     }
 }