示例#1
0
        private bool BoundsMatchSnapLine(Rect bounds, SnapLine snapLine)
        {
            if (snapLine.Location == SnapLineLocation.Baseline)
            {
                return(true);
            }
            Point cornerPoint1;
            Point cornerPoint2;

            this.GetTargetCorners(bounds, snapLine.Orientation, snapLine.LocationRelativeToTarget, out cornerPoint1, out cornerPoint2);
            double signedDistance1 = snapLine.GetSignedDistance(cornerPoint1);
            double signedDistance2 = snapLine.GetSignedDistance(cornerPoint2);

            if (Math.Abs(signedDistance1 + snapLine.OffsetRelativeToTarget) < 0.01)
            {
                return(Math.Abs(signedDistance2 + snapLine.OffsetRelativeToTarget) < 0.01);
            }
            return(false);
        }
示例#2
0
 private bool ShouldSnap(Point p1, Point p2, SnapLineLocation location, SnapLine snapLine, out double offset)
 {
     offset = 0.0;
     if (location == snapLine.Location)
     {
         if (!snapLine.IsContainerLine)
         {
             return(true);
         }
         if (snapLine.RangeOverlaps(p1, p2))
         {
             offset = location == SnapLineLocation.Minimum ? this.defaultPadding : -this.defaultPadding;
             return(true);
         }
     }
     else if ((location == SnapLineLocation.Minimum && snapLine.Location == SnapLineLocation.Maximum || location == SnapLineLocation.Maximum && snapLine.Location == SnapLineLocation.Minimum) && (!snapLine.IsContainerLine && snapLine.RangeOverlaps(p1, p2)))
     {
         offset = snapLine.Location == SnapLineLocation.Minimum ? -this.defaultMargin : this.defaultMargin;
         return(true);
     }
     return(false);
 }
示例#3
0
        private double CheckForCloserSnapLine(Point p1, SnapLineLocation location, double snapThreshold, List <SnapLine> resultSnapLines, double smallestSignedDistance, SnapLine snapLine, double offset)
        {
            double num1 = snapLine.GetSignedDistance(p1) + offset;
            double num2 = Math.Abs(num1);

            if (num2 <= snapThreshold)
            {
                if (num2 < Math.Abs(smallestSignedDistance))
                {
                    smallestSignedDistance = num1;
                    resultSnapLines.Clear();
                }
                if (Math.Abs(num1 - smallestSignedDistance) < 1E-06)
                {
                    snapLine.LocationRelativeToTarget = location;
                    snapLine.OffsetRelativeToTarget   = offset;
                    resultSnapLines.Add(snapLine);
                }
            }
            return(smallestSignedDistance);
        }