Пример #1
0
        public override void RemoveConnections()
        {
            GraphEditorViewModel editor = (GraphEditorViewModel)((MainWindow)(App.Current.MainWindow)).VisualEditor.DataContext;
            List <NodePin>       pins   = new List <NodePin>();

            pins.AddRange(Inputs.Select(pin => pin.Pin));
            pins.AddRange(Outputs.Select(pin => pin.Pin));
            pins.AddRange(ExecutionInputs.Select(pin => pin.Pin));
            pins.AddRange(ExecutionOutputs.Select(pin => pin.Pin));

            List <ConnectionViewModel> connectionsToRemove = new List <ConnectionViewModel>();

            foreach (var connection in editor.Connections)
            {
                if (pins.Contains(connection.InputPinControl) || (pins.Contains(connection.OutputPinControl)))
                {
                    connectionsToRemove.Add(connection);
                }
            }

            foreach (var connection in connectionsToRemove)
            {
                editor.Connections.Remove(connection);
            }
        }
Пример #2
0
    public void AddExecutionInputPort(string name = null)
    {
        //TODO this should create an empty gameobject and port view should create its own UIelements
        var newport = new GameObject();

        newport.AddComponent <ExecutionPortModel>();
        // initialze the port
        newport.GetComponent <ExecutionPortModel>().init(this, ExecutionInputs.Count, PortModel.porttype.input, name);

        //hookup the ports listener to the nodes propertychanged event, and hook
        // handlers on the node back from the ports connection events
        this.PropertyChanged += newport.GetComponent <ExecutionPortModel>().NodePropertyChangeEventHandler;
        newport.GetComponent <ExecutionPortModel>().PortConnected    += PortConnected;
        newport.GetComponent <ExecutionPortModel>().PortDisconnected += PortDisconnected;
        ExecutionInputs.Add(newport.GetComponent <ExecutionPortModel>());
    }