Form Remove 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
Remove IN RUN MULTIPLE FALSE FALSE
Form IN Form MULTIPLE FALSE FALSE
Controls IN Object ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.Form
{
    [IsNode("Remove Controls")]
    public class FormRemoveControls : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Remove");
        Port objectRefOut = new Port(PortType.IN, typeof(System.Windows.Forms.Form), AcceptsLinks.MULTIPLE, "Form");
        Port val = new Port(PortType.IN, typeof(object), AcceptsLinks.ONE, "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 FormRemoveControls()
        {
            this.Name = "Form Remove 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 port in val.ConnectedPorts)
                {
                    rem += formname + ".Controls.Remove(" + port.ParentNode.ReferenceName + ");\r\ns";
                }
                code = rem;
            }
            return code;
        }
    }
}