Esempio n. 1
0
 public void AddCrashMessage(Exception e, string message)
 {
     Dispatcher.Invoke(() =>
     {
         IRichTextMessage crashMessage = ObjectFactory.CreateDebugCrashMessage(e, message.AsRichTextString());
         AddMessage(crashMessage);
     });
 }
Esempio n. 2
0
 public void AddWarningMessage(string message)
 {
     Dispatcher.Invoke(() =>
     {
         IRichTextMessage warningMessage = ObjectFactory.CreateDebugWarningMessage(message.AsRichTextString());
         AddMessage(warningMessage);
     });
 }
Esempio n. 3
0
 public void AddDetailMessage(string message)
 {
     Dispatcher.Invoke(() =>
     {
         IRichTextMessage detailMessage = ObjectFactory.CreateDebugDetailMessage(message.AsRichTextString());
         AddMessage(detailMessage);
     });
 }
Esempio n. 4
0
 public void AddSummaryMessage(string message)
 {
     Dispatcher.Invoke(() =>
     {
         IRichTextMessage summaryMessage = ObjectFactory.CreateDebugSummaryMessage(message.AsRichTextString());
         AddMessage(summaryMessage);
     });
 }
Esempio n. 5
0
        private void AddMessage(IRichTextMessage newMessage)
        {
            bool scrollToEnd = (ConsoleOutputScrollViewer.VerticalOffset == ConsoleOutputScrollViewer.ScrollableHeight);

            AddMessageToList(newMessage);
            AddMessageToGrid(newMessage);
            if (scrollToEnd)
            {
                ConsoleOutputScrollViewer.ScrollToBottom();
            }
        }
Esempio n. 6
0
        private void AddMessageToList(IRichTextMessage newMessage)
        {
            lock (_messageList)
            {
                Dispatcher.Invoke(() =>
                {
                    #region Add to List

                    _messageList.Add(newMessage);

                    #endregion
                });
            }
        }
Esempio n. 7
0
 public void AddUserMessage(IUser user, string message)
 {
     try
     {
         Dispatcher.Invoke(() =>
         {
             IRichTextMessage userMessage = ObjectFactory.CreateConsoleUserMessage(user, message.AsRichTextString());
             AddMessage(userMessage);
         });
     }
     catch
     {
     }
 }
Esempio n. 8
0
 public void AddInformationMessage(string message)
 {
     try
     {
         Dispatcher.Invoke(() =>
         {
             IRichTextMessage informationMessage = ObjectFactory.CreateConsoleInformationMessage(message.AsRichTextString());
             AddMessage(informationMessage);
         });
     }
     catch
     {
     }
 }
Esempio n. 9
0
                    public Paragraph(IRichTextMessage input)
                    {
                        Name = "p";
                        //Contents = input.ToString(); //input.AsHTMLParagraph;

                        //break elements up,
                        var   output    = new StringBuilder();
                        Style dateStyle = new Style();

                        dateStyle.Classes.Add("colorF");

                        Span dateSpan = new Span();

                        dateSpan.Attributes.Add(dateStyle);
                        dateSpan.Contents = input.Datestamp + " " + input.Timestamp + ": ";
                        output.Append(dateSpan);
                        foreach (var thisElement in input.String.Elements)
                        {
                            Style thisStyle = new Style();
                            thisStyle.Classes.Add("color" + thisElement.ForeColor);
                            if (thisElement.IsBold)
                            {
                                thisStyle.Classes.Add("bold");
                            }
                            if (thisElement.IsItallic)
                            {
                                thisStyle.Classes.Add("italic");
                            }
                            if (thisElement.IsObfuscated)
                            {
                                thisStyle.Classes.Add("obfuscated");
                            }
                            if (thisElement.IsStrikeout)
                            {
                                thisStyle.Classes.Add("strikethrough");
                            }
                            if (thisElement.IsUnderlined)
                            {
                                thisStyle.Classes.Add("underlined");
                            }

                            Span thisSpan = new Span();
                            thisSpan.Attributes.Add(thisStyle);
                            thisSpan.Contents = thisElement.Message;
                            output.Append(thisSpan);
                        }
                        Contents = output.ToString();
                        string messagetype = "unknown";

                        {
                            switch (input.Type)
                            {
                            case MessageType.User:
                                messagetype = "user";
                                break;

                            case MessageType.ConsoleInformation:
                                messagetype = "consoleinformation";
                                break;

                            case MessageType.DebugSummary:
                                messagetype = "debugsummary";
                                break;

                            case MessageType.DebugDetail:
                                messagetype = "debugdetail";
                                break;

                            case MessageType.DebugWarning:
                                messagetype = "debugwarning";
                                break;

                            case MessageType.DebugError:
                                messagetype = "debugerror";
                                break;

                            case MessageType.DebugCrash:
                                messagetype = "debugcrash";
                                break;
                            }
                        }
                        Attributes.Add(new Class(messagetype));
                    }
Esempio n. 10
0
        public RichTextMessageTextBlockContainer(IRichTextMessage input)
        {
            #region Color BG
            byte   BGAlpha = (byte)(0.25f * 255);
            IColor BGColor = ObjectFactory.CreateColor(BGAlpha, 16, 16, 16);
            switch (input.Type)
            {
            case MessageType.Unknown:
            default:
                BGColor = ObjectFactory.CreateColor(BGAlpha, 100, 0, 100);
                break;

            case MessageType.User:
                BGColor = ObjectFactory.CreateColor(BGAlpha, 16, 16, 16);
                break;

            case MessageType.ConsoleInformation:
                BGColor = ObjectFactory.CreateColor(BGAlpha, 0, 32, 48);
                break;

            case MessageType.DebugSummary:
                BGColor = ObjectFactory.CreateColor(BGAlpha, 0, 100, 150);
                break;

            case MessageType.DebugDetail:
                BGColor = ObjectFactory.CreateColor(BGAlpha, 0, 50, 100);
                break;

            case MessageType.DebugWarning:
                BGColor = ObjectFactory.CreateColor(BGAlpha, 150, 150, 0);
                break;

            case MessageType.DebugError:
                BGColor = ObjectFactory.CreateColor(BGAlpha, 200, 100, 0);
                break;

            case MessageType.DebugCrash:
                BGColor = ObjectFactory.CreateColor(BGAlpha, 120, 0, 0);
                break;
            }
            #endregion

            #region Message
            Message = input;
            #endregion

            #region Datestamp
            IFormattingDescriptor dateFormattingDescriptor = ObjectFactory.CreateFormattingDescriptor
                                                             (
                foreColor: SimpleColors.DarkGray.Color,
                backColor: ObjectFactory.CreateColor(16, 16, 16),
                isBold: false,
                isItallic: true,
                isUnderlined: false,
                isStrikeout: false,
                isObfuscated: false
                                                             );
            IRichTextString dateStampString = ObjectFactory.CreateRichTextString(dateFormattingDescriptor);
            dateStampString.AddFormattedString(input.Datestamp.ToSystemString());

            Datestamp = RichTextStringConverter.ToTextBlock(dateStampString).ToFormattedTextBlock(BGColor);

            #endregion
            #region Timestamp

            IFormattingDescriptor timeFormattingDescriptor = ObjectFactory.CreateFormattingDescriptor
                                                             (
                foreColor: SimpleColors.Gray.Color,
                backColor: ObjectFactory.CreateColor(16, 16, 16),
                isBold: false,
                isItallic: true,
                isUnderlined: false,
                isStrikeout: false,
                isObfuscated: false
                                                             );
            IRichTextString timeStampString = ObjectFactory.CreateRichTextString(timeFormattingDescriptor);
            timeStampString.AddFormattedString(input.Timestamp.ToSystemString());

            Timestamp = RichTextStringConverter.ToTextBlock(timeStampString).ToFormattedTextBlock(BGColor);

            #endregion
            #region User

            User = RichTextStringConverter.ToTextBlock(input.User.UserName).ToFormattedTextBlock(BGColor);

            #endregion
            #region Type

            IFormattingDescriptor typeFormattingDescriptor;
            typeFormattingDescriptor = ObjectFactory.CreateFormattingDescriptor
                                       (
                foreColor: SimpleColors.DarkGray.Color,
                backColor: ObjectFactory.CreateColor(16, 16, 16),
                isBold: false,
                isItallic: true,
                isUnderlined: false,
                isStrikeout: false,
                isObfuscated: false
                                       );
            switch (input.Type)
            {
            case MessageType.Unknown:
            default:
            {
                typeFormattingDescriptor.ForeColor    = SimpleColors.White.Color;
                typeFormattingDescriptor.BackColor    = ObjectFactory.CreateColor(16, 16, 16);
                typeFormattingDescriptor.IsBold       = false;
                typeFormattingDescriptor.IsItallic    = true;
                typeFormattingDescriptor.IsUnderlined = false;
                typeFormattingDescriptor.IsStrikeout  = false;
                typeFormattingDescriptor.IsObfuscated = false;
                break;
            }

            case MessageType.User:
            {
                typeFormattingDescriptor.ForeColor    = SimpleColors.White.Color;
                typeFormattingDescriptor.BackColor    = ObjectFactory.CreateColor(16, 16, 16);
                typeFormattingDescriptor.IsBold       = false;
                typeFormattingDescriptor.IsItallic    = false;
                typeFormattingDescriptor.IsUnderlined = false;
                typeFormattingDescriptor.IsStrikeout  = false;
                typeFormattingDescriptor.IsObfuscated = false;
                break;
            }

            case MessageType.ConsoleInformation:
            {
                typeFormattingDescriptor.ForeColor    = SimpleColors.DarkTeal.Color;
                typeFormattingDescriptor.BackColor    = ObjectFactory.CreateColor(16, 16, 16);
                typeFormattingDescriptor.IsBold       = false;
                typeFormattingDescriptor.IsItallic    = true;
                typeFormattingDescriptor.IsUnderlined = false;
                typeFormattingDescriptor.IsStrikeout  = false;
                typeFormattingDescriptor.IsObfuscated = false;
                break;
            }

            case MessageType.DebugSummary:
            {
                typeFormattingDescriptor.ForeColor    = SimpleColors.Blue.Color;
                typeFormattingDescriptor.BackColor    = ObjectFactory.CreateColor(16, 16, 16);
                typeFormattingDescriptor.IsBold       = false;
                typeFormattingDescriptor.IsItallic    = true;
                typeFormattingDescriptor.IsUnderlined = false;
                typeFormattingDescriptor.IsStrikeout  = false;
                typeFormattingDescriptor.IsObfuscated = false;
                break;
            }

            case MessageType.DebugDetail:
            {
                typeFormattingDescriptor.ForeColor    = SimpleColors.DarkBlue.Color;
                typeFormattingDescriptor.BackColor    = ObjectFactory.CreateColor(16, 16, 16);
                typeFormattingDescriptor.IsBold       = false;
                typeFormattingDescriptor.IsItallic    = true;
                typeFormattingDescriptor.IsUnderlined = false;
                typeFormattingDescriptor.IsStrikeout  = false;
                typeFormattingDescriptor.IsObfuscated = false;
                break;
            }

            case MessageType.DebugWarning:
            {
                typeFormattingDescriptor.ForeColor    = SimpleColors.Yellow.Color;
                typeFormattingDescriptor.BackColor    = ObjectFactory.CreateColor(16, 16, 16);
                typeFormattingDescriptor.IsBold       = false;
                typeFormattingDescriptor.IsItallic    = false;
                typeFormattingDescriptor.IsUnderlined = false;
                typeFormattingDescriptor.IsStrikeout  = false;
                typeFormattingDescriptor.IsObfuscated = false;
                break;
            }

            case MessageType.DebugError:
            {
                typeFormattingDescriptor.ForeColor    = SimpleColors.Gray.Color;
                typeFormattingDescriptor.BackColor    = ObjectFactory.CreateColor(240, 200, 16);
                typeFormattingDescriptor.IsBold       = true;
                typeFormattingDescriptor.IsItallic    = false;
                typeFormattingDescriptor.IsUnderlined = false;
                typeFormattingDescriptor.IsStrikeout  = false;
                typeFormattingDescriptor.IsObfuscated = false;
                break;
            }

            case MessageType.DebugCrash:
            {
                typeFormattingDescriptor.ForeColor    = SimpleColors.White.Color;
                typeFormattingDescriptor.BackColor    = ObjectFactory.CreateColor(240, 16, 16);
                typeFormattingDescriptor.IsBold       = true;
                typeFormattingDescriptor.IsItallic    = false;
                typeFormattingDescriptor.IsUnderlined = false;
                typeFormattingDescriptor.IsStrikeout  = false;
                typeFormattingDescriptor.IsObfuscated = false;
                break;
            }
            }


            IRichTextString typeRichTextString = ObjectFactory.CreateRichTextString(typeFormattingDescriptor);
            string          typeString         = "???";
            switch (input.Type)
            {
            case MessageType.Unknown:
            default:
                typeString = "???";
                break;

            case MessageType.User:
                typeString = "User";
                break;

            case MessageType.ConsoleInformation:
                typeString = "Console Information";
                break;

            case MessageType.DebugSummary:
                typeString = "Debug Summary";
                break;

            case MessageType.DebugDetail:
                typeString = "Debug Detail";
                break;

            case MessageType.DebugWarning:
                typeString = "Debug Warning";
                break;

            case MessageType.DebugError:
                typeString = "Debug Error";
                break;

            case MessageType.DebugCrash:
                typeString = "Debug Crash";
                break;
            }

            typeRichTextString.AddFormattedString(typeString);

            Type = RichTextStringConverter.ToTextBlock(typeRichTextString).ToFormattedTextBlock(BGColor);

            #endregion
            #region String
            String = RichTextStringConverter.ToTextBlock(input.String).ToFormattedTextBlock(BGColor);
            #endregion
        }
Esempio n. 11
0
        private void AddMessageToGrid(IRichTextMessage newMessage)
        {
            lock (_messageList)
            {
                Dispatcher.Invoke(() =>
                {
                    #region Limit Grid Size

                    if (_messageList.Count >= 10000)
                    {
                        _messageList.RemoveRange(0, _messageList.Count - 8000);
                        RefreshGrid();
                        return;
                    }

                    #endregion

                    #region RETURN if Row should be Hidden

                    if (newMessage.Type == MessageType.ConsoleInformation &&
                        !SettingsLibrary.Settings.UserInterface.Console.ShowMessages.Console)
                    {
                        return;
                    }
                    if (newMessage.Type == MessageType.User &&
                        !SettingsLibrary.Settings.UserInterface.Console.ShowMessages.User)
                    {
                        return;
                    }

                    if (newMessage.Type == MessageType.DebugSummary &&
                        !SettingsLibrary.Settings.UserInterface.Console.ShowDebug.Summary)
                    {
                        return;
                    }
                    if (newMessage.Type == MessageType.DebugDetail &&
                        !SettingsLibrary.Settings.UserInterface.Console.ShowDebug.Detail)
                    {
                        return;
                    }
                    if (newMessage.Type == MessageType.DebugWarning &&
                        !SettingsLibrary.Settings.UserInterface.Console.ShowDebug.Warning)
                    {
                        return;
                    }
                    if (newMessage.Type == MessageType.DebugError &&
                        !SettingsLibrary.Settings.UserInterface.Console.ShowDebug.Error)
                    {
                        return;
                    }
                    if (newMessage.Type == MessageType.DebugCrash &&
                        !SettingsLibrary.Settings.UserInterface.Console.ShowDebug.Crash)
                    {
                        return;
                    }

                    #endregion

                    #region ELSE, Add to Grid

                    #region Convert

                    RichTextMessageTextBlockContainer newTextBlockContainer = new RichTextMessageTextBlockContainer(newMessage);

                    #endregion

                    #region Borders

                    Border border_Date   = newTextBlockContainer.Datestamp;
                    Border border_Time   = newTextBlockContainer.Timestamp;
                    Border border_Type   = newTextBlockContainer.Type;
                    Border border_User   = newTextBlockContainer.User;
                    Border border_String = newTextBlockContainer.String;

                    #endregion

                    #region Row

                    RowDefinition newRow = new RowDefinition();
                    newRow.Height        = new GridLength(1, GridUnitType.Auto);

                    #endregion

                    #region Add Borders to Grid

                    if (DatestampColumn.Width.Value > 0)
                    {
                        ConsoleOutputGrid.Children.Add(border_Date);
                    }
                    if (TimestampColumn.Width.Value > 0)
                    {
                        ConsoleOutputGrid.Children.Add(border_Time);
                    }
                    if (TypeColumn.Width.Value > 0)
                    {
                        ConsoleOutputGrid.Children.Add(border_Type);
                    }
                    if (UserColumn.Width.Value > 0)
                    {
                        ConsoleOutputGrid.Children.Add(border_User);
                    }
                    if (StringColumn.Width.Value > 0)
                    {
                        ConsoleOutputGrid.Children.Add(border_String);
                    }

                    #endregion

                    #region Add Row to Grid

                    ConsoleOutputGrid.RowDefinitions.Add(newRow);

                    #endregion

                    #region Position TextBlocks in Grid

                    #region Position Row

                    if (DatestampColumn.Width.Value > 0)
                    {
                        Grid.SetRow(border_Date, ConsoleOutputGrid.RowDefinitions.Count - 1);
                    }
                    if (TimestampColumn.Width.Value > 0)
                    {
                        Grid.SetRow(border_Time, ConsoleOutputGrid.RowDefinitions.Count - 1);
                    }
                    if (TypeColumn.Width.Value > 0)
                    {
                        Grid.SetRow(border_Type, ConsoleOutputGrid.RowDefinitions.Count - 1);
                    }
                    if (UserColumn.Width.Value > 0)
                    {
                        Grid.SetRow(border_User, ConsoleOutputGrid.RowDefinitions.Count - 1);
                    }
                    if (StringColumn.Width.Value > 0)
                    {
                        Grid.SetRow(border_String, ConsoleOutputGrid.RowDefinitions.Count - 1);
                    }

                    #endregion

                    #region Position Column

                    if (DatestampColumn.Width.Value > 0)
                    {
                        Grid.SetColumn(border_Date, 0);
                    }
                    if (TimestampColumn.Width.Value > 0)
                    {
                        Grid.SetColumn(border_Time, 1);
                    }
                    if (TypeColumn.Width.Value > 0)
                    {
                        Grid.SetColumn(border_Type, 2);
                    }
                    if (UserColumn.Width.Value > 0)
                    {
                        Grid.SetColumn(border_User, 3);
                    }
                    if (StringColumn.Width.Value > 0)
                    {
                        Grid.SetColumn(border_String, 4);
                    }

                    #endregion

                    #endregion

                    #endregion
                });
            }
        }