protected override void OnApply(LinkLineNode node)
        {
            LinkLineNode node1 = GetLineNode(_node1);
            LinkLineNode node2 = GetLineNode(_node2);
            LinkLineNode start = (LinkLineNode)node1.PrevNode;
            LinkLineNode end   = (LinkLineNode)node2.NextNode;

            node1.ClearLine();
            node2.ClearLine();
            node.Parent.Controls.Remove(node1);
            node.Parent.Controls.Remove(node2);
            start.SetNext(end);
            end.SetPrevious(start);
            if (start.Line == null)
            {
                start.CreateForwardLine();
            }
            else
            {
                end.CreateBackwardLine();
            }
            if (start.LinkedOutPort != null)
            {
                if (end.LinkedInPort != null)
                {
                    start.LinkedOutPort.LinkedPortID = end.LinkedInPort.PortID;
                    end.LinkedInPort.LinkedPortID    = start.LinkedOutPort.PortID;
                }
            }
            ActiveDrawing.RefreshControl(node.Parent);
        }
Exemplo n.º 2
0
 /// <summary>
 /// create action components and make port links
 /// </summary>
 /// <param name="designer"></param>
 public override bool LoadToDesigner(List <UInt32> used, MethodDiagramViewer designer)
 {
     if (designer.LoadAction(this))
     {
         if (_ifActions != null)
         {
             if (_ifActions.LoadToDesigner(used, designer))
             {
                 //make port link
                 if (this.OutPortList[0].LinkedInPort == null)
                 {
                     LinkLineNode end = this.OutPortList[0].End;
                     ActionPortIn pi  = _ifActions.GetInPort(this.OutPortList[0].LinkedPortID, this.OutPortList[0].LinkedPortInstanceID);
                     if (pi == null)
                     {
                         throw new MathException("Out port {0} is linked to [{1},{2}] of Branch {3}; but [{1},{2}] is not among the in-ports of the branch", this.OutPortList[0].PortID, this.OutPortList[0].LinkedPortID, this.OutPortList[0].LinkedPortInstanceID, _ifActions.BranchId);
                     }
                     LinkLineNode start = pi.Start;
                     end.SetNext(start);
                     start.SetPrevious(end);
                 }
             }
         }
         if (_elseActions != null)
         {
             if (_elseActions.LoadToDesigner(used, designer))
             {
                 //make port link
                 if (this.OutPortList[1].LinkedInPort == null)
                 {
                     LinkLineNode end = this.OutPortList[1].End;
                     ActionPortIn pi  = _elseActions.GetInPort(this.OutPortList[1].LinkedPortID, this.OutPortList[1].LinkedPortInstanceID);
                     if (pi == null)
                     {
                         throw new MathException("Out port {0} is linked to [{1},{2}] of Branch {3}; but [{1},{2}] is not among the in-ports of the branch", this.OutPortList[1].PortID, this.OutPortList[1].LinkedPortID, this.OutPortList[1].LinkedPortInstanceID, _elseActions.BranchId);
                     }
                     LinkLineNode start = pi.Start;
                     end.SetNext(start);
                     start.SetPrevious(end);
                 }
             }
         }
         return(true);
     }
     return(false);
 }
Exemplo n.º 3
0
        void componentChangeService_ComponentRemoving(object sender, ComponentEventArgs e)
        {
            if (bLoading)
            {
                return;
            }

            MathExpViewer mv = e.Component as MathExpViewer;

            if (mv != null)
            {
                List <LinkLineNodePort> ports = mv.GetPorts();
                for (int i = 0; i < ports.Count; i++)
                {
                    LinkLineNode l = ports[i];
                    l.ClearLine();
                    root.Controls.Remove(ports[i]);
                    root.Controls.Remove(ports[i].Label);
                    if (l is LinkLineNodeInPort)
                    {
                        if (l.LinkedOutPort == null)
                        {
                            //it is not linked to an output, remove all nodes
                            l = (LinkLineNode)l.PrevNode;
                            while (l != null)
                            {
                                root.Controls.Remove(l);
                                l = (LinkLineNode)l.PrevNode;
                            }
                        }
                        else
                        {
                            l.LinkedOutPort.LinkedPortID = 0;
                            //replace this port with a node
                            LinkLineNode prev = (LinkLineNode)l.PrevNode;
                            LinkLineNode end  = new LinkLineNode(null, prev);
                            end.Location = l.Location;
                            root.Controls.Add(end);
                            prev.SetNext(end);
                            if (prev.Line == null)
                            {
                                prev.CreateForwardLine();
                            }
                            else
                            {
                                if (prev.Line.EndPoint == l)
                                {
                                    prev.Line.SetEnd(end);
                                }
                                else
                                {
                                    end.CreateBackwardLine();
                                }
                            }
                        }
                    }
                    else if (l is LinkLineNodeOutPort)
                    {
                        if (l.LinkedInPort == null)
                        {
                            //it is not linked to an input, remove all nodes
                            l = (LinkLineNode)l.NextNode;
                            while (l != null)
                            {
                                root.Controls.Remove(l);
                                l = (LinkLineNode)l.NextNode;
                            }
                        }
                        else
                        {
                            l.LinkedInPort.LinkedPortID = 0;
                            //replace this port with a node
                            LinkLineNode next = (LinkLineNode)l.NextNode;
                            if (next.Parent != null)
                            {
                                LinkLineNode end = new LinkLineNode(next, null);
                                end.Location = l.Location;
                                next.Parent.Controls.Add(end);
                                next.SetPrevious(end);
                                if (next.Line == null)
                                {
                                    next.CreateBackwardLine();
                                }
                                else
                                {
                                    if (next.Line.StartPoint == l)
                                    {
                                        next.Line.SetStart(end);
                                    }
                                    else
                                    {
                                        end.CreateForwardLine();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }