Wouterdek/NodeNetwork

Problems with 'Network.Nodes.Add(Node)' and 'Node.Inputs.Add(PrintNodeInput);'

EagerTechnologies opened this issue · 3 comments

I was looking at the 'Value Nodes' page on the NetworkNodes website from the cookbooks part and I seen that I could change my 'var PrintNode = new NodeInputViewModel()' line to 'var PrintNode = new ValueNodeInputViewModel()'.

I did this, but and then I got an error with the 'Nodes.Add' and 'Node.Inputs.Add' but I don't know exactly what caused it.

Here is my code:
`
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DynamicData;
using NodeNetwork.Toolkit.ValueNode;
using NodeNetwork.ViewModels;

namespace Editor
{
///


/// Interaction logic for NodeGraphWindow.xaml
///

public partial class NodeGraphWindow : Window
{
public NodeGraphWindow()
{
InitializeComponent();

        /*---------------------------------------
            Node Graph Impl
        -----------------------------------------*/

        var Network = new NetworkViewModel();

        var StartNode = new NodeViewModel();
        StartNode.Name = "Start";
        Network.Nodes.Add(StartNode);

        var StartNodeOutput = new NodeOutputViewModel();
        StartNodeOutput.Name = "Exec";
        StartNode.Outputs.Add(StartNodeOutput);

        var PrintNode = new ValueNodeInputViewModel<string>();
        PrintNode.Name = "Print";
        Network.Nodes.Add(PrintNode);

        var PrintNodeInput = new NodeInputViewModel();
        PrintNodeInput.Name = "String";
        PrintNode.Inputs.Add(PrintNodeInput);

        PrintNode.ValueChanged.Subscribe(NewValue =>
        {
            Console.WriteLine(NewValue);
        });

        NodeGraph.ViewModel = Network;
    }

}

}
`

What could I do to fix this?

EDIT: Sorry for the bad code snippet formatting, it wouldn't work properly for some reason...

Figured it out, I got the code totally wrong.

Glad you were able to figure it out. :) For future reference, multiline code formatting requires 3 backticks before and 3 backticks after the code, and a blank line on each end.

Glad you were able to figure it out. :) For future reference, multiline code formatting requires 3 backticks before and 3 backticks after the code, and a blank line on each end.

Thank you :) Also, this extension is awesome! Great work! :)