예제 #1
0
        /// <summary>
        /// Append Log of the given color.
        /// </summary>
        /// <param name="inLog">new Log to add to the Log Control</param>
        void AppendLog(Log inLog)
        {
            if (!LogRTB.IsDisposed)
            {
                int    lengthBefore = LogRTB.TextLength;
                string pad          = "";
                for (int i = 8 - inLog.Severity.ToString().Length; i > 0; i--)
                {
                    pad += " ";
                }

                string log = String.Format("{0}{1}: {2}\r\n", inLog.Severity, pad, inLog.Text);

                LogRTB.SelectionLength = 0; // clear
                LogRTB.SelectionStart  = 0;
                LogRTB.SelectedText    = log;

                int length = LogRTB.TextLength - lengthBefore;

                // Textbox may transform chars, so (end-start) != text.Length
                LogRTB.Select(0, length);
                {
                    LogRTB.SelectionColor = LogColors[inLog.Severity];
                }
            }
        }
예제 #2
0
        private void RefreshLogs()
        {
            LogRTB.Clear();
            LogRTB.SuspendLayout();

            for (var i = 0; i < logger.Logs.Count; i++)
            {
                if (IsVisible(logger.Logs[i]))
                {
                    AppendLog(logger.Logs[i]);
                }
            }

            LogRTB.ResumeLayout(true);
        }