Ejemplo n.º 1
0
 /// <summary>
 /// Some Scout functions in this test application are executed using threading.
 /// Because of this, cross-threading issues may arise when attempting to
 /// perform operations on the main GUI thread. To prevent this, use the
 /// Invoke method. Refer to the <see cref="Button_DMC_Click"/> method.</summary>
 /// <param name="lvl">level of error severity <c>Okuma.Scout.Enums.MessageLevel</c></param>
 /// <param name="text">If level is other than "Exception", this contains the message to be displayed.</param>
 internal void PostError(Okuma.Scout.Enums.MessageLevel lvl, string text)
 {
     this.Invoke((MethodInvoker) delegate
     {
         this.TextBox_ErrorHandling.Text = this.TextBox_ErrorHandling.Text +
                                           lvl.ToString() + ":  " + text + Environment.NewLine;
     });
 }
Ejemplo n.º 2
0
        private FlowDocument AppendFlowLog(FlowDocument log, Okuma.Scout.Enums.MessageLevel level, string msg)
        {
            FlowDocument _log = log;

            try
            {
                Paragraph p    = new Paragraph();
                Run       when = new Run(DateTime.Now + "    ");
                p.Inlines.Add(when);
                switch (level)
                {
                default:     // Default will be INFO
                {
                    Run type = new Run("INFO:  ");
                    type.FontWeight = FontWeights.Bold;
                    type.Foreground = Brushes.DarkBlue;
                    p.Inlines.Add(type);
                    break;
                }

                case Okuma.Scout.Enums.MessageLevel.Exception:
                {
                    Run type = new Run("EXCEPTION:  ");
                    type.FontWeight = FontWeights.Bold;
                    type.Foreground = Brushes.Fuchsia;
                    p.Inlines.Add(type);
                    break;
                }

                case Okuma.Scout.Enums.MessageLevel.Error:
                {
                    Run type = new Run("ERROR:  ");
                    type.FontWeight = FontWeights.Bold;
                    type.Foreground = Brushes.Crimson;
                    p.Inlines.Add(type);
                    break;
                }

                case Okuma.Scout.Enums.MessageLevel.Warning:
                {
                    Run type = new Run("WARNING:  ");
                    type.FontWeight = FontWeights.Bold;
                    type.Foreground = Brushes.OrangeRed;
                    p.Inlines.Add(type);
                    break;
                }
                }

                Run message = new Run(msg);
                message.FontFamily = MessageFont;
                p.Inlines.Add(message);
                _log.Blocks.InsertBefore(_log.Blocks.FirstBlock, p);

                if (log.Blocks.Count() > 2000)
                {
                    log.Blocks.Remove(log.Blocks.ElementAt(2000));
                }
            }
            catch { }

            return(_log);
        }