AddMessage() public méthode

public AddMessage ( string message, System.Windows.Media.Brush messageColor ) : void
message string
messageColor System.Windows.Media.Brush
Résultat void
Exemple #1
0
        /// <summary>
        /// Add a logging message to the progress window.
        /// </summary>
        /// <remarks>
        /// This method can be called from worker thread.
        /// </remarks>
        public void AddMessage(MessageLevel level, string message)
        {
            if (!_uiDispatcher.CheckAccess())
            {
                _uiDispatcher.BeginInvoke(new Action <MessageLevel, string>(AddMessage), DispatcherPriority.Send, level, message);
                return;
            }

            if (IsOpen)
            {
                Brush messageBrush;

                // select message color based on MessageLevel value.
                // these colors match the colors in the console, which are set in MyHostUI.cs
                if (SystemParameters.HighContrast)
                {
                    // Use the plain System brush
                    messageBrush = SystemColors.ControlTextBrush;
                }
                else
                {
                    switch (level)
                    {
                    case MessageLevel.Debug:
                        messageBrush = Brushes.DarkGray;
                        break;

                    case MessageLevel.Error:
                        messageBrush = Brushes.Red;
                        break;

                    case MessageLevel.Warning:
                        messageBrush = Brushes.Magenta;
                        break;

                    default:
                        messageBrush = Brushes.Black;
                        break;
                    }
                }

                _currentWindow.AddMessage(message, messageBrush);
            }
        }
Exemple #2
0
        /// <summary>
        /// Add a logging message to the progress window.
        /// </summary>
        /// <remarks>
        /// This method can be called from worker thread.
        /// </remarks>
        public void AddMessage(LogMessageLevel level, string message)
        {
            if (!_uiDispatcher.CheckAccess())
            {
                _uiDispatcher.BeginInvoke(new Action <LogMessageLevel, string>(AddMessage), level, message);
                return;
            }

            if (IsOpen)
            {
                Brush messageBrush;

                // select message color based on LogMessageLevel value.
                // these colors match the colors in the console, which are set in MyHostUI.cs
                switch (level)
                {
                case LogMessageLevel.Debug:
                    messageBrush = Brushes.DarkGray;
                    break;

                case LogMessageLevel.Error:
                    messageBrush = Brushes.Red;
                    break;

                case LogMessageLevel.Warning:
                    messageBrush = Brushes.Magenta;
                    break;

                default:
                    messageBrush = Brushes.Black;
                    break;
                }

                _currentWindow.AddMessage(message, messageBrush);
            }
            else
            {
                throw new InvalidOperationException();
            }
        }