Example #1
0
            /// <summary>
            /// When creating a new node, does the base class boilerplate then calls upon the subclass
            /// to modify it as it needs
            /// </summary>
            /// <param name="mousePos"></param>
            protected void AddNode(Vector2 mousePos, System.Action <DerivedNode> onAddNode)
            {
                // Create the node, initialize it
                var newNode = new DerivedNode();

                newNode.Initialize(new Rect(mousePos, this.NodeSize), this.DefaultNodeStyle,
                                   this.SelectedNodeStyle, OnNodeEvent);
                // Create its endpoints
                var orientation     = ConnectionPoint.OrientationType.Vertical;
                var inPointSettings = new ConnectionPoint.ConnectionSettings(ConnectionPoint.ConnectionType.In,
                                                                             orientation, InPointStyle, OnClickInPoint);
                var outPointSettings = new ConnectionPoint.ConnectionSettings(ConnectionPoint.ConnectionType.Out,
                                                                              orientation, OutPointStyle, OnClickOutPoint);

                newNode.AddConnection(inPointSettings);
                newNode.AddConnection(outPointSettings);

                // Have the in-point enabled by default
                newNode.InPoint.Enabled = true;

                // Add it to our current list of nodes
                Nodes.Add(newNode);

                // Now pass the newly-created node to the callback function
                onAddNode(newNode);
            }
Example #2
0
 //------------------------------------------------------------------------/
 // Methods: Modification
 //------------------------------------------------------------------------/
 public void AddConnection(ConnectionPoint.ConnectionSettings settings)
 {
     if (settings.Type == ConnectionPoint.ConnectionType.In)
     {
         this.InPoint = new ConnectionPoint(this, settings);
     }
     else if (settings.Type == ConnectionPoint.ConnectionType.Out)
     {
         this.OutPoint = new ConnectionPoint(this, settings);
     }
 }