Esempio n. 1
0
        private void TrimDisplayedLog()
        {
            var       numLines = textBoxLog.Lines.Length;
            const int buffer   = AutoQcLogger.MaxLogLines / 10;

            if (numLines > AutoQcLogger.MaxLogLines + buffer)
            {
                textBoxLog.ReadOnly        = false; // Make text box editable. This is required for the following to work
                textBoxLog.SelectionStart  = 0;
                textBoxLog.SelectionLength = textBoxLog.GetFirstCharIndexFromLine(numLines - AutoQcLogger.MaxLogLines);
                textBoxLog.SelectedText    = string.Empty;

                var message = (_currentAutoQcLogger != null) ?
                              string.Format(AutoQcLogger.LogTruncatedMessage, _currentAutoQcLogger.GetFile())
                    : "... Log truncated ...";
                textBoxLog.Text            = textBoxLog.Text.Insert(0, message + Environment.NewLine);
                textBoxLog.SelectionStart  = 0;
                textBoxLog.SelectionLength = textBoxLog.GetFirstCharIndexFromLine(1); // 0-based index
                textBoxLog.SelectionColor  = Color.Red;

                textBoxLog.SelectionStart = textBoxLog.TextLength;
                textBoxLog.SelectionColor = textBoxLog.ForeColor;
                textBoxLog.ReadOnly       = true; // Make text box read-only
            }
        }
Esempio n. 2
0
 public string GetLogDirectory()
 {
     return(Path.GetDirectoryName(_logger.GetFile()));
 }