Ejemplo n.º 1
0
 internal void DetachLine(ConnectionLine line)
 {
     if (m_Lines.Contains(line))
     {
         m_Lines.Remove(line);
     }
 }
Ejemplo n.º 2
0
 internal void AttachLine(ConnectionLine line)
 {
     if (m_Lines.Contains(line))
     {
         return;
     }
     m_Lines.Add(line);
 }
        /// <summary>
        /// Merges all connected Terminals of the given connection to this one
        /// </summary>
        /// <param name="graphicConnection">connection to derive connection items from</param>
        internal void Merge(GraphicConnection graphicConnection)
        {
            Connection otherConnection = graphicConnection.LinkedObject as Connection;
            Connection connection      = LinkedObject as Connection;

            foreach (Terminal terminal in otherConnection.Terminals)
            {
                otherConnection.DisconnectTerminal(terminal);
                connection.ConnectTerminal(terminal);
            }
            //clone all nodes of the other connection
            foreach (GraphicBaseElement child in graphicConnection.Children)
            {
                if (child is ConnectionNode)
                {
                    ConnectionNode clone = new ConnectionNode(child.Location);
                    AddChild(clone);
                }
            }
            //clone all lines of the other connection attached to the previously cloned nodes
            foreach (GraphicBaseElement child in graphicConnection.Children)
            {
                if (child is ConnectionLine)
                {
                    ConnectionLine orig = child as ConnectionLine;
                    ConnectionNode node1, node2;
                    //select cloned nodes or terminal nodes
                    if (orig.Nodes[0].Parent is GraphicConnection)
                    {
                        node1 = GetItemAt(orig.Nodes[0].Location, typeof(ConnectionNode)) as ConnectionNode;
                    }
                    else
                    {
                        node1 = orig.Nodes[0];
                    }
                    if (orig.Nodes[1].Parent is GraphicConnection)
                    {
                        node2 = GetItemAt(orig.Nodes[1].Location, typeof(ConnectionNode)) as ConnectionNode;
                    }
                    else
                    {
                        node2 = orig.Nodes[1];
                    }
                    if (node1 != null && node2 != null)
                    {
                        graphicConnection.RemoveChild(child);
                        ConnectionLine clone = new ConnectionLine(node1, node2);
                        AddChild(clone);
                    }
                }
            }
            foreach (GraphicBaseElement child in graphicConnection.Children)
            {
                graphicConnection.RemoveChild(child);
            }
            BuildBody();
        }
 internal override void RemoveChild(GraphicBaseElement child)
 {
     base.RemoveChild(child);
     if (child is ConnectionLine)
     {
         ConnectionLine line = child as ConnectionLine;
         line.DetachNodes();
     }
 }