diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index f7378dab7..36d37e0d3 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -58,7 +58,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v2 with: - dotnet-version: '6.0.x' + dotnet-version: '7.0.x' - name: Publish Artemis run: dotnet publish --configuration Release -p:Version=${{ needs.version.outputs.version-number }} --runtime ${{ matrix.rid }} --output build/${{ matrix.rid }} --self-contained Artemis/src/Artemis.UI.${{ matrix.csproj }}/Artemis.UI.${{ matrix.csproj }}.csproj - name: Publish Plugins diff --git a/src/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs b/src/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs index 3a0f2eab1..e403d0c93 100644 --- a/src/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs @@ -28,6 +28,7 @@ public partial class ArtemisIcon : UserControl InitializeComponent(); DetachedFromLogicalTree += OnDetachedFromLogicalTree; LayoutUpdated += OnLayoutUpdated; + PropertyChanged += OnPropertyChanged; } private void Update() @@ -86,6 +87,12 @@ public partial class ArtemisIcon : UserControl contentControl.Height = Bounds.Height; } } + + private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) + { + if (e.Property == IconProperty || e.Property == FillProperty) + Update(); + } private void OnDetachedFromLogicalTree(object? sender, LogicalTreeAttachmentEventArgs e) { @@ -109,11 +116,7 @@ public partial class ArtemisIcon : UserControl public object? Icon { get => GetValue(IconProperty); - set - { - SetValue(IconProperty, value); - Update(); - } + set => SetValue(IconProperty, value); } /// @@ -129,11 +132,7 @@ public partial class ArtemisIcon : UserControl public bool Fill { get => GetValue(FillProperty); - set - { - SetValue(FillProperty, value); - Update(); - } + set => SetValue(FillProperty, value); } #endregion diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs index b995da975..eeea0fab8 100644 --- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs +++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs @@ -38,12 +38,14 @@ public class DeviceVisualizer : Control _deviceVisualizerLeds = new List(); PointerReleased += OnPointerReleased; + PropertyChanged += OnPropertyChanged; } + /// public override void Render(DrawingContext drawingContext) { - if (Device == null) + if (Device == null || _deviceBounds.Width == 0 || _deviceBounds.Height == 0) return; // Determine the scale required to fit the desired size of the control @@ -54,11 +56,11 @@ public class DeviceVisualizer : Control { // Scale the visualization in the desired bounding box if (Bounds.Width > 0 && Bounds.Height > 0) - boundsPush = drawingContext.PushPreTransform(Matrix.CreateScale(scale, scale)); + boundsPush = drawingContext.PushTransform(Matrix.CreateScale(scale, scale)); // Apply device rotation - using DrawingContext.PushedState translationPush = drawingContext.PushPreTransform(Matrix.CreateTranslation(0 - _deviceBounds.Left, 0 - _deviceBounds.Top)); - using DrawingContext.PushedState rotationPush = drawingContext.PushPreTransform(Matrix.CreateRotation(Matrix.ToRadians(Device.Rotation))); + using DrawingContext.PushedState translationPush = drawingContext.PushTransform(Matrix.CreateTranslation(0 - _deviceBounds.Left, 0 - _deviceBounds.Top)); + using DrawingContext.PushedState rotationPush = drawingContext.PushTransform(Matrix.CreateRotation(Matrix.ToRadians(Device.Rotation))); // Render device and LED images if (_deviceImage != null) @@ -75,7 +77,7 @@ public class DeviceVisualizer : Control lock (_deviceVisualizerLeds) { // Apply device scale - using DrawingContext.PushedState scalePush = drawingContext.PushPreTransform(Matrix.CreateScale(Device.Scale, Device.Scale)); + using DrawingContext.PushedState scalePush = drawingContext.PushTransform(Matrix.CreateScale(Device.Scale, Device.Scale)); foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds) deviceVisualizerLed.RenderGeometry(drawingContext, false); } @@ -152,6 +154,12 @@ public class DeviceVisualizer : Control OnClicked(e); } + private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) + { + if (e.Property == DeviceProperty) + SetupForDevice(); + } + private void DevicePropertyChanged(object? sender, PropertyChangedEventArgs e) { Dispatcher.UIThread.Post(SetupForDevice, DispatcherPriority.Background); @@ -169,18 +177,14 @@ public class DeviceVisualizer : Control /// public static readonly StyledProperty DeviceProperty = AvaloniaProperty.Register(nameof(Device)); - + /// /// Gets or sets the to display /// public ArtemisDevice? Device { get => GetValue(DeviceProperty); - set - { - SetValue(DeviceProperty, value); - SetupForDevice(); - } + set => SetValue(DeviceProperty, value); } /// diff --git a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml index d480b0c51..3edd26150 100644 --- a/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml +++ b/src/Artemis.UI.Shared/Controls/DraggableNumberBox.axaml @@ -23,7 +23,7 @@ - GetValue(ValueProperty); - set - { - SetValue(ValueProperty, value); - SetNumberBoxValue(value); - } + set => SetValue(ValueProperty, value); } /// @@ -165,11 +162,11 @@ public partial class DraggableNumberBox : UserControl private void SetNumberBoxValue(double value) { - if (!(Math.Abs(NumberBox.Value - Value) > 0.00001)) + if (!(Math.Abs(InnerNumberBox.Value - Value) > 0.00001)) return; _updating = true; - NumberBox.Value = Value; + InnerNumberBox.Value = Value; _updating = false; } @@ -182,7 +179,7 @@ public partial class DraggableNumberBox : UserControl private void OnPointerPressed(object? sender, PointerPressedEventArgs e) { PointerPoint point = e.GetCurrentPoint(this); - _inputTextBox = NumberBox.FindDescendantOfType(); + _inputTextBox = InnerNumberBox.FindDescendantOfType(); _moved = false; _startX = point.Position.X; _lastX = point.Position.X; @@ -246,6 +243,12 @@ public partial class DraggableNumberBox : UserControl e.Handled = true; } + + private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) + { + if (e.Property == ValueProperty) + SetNumberBoxValue(Value); + } private void NumberBox_OnValueChanged(NumberBox sender, NumberBoxValueChangedEventArgs args) { @@ -254,17 +257,17 @@ public partial class DraggableNumberBox : UserControl if (args.NewValue < Minimum) { - NumberBox.Value = Minimum; + InnerNumberBox.Value = Minimum; return; } if (args.NewValue > Maximum) { - NumberBox.Value = Maximum; + InnerNumberBox.Value = Maximum; return; } - if (Math.Abs(Value - NumberBox.Value) > 0.00001) - Value = NumberBox.Value; + if (Math.Abs(Value - InnerNumberBox.Value) > 0.00001) + Value = InnerNumberBox.Value; } } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs b/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs index 93c669e24..ff2869519 100644 --- a/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs @@ -30,21 +30,26 @@ public partial class EnumComboBox : UserControl /// public EnumComboBox() { + PropertyChanged += OnPropertyChanged; InitializeComponent(); } + private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) + { + if (e.Property == ValueProperty) + { + UpdateValues(); + UpdateSelection(); + } + } + /// /// Gets or sets the currently selected value /// public object? Value { get => GetValue(ValueProperty); - set - { - SetValue(ValueProperty, value); - UpdateValues(); - UpdateSelection(); - } + set => SetValue(ValueProperty, value); } private void OnSelectionChanged(object? sender, SelectionChangedEventArgs e) diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs index 7edb8e13b..11215c7f0 100644 --- a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs +++ b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPicker.cs @@ -94,6 +94,8 @@ public class GradientPicker : TemplatedControl SelectedColorStop = EditingColorGradient.ElementAtOrDefault(index); }); + + PropertyChanged += OnPropertyChanged; } /// @@ -102,11 +104,7 @@ public class GradientPicker : TemplatedControl public ColorGradient ColorGradient { get => GetValue(ColorGradientProperty); - set - { - SetValue(ColorGradientProperty, value); - ApplyToField(); - } + set => SetValue(ColorGradientProperty, value); } /// @@ -342,4 +340,10 @@ public class GradientPicker : TemplatedControl EditingColorGradient.Randomize(6); SelectedColorStop = EditingColorGradient.First(); } + + private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) + { + if (e.Property == ColorGradientProperty) + ApplyToField(); + } } \ No newline at end of file diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerButton.cs b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerButton.cs index 4938f59ec..407f7ed11 100644 --- a/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerButton.cs +++ b/src/Artemis.UI.Shared/Controls/GradientPicker/GradientPickerButton.cs @@ -47,17 +47,19 @@ public class GradientPickerButton : TemplatedControl private Button? _button; private ColorGradient? _lastColorGradient; + /// + public GradientPickerButton() + { + PropertyChanged += OnPropertyChanged; + } + /// /// Gets or sets the color gradient. /// public ColorGradient? ColorGradient { get => GetValue(ColorGradientProperty); - set - { - SetValue(ColorGradientProperty, value); - Subscribe(); - } + set => SetValue(ColorGradientProperty, value); } /// @@ -175,6 +177,12 @@ public class GradientPickerButton : TemplatedControl LinearGradientBrush.GradientStops = collection; } + private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) + { + if (e.Property == ColorGradientProperty) + Subscribe(); + } + #region Overrides of Visual /// diff --git a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs index 45480fcc3..d87e02d70 100644 --- a/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs +++ b/src/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs @@ -19,21 +19,24 @@ namespace Artemis.UI.Shared; /// public partial class HotkeyBox : UserControl { - private readonly TextBox _displayTextBox; - /// /// Creates a new instance of the class /// public HotkeyBox() { InitializeComponent(); - - _displayTextBox = this.Find("DisplayTextBox"); - _displayTextBox.KeyDown += DisplayTextBoxOnKeyDown; - _displayTextBox.KeyUp += DisplayTextBoxOnKeyUp; + PropertyChanged += OnPropertyChanged; + DisplayTextBox.KeyDown += DisplayTextBoxOnKeyDown; + DisplayTextBox.KeyUp += DisplayTextBoxOnKeyUp; UpdateDisplayTextBox(); } + private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) + { + if (e.Property == HotkeyProperty) + UpdateDisplayTextBox(); + } + private void DisplayTextBoxOnKeyDown(object? sender, KeyEventArgs e) { if (e.Key >= Key.LeftShift && e.Key <= Key.RightAlt) @@ -44,7 +47,7 @@ public partial class HotkeyBox : UserControl Hotkey.Modifiers = (KeyboardModifierKey?) e.KeyModifiers; UpdateDisplayTextBox(); HotkeyChanged?.Invoke(this, EventArgs.Empty); - + e.Handled = true; } @@ -64,8 +67,8 @@ public partial class HotkeyBox : UserControl if (Hotkey?.Key != null) display = string.IsNullOrEmpty(display) ? Hotkey.Key.ToString() : $"{display}+{Hotkey.Key}"; - _displayTextBox.Text = display; - _displayTextBox.CaretIndex = _displayTextBox.Text?.Length ?? 0; + DisplayTextBox.Text = display; + DisplayTextBox.CaretIndex = DisplayTextBox.Text?.Length ?? 0; } private void Button_OnClick(object? sender, RoutedEventArgs e) @@ -101,11 +104,7 @@ public partial class HotkeyBox : UserControl public Hotkey? Hotkey { get => GetValue(HotkeyProperty); - set - { - SetValue(HotkeyProperty, value); - UpdateDisplayTextBox(); - } + set => SetValue(HotkeyProperty, value); } /// diff --git a/src/Artemis.UI.Shared/Controls/SelectionRectangle.cs b/src/Artemis.UI.Shared/Controls/SelectionRectangle.cs index 5da12bd99..8e997d532 100644 --- a/src/Artemis.UI.Shared/Controls/SelectionRectangle.cs +++ b/src/Artemis.UI.Shared/Controls/SelectionRectangle.cs @@ -69,6 +69,14 @@ public class SelectionRectangle : Control { AffectsRender(BackgroundProperty, BorderBrushProperty, BorderThicknessProperty); IsHitTestVisible = false; + + PropertyChanged += OnPropertyChanged; + } + + private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e) + { + if (e.Property == InputElementProperty) + SubscribeToInputElement(); } /// @@ -113,11 +121,7 @@ public class SelectionRectangle : Control public InputElement? InputElement { get => GetValue(InputElementProperty); - set - { - SetValue(InputElementProperty, value); - SubscribeToInputElement(); - } + set => SetValue(InputElementProperty, value); } /// diff --git a/src/Artemis.UI.Shared/Styles/Border.axaml b/src/Artemis.UI.Shared/Styles/Border.axaml index e82655006..9bb22454e 100644 --- a/src/Artemis.UI.Shared/Styles/Border.axaml +++ b/src/Artemis.UI.Shared/Styles/Border.axaml @@ -27,14 +27,7 @@ - - - - + + + + - @@ -20,8 +29,8 @@ - - + + diff --git a/src/Artemis.UI/MainWindow.axaml.cs b/src/Artemis.UI/MainWindow.axaml.cs index 2d41c3a43..38c92d921 100644 --- a/src/Artemis.UI/MainWindow.axaml.cs +++ b/src/Artemis.UI/MainWindow.axaml.cs @@ -14,8 +14,6 @@ namespace Artemis.UI; public partial class MainWindow : ReactiveAppWindow { - private readonly Panel _rootPanel; - private readonly ContentControl _sidebarContentControl; private bool _activated; public MainWindow() @@ -24,12 +22,10 @@ public partial class MainWindow : ReactiveAppWindow Activated += OnActivated; Deactivated += OnDeactivated; - // ApplyWindowSize(); InitializeComponent(); - - _rootPanel = this.Get("RootPanel"); - _sidebarContentControl = this.Get("SidebarContentControl"); - _rootPanel.LayoutUpdated += OnLayoutUpdated; + ApplyWindowSize(); + + RootPanel.LayoutUpdated += OnLayoutUpdated; #if DEBUG this.AttachDevTools(); @@ -56,22 +52,16 @@ public partial class MainWindow : ReactiveAppWindow RootViewModel.WindowSizeSetting.Value ??= new WindowSize(); RootViewModel.WindowSizeSetting.Value.ApplyFromWindow(this); } - - // TODO: Replace with a media query once https://github.com/AvaloniaUI/Avalonia/pull/7938 is implemented + private void OnLayoutUpdated(object? sender, EventArgs e) { - _sidebarContentControl.Width = _rootPanel.Bounds.Width >= 1800 ? 300 : 240; + SidebarContentControl.Width = RootPanel.Bounds.Width >= 1800 ? 300 : 240; } private void OnOpened(object? sender, EventArgs e) { Opened -= OnOpened; - // ICoreApplicationView coreAppTitleBar = this; - // if (coreAppTitleBar.TitleBar != null) - // { - // coreAppTitleBar.TitleBar.ExtendViewIntoTitleBar = true; - // SetTitleBar(this.Get("DragHandle")); - // } + TitleBar.ExtendsContentIntoTitleBar = true; } private void OnActivated(object? sender, EventArgs e) diff --git a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml index 7b79b8273..b8e1c5756 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml @@ -84,11 +84,7 @@ - + diff --git a/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorTitleBarView.axaml b/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorTitleBarView.axaml index a4add314f..3a69989c8 100644 --- a/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorTitleBarView.axaml +++ b/src/Artemis.UI/Screens/ProfileEditor/ProfileEditorTitleBarView.axaml @@ -3,15 +3,18 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" + xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia" + xmlns:profileEditor="clr-namespace:Artemis.UI.Screens.ProfileEditor" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" - x:Class="Artemis.UI.Screens.ProfileEditor.ProfileEditorTitleBarView"> - - - - - - - diff --git a/src/Artemis.UI/Screens/Root/DefaultTitleBarView.axaml b/src/Artemis.UI/Screens/Root/DefaultTitleBarView.axaml index 1bfa0720c..057fca3d0 100644 --- a/src/Artemis.UI/Screens/Root/DefaultTitleBarView.axaml +++ b/src/Artemis.UI/Screens/Root/DefaultTitleBarView.axaml @@ -3,9 +3,10 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia" + xmlns:windowing="clr-namespace:FluentAvalonia.UI.Windowing;assembly=FluentAvalonia" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Artemis.UI.Screens.Root.DefaultTitleBarView"> - \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Sidebar/SidebarView.axaml b/src/Artemis.UI/Screens/Sidebar/SidebarView.axaml index e4e9a7c40..e79099445 100644 --- a/src/Artemis.UI/Screens/Sidebar/SidebarView.axaml +++ b/src/Artemis.UI/Screens/Sidebar/SidebarView.axaml @@ -25,7 +25,7 @@ Margin="10 2" Items="{CompiledBinding SidebarScreens}" SelectedItem="{CompiledBinding SelectedSidebarScreen}" /> - + @@ -39,7 +39,7 @@ - + - + @@ -44,6 +44,7 @@ + diff --git a/src/Artemis.UI/Styles/Artemis.axaml b/src/Artemis.UI/Styles/Artemis.axaml index c8febf069..242bef032 100644 --- a/src/Artemis.UI/Styles/Artemis.axaml +++ b/src/Artemis.UI/Styles/Artemis.axaml @@ -3,7 +3,7 @@ xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia" xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"> - +