From a991917ea931e376b481b127a9b84b03328263b2 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Fri, 14 Jul 2023 17:02:41 +0100 Subject: [PATCH 1/4] Fixed text selection in the debug logs view --- .../Debugger/Tabs/Logs/LogsDebugView.axaml | 9 +++-- .../Debugger/Tabs/Logs/LogsDebugView.axaml.cs | 33 ------------------- .../Debugger/Tabs/Logs/LogsDebugViewModel.cs | 10 +++++- 3 files changed, 15 insertions(+), 37 deletions(-) diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugView.axaml b/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugView.axaml index 5a5c6d457..f41b9b272 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugView.axaml +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugView.axaml @@ -2,13 +2,16 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:aedit="https://github.com/avaloniaui/avaloniaedit" - xmlns:controls="clr-namespace:Artemis.UI.Controls" xmlns:logs="clr-namespace:Artemis.UI.Screens.Debugger.Logs" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.Debugger.Logs.LogsDebugView" x:DataType="logs:LogsDebugViewModel"> - + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugView.axaml.cs b/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugView.axaml.cs index 219215877..26d8ab003 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugView.axaml.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugView.axaml.cs @@ -10,50 +10,17 @@ namespace Artemis.UI.Screens.Debugger.Logs; public partial class LogsDebugView : ReactiveUserControl { - private int _lineCount; - public LogsDebugView() { - _lineCount = 0; InitializeComponent(); } - protected override void OnInitialized() { base.OnInitialized(); Dispatcher.UIThread.Post(() => LogsScrollViewer.ScrollToEnd(), DispatcherPriority.ApplicationIdle); } - // private void OnTextChanged(object? sender, EventArgs e) - // { - // if (LogTextEditor.ExtentHeight == 0) - // return; - // - // int linesAdded = LogTextEditor.LineCount - _lineCount; - // double lineHeight = LogTextEditor.ExtentHeight / LogTextEditor.LineCount; - // double outOfScreenTextHeight = LogTextEditor.ExtentHeight - LogTextEditor.VerticalOffset - LogTextEditor.ViewportHeight; - // double outOfScreenLines = outOfScreenTextHeight / lineHeight; - // - // //we need this help distance because of rounding. - // //if we scroll slightly above the end, we still want it - // //to scroll down to the new lines. - // const double GRACE_DISTANCE = 1d; - // - // //if we were at the bottom of the log and - // //if the last log event was 5 lines long - // //we will be 5 lines out sync. - // //if this is the case, scroll down. - // - // //if we are more than that out of sync, - // //the user scrolled up and we should not - // //mess with anything. - // if (_lineCount == 0 || linesAdded + GRACE_DISTANCE > outOfScreenLines) - // { - // Dispatcher.UIThread.Post(() => LogTextEditor.ScrollToEnd(), DispatcherPriority.ApplicationIdle); - // _lineCount = LogTextEditor.LineCount; - // } - // } private void Control_OnSizeChanged(object? sender, SizeChangedEventArgs e) { if (!(LogsScrollViewer.Extent.Height - LogsScrollViewer.Offset.Y - LogsScrollViewer.Bounds.Bottom <= 60)) diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugViewModel.cs b/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugViewModel.cs index 4df1be54e..47309a3ad 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugViewModel.cs @@ -7,7 +7,9 @@ using ReactiveUI; using Serilog.Events; using Serilog.Formatting.Display; using System.IO; +using System.Linq; using System.Reactive.Disposables; +using System.Text; using Avalonia.Controls.Documents; using Avalonia.Media; @@ -54,8 +56,14 @@ public class LogsDebugViewModel : ActivatableViewModelBase _formatter.Format(logEvent, writer); string line = writer.ToString(); + StringBuilder builder = new(); - Lines.Add(new Run(line.TrimEnd('\r', '\n') + '\n') + //hack: https://github.com/AvaloniaUI/Avalonia/issues/10913 + string paddedLine2 = line.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries) + .Aggregate(builder, (sb, s) => sb.Append(s).Append(' ', 400 - s.Length).AppendLine()) + .ToString(); + + Lines.Add(new Run(paddedLine2) { Foreground = logEvent.Level switch { From de7c09f047692f0c767d37b2f8a849526a248529 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Fri, 14 Jul 2023 23:19:28 +0100 Subject: [PATCH 2/4] Core - Override ColorSwatch.ToString This cleans up the datamodel viewer a lot, currently since ColorSwatch is a struct, it has a very long name. Since the properties can be seen by looking at the children in the datamodel, this information is useless. --- .../ColorScience/Quantization/ColorSwatch.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Artemis.Core/ColorScience/Quantization/ColorSwatch.cs b/src/Artemis.Core/ColorScience/Quantization/ColorSwatch.cs index 16dd769b3..602f3d480 100644 --- a/src/Artemis.Core/ColorScience/Quantization/ColorSwatch.cs +++ b/src/Artemis.Core/ColorScience/Quantization/ColorSwatch.cs @@ -1,4 +1,5 @@ -using SkiaSharp; +using System.Text; +using SkiaSharp; namespace Artemis.Core.ColorScience; @@ -36,4 +37,14 @@ public readonly record struct ColorSwatch /// The component. /// public SKColor DarkMuted { get; init; } + + /// + /// Override the record ToString method, + /// so we get a cleaner datamodel viewer + /// + /// + public override string? ToString() + { + return base.ToString(); + } } \ No newline at end of file From 27d69bc1bcefbf4e6a5fe4e6cc26637dfe47e23a Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Sun, 16 Jul 2023 17:30:27 +0100 Subject: [PATCH 3/4] Fixed enum swich node not respecting DisplayAttribute --- src/Artemis.VisualScripting/Nodes/Branching/EnumSwitchNode.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Artemis.VisualScripting/Nodes/Branching/EnumSwitchNode.cs b/src/Artemis.VisualScripting/Nodes/Branching/EnumSwitchNode.cs index 5ca915053..eb3803290 100644 --- a/src/Artemis.VisualScripting/Nodes/Branching/EnumSwitchNode.cs +++ b/src/Artemis.VisualScripting/Nodes/Branching/EnumSwitchNode.cs @@ -71,7 +71,7 @@ public class EnumSwitchNode : Node foreach (Enum enumValue in Enum.GetValues(enumType).Cast()) { - InputPin pin = CreateOrAddInputPin(typeof(object), enumValue.ToString().Humanize(LetterCasing.Sentence)); + InputPin pin = CreateOrAddInputPin(typeof(object), enumValue.Humanize(LetterCasing.Sentence)); pin.PinConnected += OnInputPinConnected; pin.PinDisconnected += OnInputPinDisconnected; _inputPins[enumValue] = pin; From 49362132496bd709c37df7ca0fd601d73ad34c95 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Fri, 21 Jul 2023 17:00:35 +0100 Subject: [PATCH 4/4] Fix plugin module being case sensitive comparing guids --- src/Artemis.Core/Services/WebServer/PluginsModule.cs | 5 +++-- .../Screens/Debugger/Tabs/Logs/LogsDebugViewModel.cs | 9 +-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Artemis.Core/Services/WebServer/PluginsModule.cs b/src/Artemis.Core/Services/WebServer/PluginsModule.cs index e4d234326..c9d423760 100644 --- a/src/Artemis.Core/Services/WebServer/PluginsModule.cs +++ b/src/Artemis.Core/Services/WebServer/PluginsModule.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using EmbedIO; @@ -15,7 +16,7 @@ public class PluginsModule : WebModuleBase internal PluginsModule(string baseRoute) : base(baseRoute) { - _pluginEndPoints = new Dictionary>(); + _pluginEndPoints = new Dictionary>(comparer: StringComparer.InvariantCultureIgnoreCase); } internal void AddPluginEndPoint(PluginEndPoint registration) diff --git a/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugViewModel.cs b/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugViewModel.cs index 47309a3ad..95a87a167 100644 --- a/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugViewModel.cs +++ b/src/Artemis.UI/Screens/Debugger/Tabs/Logs/LogsDebugViewModel.cs @@ -56,14 +56,7 @@ public class LogsDebugViewModel : ActivatableViewModelBase _formatter.Format(logEvent, writer); string line = writer.ToString(); - StringBuilder builder = new(); - - //hack: https://github.com/AvaloniaUI/Avalonia/issues/10913 - string paddedLine2 = line.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries) - .Aggregate(builder, (sb, s) => sb.Append(s).Append(' ', 400 - s.Length).AppendLine()) - .ToString(); - - Lines.Add(new Run(paddedLine2) + Lines.Add(new Run(line.TrimEnd('\r', '\n') + '\n') { Foreground = logEvent.Level switch {