Pickaxe.Studio.TextBoxAppender.Append C# (CSharp) Method

Append() protected method

protected Append ( log4net.Core.LoggingEvent loggingEvent ) : void
loggingEvent log4net.Core.LoggingEvent
return void
        protected override void Append(LoggingEvent loggingEvent)
        {
            var property = loggingEvent.LookupProperty(Config.LogKey) as string;
            var form = Application.OpenForms[FormName];
            TextBox textBox = null;
            TabPage tabControl = null;
            if(property != null)
            {
                tabControl = FindControl(property, form) as TabPage;
            }

            if (tabControl != null)
            {
                textBox = FindControl(TextBoxName, tabControl) as TextBox;
            }

            if (textBox == null)
                return;

            var action = new Action(() =>
            {
                if (textBox.Lines.Count() > 300)
                    textBox.Clear();

                textBox.AppendText(RenderLoggingEvent(loggingEvent));
                textBox.ScrollToCaret();
            });

            if (form.InvokeRequired)
            {
                form.BeginInvoke(action);
            }
            else
            {
                action();
            }
        }
TextBoxAppender