Example #1
0
        /// <summary>
        /// Initializes a new instance of a NodeConnector with the passed parameters.
        /// </summary>
        /// <param name="_label">In the node shown name of the connector.</param>
        /// <param name="_type">Determines if it's an input or an output connector</param>
        /// <param name="_parentNode">Node which contains this new NodeConnector.</param>
        /// <param name="_allowedNodeType">Type of node which is allowed to connector to this connector. If you want all nodes of a base type to be allowed use EVENT, ACTION or PARAM</param>
        /// <param name="_allowedConnectionCount">Number of allowed connections to this node</param>
        public NodeConnector(string _label, NodeConnectorType _type, Node _parentNode, NodeType _allowedNodeType, int _positionIndex, int _allowedConnectionCount = 1)
        {
            InitializeComponent();

            Debug.Assert(_type != NodeConnectorType.NONE); //A node connector can't have NONE as type. It must be either an input or an output connector
            type                   = _type;
            ParentNode             = _parentNode;
            allowedNodeType        = _allowedNodeType;
            allowedConnectionCount = _allowedConnectionCount;
            positionIndex          = _positionIndex;

            ellipse.Fill      = type == NodeConnectorType.INPUT ? Brushes.Aqua : Brushes.IndianRed;
            ellipse.AllowDrop = true;

            if (Node.GetSuperiorType(allowedNodeType) != NodeType.NONE)
            {
                ToolTip toolTip = new ToolTip()
                {
                    Content = "Right click for creation of corresponding node."
                };
                ellipse.ToolTip = toolTip;
            }

            label.Content = _label;

            if (type == NodeConnectorType.PARAM)
            {
                HorizontalAlignment       = HorizontalAlignment.Center;
                label.HorizontalAlignment = HorizontalAlignment.Center;
                Grid.SetRow(ellipse, 1);
            }
            else
            {
                //If it's an input connector the ellipse must be first element respectively the element on the left
                ellipse.SetValue(Grid.ColumnProperty, type == NodeConnectorType.INPUT ? 0 : 1);
                label.SetValue(Grid.ColumnProperty, type == NodeConnectorType.INPUT ? 1 : 0);
            }

            connectedNodeConnectors = new List <NodeConnector>();
        }
Example #2
0
 private static void RaiseNodeConnectorSelected( NodeGUIBase node, int connectorIndex, NodeConnectorType connectorType )
 {
     if ( OnNodeConnectorSelected != null )
     {
         OnNodeConnectorSelected( node, connectorIndex, connectorType );
     }
 }