From 00a7c4f3517492778b8387a4dfc2e2f1f0315bef Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Mon, 24 Oct 2016 23:30:10 +0200 Subject: [PATCH] Added markdown support to the changelog display Added live log to the debug window --- Artemis/Artemis/App.xaml | 1 + Artemis/Artemis/Artemis.csproj | 21 + .../Artemis/Controls/Log/LoggingControl.xaml | 27 + .../Controls/Log/LoggingControl.xaml.cs | 37 + .../Artemis/Controls/Log/MemoryEventTarget.cs | 20 + Artemis/Artemis/Dialogs/MarkdownDialog.xaml | 53 + .../Artemis/Dialogs/MarkdownDialog.xaml.cs | 28 + .../Artemis/Services/MetroDialogService.cs | 16 + Artemis/Artemis/Styles/MarkdownStyles.xaml | 57 + Artemis/Artemis/Utilities/Logging.cs | 29 +- .../Artemis/Utilities/Markdown/Markdown.cs | 1051 +++++++++++++++++ .../Markdown/TextToFlowDocumentConverter.cs | 62 + Artemis/Artemis/Utilities/Updater.cs | 8 +- Artemis/Artemis/ViewModels/DebugViewModel.cs | 20 +- Artemis/Artemis/Views/DebugView.xaml | 15 +- 15 files changed, 1433 insertions(+), 12 deletions(-) create mode 100644 Artemis/Artemis/Controls/Log/LoggingControl.xaml create mode 100644 Artemis/Artemis/Controls/Log/LoggingControl.xaml.cs create mode 100644 Artemis/Artemis/Controls/Log/MemoryEventTarget.cs create mode 100644 Artemis/Artemis/Dialogs/MarkdownDialog.xaml create mode 100644 Artemis/Artemis/Dialogs/MarkdownDialog.xaml.cs create mode 100644 Artemis/Artemis/Styles/MarkdownStyles.xaml create mode 100644 Artemis/Artemis/Utilities/Markdown/Markdown.cs create mode 100644 Artemis/Artemis/Utilities/Markdown/TextToFlowDocumentConverter.cs diff --git a/Artemis/Artemis/App.xaml b/Artemis/Artemis/App.xaml index e13bd017f..1b093a2b3 100644 --- a/Artemis/Artemis/App.xaml +++ b/Artemis/Artemis/App.xaml @@ -21,6 +21,7 @@ Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" /> + diff --git a/Artemis/Artemis/Artemis.csproj b/Artemis/Artemis/Artemis.csproj index abd596e18..bce65305f 100644 --- a/Artemis/Artemis/Artemis.csproj +++ b/Artemis/Artemis/Artemis.csproj @@ -303,6 +303,10 @@ Code + + LoggingControl.xaml + + @@ -313,6 +317,9 @@ + + MarkdownDialog.xaml + @@ -511,6 +518,8 @@ + + @@ -686,6 +695,14 @@ + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -746,6 +763,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/Artemis/Artemis/Controls/Log/LoggingControl.xaml b/Artemis/Artemis/Controls/Log/LoggingControl.xaml new file mode 100644 index 000000000..b1ded7610 --- /dev/null +++ b/Artemis/Artemis/Controls/Log/LoggingControl.xaml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Artemis/Artemis/Controls/Log/LoggingControl.xaml.cs b/Artemis/Artemis/Controls/Log/LoggingControl.xaml.cs new file mode 100644 index 000000000..cf771ba2d --- /dev/null +++ b/Artemis/Artemis/Controls/Log/LoggingControl.xaml.cs @@ -0,0 +1,37 @@ +using System.Collections.ObjectModel; +using System.Windows.Controls; +using Artemis.Utilities; +using NLog; + +namespace Artemis.Controls.Log +{ + /// + /// Interaction logic for LoggingControl.xaml + /// + public partial class LoggingControl : UserControl + { + public LoggingControl() + { + LogCollection = new ObservableCollection(); + + InitializeComponent(); + + // init memory queue + Logging.ClearLoggingEvent(); + Logging.MemoryEvent += EventReceived; + } + + public static ObservableCollection LogCollection { get; set; } + + private async void EventReceived(LogEventInfo message) + { + await Dispatcher.InvokeAsync(() => + { + if (LogCollection.Count >= 50) + LogCollection.RemoveAt(LogCollection.Count - 1); + + LogCollection.Add(message); + }); + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Controls/Log/MemoryEventTarget.cs b/Artemis/Artemis/Controls/Log/MemoryEventTarget.cs new file mode 100644 index 000000000..acbe7690e --- /dev/null +++ b/Artemis/Artemis/Controls/Log/MemoryEventTarget.cs @@ -0,0 +1,20 @@ +using System; +using NLog; +using NLog.Targets; + +namespace Artemis.Controls.Log +{ + public class MemoryEventTarget : Target + { + public event Action EventReceived; + + /// + /// Notifies listeners about new event + /// + /// The logging event. + protected override void Write(LogEventInfo logEvent) + { + EventReceived?.Invoke(logEvent); + } + } +} \ No newline at end of file diff --git a/Artemis/Artemis/Dialogs/MarkdownDialog.xaml b/Artemis/Artemis/Dialogs/MarkdownDialog.xaml new file mode 100644 index 000000000..8a9587fe5 --- /dev/null +++ b/Artemis/Artemis/Dialogs/MarkdownDialog.xaml @@ -0,0 +1,53 @@ + + + + + + + + + + + + + + + +