Пример #1
0
        public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result)
        {
            PointF     tf5;
            RectangleF ef1     = this.Bounds;
            float      single1 = base.InternalPenWidth / 2f;

            PointF[] tfArray1 = this.getPoints();
            PointF   tf1      = DiagramGraph.ExpandPointOnEdge(tfArray1[0], ef1, single1);
            PointF   tf2      = DiagramGraph.ExpandPointOnEdge(tfArray1[1], ef1, single1);
            PointF   tf3      = DiagramGraph.ExpandPointOnEdge(tfArray1[2], ef1, single1);
            PointF   tf4      = DiagramGraph.ExpandPointOnEdge(tfArray1[3], ef1, single1);
            float    single2  = p1.X;
            float    single3  = p1.Y;
            float    single4  = 1E+21f;
            PointF   tf6      = new PointF();

            if (StrokeGraph.NearestIntersectionOnLine(tf1, tf2, p1, p2, out tf5))
            {
                float single5 = ((tf5.X - single2) * (tf5.X - single2)) + ((tf5.Y - single3) * (tf5.Y - single3));
                if (single5 < single4)
                {
                    single4 = single5;
                    tf6     = tf5;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf2, tf3, p1, p2, out tf5))
            {
                float single6 = ((tf5.X - single2) * (tf5.X - single2)) + ((tf5.Y - single3) * (tf5.Y - single3));
                if (single6 < single4)
                {
                    single4 = single6;
                    tf6     = tf5;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf3, tf4, p1, p2, out tf5))
            {
                float single7 = ((tf5.X - single2) * (tf5.X - single2)) + ((tf5.Y - single3) * (tf5.Y - single3));
                if (single7 < single4)
                {
                    single4 = single7;
                    tf6     = tf5;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf4, tf1, p1, p2, out tf5))
            {
                float single8 = ((tf5.X - single2) * (tf5.X - single2)) + ((tf5.Y - single3) * (tf5.Y - single3));
                if (single8 < single4)
                {
                    single4 = single8;
                    tf6     = tf5;
                }
            }
            result = tf6;
            return(single4 < 1E+21f);
        }
Пример #2
0
 public override void DoResize(DiagramView view, RectangleF origRect, PointF newPoint, int whichHandle, InputState evttype, SizeF min, SizeF max)
 {
     if (((whichHandle == 0x40f) || (whichHandle == 1040)) && ((this.ResizesRealtime || (evttype == InputState.Finish)) || (evttype == InputState.Cancel)))
     {
         if (whichHandle == 0x40f)
         {
             RectangleF ef1     = this.Bounds;
             float      single1 = ef1.Width / 2f;
             float      single2 = ef1.Height / 2f;
             float      single3 = ef1.X + single1;
             float      single4 = ef1.Y + single2;
             float      single5 = StrokeGraph.GetAngle(newPoint.X - single3, newPoint.Y - single4);
             float      single6 = this.SweepAngle - (single5 - this.StartAngle);
             if (this.SweepAngle >= 0f)
             {
                 if (single6 < 0f)
                 {
                     single6 += 360f;
                 }
             }
             else if (single6 >= 0f)
             {
                 single6 -= 360f;
             }
             this.SweepAngle = single6;
             this.StartAngle = single5;
         }
         else if (whichHandle == 1040)
         {
             RectangleF ef2      = this.Bounds;
             float      single7  = ef2.Width / 2f;
             float      single8  = ef2.Height / 2f;
             float      single9  = ef2.X + single7;
             float      single10 = ef2.Y + single8;
             float      single11 = StrokeGraph.GetAngle(newPoint.X - single9, newPoint.Y - single10);
             float      single12 = single11 - this.StartAngle;
             if (this.SweepAngle >= 0f)
             {
                 if (single12 < 0f)
                 {
                     single12 += 360f;
                 }
             }
             else if (single12 >= 0f)
             {
                 single12 -= 360f;
             }
             this.SweepAngle = single12;
         }
     }
     else
     {
         base.DoResize(view, origRect, newPoint, whichHandle, evttype, min, max);
     }
 }
Пример #3
0
 public override bool ContainsPoint(PointF p)
 {
     if (base.ContainsPoint(p))
     {
         float      single9;
         float      single10;
         RectangleF ef1     = this.Bounds;
         float      single1 = base.InternalPenWidth / 2f;
         float      single2 = ef1.Width / 2f;
         float      single3 = ef1.Height / 2f;
         float      single4 = ef1.X + single2;
         float      single5 = ef1.Y + single3;
         single2 += single1;
         single3 += single1;
         if ((single2 == 0f) || (single3 == 0f))
         {
             return(false);
         }
         float single6 = p.X - single4;
         float single7 = p.Y - single5;
         if ((((single6 * single6) / (single2 * single2)) + ((single7 * single7) / (single3 * single3))) > 1f)
         {
             return(false);
         }
         float single8 = StrokeGraph.GetAngle(p.X - single4, p.Y - single5);
         if (this.SweepAngle < 0f)
         {
             single9  = this.StartAngle + this.SweepAngle;
             single10 = -this.SweepAngle;
         }
         else
         {
             single9  = this.StartAngle;
             single10 = this.SweepAngle;
         }
         if (single10 > 360f)
         {
             return(true);
         }
         if ((single9 + single10) > 360f)
         {
             if (single8 < single9)
             {
                 return(single8 <= ((single9 + single10) - 360f));
             }
             return(true);
         }
         if (single8 >= single9)
         {
             return(single8 <= (single9 + single10));
         }
     }
     return(false);
 }
Пример #4
0
        protected virtual void LayoutMidLabel(Dot.Utility.Media.Diagram.Shapes.DiagramShape childchanged)
        {
            DiagramShape obj1 = this.MidLabel;

            if (obj1 != null)
            {
                Shapes.LineGraph link1 = this.RealLink;
                int num1 = link1.PointsCount;
                if (num1 >= 2)
                {
                    if ((link1.Style == StrokeGraphStyle.Bezier) && (num1 < 7))
                    {
                        PointF tf5;
                        PointF tf6;
                        PointF tf1 = link1.GetPoint(0);
                        PointF tf2 = link1.GetPoint(1);
                        PointF tf3 = link1.GetPoint(num1 - 2);
                        PointF tf4 = link1.GetPoint(num1 - 1);
                        StrokeGraph.BezierMidPoint(tf1, tf2, tf3, tf4, out tf5, out tf6);
                        this.PositionMidLabel(obj1, tf5, tf6);
                    }
                    else
                    {
                        int num2 = num1 / 2;
                        if ((num1 % 2) == 0)
                        {
                            PointF tf7 = link1.GetPoint(num2 - 1);
                            PointF tf8 = link1.GetPoint(num2);
                            this.PositionMidLabel(obj1, tf7, tf8);
                        }
                        else
                        {
                            PointF tf9     = link1.GetPoint(num2 - 1);
                            PointF tf10    = link1.GetPoint(num2);
                            PointF tf11    = link1.GetPoint(num2 + 1);
                            float  single1 = tf10.X - tf9.X;
                            float  single2 = tf10.Y - tf9.Y;
                            float  single3 = tf11.X - tf10.X;
                            float  single4 = tf11.Y - tf10.Y;
                            if (((single1 * single1) + (single2 * single2)) >= ((single3 * single3) + (single4 * single4)))
                            {
                                this.PositionMidLabel(obj1, tf9, tf10);
                            }
                            else
                            {
                                this.PositionMidLabel(obj1, tf10, tf11);
                            }
                        }
                    }
                }
            }
        }
Пример #5
0
        public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result)
        {
            PointF     tf1;
            RectangleF ef1     = this.Bounds;
            float      single1 = base.InternalPenWidth / 2f;
            float      single2 = 1E+21f;
            PointF     tf2     = new PointF();

            if (this.Style == PolygonGraphStyle.Bezier)
            {
                for (int num1 = 3; num1 < this.myPointsCount; num1 += 3)
                {
                    PointF tf3 = this.GetPoint(num1 - 3);
                    PointF tf4 = this.GetPoint(num1 - 2);
                    if ((num1 + 3) >= this.myPointsCount)
                    {
                        num1 = this.myPointsCount - 1;
                    }
                    PointF tf5 = this.GetPoint(num1 - 1);
                    PointF tf6 = this.GetPoint(num1);
                    if (StrokeGraph.BezierNearestIntersectionOnLine(tf3, tf4, tf5, tf6, p1, p2, out tf1))
                    {
                        float single3 = ((tf1.X - p1.X) * (tf1.X - p1.X)) + ((tf1.Y - p1.Y) * (tf1.Y - p1.Y));
                        if (single3 < single2)
                        {
                            single2 = single3;
                            tf2     = tf1;
                        }
                    }
                }
            }
            else
            {
                for (int num2 = 0; num2 < this.PointsCount; num2++)
                {
                    PointF tf7 = DiagramGraph.ExpandPointOnEdge(this.GetPoint(num2), ef1, single1);
                    PointF tf8 = DiagramGraph.ExpandPointOnEdge(this.GetPoint(((num2 + 1) < this.PointsCount) ? (num2 + 1) : 0), ef1, single1);
                    if (StrokeGraph.NearestIntersectionOnLine(tf7, tf8, p1, p2, out tf1))
                    {
                        float single4 = ((tf1.X - p1.X) * (tf1.X - p1.X)) + ((tf1.Y - p1.Y) * (tf1.Y - p1.Y));
                        if (single4 < single2)
                        {
                            single2 = single4;
                            tf2     = tf1;
                        }
                    }
                }
            }
            result = tf2;
            return(single2 < 1E+21f);
        }
Пример #6
0
        public virtual float GetAngle(IDiagramLine link)
        {
            if (link == null)
            {
                return(0f);
            }
            IDiagramPort port1 = link.GetOtherPort(this);

            if (port1 == null)
            {
                if (((link.FromPort != null) && (link.FromPort.DiagramShape != null)) && (link.FromPort.DiagramShape.Bounds == this.Bounds))
                {
                    port1 = link.ToPort;
                }
                else if (((link.ToPort != null) && (link.ToPort.DiagramShape != null)) && (link.ToPort.DiagramShape.Bounds == this.Bounds))
                {
                    port1 = link.FromPort;
                }
            }
            if (port1 == null)
            {
                return(0f);
            }
            DiagramShape obj1 = port1.DiagramShape;

            if (obj1 == null)
            {
                return(0f);
            }
            PointF tf1 = obj1.Center;
            PointF tf2 = base.Center;

            Shapes.LineGraph link1 = link as Shapes.LineGraph;
            if ((link1 == null) && (link is TextLine))
            {
                link1 = ((TextLine)link).RealLink;
            }
            if ((link1 != null) && (link1.PointsCount > 0))
            {
                if (link1.FromPort == port1)
                {
                    tf1 = link1.GetPoint(0);
                }
                else
                {
                    tf1 = link1.GetPoint(link1.PointsCount - 1);
                }
            }
            return(StrokeGraph.GetAngle(tf1.X - tf2.X, tf1.Y - tf2.Y));
        }
Пример #7
0
        protected override RectangleF ComputeBounds()
        {
            int num1 = this.PointsCount;

            if (num1 <= 0)
            {
                PointF tf1 = base.Position;
                return(new RectangleF(tf1.X, tf1.Y, 0f, 0f));
            }
            PointF tf2     = this.GetPoint(0);
            float  single1 = tf2.X;
            float  single2 = tf2.Y;
            float  single3 = tf2.X;
            float  single4 = tf2.Y;

            if (this.Style == PolygonGraphStyle.Bezier)
            {
                for (int num2 = 3; num2 < this.myPointsCount; num2 += 3)
                {
                    PointF tf3 = this.GetPoint(num2 - 3);
                    PointF tf4 = this.GetPoint(num2 - 2);
                    if ((num2 + 3) >= this.myPointsCount)
                    {
                        num2 = this.myPointsCount - 1;
                    }
                    PointF     tf5 = this.GetPoint(num2 - 1);
                    PointF     tf6 = this.GetPoint(num2);
                    RectangleF ef1 = StrokeGraph.BezierBounds(tf3, tf4, tf5, tf6);
                    single1 = System.Math.Min(single1, ef1.X);
                    single2 = System.Math.Min(single2, ef1.Y);
                    single3 = System.Math.Max(single3, (float)(ef1.X + ef1.Width));
                    single4 = System.Math.Max(single4, (float)(ef1.Y + ef1.Height));
                }
            }
            else
            {
                for (int num3 = 1; num3 < num1; num3++)
                {
                    tf2     = this.GetPoint(num3);
                    single1 = System.Math.Min(single1, tf2.X);
                    single2 = System.Math.Min(single2, tf2.Y);
                    single3 = System.Math.Max(single3, tf2.X);
                    single4 = System.Math.Max(single4, tf2.Y);
                }
            }
            return(new RectangleF(single1, single2, single3 - single1, single4 - single2));
        }
Пример #8
0
        public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result)
        {
            PointF     tf5;
            RectangleF ef2;
            RectangleF ef3;
            float      single3;
            float      single4;
            RectangleF ef1     = this.Bounds;
            float      single1 = base.InternalPenWidth / 2f;

            PointF[] tfArray1 = this.getPoints(0f, 0f);
            PointF   tf1      = DiagramGraph.ExpandPointOnEdge(tfArray1[0], ef1, single1);
            PointF   tf2      = DiagramGraph.ExpandPointOnEdge(tfArray1[1], ef1, single1);
            PointF   tf3      = DiagramGraph.ExpandPointOnEdge(tfArray1[2], ef1, single1);
            PointF   tf4      = DiagramGraph.ExpandPointOnEdge(tfArray1[3], ef1, single1);
            float    single2  = 1E+21f;
            PointF   tf6      = new PointF();

            if (this.Orientation == System.Windows.Forms.Orientation.Vertical)
            {
                ef2     = new RectangleF(ef1.X, ef1.Y, ef1.Width, this.MinorRadius * 2f);
                ef3     = new RectangleF(ef1.X, (ef1.Y + ef1.Height) - (this.MinorRadius * 2f), ef1.Width, this.MinorRadius * 2f);
                single3 = 180f;
                single4 = 0f;
            }
            else
            {
                ef2     = new RectangleF(ef1.X, ef1.Y, this.MinorRadius * 2f, ef1.Height);
                ef3     = new RectangleF((ef1.X + ef1.Width) - (this.MinorRadius * 2f), ef1.Y, this.MinorRadius * 2f, ef1.Height);
                single3 = 90f;
                single4 = 270f;
            }
            if (EllipseGraph.NearestIntersectionOnArc(ef2, p1, p2, out tf5, single3, 180f))
            {
                float single5 = ((tf5.X - p1.X) * (tf5.X - p1.X)) + ((tf5.Y - p1.Y) * (tf5.Y - p1.Y));
                if (single5 < single2)
                {
                    single2 = single5;
                    tf6     = tf5;
                }
            }
            if (this.Orientation == System.Windows.Forms.Orientation.Horizontal)
            {
                if (EllipseGraph.NearestIntersectionOnArc(ef3, p1, p2, out tf5, 270f, 90f))
                {
                    float single6 = ((tf5.X - p1.X) * (tf5.X - p1.X)) + ((tf5.Y - p1.Y) * (tf5.Y - p1.Y));
                    if (single6 < single2)
                    {
                        single2 = single6;
                        tf6     = tf5;
                    }
                }
                if (EllipseGraph.NearestIntersectionOnArc(ef3, p1, p2, out tf5, 0f, 90f))
                {
                    float single7 = ((tf5.X - p1.X) * (tf5.X - p1.X)) + ((tf5.Y - p1.Y) * (tf5.Y - p1.Y));
                    if (single7 < single2)
                    {
                        single2 = single7;
                        tf6     = tf5;
                    }
                }
            }
            else if (EllipseGraph.NearestIntersectionOnArc(ef3, p1, p2, out tf5, single4, 180f))
            {
                float single8 = ((tf5.X - p1.X) * (tf5.X - p1.X)) + ((tf5.Y - p1.Y) * (tf5.Y - p1.Y));
                if (single8 < single2)
                {
                    single2 = single8;
                    tf6     = tf5;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf1, tf2, p1, p2, out tf5))
            {
                float single9 = ((tf5.X - p1.X) * (tf5.X - p1.X)) + ((tf5.Y - p1.Y) * (tf5.Y - p1.Y));
                if (single9 < single2)
                {
                    single2 = single9;
                    tf6     = tf5;
                }
            }
            if (StrokeGraph.NearestIntersectionOnLine(tf3, tf4, p1, p2, out tf5))
            {
                float single10 = ((tf5.X - p1.X) * (tf5.X - p1.X)) + ((tf5.Y - p1.Y) * (tf5.Y - p1.Y));
                if (single10 < single2)
                {
                    single2 = single10;
                    tf6     = tf5;
                }
            }
            result = tf6;
            return(single2 < 1E+21f);
        }
Пример #9
0
        public static bool NearestIntersectionOnArc(RectangleF rect, PointF p1, PointF p2, out PointF result, float startAngle, float sweepAngle)
        {
            float single5;
            float single6;
            float single1 = rect.Width / 2f;
            float single2 = rect.Height / 2f;
            float single3 = rect.X + single1;
            float single4 = rect.Y + single2;

            if (sweepAngle < 0f)
            {
                single5 = startAngle + sweepAngle;
                single6 = -sweepAngle;
            }
            else
            {
                single5 = startAngle;
                single6 = sweepAngle;
            }
            if (p1.X != p2.X)
            {
                float single7;
                if (p1.X > p2.X)
                {
                    single7 = (p1.Y - p2.Y) / (p1.X - p2.X);
                }
                else
                {
                    single7 = (p2.Y - p1.Y) / (p2.X - p1.X);
                }
                float single8  = (p1.Y - single4) - (single7 * (p1.X - single3));
                float single9  = (float)System.Math.Sqrt((double)((((single1 * single1) * (single7 * single7)) + (single2 * single2)) - (single8 * single8)));
                float single10 = ((-(((single1 * single1) * single7) * single8) + ((single1 * single2) * single9)) / ((single2 * single2) + ((single1 * single1) * (single7 * single7)))) + single3;
                float single11 = ((-(((single1 * single1) * single7) * single8) - ((single1 * single2) * single9)) / ((single2 * single2) + ((single1 * single1) * (single7 * single7)))) + single3;
                float single12 = ((single7 * (single10 - single3)) + single8) + single4;
                float single13 = ((single7 * (single11 - single3)) + single8) + single4;
                float single14 = StrokeGraph.GetAngle(single10 - single3, single12 - single4);
                float single15 = StrokeGraph.GetAngle(single11 - single3, single13 - single4);
                if (single14 < single5)
                {
                    single14 += 360f;
                }
                if (single15 < single5)
                {
                    single15 += 360f;
                }
                if (single14 > (single5 + single6))
                {
                    single14 -= 360f;
                }
                if (single15 > (single5 + single6))
                {
                    single15 -= 360f;
                }
                bool flag1 = (single14 >= single5) && (single14 <= (single5 + single6));
                bool flag2 = (single15 >= single5) && (single15 <= (single5 + single6));
                if (flag1 && flag2)
                {
                    float single16 = System.Math.Abs((float)((p1.X - single10) * (p1.X - single10))) + System.Math.Abs((float)((p1.Y - single12) * (p1.Y - single12)));
                    float single17 = System.Math.Abs((float)((p1.X - single11) * (p1.X - single11))) + System.Math.Abs((float)((p1.Y - single13) * (p1.Y - single13)));
                    if (single16 < single17)
                    {
                        result = new PointF(single10, single12);
                    }
                    else
                    {
                        result = new PointF(single11, single13);
                    }
                    return(true);
                }
                if (flag1 && !flag2)
                {
                    result = new PointF(single10, single12);
                    return(true);
                }
                if (!flag1 && flag2)
                {
                    result = new PointF(single11, single13);
                    return(true);
                }
                result = new PointF();
                return(false);
            }
            float single18 = (float)System.Math.Sqrt((double)((single2 * single2) - (((single2 * single2) / (single1 * single1)) * ((p1.X - single3) * (p1.X - single3)))));
            float single19 = single4 + single18;
            float single20 = single4 - single18;
            float single21 = StrokeGraph.GetAngle(p1.X - single3, single19 - single4);
            float single22 = StrokeGraph.GetAngle(p1.X - single3, single20 - single4);

            if (single21 < single5)
            {
                single21 += 360f;
            }
            if (single22 < single5)
            {
                single22 += 360f;
            }
            if (single21 > (single5 + single6))
            {
                single21 -= 360f;
            }
            if (single22 > (single5 + single6))
            {
                single22 -= 360f;
            }
            bool flag3 = (single21 >= single5) && (single21 <= (single5 + single6));
            bool flag4 = (single22 >= single5) && (single22 <= (single5 + single6));

            if (flag3 && flag4)
            {
                float single23 = System.Math.Abs((float)(single19 - p1.Y));
                float single24 = System.Math.Abs((float)(single20 - p1.Y));
                if (single23 < single24)
                {
                    result = new PointF(p1.X, single19);
                }
                else
                {
                    result = new PointF(p1.X, single20);
                }
                return(true);
            }
            if (flag3 && !flag4)
            {
                result = new PointF(p1.X, single19);
                return(true);
            }
            if (!flag3 && flag4)
            {
                result = new PointF(p1.X, single20);
                return(true);
            }
            result = new PointF();
            return(false);
        }
Пример #10
0
        public static bool NearestIntersectionOnEllipse(RectangleF rect, PointF p1, PointF p2, out PointF result)
        {
            if (rect.Width == 0f)
            {
                return(StrokeGraph.NearestIntersectionOnLine(new PointF(rect.X, rect.Y), new PointF(rect.X, rect.Y + rect.Height), p1, p2, out result));
            }
            if (rect.Height == 0f)
            {
                return(StrokeGraph.NearestIntersectionOnLine(new PointF(rect.X, rect.Y), new PointF(rect.X + rect.Width, rect.Y), p1, p2, out result));
            }
            float single1 = rect.Width / 2f;
            float single2 = rect.Height / 2f;
            float single3 = rect.X + single1;
            float single4 = rect.Y + single2;

            if (p1.X != p2.X)
            {
                float single5;
                if (p1.X > p2.X)
                {
                    single5 = (p1.Y - p2.Y) / (p1.X - p2.X);
                }
                else
                {
                    single5 = (p2.Y - p1.Y) / (p2.X - p1.X);
                }
                float single6 = (p1.Y - single4) - (single5 * (p1.X - single3));
                if (((((single1 * single1) * (single5 * single5)) + (single2 * single2)) - (single6 * single6)) < 0f)
                {
                    result = new PointF();
                    return(false);
                }
                float single7  = (float)System.Math.Sqrt((double)((((single1 * single1) * (single5 * single5)) + (single2 * single2)) - (single6 * single6)));
                float single8  = ((-(((single1 * single1) * single5) * single6) + ((single1 * single2) * single7)) / ((single2 * single2) + ((single1 * single1) * (single5 * single5)))) + single3;
                float single9  = ((-(((single1 * single1) * single5) * single6) - ((single1 * single2) * single7)) / ((single2 * single2) + ((single1 * single1) * (single5 * single5)))) + single3;
                float single10 = ((single5 * (single8 - single3)) + single6) + single4;
                float single11 = ((single5 * (single9 - single3)) + single6) + single4;
                float single12 = System.Math.Abs((float)((p1.X - single8) * (p1.X - single8))) + System.Math.Abs((float)((p1.Y - single10) * (p1.Y - single10)));
                float single13 = System.Math.Abs((float)((p1.X - single9) * (p1.X - single9))) + System.Math.Abs((float)((p1.Y - single11) * (p1.Y - single11)));
                if (single12 < single13)
                {
                    result = new PointF(single8, single10);
                }
                else
                {
                    result = new PointF(single9, single11);
                }
            }
            else
            {
                float single14 = single2 * single2;
                float single15 = single1 * single1;
                float single16 = p1.X - single3;
                float single17 = single14 - ((single14 / single15) * (single16 * single16));
                if (single17 < 0f)
                {
                    result = new PointF();
                    return(false);
                }
                float single18 = (float)System.Math.Sqrt((double)single17);
                float single19 = single4 + single18;
                float single20 = single4 - single18;
                float single21 = System.Math.Abs((float)(single19 - p1.Y));
                float single22 = System.Math.Abs((float)(single20 - p1.Y));
                if (single21 < single22)
                {
                    result = new PointF(p1.X, single19);
                }
                else
                {
                    result = new PointF(p1.X, single20);
                }
            }
            return(true);
        }
Пример #11
0
        public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result)
        {
            PointF     tf1;
            RectangleF ef1     = this.Bounds;
            float      single1 = base.InternalPenWidth / 2f;

            DiagramShape.InflateRect(ref ef1, single1, single1);
            float single2  = ef1.Width / 2f;
            float single3  = ef1.Height / 2f;
            float single4  = ef1.X + single2;
            float single5  = ef1.Y + single3;
            float single6  = p1.X - single4;
            float single7  = p1.Y - single5;
            float single8  = this.StartAngle;
            float single9  = this.SweepAngle;
            float single10 = single8 + single9;

            if (single10 > 360f)
            {
                single10 -= 360f;
            }
            bool  flag1    = false;
            float single11 = 1E+21f;

            result = new PointF();
            if ((-0.01f < single6) && (single6 < 0.01f))
            {
                single6 = 0.01f;
            }
            if ((-0.01f < single7) && (single7 < 0.01f))
            {
                single7 = 0.01f;
            }
            if (single9 >= 360f)
            {
                if (EllipseGraph.NearestIntersectionOnEllipse(ef1, p1, p2, out tf1))
                {
                    float single12 = ((p1.X - tf1.X) * (p1.X - tf1.X)) + ((p1.Y - tf1.Y) * (p1.Y - tf1.Y));
                    if (single12 < single11)
                    {
                        flag1    = true;
                        result   = tf1;
                        single11 = single12;
                    }
                }
            }
            else if ((single9 + single8) > 360f)
            {
                if (EllipseGraph.NearestIntersectionOnArc(ef1, p1, p2, out tf1, single8, 360f - single8))
                {
                    float single13 = ((p1.X - tf1.X) * (p1.X - tf1.X)) + ((p1.Y - tf1.Y) * (p1.Y - tf1.Y));
                    if (single13 < single11)
                    {
                        flag1    = true;
                        result   = tf1;
                        single11 = single13;
                    }
                }
                if (EllipseGraph.NearestIntersectionOnArc(ef1, p1, p2, out tf1, 0f, single9 - (360f - single8)))
                {
                    float single14 = ((p1.X - tf1.X) * (p1.X - tf1.X)) + ((p1.Y - tf1.Y) * (p1.Y - tf1.Y));
                    if (single14 < single11)
                    {
                        flag1    = true;
                        result   = tf1;
                        single11 = single14;
                    }
                }
            }
            else if (EllipseGraph.NearestIntersectionOnArc(ef1, p1, p2, out tf1, single8, single9))
            {
                float single15 = ((p1.X - tf1.X) * (p1.X - tf1.X)) + ((p1.Y - tf1.Y) * (p1.Y - tf1.Y));
                if (single15 < single11)
                {
                    flag1    = true;
                    result   = tf1;
                    single11 = single15;
                }
            }
            PointF tf2 = this.GetPointAtAngle(single8);

            if (StrokeGraph.NearestIntersectionOnLine(new PointF(single4, single5), tf2, p1, p2, out tf1))
            {
                float single16 = ((p1.X - tf1.X) * (p1.X - tf1.X)) + ((p1.Y - tf1.Y) * (p1.Y - tf1.Y));
                if (single16 < single11)
                {
                    flag1    = true;
                    result   = tf1;
                    single11 = single16;
                }
            }
            PointF tf3 = this.GetPointAtAngle(single10);

            if (StrokeGraph.NearestIntersectionOnLine(new PointF(single4, single5), tf3, p1, p2, out tf1))
            {
                float single17 = ((p1.X - tf1.X) * (p1.X - tf1.X)) + ((p1.Y - tf1.Y) * (p1.Y - tf1.Y));
                if (single17 < single11)
                {
                    flag1    = true;
                    result   = tf1;
                    single11 = single17;
                }
            }
            return(flag1);
        }