Set Properties


Node Information
Sets properties to the specifed object. Click on the info button for available properties.
General Information
• This node has other options, you can view them by clicking on the info button, this also means according to the node you might be able to add more ports than what is already listed.
• Some of the ports of this node can change their types and accept types automatically.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Set IN RUN MULTIPLE FALSE FALSE
IN Object ONE FALSE TRUE

Source
namespace Korduene.KGraph.Nodes.IO.SerialPort
{
    [IsNode("Set Properties")]
    public class SetProperties : Node
    {
        Port set = new Port(PortType.IN, typeof(RUN), AcceptsLinks.ONE, "Set");
        Port serial = new Port(PortType.IN, typeof(System.IO.Ports.SerialPort), AcceptsLinks.ONE, "SerialPort");
        public SetProperties()
        {
            NodeType = KGraph.NodeType.Method;
            Name = "Set Properties";
            AddPort(set);
            AddPort(serial);
            OptionsAvilable = true;
            Information = "Sets properties of the specified Serial Port.";
            InfoContextMenu = GetTypePropertiesMenu(typeof(System.IO.Ports.SerialPort), true);
        }
        public override void OnTypePropertySelected(System.Reflection.PropertyInfo opi)
        {
            Port port = new Port(PortType.IN, opi.PropertyType, AcceptsLinks.ONE, opi.Name, true);
            port.IsRemovable = true;
            AddPort(port);
        }
        public override string Code()
        {
            string serialvalue = GetValue(serial);
            string code = string.Empty;
            foreach (var port in Ports)
            {
                if (port.IsExtra)
                {
                    code += serialvalue + "." + port.Text + " = " + GetValue(port) + ";\r\n";
                }
            }
            return code;
        }
        public override void UpdateResults()
        {
            if (!serial.IsConnected)
            {
                ErrorMessage = "No Serial Port is connected.";
                Status = NodeStatus.ERROR;
            }
            else
            {
                Status = NodeStatus.OK;
            }
        }
    }
}