Beispiel #1
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));
        }
Beispiel #2
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);
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
 public override void LayoutChildren(Dot.Utility.Media.Diagram.Shapes.DiagramShape childchanged)
 {
     if (!base.Initializing)
     {
         Shapes.LineGraph link1 = this.RealLink;
         if (link1 != null)
         {
             int num1 = link1.PointsCount;
             if (num1 >= 2)
             {
                 DiagramShape obj1 = this.FromLabel;
                 if (obj1 != null)
                 {
                     PointF tf1 = link1.GetPoint(0);
                     PointF tf2 = link1.GetPoint(1);
                     if (num1 == 2)
                     {
                         this.PositionEndLabel(obj1, false, tf1, tf1, tf2);
                     }
                     else
                     {
                         this.PositionEndLabel(obj1, false, tf1, tf2, link1.GetPoint(2));
                     }
                 }
                 this.LayoutMidLabel(childchanged);
                 obj1 = this.ToLabel;
                 if (obj1 != null)
                 {
                     PointF tf3 = link1.GetPoint(num1 - 1);
                     PointF tf4 = link1.GetPoint(num1 - 2);
                     if (num1 == 2)
                     {
                         this.PositionEndLabel(obj1, true, tf3, tf3, tf4);
                     }
                     else
                     {
                         this.PositionEndLabel(obj1, true, tf3, tf4, link1.GetPoint(num1 - 3));
                     }
                 }
             }
         }
     }
 }
Beispiel #4
0
 public virtual void StartRelink(Shapes.IDiagramLine oldlink, Shapes.IDiagramPort oldport, PointF dc)
 {
     if (oldlink != null)
     {
         Shapes.DiagramShape obj1 = oldlink.DiagramShape;
         if ((obj1 != null) && (obj1.Layer != null))
         {
             base.StartTransaction();
             this.myLinkingNew    = false;
             this.OriginalEndPort = oldport;
             this.Link            = oldlink;
             if (oldlink.ToPort == oldport)
             {
                 this.Forwards          = true;
                 this.OriginalStartPort = oldlink.FromPort;
                 PointF tf1 = dc;
                 if (this.OriginalStartPort != null)
                 {
                     tf1 = this.OriginalStartPort.DiagramShape.Center;
                 }
                 else if (oldlink is Shapes.LineGraph)
                 {
                     Shapes.LineGraph link1 = (Shapes.LineGraph)oldlink;
                     if (link1.PointsCount > 0)
                     {
                         tf1 = link1.GetPoint(0);
                     }
                 }
                 else if (oldlink is Shapes.TextLine)
                 {
                     Shapes.TextLine link2 = (Shapes.TextLine)oldlink;
                     if (link2.RealLink.PointsCount > 0)
                     {
                         tf1 = link2.RealLink.GetPoint(0);
                     }
                 }
                 this.StartPort   = this.CreateTemporaryPort(this.OriginalStartPort, tf1, false, false);
                 oldlink.FromPort = this.StartPort;
                 this.EndPort     = this.CreateTemporaryPort(this.OriginalEndPort, dc, true, true);
                 oldlink.ToPort   = this.EndPort;
             }
             else if (oldlink.FromPort == oldport)
             {
                 this.Forwards          = false;
                 this.OriginalStartPort = oldlink.ToPort;
                 PointF tf2 = dc;
                 if (this.OriginalStartPort != null)
                 {
                     tf2 = this.OriginalStartPort.DiagramShape.Center;
                 }
                 else if (oldlink is Shapes.LineGraph)
                 {
                     Shapes.LineGraph link3 = (Shapes.LineGraph)oldlink;
                     if (link3.PointsCount > 0)
                     {
                         tf2 = link3.GetPoint(link3.PointsCount - 1);
                     }
                 }
                 else if (oldlink is Shapes.TextLine)
                 {
                     Shapes.TextLine link4 = (Shapes.TextLine)oldlink;
                     if (link4.RealLink.PointsCount > 0)
                     {
                         tf2 = link4.RealLink.GetPoint(link4.RealLink.PointsCount - 1);
                     }
                 }
                 this.StartPort   = this.CreateTemporaryPort(this.OriginalStartPort, tf2, true, false);
                 oldlink.ToPort   = this.StartPort;
                 this.EndPort     = this.CreateTemporaryPort(this.OriginalEndPort, dc, false, true);
                 oldlink.FromPort = this.EndPort;
             }
             base.View.Cursor = Cursors.Hand;
         }
     }
 }