TextBox Append Text


Node Information
Appends text to the specified TextBox.
General Information
• This node doesn't have other available options.
Visual
Visual

Ports
Text Type DataType Accepts IsList CustomAcception
Append IN RUN MULTIPLE FALSE FALSE
TextBox IN TextBox ONE FALSE FALSE
Text IN String ONE FALSE FALSE
NewLine IN Boolean ONE FALSE FALSE
ScrollToCaret IN Boolean ONE FALSE FALSE

Source
namespace Korduene.KGraph.Nodes.UI.RichTextBox
{
    [IsNode("Append Text")]
    public class AppendText : Node
    {
        Port run = new Port(PortType.IN, typeof(RUN), AcceptsLinks.MULTIPLE, "Append");
        Port objectRef = new Port(PortType.IN, typeof(Korduene.Designer.Standard.RichTextBox), AcceptsLinks.ONE, "RichTextBox");
        Port text = new Port(PortType.IN, typeof(string), AcceptsLinks.ONE, "Text");
        Port font = new Port(PortType.IN, typeof(System.Drawing.Font), AcceptsLinks.ONE, "Font");
        Port nobackColor = new Port(PortType.IN, typeof(bool), AcceptsLinks.ONE, "NoBackColor");
        Port newline = new Port(PortType.IN, typeof(bool), AcceptsLinks.ONE, "NewLine");
        Port scrolltocaret = new Port(PortType.IN, typeof(bool), AcceptsLinks.ONE, "ScrollToCaret");
        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");
        private bool NewLine
        {
            get { return GetRuntimeValue(newline); }
        }
        public bool ScrollToCaret
        {
            get { return GetRuntimeValue(scrolltocaret); }
        }
        public bool NoBackColor
        {
            get { return GetRuntimeValue(nobackColor); }
        }
        public AppendText()
        {
            NodeType = KGraph.NodeType.Method;
            this.Name = "RichTextBox Append Text";
            AddPort(run);
            AddPort(objectRef);
            AddPort(text);
            AddPort(font);
            AddPort(nobackColor);
            AddPort(newline);
            AddPort(scrolltocaret);
            AddPort(forecolor);
            AddPort(backcolor);
            Information = "Appends text to the specified RichTextBox.";
        }
        public override string Code()
        {
            string code = string.Empty;
            string txt = GetValue(text);
            if (NewLine)
            {
                txt = txt + " + Environment.NewLine";
            }
            string o = GetValue(objectRef);
            string fnt = GetValue(font);
            if (!string.IsNullOrWhiteSpace(fnt))
            {
                fnt = o + ".SelectionFont = " + GetValue(font) + ";\r\n";
            }
            code = fnt + o + ".SelectionColor = " + GetValue(forecolor) + ";\r\n";
            if (!NoBackColor)
            {
                code += o + ".SelectionBackColor = " + GetValue(backcolor) + ";\r\n";
            }
            code += o + ".AppendText(" + txt + ");\r\n";
            if (ScrollToCaret)
            {
                code += o + ".ScrollToCaret();";
            }
            return code;
        }
    }
}