Exemple #1
0
        public void AddProperty()
        {
            PendingConnectionViewModel pending = Parent.PendingConnection;

            if (pending == null || pending.Output == null || !(pending.Output.Parent is SubstanceNodeViewModel))
            {
                return;
            }

            SubstanceNodeViewModel sub_view = pending.Output.Parent as SubstanceNodeViewModel;

            NodeInputViewModel new_prop_input = new NodeInputViewModel();

            new_prop_input.Connections.Connect()
            .Subscribe(change => {
                OnPropertyInputChanged(change);
            });

            Inputs.Edit(x => x.Add(new_prop_input));

            ConnectionViewModel new_prop_connection = new ConnectionViewModel(
                Parent,
                new_prop_input,
                sub_view.Outputs.Items.First());

            Parent.Connections.Edit(x => x.Add(new_prop_connection));
        }
Exemple #2
0
        public void AddPropertiesToNode()
        {
            System.Windows.Point prop_offset = new System.Windows.Point(Position.X - 200, Position.Y + 70);

            for (int i = 0; i < Cut.Properties.Count; i++)
            {
                Substance s = Cut.Properties[i];

                // If we have enough node inputs already, just grab the one corresponding to this property;
                // Otherwise, add a new input to the input view model.
                NodeInputViewModel prop_input = new NodeInputViewModel();
                if (Inputs.Count > i + 1)
                {
                    prop_input = Inputs.Items.ElementAt(i + 1);
                }
                else
                {
                    Inputs.Edit(x => x.Add(prop_input));
                }

                if (Cut.Properties[i] == null)
                {
                    continue;
                }

                prop_input.Connections.Connect()
                .Subscribe(change => {
                    OnPropertyInputChanged(change);
                });

                // Create a node for the property
                SubstanceNodeViewModel temp_node = new SubstanceNodeViewModel(s);
                temp_node.Position = prop_offset;

                Parent.Nodes.Edit(x => x.Add(temp_node));

                prop_offset.Y = (temp_node.Position.Y + temp_node.Size.Height + 125);

                // Connect the property node to the cut node.
                ConnectionViewModel first_to_begin = new ConnectionViewModel(
                    Parent,
                    prop_input,
                    temp_node.Outputs.Items.First());
                Parent.Connections.Edit(x => x.Add(first_to_begin));
            }

            m_EnableConnectionUpdates = true;
        }
Exemple #3
0
        private void ProcessPropertyInputRemove(ItemChange <ConnectionViewModel> change)
        {
            SubstanceNodeViewModel sub_view = change.Current.Output.Parent as SubstanceNodeViewModel;

            if (sub_view == null)
            {
                return;
            }

            int substance_index = Cut.Properties.IndexOf(sub_view.Substance);

            Inputs.Edit(x => x[substance_index + 1].Connections.Dispose());
            Inputs.Edit(x => x.RemoveAt(substance_index + 1));

            Cut.Properties.Remove(sub_view.Substance);
        }
Exemple #4
0
        public CutNodeViewModel(Cut cut)
        {
            Cut = cut;
            cut.NodeViewModel = this;

            // Create exec input node
            NodeInputViewModel exec_input = new NodeInputViewModel()
            {
                Port = new ExecPortViewModel()
                {
                    PortType = PortType.Execution
                }, MaxConnections = 1
            };

            Inputs.Edit(x => x.Add(exec_input));

            exec_input.Connections.Connect()
            .Subscribe(change => {
                OnExecInputChanged(change);
            });

            // Create exec output node
            NodeOutputViewModel exec_output = new NodeOutputViewModel()
            {
                Port = new ExecPortViewModel()
                {
                    PortType = PortType.Execution
                }, MaxConnections = 1
            };

            Outputs.Edit(x => x.Add(exec_output));

            exec_output.Connections.Connect()
            .Subscribe(change => {
                OnExecOutputChanged(change);
            });

            PropertyChanged += CutNodeViewModel_PropertyChanged;
        }
Exemple #5
0
        public BlockingCutNodeViewModel(Cut cut)
        {
            Cut  = cut;
            Name = "Blocking Actions";
            BlockingCutEditor = new BlockingCutEditorViewModel(cut);

            // Create exec input node
            NodeInputViewModel exec_input = new NodeInputViewModel()
            {
                Port = new ExecPortViewModel()
                {
                    PortType = PortType.Execution
                }, MaxConnections = 1
            };

            Inputs.Edit(x => x.Add(exec_input));

            exec_input.Connections.Connect()
            .Subscribe(change => {
                OnExecInputChanged(change);
            });

            // Create exec output node
            NodeOutputViewModel exec_output = new NodeOutputViewModel()
            {
                Port = new ExecPortViewModel()
                {
                    PortType = PortType.Execution
                }, MaxConnections = 1, Editor = BlockingCutEditor
            };

            Outputs.Edit(x => x.Add(exec_output));

            exec_output.Connections.Connect()
            .Subscribe(change => {
                OnExecOutputChanged(change);
            });
        }
Exemple #6
0
        private void AddProperty(Substance Sub, System.Windows.Point Position)
        {
            SubstanceNodeViewModel sub_view = new SubstanceNodeViewModel(Sub);

            sub_view.Position = Position;

            NodeInputViewModel new_prop_input = new NodeInputViewModel();

            new_prop_input.Connections.Connect()
            .Subscribe(change => {
                OnPropertyInputChanged(change);
            });

            Parent.Nodes.Edit(x => x.Add(sub_view));

            Inputs.Edit(x => x.Add(new_prop_input));

            ConnectionViewModel new_prop_connection = new ConnectionViewModel(
                Parent,
                new_prop_input,
                sub_view.Outputs.Items.First());

            Parent.Connections.Edit(x => x.Add(new_prop_connection));
        }
Exemple #7
0
        private void OnRequestCreatePropertyNode(Tuple <string, string, SubstanceType> args)
        {
            Substance new_sub = null;

            switch (args.Item3)
            {
            case SubstanceType.Float:
                float FloatDefault = 0.0f;
                float.TryParse(args.Item2, out FloatDefault);

                new_sub = new Substance <ObservableCollection <PrimitiveBinding <float> > >(args.Item1, args.Item3)
                {
                    Data = new ObservableCollection <PrimitiveBinding <float> >()
                    {
                        new PrimitiveBinding <float>(FloatDefault)
                    }
                };
                break;

            case SubstanceType.Int:
                int IntDefault = 0;
                int.TryParse(args.Item2, out IntDefault);

                new_sub = new Substance <ObservableCollection <PrimitiveBinding <int> > >(args.Item1, args.Item3)
                {
                    Data = new ObservableCollection <PrimitiveBinding <int> >()
                    {
                        new PrimitiveBinding <int>(IntDefault)
                    }
                };
                break;

            case SubstanceType.String:
                new_sub = new Substance <PrimitiveBinding <string> >(args.Item1, args.Item3)
                {
                    Data = new PrimitiveBinding <string>(args.Item2)
                };
                break;

            case SubstanceType.Vec3:
                new_sub = new Substance <ObservableCollection <BindingVector3> >(args.Item1, args.Item3)
                {
                    Data = new ObservableCollection <BindingVector3>()
                    {
                        new BindingVector3(new OpenTK.Vector3(0, 0, 0))
                    }
                };
                break;
            }

            SubstanceNodeViewModel temp_node = new SubstanceNodeViewModel(new_sub);

            temp_node.Position = Position;

            Parent.Nodes.Edit(x => x.Add(temp_node));

            NodeInputViewModel new_prop_input = new NodeInputViewModel();

            new_prop_input.Connections.Connect()
            .Subscribe(change => {
                OnPropertyInputChanged(change);
            });

            Inputs.Edit(x => x.Add(new_prop_input));

            ConnectionViewModel new_prop_connection = new ConnectionViewModel(
                Parent,
                new_prop_input,
                temp_node.Outputs.Items.First());

            Parent.Connections.Edit(x => x.Add(new_prop_connection));
        }