Set Form Properties


Node Information
Reference 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.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Set IN RUN MULTIPLE FALSE FALSE
Get IN Form ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.Form
{
    [IsNode("Set Properties")]
    public class FormSetProperties : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Set");
        Port objectRefIn = new Port(PortType.IN, typeof(System.Windows.Forms.Form), AcceptsLinks.ONE, "Get");
        [System.ComponentModel.Description("if there is no forms connected the value will be set to the current form, which is refered to as 'this'.")]
        public string FormName
        {
            get { return "this"; }
        }
        public FormSetProperties()
        {
            this.NodeType = KGraph.NodeType.Method;
            this.Name = "Set Form Properties";
            this.OptionsAvilable = true;
            AddPort(run);
            AddPort(objectRefIn);
            Information = "Reference to the specifed object. Click on the info button for available properties.";
            CreateContextMenu();
        }
        public void CreateContextMenu()
        {
            InfoContextMenu = GetObjectPropertiesMenu(typeof(System.Windows.Forms.Form), true);
        }
        public override void OnPropertiesMenuSelected(ObjectPropertyInfo opi)
        {
            Port newport = new Port(PortType.IN, opi.DataType, AcceptsLinks.ONE, opi.Name, true);
            newport.DataType = opi.DataType;
            newport.IsRemovable = true;
            AddPort(newport);
        }
        public override string Code()
        {
            string code = string.Empty;
            foreach (var port in Ports)
            {
                if (port.IsExtra)
                {
                    code += FormName + "." + port.Text + " = " + GetValue(port) + ";\r\n";
                }
            }
            return code;
        }
        public override void UpdateResults()
        {
            ReferenceName = "this";
            if (objectRefIn.IsConnected)
            {
                ReferenceName = GetValue(objectRefIn);
            }
            else
            {
                ReferenceName = FormName;
            }
        }
    }
}