Form Add Controls


Node Information
Adds controls to the specified Form.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Add IN RUN MULTIPLE FALSE FALSE
Form IN Form ONE FALSE FALSE
Controls IN Object MULTIPLE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.Form
{
    [IsNode("Add Controls")]
    public class FormControlAddRange : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Add");
        Port objectRefOut = new Port(PortType.IN, typeof(System.Windows.Forms.Form), AcceptsLinks.ONE, "Form");
        Port val = new Port(PortType.IN, typeof(object), AcceptsLinks.MULTIPLE, "Controls");
        [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 FormControlAddRange()
        {
            this.Name = "Form Add Controls";
            this.NodeType = KGraph.NodeType.Method;
            AddPort(run);
            AddPort(objectRefOut);
            AddPort(val);
            Information = "Adds controls to the specified Form.";
        }
        public override string Code()
        {
            string code = string.Empty;
            string formname = "this";
            if (objectRefOut.IsConnected)
            {
                formname = GetValue(objectRefOut);
            }
            else
            {
                formname = FormName;
            }
            if (val.IsConnected)
            {
                string rem = string.Empty;
                foreach (var item in val.ConnectedPorts)
                {
                    rem += formname + ".Controls.Add(" + item.ParentNode.ReferenceName + ");" + Environment.NewLine;
                }
                code = rem;
            }
            return code;
        }
    }
}