Ejemplo n.º 1
0
 /// <summary>
 /// Raises the button press event, event args will contain the type of node to instantiate.
 /// current graphmodels will subscribe to the library's buttonpress event so nodes can be instantiated
 /// </summary>
 /// <param name="e">E.</param>
 public void OnButtonPress(LibraryButton button, EventArgs e)
 {
     if (ButtonPressed != null)
     {
         ButtonPressed(button, e);
     }
 }
    private void OnLibraryButtonPress(LibraryButton button, EventArgs e)
    {
        //TODO clean this logic up
        //for now just check the type of library button, and perform the correct instantiation logic
        //could alternatively store this logic on the button so can just call it from here.... i like that more

        //TODO for both of these methods instantiation points should just be in front of the camera by x units

        if (button.GetType() == typeof(CustomNodeLibraryButton))
        {
            var nodeinfo = (button as CustomNodeLibraryButton).Info;
            _appmodel.CollapsedCustomGraphNodeManager.CreateCustomNodeInstance(nodeinfo.FunctionId, new Guid(), new Vector3(0, 0, 0), this, null, nodeinfo.Name);
        }

        else
        {
            var        nodetype = button.LoadedType;
            MethodInfo method   = this.GetType().GetMethod("InstantiateNode");
            MethodInfo generic  = method.MakeGenericMethod(nodetype);
            //generic is a delegate pointing towards instantiate node, we're passing the nodetype to instantiate
            //this is a fully qualified type extracted from the libraryButton
            generic.Invoke(this, new object[] { new Vector3(0, 0, 0), new Guid() });
        }
    }