Exemplo n.º 1
0
        public override bool GetNearestIntersectionPoint(PointF p1, PointF p2, out PointF result)
        {
            RectangleF ef1     = this.Bounds;
            float      single1 = base.InternalPenWidth / 2f;

            DiagramShape.InflateRect(ref ef1, single1, single1);
            return(EllipseGraph.NearestIntersectionOnEllipse(ef1, p1, p2, out result));
        }
Exemplo n.º 2
0
        protected virtual DiagramGraph CreateShape(DiagramPort p)
        {
            DiagramGraph shape1 = new EllipseGraph();
            SizeF        ef1    = p.Size;

            shape1.Size       = new SizeF(ef1.Width + (2f * BasicNode.DefaultShapeMargin.Width), ef1.Height + (2f * BasicNode.DefaultShapeMargin.Height));
            shape1.Selectable = false;
            shape1.Resizable  = false;
            shape1.Reshapable = false;
            shape1.Brush      = DiagramGraph.Brushes_White;
            return(shape1);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
 protected virtual DiagramGraph CreateShape(DiagramPort p)
 {
     DiagramGraph shape1 = new EllipseGraph();
     SizeF ef1 = p.Size;
     shape1.Size = new SizeF(ef1.Width + (2f * BasicNode.DefaultShapeMargin.Width), ef1.Height + (2f * BasicNode.DefaultShapeMargin.Height));
     shape1.Selectable = false;
     shape1.Resizable = false;
     shape1.Reshapable = false;
     shape1.Brush = DiagramGraph.Brushes_White;
     return shape1;
 }
Exemplo n.º 5
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);
        }