ListView Add Item


Node Information
Adds item to the specified ListView.
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
ListView IN ListView ONE FALSE FALSE
Text IN String ONE FALSE FALSE
Name IN String ONE FALSE FALSE
SubItems IN List<String> ONE TRUE FALSE
ForeColor IN Color ONE FALSE FALSE
BackColor IN Color ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.ListView
{
    [IsNode("Add Item")]
    public class ListViewAdd : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Add");
        Port text = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Text");
        Port name = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Name");
        Port subitems = new Port(PortType.IN, typeof(List<string>), AcceptsLinks.ONE, "SubItems");
        Port forecolor = new Port(PortType.IN, typeof(System.Drawing.Color), AcceptsLinks.ONE, "ForeColor");
        Port backcolor = new Port(PortType.IN, typeof(System.Drawing.Color), AcceptsLinks.ONE, "BackColor");
        Port control = new Port(PortType.IN, typeof(Korduene.Designer.Standard.ListView), AcceptsLinks.ONE, "ListView");
        public string Text
        {
            set { text.Value = value.ToString(); }
            get { return GetRuntimeValue(text); }
        }
        public ListViewAdd()
        {
            this.Name = "ListView Add Item";
            this.NodeType = KGraph.NodeType.Method;
            AddPort(run);
            AddPort(control);
            AddPort(text);
            AddPort(name);
            AddPort(subitems);
            AddPort(forecolor);
            AddPort(backcolor);
            Information = "Adds item to the specified ListView.";
        }
        public override string Code()
        {
            string sub = string.Empty;
            if (subitems.ConnectedPorts.Count == 0)
            {
                sub = string.Empty;
            }
            else
            {
                sub = "foreach (var item in " + GetValue(subitems) + "){" + Environment.NewLine + "lvi.SubItems.Add(item);}";
            }
            return
            "System.Windows.Forms.ListViewItem lvi = new System.Windows.Forms.ListViewItem(" + GetValue(text) + ");\r\n" +
            "lvi.Name = " + GetValue(name) + ";\r\n" +
             sub + Environment.NewLine +
            "lvi.ForeColor = " + GetValue(forecolor) + ";\r\n" + "lvi.BackColor = " + GetValue(backcolor) + ";\r\n" +
            GetValue(control) + ".Items.Add(lvi);";
        }
    }
}