komorra / NodeEditorWinforms

Node based user control / editor for Windows Forms
MIT License
507 stars 142 forks source link

Adding combo box to a standary node #9

Open laserdave opened 6 years ago

laserdave commented 6 years ago

Hi there, thanks for sharing this great project. I am using it like you said as a signal routing patcher for an osc/midi/dmx system for our band. I have sucsessfully added and expanded to it. However I have a couple of issues and I need help. To make things easier I have taken your original code and made a very minor change but I still have the same issue. I made a minor change to the Serialise function to enable me to save .nds with filename, its now a void function and return commented out. If I add a modified module with a combo box save and reload the nds file the app dies in .also how to I access combo box ie read or write entry.

    public void Deserialize(byte[] data)
    {
        using (var br = new BinaryReader(new MemoryStream(data)))
        {
            var ident = br.ReadString();
        //unable to read past end of file

       //modified node added combo box
   [Node("Value", "Input", "Basic", "Allows to output a simple value.",false,false, typeof(ComboBox))]
    public void InputValue(float inValue, out float outValue)
    {
        outValue = inValue;
    }

    public void Serialize(string fn)
    {

        using (BinaryWriter bw = new BinaryWriter(File.Open(fn, FileMode.Create)))

        {
            bw.Write("NodeSystemP"); //recognization string
            bw.Write(1000); //version
            bw.Write(graph.Nodes.Count);
            foreach (var node in graph.Nodes)
            {
                SerializeNode(bw, node);
            }
            bw.Write(graph.Connections.Count);
            foreach (var connection in graph.Connections)
            {
                bw.Write(connection.OutputNode.GUID);
                bw.Write(connection.OutputSocketName);

                bw.Write(connection.InputNode.GUID);
                bw.Write(connection.InputSocketName);
                bw.Write(0); //additional data size per connection
            }
            bw.Write(0); //additional data size per graph
            // return (bw.BaseStream as MemoryStream).ToArray();
        }
    }