ComboBox Add Items


Node Information
Adds items to the specified ComboBox.
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
ComboBox IN ComboBox ONE FALSE FALSE
List IN List<String> ONE TRUE FALSE
SelectFirst IN Boolean ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.ComboBox
{
    [IsNode("Add Items")]
    public class ComboBoxAddRange : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Add");
        Port val = new Port(PortType.IN, typeof(List<string>), AcceptsLinks.ONE, "List");
        Port selectfirst = new Port(PortType.IN, typeof(bool), AcceptsLinks.ONE, "SelectFirst");
        Port control = new Port(PortType.IN, typeof(Korduene.Designer.Standard.ComboBox), AcceptsLinks.ONE, "ComboBox");
        private bool SelectFirst
        {
            get { return GetRuntimeValue(selectfirst); }
        }
        public ComboBoxAddRange()
        {
            this.Name = "ComboBox Add Items";
            this.NodeType = KGraph.NodeType.Method;
            AddPort(run);
            AddPort(control);
            AddPort(val);
            AddPort(selectfirst);
            Information = "Adds items to the specified ComboBox.";
        }
        public override string Code()
        {
            string code = GetValue(control) + ".Items.AddRange((" + GetValue(val) + ").ToArray());\r\n";
            if (SelectFirst)
            {
                code += "if(" + GetValue(control) + ".Items.Count > 0) {" + GetValue(control) + ".SelectedIndex = 0;}";
            }
            return code;
        }
    }
}