public async Task AddToLog(LogMessange content) { await Task.Factory.StartNew(() => DispatcherHelper.CheckBeginInvokeOnUI(() => { LoggerBox.Document.Blocks.Add(content.Content); LoggerBox.ScrollToEnd(); })); }
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); }
private void TextChangedEventHandler(object sender, TextChangedEventArgs e) { LoggerBox.ScrollToEnd(); }
protected override void Awake() { base.Awake(); instance = this; waitForStayTime = new WaitForSeconds(LOGMSG_STAY_TIME); }