internal GraphicTerminal(BaseElement linkedObject)
     : base(linkedObject)
 {
     BuildBody();
     m_Node = new ConnectionNode(m_Body.Path.GetLastPoint());
     AddChild(m_Node);
 }
Example #2
0
 public ConnectionLine(ConnectionNode first, ConnectionNode second)
 {
     m_Nodes = new List <ConnectionNode>(2);
     AttachNode(first);
     AttachNode(second);
     BuildBody();
 }
        /// <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();
        }
Example #4
0
 /// <summary>
 /// Detaches this line from a node
 /// </summary>
 /// <param name="node">Node to detach from</param>
 private void DetachNode(ConnectionNode node)
 {
     if (m_Nodes.Contains(node))
     {
         m_Nodes.Remove(node);
         node.DetachLine(this);
         node.OnLocationChanged -= Node_OnLocationChanged;
     }
 }
Example #5
0
 /// <summary>
 /// Attaches this line to a node
 /// </summary>
 /// <param name="node">Node to attach to</param>
 private void AttachNode(ConnectionNode node)
 {
     if (m_Nodes.Contains(node) || m_Nodes.Count >= 2)
     {
         return;
     }
     m_Nodes.Add(node);
     node.AttachLine(this);
     node.OnLocationChanged += new LocationChangeEvent(Node_OnLocationChanged);
 }