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);
        }
        protected override void OnApply(LinkLineNode node)
        {
            LinkLineNode prevNode = node;

            if (prevNode != null)
            {
                LinkLineNode nextNode = GetLineNode(_next);
                if (nextNode != null)
                {
                    if (prevNode.Line != null)
                    {
                        if (prevNode.Line.EndPoint == nextNode)
                        {
                            prevNode.ClearLine();
                        }
                    }
                    if (nextNode.Line != null)
                    {
                        if (nextNode.Line.StartPoint == prevNode)
                        {
                            nextNode.ClearLine();
                        }
                    }
                    LinkLineNode newNode = new LinkLineNode(nextNode, prevNode);
                    newNode.Location        = _point;
                    newNode.ActiveDrawingID = _deleted;
                    nextNode.Parent.Controls.Add(newNode);
                    if (prevNode.Line == null)
                    {
                        prevNode.CreateForwardLine();
                        newNode.CreateForwardLine();
                    }
                    else
                    {
                        newNode.CreateBackwardLine();
                        nextNode.CreateBackwardLine();
                    }
                    ActiveDrawing.RefreshControl(nextNode.Parent);
                }
            }
        }
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();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }