コード例 #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
        protected void Clicked()
        {
            GraphEditorViewModel editor = (GraphEditorViewModel)((MainWindow)(App.Current.MainWindow)).VisualEditor.DataContext;

            foreach (VisualGraphComponentViewModel visualNode in editor.VisualNodes)
            {
                visualNode.IsSelected = false;
            }

            IsSelected = true;
        }
コード例 #3
0
        protected void Delete()
        {
            GraphEditorViewModel graphViewModel = ((MainWindow)App.Current.MainWindow)
                                                  .VisualEditor
                                                  .DataContext as GraphEditorViewModel;

            if (graphViewModel.VisualNodes.Contains(this))
            {
                this.RemoveConnections();
                graphViewModel.VisualNodes.Remove(this);
            }
        }
コード例 #4
0
        private void RemoveConnections()
        {
            GraphEditorViewModel       editor = (GraphEditorViewModel)((MainWindow)(App.Current.MainWindow)).VisualEditor.DataContext;
            List <ConnectionViewModel> connectionsToRemove = new List <ConnectionViewModel>();

            foreach (var connection in editor.Connections)
            {
                if (connection.InputPinControl == this.Pin || connection.OutputPinControl == this.Pin)
                {
                    connectionsToRemove.Add(connection);
                }
            }

            foreach (var connection in connectionsToRemove)
            {
                editor.Connections.Remove(connection);
            }
        }
コード例 #5
0
        public MainWindowViewModel(GraphEditorViewModel graphViewModel)
        {
            this.graphViewModel = graphViewModel;

            InsertNodeCommand = new RelayCommand(InsertNode)
            {
                CanExecute = true
            };

            // Load in usable nodes
            string[]        dllFile    = Directory.GetFiles(App.PluginFolderPath, "*.dll");
            List <Assembly> assemblies = new List <Assembly>(dllFile.Length);

            foreach (string file in dllFile)
            {
                try
                {
                    Assembly assembly = Assembly.LoadFrom(file);
                    Type[]   types    = assembly.GetTypes();

                    // Look for NodeBase types
                    foreach (Type type in types)
                    {
                        if (type.IsSubclassOf(typeof(NodeBase)))
                        {
                            // Get unique name
                            LoadedNodes.Add(type);

                            // If this is a conversion node tell our graph about it
                            ConversionRule conversionRule = type.GetCustomAttribute(typeof(ConversionRule)) as ConversionRule;

                            if (conversionRule != null)
                            {
                                graphViewModel.AddConversionRule(conversionRule.InputType, conversionRule.OutputType, type);
                            }
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Error loading nodes.\nPlease ensure there are libraries in the /NodePlugins folder and that they are unblocked.");
                }
            }
        }