From 2a588375d2e27680fec7cf2f9e261e8cb6ec397d Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Fri, 12 May 2023 23:00:30 +0100 Subject: [PATCH 01/21] CI - fix docFX --- .github/workflows/docfx.yml | 4 ++-- docfx/docfx_project/docfx.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docfx.yml b/.github/workflows/docfx.yml index 044774480..1f83763b9 100644 --- a/.github/workflows/docfx.yml +++ b/.github/workflows/docfx.yml @@ -18,13 +18,13 @@ jobs: with: dotnet-version: "7.0.x" - name: Setup DocFX - run: choco install docfx -y + run: dotnet tool update -g docfx - name: Build Core run: dotnet build src/Artemis.Core/Artemis.Core.csproj - name: Build UI.Shared run: dotnet build src/Artemis.UI.Shared/Artemis.UI.Shared.csproj - name: Build DocFX - run: docfx.exe docfx/docfx_project/docfx.json + run: docfx docfx/docfx_project/docfx.json - name: Upload to FTP uses: SamKirkland/FTP-Deploy-Action@4.3.2 with: diff --git a/docfx/docfx_project/docfx.json b/docfx/docfx_project/docfx.json index 525c27ace..003caa407 100644 --- a/docfx/docfx_project/docfx.json +++ b/docfx/docfx_project/docfx.json @@ -5,7 +5,7 @@ { "files": [ "Artemis.Core/bin/net7.0/Artemis.Core.dll", - "Artemis.UI.Shared/bin/net7.0/Artemis.UI.Shared.dll", + "Artemis.UI.Shared/bin/net7.0/Artemis.UI.Shared.dll" ], "src": "../../src" } From f249f80d19548dd8c5b9d0defa00efb6b0eba96d Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 5 Jun 2023 23:39:57 +0200 Subject: [PATCH 02/21] Upgrade Avalonia to 11 rc1 --- src/Artemis.UI.Linux/Artemis.UI.Linux.csproj | 8 ++-- src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj | 8 ++-- .../Artemis.UI.Shared.csproj | 12 +++--- .../Controls/DraggableNumberBox.axaml.cs | 8 ++-- .../Controls/HotkeyBox.axaml.cs | 5 ++- src/Artemis.UI.Shared/ReactiveAppWindow.cs | 2 +- src/Artemis.UI.Shared/Utilities.cs | 19 +-------- .../Artemis.UI.Windows.csproj | 10 ++--- src/Artemis.UI/Artemis.UI.csproj | 18 ++++---- .../Behaviors/SimpleContextDragBehavior.cs | 6 ++- .../StringPropertyInputView.axaml.cs | 3 +- .../Panels/MenuBar/MenuBarView.axaml | 2 +- .../SurfaceEditor/SurfaceEditorView.axaml | 8 ++-- .../SurfaceEditor/SurfaceEditorView.axaml.cs | 3 +- .../Screens/VisualScripting/Pins/PinView.cs | 41 +++++-------------- .../Artemis.VisualScripting.csproj | 6 +-- 16 files changed, 64 insertions(+), 95 deletions(-) diff --git a/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj b/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj index 9607a10d8..21c5abd88 100644 --- a/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj +++ b/src/Artemis.UI.Linux/Artemis.UI.Linux.csproj @@ -16,11 +16,11 @@ - - + + - - + + diff --git a/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj b/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj index e674a2ad6..9e2fc0938 100644 --- a/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj +++ b/src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj @@ -15,11 +15,11 @@ - - + + - - + + diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj index 0c4439627..c0c66255d 100644 --- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj +++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj @@ -10,14 +10,14 @@ - + - - - + + + - - + + diff --git a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs index 1b3124421..fd3352add 100644 --- a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using Avalonia; using Avalonia.Controls; using Avalonia.Data; @@ -68,7 +69,7 @@ public partial class DraggableNumberBox : UserControl public DraggableNumberBox() { InitializeComponent(); - + PointerPressed += OnPointerPressed; PointerMoved += OnPointerMoved; PointerReleased += OnPointerReleased; @@ -186,8 +187,9 @@ public partial class DraggableNumberBox : UserControl private void HandleKeyUp(object? sender, KeyEventArgs e) { + IInputElement? toFocus = this.GetLogicalAncestors().OfType().LastOrDefault(); if (e.Key == Key.Enter || e.Key == Key.Escape) - FocusManager.Instance?.Focus(Parent as IInputElement); + toFocus?.Focus(); } private void OnPointerPressed(object? sender, PointerPressedEventArgs e) @@ -215,7 +217,7 @@ public partial class DraggableNumberBox : UserControl if (!_moved) { // Let our parent take focus, it would make more sense to take focus ourselves but that hides the collider - FocusManager.Instance?.Focus(Parent as IInputElement); + (Parent as IInputElement)?.Focus(); _moved = true; e.Pointer.Capture(this); DragStarted?.Invoke(this, EventArgs.Empty); diff --git a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs index 0448f9746..d5d02c63e 100644 --- a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs @@ -9,6 +9,7 @@ using Avalonia.Input; using Avalonia.Interactivity; using Avalonia.Markup.Xaml; using Avalonia.Threading; +using Avalonia.VisualTree; using DryIoc; using FluentAvalonia.Core; using Humanizer; @@ -78,7 +79,7 @@ public partial class HotkeyBox : UserControl private void InputServiceOnKeyboardKeyUp(object? sender, ArtemisKeyboardKeyEventArgs e) { if (e.Modifiers == KeyboardModifierKey.None) - Dispatcher.UIThread.Post(() => FocusManager.Instance?.Focus(null)); + Dispatcher.UIThread.Post(() => this.FindAncestorOfType()?.Focus()); } private void UpdateDisplayTextBox() @@ -96,7 +97,7 @@ public partial class HotkeyBox : UserControl private void Button_OnClick(object? sender, RoutedEventArgs e) { Hotkey = null; - FocusManager.Instance?.Focus(null); + this.FindAncestorOfType()?.Focus(); UpdateDisplayTextBox(); } diff --git a/src/Artemis.UI.Shared/ReactiveAppWindow.cs b/src/Artemis.UI.Shared/ReactiveAppWindow.cs index 58f4ad820..a751f4ee6 100644 --- a/src/Artemis.UI.Shared/ReactiveAppWindow.cs +++ b/src/Artemis.UI.Shared/ReactiveAppWindow.cs @@ -48,7 +48,7 @@ public class ReactiveAppWindow : AppWindow, IViewFor whe return; TransparencyBackgroundFallback = Brushes.Transparent; - TransparencyLevelHint = WindowTransparencyLevel.Mica; + TransparencyLevelHint = new[] {WindowTransparencyLevel.Mica}; TryEnableMicaEffect(); } diff --git a/src/Artemis.UI.Shared/Utilities.cs b/src/Artemis.UI.Shared/Utilities.cs index cb2d58992..367e6b05c 100644 --- a/src/Artemis.UI.Shared/Utilities.cs +++ b/src/Artemis.UI.Shared/Utilities.cs @@ -1,7 +1,5 @@ using System; -using System.ComponentModel; using System.Reactive.Linq; -using System.Reactive.Subjects; using Avalonia.Controls; using Avalonia.Input; using Avalonia.Input.Platform; @@ -14,12 +12,9 @@ namespace Artemis.UI.Shared; /// public static class UI { - private static readonly BehaviorSubject KeyBindingsEnabledSubject = new(false); - static UI() { - if (KeyboardDevice.Instance != null) - KeyboardDevice.Instance.PropertyChanged += InstanceOnPropertyChanged; + KeyBindingsEnabled = InputElement.GotFocusEvent.Raised.Select(e => e.Item2.Source is not TextBox); } /// @@ -35,15 +30,5 @@ public static class UI /// /// Gets a boolean indicating whether hotkeys are to be disabled. /// - public static IObservable KeyBindingsEnabled { get; } = KeyBindingsEnabledSubject.AsObservable(); - - private static void InstanceOnPropertyChanged(object? sender, PropertyChangedEventArgs e) - { - if (KeyboardDevice.Instance == null || e.PropertyName != nameof(KeyboardDevice.FocusedElement)) - return; - - bool enabled = KeyboardDevice.Instance.FocusedElement is not TextBox; - if (KeyBindingsEnabledSubject.Value != enabled) - KeyBindingsEnabledSubject.OnNext(enabled); - } + public static IObservable KeyBindingsEnabled { get; } } \ No newline at end of file diff --git a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj index bdea0536c..3910a5e65 100644 --- a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj +++ b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj @@ -21,12 +21,12 @@ - - + + - - - + + + diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index ce2eaaf18..47da417f7 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -15,20 +15,20 @@ - - - + + + - - - + + + - + - - + + diff --git a/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs b/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs index bd3845bfa..b23346427 100644 --- a/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs +++ b/src/Artemis.UI/Behaviors/SimpleContextDragBehavior.cs @@ -103,8 +103,9 @@ public class SimpleContextDragBehavior : Behavior private void AssociatedObject_PointerPressed(object? sender, PointerPressedEventArgs e) { + IFocusManager? focusManager = TopLevel.GetTopLevel(AssociatedObject)?.FocusManager; PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties; - if (!properties.IsLeftButtonPressed || FocusManager.Instance?.Current is TextBox) + if (!properties.IsLeftButtonPressed || focusManager?.GetFocusedElement() is TextBox) return; if (e.Source is not Control control || AssociatedObject?.DataContext != control.DataContext) return; @@ -130,8 +131,9 @@ public class SimpleContextDragBehavior : Behavior private async void AssociatedObject_PointerMoved(object? sender, PointerEventArgs e) { + IFocusManager? focusManager = TopLevel.GetTopLevel(AssociatedObject)?.FocusManager; PointerPointProperties properties = e.GetCurrentPoint(AssociatedObject).Properties; - if (!properties.IsLeftButtonPressed || FocusManager.Instance?.Current is TextBox) + if (!properties.IsLeftButtonPressed || focusManager?.GetFocusedElement() is TextBox) return; if (_triggerEvent is null) diff --git a/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs b/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs index 1ef4838a8..9063787d5 100644 --- a/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs +++ b/src/Artemis.UI/DefaultTypes/PropertyInput/StringPropertyInputView.axaml.cs @@ -1,5 +1,4 @@ using Avalonia.Input; -using Avalonia.Markup.Xaml; using Avalonia.ReactiveUI; namespace Artemis.UI.DefaultTypes.PropertyInput; @@ -16,6 +15,6 @@ public partial class StringPropertyInputView : ReactiveUserControl - + diff --git a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml index f3914a73f..ade53ea24 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml +++ b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml @@ -110,14 +110,14 @@ - diff --git a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml.cs b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml.cs index 833a56e20..797cad4d5 100644 --- a/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml.cs +++ b/src/Artemis.UI/Screens/SurfaceEditor/SurfaceEditorView.axaml.cs @@ -5,7 +5,6 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.PanAndZoom; using Avalonia.Input; -using Avalonia.Markup.Xaml; using Avalonia.Media; using Avalonia.ReactiveUI; @@ -30,7 +29,7 @@ public partial class SurfaceEditorView : ReactiveUserControl { - private Canvas? _container; + private readonly DispatcherTimer _updateTimer; private bool _dragging; + private Canvas? _container; private Border? _pinPoint; - private PinViewRenderLoopTaks _renderLoopTask; + + public PinView() + { + _updateTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(16), DispatcherPriority.Render, UpdatePosition); + } protected void InitializePin(Border pinPoint) { @@ -21,7 +26,6 @@ public class PinView : ReactiveUserControl _pinPoint.PointerMoved += PinPointOnPointerMoved; _pinPoint.PointerReleased += PinPointOnPointerReleased; _pinPoint.PropertyChanged += PinPointOnPropertyChanged; - _renderLoopTask = new PinViewRenderLoopTaks(this); } private void PinPointOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) @@ -74,19 +78,17 @@ public class PinView : ReactiveUserControl /// protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e) { - base.OnAttachedToVisualTree(e); _container = this.FindAncestorOfType(); - AvaloniaLocator.Current.GetRequiredService().Add(_renderLoopTask); + _updateTimer.Start(); } /// protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e) { - base.OnDetachedFromVisualTree(e); - AvaloniaLocator.Current.GetRequiredService().Remove(_renderLoopTask); + _updateTimer.Stop(); } - public void UpdatePosition() + public void UpdatePosition(object? sender, EventArgs eventArgs) { if (_container == null || _pinPoint == null || ViewModel == null) return; @@ -97,25 +99,4 @@ public class PinView : ReactiveUserControl } #endregion -} - -public class PinViewRenderLoopTaks : IRenderLoopTask -{ - private readonly PinView _pinView; - - public PinViewRenderLoopTaks(PinView pinView) - { - _pinView = pinView; - } - - public void Update(TimeSpan time) - { - _pinView.UpdatePosition(); - } - - public void Render() - { - } - - public bool NeedsUpdate => true; } \ No newline at end of file diff --git a/src/Artemis.VisualScripting/Artemis.VisualScripting.csproj b/src/Artemis.VisualScripting/Artemis.VisualScripting.csproj index 2a69a2d53..c0e7a1bec 100644 --- a/src/Artemis.VisualScripting/Artemis.VisualScripting.csproj +++ b/src/Artemis.VisualScripting/Artemis.VisualScripting.csproj @@ -8,9 +8,9 @@ - - - + + + From 06e6075c4d269942f5a878657abc6412c55d3d47 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 6 Jun 2023 12:00:05 +0100 Subject: [PATCH 03/21] DeviceVisualizer - reduce allocations --- .../Controls/DeviceVisualizer.cs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index eca232ba4..c4d298f9f 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -120,23 +120,26 @@ public class DeviceVisualizer : Control if (Device == null) return false; - Color[] state = new Color[Device.RgbDevice.Count()]; - bool difference = _previousState.Length != state.Length; + bool difference = false; + + int newLedCount = Device.RgbDevice.Count(); + if (_previousState.Length != newLedCount) + { + _previousState = new Color[newLedCount]; + difference = true; + } // Check all LEDs for differences and copy the colors to a new state int index = 0; foreach (Led led in Device.RgbDevice) { - if (!difference && !led.Color.Equals(_previousState[index])) + if (_previousState[index] != led.Color) difference = true; - state[index] = led.Color; + _previousState[index] = led.Color; index++; } - // Store the new state for next time - _previousState = state; - return difference; } From 567ca193a487ef191c820bb53253d51c4703ce1d Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 6 Jun 2023 12:00:48 +0100 Subject: [PATCH 04/21] DeviceVisualizer - don't check dirty unless necessary --- src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index c4d298f9f..2521be969 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -162,7 +162,7 @@ public class DeviceVisualizer : Control private void TimerOnTick(object? sender, EventArgs e) { - if (IsDirty() && ShowColors && IsVisible && Opacity > 0) + if (ShowColors && IsVisible && Opacity > 0 && IsDirty()) Update(); } From 88322baafd22ac1317c815e5e073fd7bb89a04e8 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Tue, 6 Jun 2023 12:17:31 +0100 Subject: [PATCH 05/21] DeviceVisualizer - Tied update to core update instead of hardcoded 25fps --- .../Controls/DeviceVisualizer.cs | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index 2521be969..80c72b0a5 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -1,9 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.IO; using System.Linq; using Artemis.Core; +using Artemis.Core.Services; using Artemis.UI.Shared.Events; using Avalonia; using Avalonia.Controls; @@ -13,6 +14,7 @@ using Avalonia.Media; using Avalonia.Media.Imaging; using Avalonia.Threading; using RGB.NET.Core; +using DryIoc; using Color = RGB.NET.Core.Color; using Point = Avalonia.Point; using Size = Avalonia.Size; @@ -24,20 +26,19 @@ namespace Artemis.UI.Shared; /// public class DeviceVisualizer : Control { - private const double UPDATE_FRAME_RATE = 25.0; + private readonly ICoreService _coreService; private readonly List _deviceVisualizerLeds; - private readonly DispatcherTimer _timer; private Rect _deviceBounds; private RenderTargetBitmap? _deviceImage; private ArtemisDevice? _oldDevice; private bool _loading; private Color[] _previousState = Array.Empty(); - + /// public DeviceVisualizer() { - _timer = new DispatcherTimer(DispatcherPriority.Background) {Interval = TimeSpan.FromMilliseconds(1000.0 / UPDATE_FRAME_RATE)}; + _coreService = UI.Locator.Resolve(); _deviceVisualizerLeds = new List(); PointerReleased += OnPointerReleased; @@ -159,11 +160,14 @@ public class DeviceVisualizer : Control return geometry.Bounds; } - - private void TimerOnTick(object? sender, EventArgs e) + + private void OnFrameRendered(object? sender, FrameRenderedEventArgs e) { - if (ShowColors && IsVisible && Opacity > 0 && IsDirty()) - Update(); + Dispatcher.UIThread.Post(() => + { + if (ShowColors && IsVisible && Opacity > 0 && IsDirty()) + Update(); + }, DispatcherPriority.Background); } private void OnPointerReleased(object? sender, PointerReleasedEventArgs e) @@ -253,16 +257,16 @@ public class DeviceVisualizer : Control /// protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e) { - _timer.Start(); - _timer.Tick += TimerOnTick; + _coreService.FrameRendered += OnFrameRendered; + base.OnAttachedToLogicalTree(e); } /// protected override void OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs e) { - _timer.Stop(); - _timer.Tick -= TimerOnTick; + _coreService.FrameRendered -= OnFrameRendered; + base.OnDetachedFromLogicalTree(e); } From aa4a740b78589eee53c47f1e0f5da00228bb743f Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 6 Jun 2023 19:19:43 +0200 Subject: [PATCH 06/21] DraggableNumberBox - Focus fixes --- .../Controls/DraggableNumberBox.axaml | 12 +++++++----- .../Controls/DraggableNumberBox.axaml.cs | 8 ++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml index 0c571239e..5802bd188 100644 --- a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml +++ b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml @@ -6,25 +6,27 @@ xmlns:sharedControls="clr-namespace:Artemis.UI.Shared.Controls" xmlns:attachedProperties="clr-namespace:Artemis.UI.Shared.AttachedProperties" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="Artemis.UI.Shared.Controls.DraggableNumberBox"> + x:Class="Artemis.UI.Shared.Controls.DraggableNumberBox" + Focusable="True"> - - - - + ().LastOrDefault(); if (e.Key == Key.Enter || e.Key == Key.Escape) - toFocus?.Focus(); + Focus(); } private void OnPointerPressed(object? sender, PointerPressedEventArgs e) @@ -217,9 +216,9 @@ public partial class DraggableNumberBox : UserControl if (!_moved) { // Let our parent take focus, it would make more sense to take focus ourselves but that hides the collider - (Parent as IInputElement)?.Focus(); + PseudoClasses.Add("dragging"); + Focus(); _moved = true; - e.Pointer.Capture(this); DragStarted?.Invoke(this, EventArgs.Empty); } @@ -254,6 +253,7 @@ public partial class DraggableNumberBox : UserControl else { _moved = false; + PseudoClasses.Remove("dragging"); DragFinished?.Invoke(this, EventArgs.Empty); } From 34824dde42f743d4fa022bacb2a74d7e175b7ec9 Mon Sep 17 00:00:00 2001 From: Robert Date: Tue, 6 Jun 2023 20:17:30 +0200 Subject: [PATCH 07/21] HotkeyBox - Focus fixes --- .../Controls/HotkeyBox.axaml.cs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs index d5d02c63e..1697977a8 100644 --- a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs @@ -41,7 +41,7 @@ public partial class HotkeyBox : UserControl { _inputService.KeyboardKeyDown += InputServiceOnKeyboardKeyDown; _inputService.KeyboardKeyUp += InputServiceOnKeyboardKeyUp; - + base.OnGotFocus(e); } @@ -50,10 +50,10 @@ public partial class HotkeyBox : UserControl { _inputService.KeyboardKeyDown -= InputServiceOnKeyboardKeyDown; _inputService.KeyboardKeyUp -= InputServiceOnKeyboardKeyUp; - + base.OnLostFocus(e); } - + private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) { if (e.Property == HotkeyProperty) @@ -68,7 +68,7 @@ public partial class HotkeyBox : UserControl Hotkey ??= new Hotkey(); Hotkey.Key = e.Key; Hotkey.Modifiers = e.Modifiers; - + Dispatcher.UIThread.Post(() => { UpdateDisplayTextBox(); @@ -79,7 +79,19 @@ public partial class HotkeyBox : UserControl private void InputServiceOnKeyboardKeyUp(object? sender, ArtemisKeyboardKeyEventArgs e) { if (e.Modifiers == KeyboardModifierKey.None) - Dispatcher.UIThread.Post(() => this.FindAncestorOfType()?.Focus()); + Dispatcher.UIThread.Post(ClearFocus); + } + + private void ClearFocus() + { + InputElement? element = this.FindAncestorOfType(); + if (element == null) + return; + + bool wasFocusable = element.Focusable; + element.Focusable = true; + element.Focus(); + element.Focusable = wasFocusable; } private void UpdateDisplayTextBox() @@ -97,7 +109,7 @@ public partial class HotkeyBox : UserControl private void Button_OnClick(object? sender, RoutedEventArgs e) { Hotkey = null; - this.FindAncestorOfType()?.Focus(); + ClearFocus(); UpdateDisplayTextBox(); } From 2e9b3d59d67394ae12b9267509d81b1396cbd96e Mon Sep 17 00:00:00 2001 From: Robert Date: Sat, 10 Jun 2023 13:23:38 +0200 Subject: [PATCH 08/21] Added workaround for invalidation issue in pan/zoom elements --- src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs | 2 +- .../Panels/VisualEditor/VisualEditorView.axaml.cs | 5 +++++ .../Screens/SurfaceEditor/SurfaceEditorView.axaml.cs | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs index 34a3af852..cb85a0bc6 100644 --- a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml.cs @@ -187,7 +187,7 @@ public partial class DraggableNumberBox : UserControl private void HandleKeyUp(object? sender, KeyEventArgs e) { - if (e.Key == Key.Enter || e.Key == Key.Escape) + if (e.Key is Key.Enter or Key.Escape) Focus(); } diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml.cs b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml.cs index 3fb88d5c5..87e7b3b2e 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml.cs +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml.cs @@ -63,7 +63,12 @@ public partial class VisualEditorView : ReactiveUserControl Date: Sun, 11 Jun 2023 09:43:05 +0200 Subject: [PATCH 09/21] Removed old Console.WriteLine --- src/Artemis.UI/Screens/VisualScripting/Pins/PinView.cs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Artemis.UI/Screens/VisualScripting/Pins/PinView.cs b/src/Artemis.UI/Screens/VisualScripting/Pins/PinView.cs index bd40c28ba..391941487 100644 --- a/src/Artemis.UI/Screens/VisualScripting/Pins/PinView.cs +++ b/src/Artemis.UI/Screens/VisualScripting/Pins/PinView.cs @@ -25,14 +25,8 @@ public class PinView : ReactiveUserControl _pinPoint = pinPoint; _pinPoint.PointerMoved += PinPointOnPointerMoved; _pinPoint.PointerReleased += PinPointOnPointerReleased; - _pinPoint.PropertyChanged += PinPointOnPropertyChanged; } - - private void PinPointOnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) - { - Console.WriteLine(e); - } - + private void PinPointOnPointerMoved(object? sender, PointerEventArgs e) { if (ViewModel == null || _container == null || _pinPoint == null) From b6762d074ad0ad9e7de3503b10dec8956e850887 Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 11 Jun 2023 18:03:18 +0200 Subject: [PATCH 10/21] Start with enabled keybinds --- src/Artemis.UI.Shared/Utilities.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Artemis.UI.Shared/Utilities.cs b/src/Artemis.UI.Shared/Utilities.cs index 367e6b05c..832e07b75 100644 --- a/src/Artemis.UI.Shared/Utilities.cs +++ b/src/Artemis.UI.Shared/Utilities.cs @@ -14,7 +14,7 @@ public static class UI { static UI() { - KeyBindingsEnabled = InputElement.GotFocusEvent.Raised.Select(e => e.Item2.Source is not TextBox); + KeyBindingsEnabled = InputElement.GotFocusEvent.Raised.Select(e => e.Item2.Source is not TextBox).StartWith(true); } /// From 61e4886869d4de07c0dd222eaee97513d5252c2d Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 11 Jun 2023 22:49:49 +0200 Subject: [PATCH 11/21] Bump RGB.NET to 2.0.0-prerelease.78 --- src/Artemis.Core/Artemis.Core.csproj | 6 +++--- src/Artemis.UI.Shared/Artemis.UI.Shared.csproj | 2 +- src/Artemis.UI/Artemis.UI.csproj | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj index ed6e16421..a36fa3fac 100644 --- a/src/Artemis.Core/Artemis.Core.csproj +++ b/src/Artemis.Core/Artemis.Core.csproj @@ -43,9 +43,9 @@ - - - + + + diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj index c0c66255d..36817bd6b 100644 --- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj +++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index 47da417f7..8a469b41c 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -32,8 +32,8 @@ - - + + From a903771be3cd63509ac374144d20bd04a87c4b28 Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 12 Jun 2023 20:03:37 +0200 Subject: [PATCH 12/21] Bump RGB.NET to 2.0.0-prerelease.83 --- src/Artemis.Core/Artemis.Core.csproj | 6 +++--- src/Artemis.UI.Shared/Artemis.UI.Shared.csproj | 2 +- src/Artemis.UI/Artemis.UI.csproj | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj index a36fa3fac..33d2a5382 100644 --- a/src/Artemis.Core/Artemis.Core.csproj +++ b/src/Artemis.Core/Artemis.Core.csproj @@ -43,9 +43,9 @@ - - - + + + diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj index 36817bd6b..3b69f3087 100644 --- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj +++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj @@ -20,7 +20,7 @@ - + diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index 8a469b41c..d57184629 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -32,8 +32,8 @@ - - + + From ff55bf0d2659cb1520929b063f77a5234eaba991 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:10:22 +0000 Subject: [PATCH 13/21] Bump Microsoft.Windows.Compatibility in /src/Artemis.UI.Windows Bumps [Microsoft.Windows.Compatibility](https://github.com/dotnet/runtime) from 7.0.0 to 7.0.3. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v7.0.0...v7.0.3) --- updated-dependencies: - dependency-name: Microsoft.Windows.Compatibility dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- src/Artemis.UI.Windows/Artemis.UI.Windows.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj index 3910a5e65..0110ec37e 100644 --- a/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj +++ b/src/Artemis.UI.Windows/Artemis.UI.Windows.csproj @@ -1,4 +1,4 @@ - + WinExe net7.0-windows10.0.17763.0 @@ -29,7 +29,7 @@ - + From 0122ab00d9aac0482f977de0d019924ba36c4b85 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Mon, 5 Jun 2023 14:26:46 +0100 Subject: [PATCH 14/21] Added more Border styles --- src/Artemis.UI.Shared/Styles/Border.axaml | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/Artemis.UI.Shared/Styles/Border.axaml b/src/Artemis.UI.Shared/Styles/Border.axaml index afcd9dee8..d753809a0 100644 --- a/src/Artemis.UI.Shared/Styles/Border.axaml +++ b/src/Artemis.UI.Shared/Styles/Border.axaml @@ -10,6 +10,15 @@ I'm in a panel yo! I'm in a panel yo! + + I'm in a panel yo! + + + + + I'm in a panel yo! + + I'm in a panel yo! @@ -50,4 +59,23 @@ + + + + + + \ No newline at end of file From cdfa14441ed2ccbe12a52de75fcb850efcaf5697 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Mon, 5 Jun 2023 14:26:53 +0100 Subject: [PATCH 15/21] Clean up csproj --- src/Artemis.UI/Artemis.UI.csproj | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj index d57184629..fa8d34923 100644 --- a/src/Artemis.UI/Artemis.UI.csproj +++ b/src/Artemis.UI/Artemis.UI.csproj @@ -41,27 +41,4 @@ - - - - UpdatingTabView.axaml - Code - - - UpdatingTabView.axaml - Code - - - PluginFeatureView.axaml - Code - - - PluginPrerequisiteActionView.axaml - Code - - - PluginPrerequisiteView.axaml - Code - - \ No newline at end of file From db069ea8bf9580f13ced32dc2bd7767903f4e728 Mon Sep 17 00:00:00 2001 From: Diogo Trindade Date: Mon, 5 Jun 2023 18:48:07 +0100 Subject: [PATCH 16/21] Reworked device properties screen --- src/Artemis.UI/DryIoc/Factories/IVMFactory.cs | 15 +- .../Screens/Device/DevicePropertiesView.axaml | 6 +- .../Device/DevicePropertiesViewModel.cs | 6 +- .../Device/Tabs/DeviceGeneralTabView.axaml | 371 ++++++++++++++++++ .../Device/Tabs/DeviceGeneralTabView.axaml.cs | 11 + .../Device/Tabs/DeviceGeneralTabViewModel.cs | 256 ++++++++++++ .../Device/Tabs/DeviceLayoutTabView.axaml | 82 ++++ .../Device/Tabs/DeviceLayoutTabView.axaml.cs | 26 ++ .../Device/Tabs/DeviceLayoutTabViewModel.cs | 143 +++++++ 9 files changed, 910 insertions(+), 6 deletions(-) create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml.cs create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabViewModel.cs create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabView.axaml create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabView.axaml.cs create mode 100644 src/Artemis.UI/Screens/Device/Tabs/DeviceLayoutTabViewModel.cs diff --git a/src/Artemis.UI/DryIoc/Factories/IVMFactory.cs b/src/Artemis.UI/DryIoc/Factories/IVMFactory.cs index d410e3cfc..8d94699dd 100644 --- a/src/Artemis.UI/DryIoc/Factories/IVMFactory.cs +++ b/src/Artemis.UI/DryIoc/Factories/IVMFactory.cs @@ -25,6 +25,7 @@ using Artemis.UI.Screens.Sidebar; using Artemis.UI.Screens.SurfaceEditor; using Artemis.UI.Screens.VisualScripting; using Artemis.UI.Screens.VisualScripting.Pins; +using Artemis.UI.Shared; using DryIoc; using ReactiveUI; @@ -40,9 +41,11 @@ public interface IDeviceVmFactory : IVmFactory DeviceSettingsViewModel DeviceSettingsViewModel(ArtemisDevice device, DevicesTabViewModel devicesTabViewModel); DeviceDetectInputViewModel DeviceDetectInputViewModel(ArtemisDevice device); DevicePropertiesTabViewModel DevicePropertiesTabViewModel(ArtemisDevice device); + DeviceLayoutTabViewModel DeviceLayoutTabViewModel(ArtemisDevice device); DeviceInfoTabViewModel DeviceInfoTabViewModel(ArtemisDevice device); DeviceLedsTabViewModel DeviceLedsTabViewModel(ArtemisDevice device, ObservableCollection selectedLeds); InputMappingsTabViewModel InputMappingsTabViewModel(ArtemisDevice device, ObservableCollection selectedLeds); + DeviceGeneralTabViewModel DeviceGeneralTabViewModel(ArtemisDevice device); } public class DeviceFactory : IDeviceVmFactory { @@ -72,7 +75,12 @@ public class DeviceFactory : IDeviceVmFactory { return _container.Resolve(new object[] { device }); } - + + public DeviceLayoutTabViewModel DeviceLayoutTabViewModel(ArtemisDevice device) + { + return _container.Resolve(new object[] { device }); + } + public DeviceInfoTabViewModel DeviceInfoTabViewModel(ArtemisDevice device) { return _container.Resolve(new object[] { device }); @@ -87,6 +95,11 @@ public class DeviceFactory : IDeviceVmFactory { return _container.Resolve(new object[] { device, selectedLeds }); } + + public DeviceGeneralTabViewModel DeviceGeneralTabViewModel(ArtemisDevice device) + { + return _container.Resolve(new object[] { device }); + } } public interface ISettingsVmFactory : IVmFactory diff --git a/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml b/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml index 22b63510e..9b78bb060 100644 --- a/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml +++ b/src/Artemis.UI/Screens/Device/DevicePropertiesView.axaml @@ -11,8 +11,8 @@ Icon="/Assets/Images/Logo/application.ico" Title="Artemis | Device Properties" WindowStartupLocation="CenterOwner" - Width="1250" - Height="900"> + Width="1400" + Height="800"> @@ -52,7 +52,7 @@ - + diff --git a/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs b/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs index 87ee3ae20..395a718f8 100644 --- a/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs +++ b/src/Artemis.UI/Screens/Device/DevicePropertiesViewModel.cs @@ -64,8 +64,10 @@ public class DevicePropertiesViewModel : DialogViewModelBase private void AddTabs() { - Tabs.Add(_deviceVmFactory.DevicePropertiesTabViewModel(Device)); - Tabs.Add(_deviceVmFactory.DeviceInfoTabViewModel(Device)); + Tabs.Add(_deviceVmFactory.DeviceGeneralTabViewModel(Device)); + Tabs.Add(_deviceVmFactory.DeviceLayoutTabViewModel(Device)); + //Tabs.Add(_deviceVmFactory.DevicePropertiesTabViewModel(Device)); + //Tabs.Add(_deviceVmFactory.DeviceInfoTabViewModel(Device)); if (Device.DeviceType == RGBDeviceType.Keyboard) Tabs.Add(_deviceVmFactory.InputMappingsTabViewModel(Device, SelectedLeds)); Tabs.Add(_deviceVmFactory.DeviceLedsTabViewModel(Device, SelectedLeds)); diff --git a/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml b/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml new file mode 100644 index 000000000..a62df0f73 --- /dev/null +++ b/src/Artemis.UI/Screens/Device/Tabs/DeviceGeneralTabView.axaml @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + X-coordinate + + mm + + Y-coordinate + + mm + + Scale + + times + + Rotation + + deg + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +