Ejemplo n.º 1
0
 public async Task AddToLog(LogMessange content)
 {
     await Task.Factory.StartNew(()
                                 => DispatcherHelper.CheckBeginInvokeOnUI(()
                                                                          =>
     {
         LoggerBox.Document.Blocks.Add(content.Content);
         LoggerBox.ScrollToEnd();
     }));
 }
Ejemplo n.º 2
0
        private void Log(object sender, LoggerEventArgs e)
        {
            Run category = new Run("[" + e.Category.ToUpper() + "]: ");

            category.Foreground = new SolidColorBrush(Colors.DarkSlateBlue);
            category.FontWeight = FontWeights.Bold;
            category.FontSize   = 12;
            category.FontFamily = new FontFamily("Consolas");

            Run message = new Run(e.Message);

            switch (e.Level)
            {
            case LogLevel.Debug:
                message.Foreground = new SolidColorBrush(Colors.DarkGray);
                break;

            case LogLevel.Info:
                message.Foreground = new SolidColorBrush(Colors.Black);
                break;

            case LogLevel.Warning:
                message.Foreground = new SolidColorBrush(Colors.Orange);
                message.FontWeight = FontWeights.Bold;
                break;

            case LogLevel.Error:
                message.Foreground = new SolidColorBrush(Colors.Red);
                message.FontWeight = FontWeights.Bold;
                break;

            case LogLevel.Fatal:
                message.Foreground = new SolidColorBrush(Colors.DarkRed);
                message.FontWeight = FontWeights.Bold;
                break;

            default:
                break;
            }
            message.FontSize   = 12;
            message.FontFamily = new FontFamily("Consolas");

            TextBlock log = new TextBlock();

            log.Inlines.Add(category);
            log.Inlines.Add(message);

            LoggerBox.Items.Add(log);
            LoggerBox.ScrollIntoView(log);
        }
Ejemplo n.º 3
0
 private void TextChangedEventHandler(object sender, TextChangedEventArgs e)
 {
     LoggerBox.ScrollToEnd();
 }
Ejemplo n.º 4
0
 protected override void Awake()
 {
     base.Awake();
     instance        = this;
     waitForStayTime = new WaitForSeconds(LOGMSG_STAY_TIME);
 }