Beispiel #1
0
        //*************************************************************************************************************
        public void Log(string text, Color textColor)
        {
            if (Closing)
            {
                return;
            }

            if (text.StartsWith("OK   :"))
            {
                textColor = Color.Green;
            }

            if (text.StartsWith("ERROR:"))
            {
                textColor = Color.Red;
            }

            Invoke((Action)(() =>
            {
                lock (StatusBox)
                {
                    try
                    {
                        string str = text.Replace("\r\n", "\n") + "\n";
                        StatusBox.AppendText(str);
                        StatusBox.Select(StatusBox.Text.Length - str.Length, str.Length);
                        StatusBox.SelectionColor = textColor;

                        if (StatusBox.Text.Length > 2048)
                        {
                            StatusBox.Text = StatusBox.Text.Remove(0, StatusBox.Text.Length - 2048);
                        }

                        StatusBox.Select(StatusBox.Text.Length, 0);
                        StatusBox.ScrollToCaret();
                    }
                    catch { }
                }
            }));
        }