示例#1
0
        /// <summary>
        /// Selects the given <paramref name="message"/>.
        /// </summary>
        /// <param name="message">The <see cref="LogMessage"/> o select</param>
        public bool SelectLogMessage(LogMessage message)
        {
            LogMessageWinDebug logMessage = message as LogMessageWinDebug;

            try
            {
                this.SuspendDrawing();

                if (logMessage != null)
                {
                    txtDataNumber.Text    = logMessage.Index.ToString();
                    txtDataLevel.Text     = logMessage.Level.ToString();
                    txtDataTime.Text      = logMessage.Timestamp.ToString(Settings.Default.TimestampFormat);
                    txtDataProcessId.Text = logMessage.ProcessId.ToString();

                    if (logMessage.TimeShiftOffset.Milliseconds != 0)
                    {
                        txtDataTime.Text += string.Format(
                            Resources.strLoggerDetailsCtrlOffset
                            , logMessage.TimeShiftOffset.Milliseconds);
                    }

                    // Replace all known new line character combinations with the .net one.
                    txtDataMessage.Text = Regex.Replace(
                        logMessage.Message
                        , @"\r(?!\n)|(?<!\r)\n"
                        , Environment.NewLine);
                }
                else
                {
                    txtDataNumber.Text = message != null?message.Index.ToString() : string.Empty;

                    txtDataLevel.Text = message != null?message.Level.ToString() : string.Empty;

                    txtDataTime.Text = message != null?message.Timestamp.ToString(Settings.Default.TimestampFormat) : string.Empty;

                    txtDataProcessId.Text = string.Empty;
                    txtDataMessage.Text   = message != null?message.Message.Trim() : string.Empty;
                }

                pbxCopyNumber.Visible    = !string.IsNullOrEmpty(txtDataNumber.Text);
                pbxCopyLevel.Visible     = !string.IsNullOrEmpty(txtDataLevel.Text);
                pbxCopyTime.Visible      = !string.IsNullOrEmpty(txtDataTime.Text);
                pbxCopyProcessId.Visible = !string.IsNullOrEmpty(txtDataProcessId.Text);
                pbxCopyMessage.Visible   = !string.IsNullOrEmpty(txtDataMessage.Text);
            }
            finally
            {
                txtDataProcessId.AdjustHeightToContent();
                txtDataMessage.AdjustHeightToContent();

                this.ResumeDrawing();
            }

            return(true);
        }
示例#2
0
        /// <summary>
        /// Handles the OnoutputDebugString event of the <see cref="DebugMonitor"/> instance.
        /// </summary>
        /// <param name="pid">The process ID of the sender application.</param>
        /// <param name="text">the message that is created by the sender application.</param>
        private void DebugMonitorOnOutputDebugString(int pid, string text)
        {
            if (mIsActive && (mProcess == null || Equals(mProcess.Id, pid)))
            {
                LogMessage newLogMsg = new LogMessageWinDebug(
                    pid
                    , text
                    , ++mLogNumber);

                if (mLogHandler != null)
                {
                    mLogHandler.HandleMessage(newLogMsg);
                }
            }
        }