private void UserControl_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (true.Equals(e.NewValue)) { LoggerTextBox.Clear(); using (Logger.Default.Subscribe(new TextBoxLoggerApender(LoggerTextBox))) { ((ServerListViewModel)DataContext).LookForInstallation(); } } }
void LoggerUpdated(LogItem item) { Dispatcher.BeginInvoke(new Action(() => { // [{time} | {level}] {data}\n TextRange tr1 = new TextRange(LoggerTextBox.Document.ContentEnd, LoggerTextBox.Document.ContentEnd); tr1.Text = "[" + item.Timestamp + " | "; tr1.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black); TextRange tr2 = new TextRange(LoggerTextBox.Document.ContentEnd, LoggerTextBox.Document.ContentEnd); tr2.Text = Logger.levelMap[item.Level]; tr2.ApplyPropertyValue(TextElement.ForegroundProperty, levelColorMap[item.Level]); TextRange tr3 = new TextRange(LoggerTextBox.Document.ContentEnd, LoggerTextBox.Document.ContentEnd); tr3.Text = "] " + item.Text + "\r"; tr3.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Black); LoggerTextBox.ScrollToEnd(); })); }