//Handle data recieved from server private void ServerOutput_OutputDataRecieved(object sender, DataReceivedEventArgs e) { Dispatcher.InvokeAsync(() => { try { if (e.Data.Contains("WARN")) { ServerOutputWindow.AppendText(e.Data + "\n"); TextRange WarnOutputTextRange = new TextRange(ServerOutputWindow.Document.ContentEnd, ServerOutputWindow.Document.ContentEnd); WarnOutputTextRange.Text = e.Data; WarnOutputTextRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(WarningOutputColor)); } else if (e.Data.Contains("ERROR")) { ServerOutputWindow.AppendText(e.Data + "\n"); TextRange ErrorOutputTextRange = new TextRange(ServerOutputWindow.Document.ContentEnd, ServerOutputWindow.Document.ContentEnd); ErrorOutputTextRange.Text = e.Data; ErrorOutputTextRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(ErrorOutputColor)); } else if (e.Data.Contains("logged in with") || e.Data.Contains("left the game")) { ServerOutputWindow.AppendText(e.Data + "\n"); TextRange PlayEventTextRange = new TextRange(ServerOutputWindow.Document.ContentEnd, ServerOutputWindow.Document.ContentEnd); PlayEventTextRange.Text = e.Data; PlayEventTextRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(PlayerEventOutputColor)); } else if (e.Data.Contains("Done") && e.Data.Contains("For help, type \"help\"")) { ServerOutputWindow.AppendText(e.Data + "\n"); TextRange PlayEventTextRange = new TextRange(ServerOutputWindow.Document.ContentEnd, ServerOutputWindow.Document.ContentEnd); PlayEventTextRange.Text = e.Data; PlayEventTextRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(ServerDoneLoadingColor)); } else { ServerOutputWindow.AppendText(e.Data + "\n"); TextRange DefaultOutputTextRange = new TextRange(ServerOutputWindow.Document.ContentEnd, ServerOutputWindow.Document.ContentEnd); DefaultOutputTextRange.Text = e.Data; DefaultOutputTextRange.ApplyPropertyValue(TextElement.ForegroundProperty, new SolidColorBrush(DefaultOutputColor)); } } catch (Exception) { } if (ServerOutputWindow_AutoScroll) { ServerOutputWindow.ScrollToEnd(); } }); }
private void ServerOutputWindow_AutoScrollButton_Click(object sender, RoutedEventArgs e) { ServerOutputWindow_AutoScroll = true; ServerOutputWindow_AutoScrollButton.Opacity = 0; ServerOutputWindow.ScrollToEnd(); }