From 257fa8ae0dd2ead935c0a58e3d75c0f1e66dede5 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 24 Mar 2024 21:58:49 +0100 Subject: [PATCH 1/4] Markdown - Tweak inline code and HR styles --- src/Artemis.UI/Styles/Markdown.axaml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Artemis.UI/Styles/Markdown.axaml b/src/Artemis.UI/Styles/Markdown.axaml index 6f03f8291..c56fb22af 100644 --- a/src/Artemis.UI/Styles/Markdown.axaml +++ b/src/Artemis.UI/Styles/Markdown.axaml @@ -1,7 +1,13 @@ + xmlns:ctxt="clr-namespace:ColorTextBlock.Avalonia;assembly=ColorTextBlock.Avalonia" + xmlns:controls="clr-namespace:Markdown.Avalonia.Controls;assembly=Markdown.Avalonia"> + + + Markdown.Xaml support ```inline code ``` and block code. + + @@ -60,4 +66,21 @@ + + + + \ No newline at end of file From 107b604c86e071671bd9bf0b76310b2d2f7b32e5 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 25 Mar 2024 20:41:15 +0100 Subject: [PATCH 2/4] Linux - Fix crash in keyframes --- .../Panels/ProfileTree/TreeItemViewModel.cs | 24 ++++++++----------- .../Keyframes/TimelineKeyframeViewModel.cs | 7 ++++-- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/TreeItemViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/TreeItemViewModel.cs index c19e68726..c5adf0948 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/TreeItemViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/ProfileTree/TreeItemViewModel.cs @@ -34,7 +34,7 @@ public abstract partial class TreeItemViewModel : ActivatableViewModelBase private RenderProfileElement? _currentProfileElement; private ObservableAsPropertyHelper? _isFocused; private TimeSpan _time; - + [Notify] private bool _canPaste; [Notify] private bool _isExpanded; [Notify] private bool _isFlyoutOpen; @@ -100,7 +100,7 @@ public abstract partial class TreeItemViewModel : ActivatableViewModelBase public ReactiveCommand Paste { get; } public ReactiveCommand Delete { get; } public abstract bool SupportsChildren { get; } - + public async Task ShowBrokenStateExceptions() { if (ProfileElement == null) @@ -117,7 +117,7 @@ public abstract partial class TreeItemViewModel : ActivatableViewModelBase return; } } - + public void InsertElement(TreeItemViewModel elementViewModel, int targetIndex) { if (elementViewModel.Parent == this && Children.IndexOf(elementViewModel) == targetIndex) @@ -239,26 +239,22 @@ public abstract partial class TreeItemViewModel : ActivatableViewModelBase await _windowService.ShowDialogAsync(layer); await ProfileEditorService.SaveProfileAsync(); } - + private void ExecuteApplyAdaptionHints() { if (ProfileElement is not Layer layer) return; - + ProfileEditorService.ExecuteCommand(new ApplyAdaptionHints(layer, _deviceService.EnabledDevices.ToList())); } private async void UpdateCanPaste(bool isFlyoutOpen) { - string[] formats = await Shared.UI.Clipboard.GetFormatsAsync(); - //diogotr7: This can be null on Linux sometimes. I'm not sure why. - if (formats == null!) - { - CanPaste = false; - return; - } - - CanPaste = formats.Contains(ProfileElementExtensions.ClipboardDataFormat); + string[]? formats = await Shared.UI.Clipboard.GetFormatsAsync(); + + // Can be null on some platforms + // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract + CanPaste = formats != null && formats.Contains(ProfileElementExtensions.ClipboardDataFormat); } private bool GetIsFocused(ProfileEditorFocusMode focusMode, RenderProfileElement? currentProfileElement) diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Keyframes/TimelineKeyframeViewModel.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Keyframes/TimelineKeyframeViewModel.cs index c568924bc..3c618d0b8 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Keyframes/TimelineKeyframeViewModel.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/Properties/Timeline/Keyframes/TimelineKeyframeViewModel.cs @@ -174,8 +174,11 @@ public partial class TimelineKeyframeViewModel : ActivatableViewModelBase, IT private async void UpdateCanPaste(bool isFlyoutOpen) { - string[] formats = await Shared.UI.Clipboard.GetFormatsAsync(); - CanPaste = formats.Contains("Artemis.Keyframes"); + string[]? formats = await Shared.UI.Clipboard.GetFormatsAsync(); + + // Can be null on some platforms + // ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract + CanPaste = formats != null && formats.Contains("Artemis.Keyframes"); } #endregion From f152812064899da9217759181bb72e6f3bb5203b Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 30 Mar 2024 20:28:01 +0100 Subject: [PATCH 3/4] Device properties - Show layout error state --- src/Artemis.Core/Models/Surface/LayoutSelection.cs | 10 ++++++++++ src/Artemis.Core/Services/DeviceService.cs | 5 +++-- .../Device/Tabs/Layout/DeviceLayoutTabView.axaml | 4 ++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Artemis.Core/Models/Surface/LayoutSelection.cs b/src/Artemis.Core/Models/Surface/LayoutSelection.cs index f64c54eb1..f88f2ac0c 100644 --- a/src/Artemis.Core/Models/Surface/LayoutSelection.cs +++ b/src/Artemis.Core/Models/Surface/LayoutSelection.cs @@ -7,6 +7,7 @@ public class LayoutSelection : CorePropertyChanged { private string? _type; private string? _parameter; + private string? _errorState; /// /// Gets or sets what kind of layout reference this is. @@ -25,4 +26,13 @@ public class LayoutSelection : CorePropertyChanged get => _parameter; set => SetAndNotify(ref _parameter, value); } + + /// + /// Gets or sets the error state of the layout reference. + /// + public string? ErrorState + { + get => _errorState; + set => SetAndNotify(ref _errorState, value); + } } \ No newline at end of file diff --git a/src/Artemis.Core/Services/DeviceService.cs b/src/Artemis.Core/Services/DeviceService.cs index da81a82a6..111594c4a 100644 --- a/src/Artemis.Core/Services/DeviceService.cs +++ b/src/Artemis.Core/Services/DeviceService.cs @@ -184,13 +184,14 @@ internal class DeviceService : IDeviceService device.ApplyLayout(null, false, false); else provider?.ApplyLayout(device, layout); + + UpdateLeds(); } catch (Exception e) { + device.LayoutSelection.ErrorState = e.Message; _logger.Error(e, "Failed to apply device layout"); } - - UpdateLeds(); } /// diff --git a/src/Artemis.UI/Screens/Device/Tabs/Layout/DeviceLayoutTabView.axaml b/src/Artemis.UI/Screens/Device/Tabs/Layout/DeviceLayoutTabView.axaml index 9dccbfef4..e741e286c 100644 --- a/src/Artemis.UI/Screens/Device/Tabs/Layout/DeviceLayoutTabView.axaml +++ b/src/Artemis.UI/Screens/Device/Tabs/Layout/DeviceLayoutTabView.axaml @@ -83,6 +83,10 @@ + From ff2e57aeaa21960192d7a8d9a5fa28fef244e784 Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 30 Mar 2024 20:40:24 +0100 Subject: [PATCH 4/4] Device properties - We can do a bit better with UX than that :P --- .../Tabs/Layout/DeviceLayoutTabView.axaml | 197 +++++++++--------- 1 file changed, 102 insertions(+), 95 deletions(-) diff --git a/src/Artemis.UI/Screens/Device/Tabs/Layout/DeviceLayoutTabView.axaml b/src/Artemis.UI/Screens/Device/Tabs/Layout/DeviceLayoutTabView.axaml index e741e286c..5b4ffc40f 100644 --- a/src/Artemis.UI/Screens/Device/Tabs/Layout/DeviceLayoutTabView.axaml +++ b/src/Artemis.UI/Screens/Device/Tabs/Layout/DeviceLayoutTabView.axaml @@ -9,104 +9,111 @@ mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="800" x:Class="Artemis.UI.Screens.Device.Layout.DeviceLayoutTabView" x:DataType="layout:DeviceLayoutTabViewModel"> - - - - - - - - - - - - - + + - - - - - - - - - - + + + + + + + + + + + + + - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - + + + + + + + - - + + + + + + + + + +