Beispiel #1
0
 public static void SafeLog(this Console console, Message message)
 {
     if(console !=null)
     {
         console.Log(message);
     }
 }
Beispiel #2
0
        private void UpdateConsole(object sender, Message e)
        {
            if (InvokeRequired)
            {
                // Execute the same method, but this time on the GUI thread
                BeginInvoke(new ThreadStart(() => PrintToConsole(e)));
                return;
            }

            PrintToConsole(e);
        }
Beispiel #3
0
        /// <summary>
        /// Prints a <see cref="Message"/> to the console.
        /// </summary>
        /// <param name="message">The message to be printed to the console</param>
        private void PrintToConsole(Message message)
        {
            Color textColor;

            //Set the color of the message before printing it to the console
            switch (message.Level)
            {
                case ErrorLevel.Error:
                    textColor = Color.Firebrick;
                    break;
                case ErrorLevel.Warning:
                    textColor = Color.DarkOrchid;
                    break;
                default:
                    textColor = Color.Black;
                    break;
            }

            txtBoxConsole.AppendColoredText(message.MessageText + Environment.NewLine, textColor);
        }