From 6c48fc1f5eee7147c18850fca78bc98750a5fd44 Mon Sep 17 00:00:00 2001 From: Mbucari <37587114+Mbucari@users.noreply.github.com> Date: Fri, 2 Jun 2023 23:39:16 -0600 Subject: [PATCH] Update avalonia ro v11-RC1 --- Source/LibationAvalonia/App.axaml.cs | 3 -- .../Controls/LinkLabel.axaml.cs | 4 +- .../Controls/WheelComboBox.axaml.cs | 6 +++ .../LibationAvalonia/LibationAvalonia.csproj | 14 +++--- .../LibationAvalonia/MacAccessKeyHandler.cs | 44 ------------------- .../Views/ProductsDisplay.axaml.cs | 4 +- Source/LibationAvalonia/Walkthrough.cs | 2 +- 7 files changed, 18 insertions(+), 59 deletions(-) delete mode 100644 Source/LibationAvalonia/MacAccessKeyHandler.cs diff --git a/Source/LibationAvalonia/App.axaml.cs b/Source/LibationAvalonia/App.axaml.cs index 939e9513..55d3002a 100644 --- a/Source/LibationAvalonia/App.axaml.cs +++ b/Source/LibationAvalonia/App.axaml.cs @@ -28,8 +28,6 @@ namespace LibationAvalonia public static IBrush ProcessQueueBookDefaultBrush { get; private set; } public static IBrush SeriesEntryGridBackgroundBrush { get; private set; } - public static IAssetLoader AssetLoader { get; private set; } - public static readonly Uri AssetUriBase = new("avares://Libation/Assets/"); public static Stream OpenAsset(string assetRelativePath) => AssetLoader.Open(new Uri(AssetUriBase, assetRelativePath)); @@ -37,7 +35,6 @@ namespace LibationAvalonia public override void Initialize() { AvaloniaXamlLoader.Load(this); - AssetLoader = AvaloniaLocator.Current.GetService(); } public static Task> LibraryTask; diff --git a/Source/LibationAvalonia/Controls/LinkLabel.axaml.cs b/Source/LibationAvalonia/Controls/LinkLabel.axaml.cs index 097416ff..b0dff8ea 100644 --- a/Source/LibationAvalonia/Controls/LinkLabel.axaml.cs +++ b/Source/LibationAvalonia/Controls/LinkLabel.axaml.cs @@ -10,9 +10,9 @@ using System.Windows.Input; namespace LibationAvalonia.Controls { - public partial class LinkLabel : TextBlock, IStyleable, ICommandSource + public partial class LinkLabel : TextBlock, ICommandSource { - Type IStyleable.StyleKey => typeof(LinkLabel); + protected override Type StyleKeyOverride => typeof(LinkLabel); public static readonly StyledProperty CommandProperty = AvaloniaProperty.Register(nameof(Command), enableDataValidation: true); diff --git a/Source/LibationAvalonia/Controls/WheelComboBox.axaml.cs b/Source/LibationAvalonia/Controls/WheelComboBox.axaml.cs index cf6a150f..ec19da90 100644 --- a/Source/LibationAvalonia/Controls/WheelComboBox.axaml.cs +++ b/Source/LibationAvalonia/Controls/WheelComboBox.axaml.cs @@ -16,9 +16,15 @@ namespace LibationAvalonia.Controls { var dir = Math.Sign(e.Delta.Y); if (dir == 1 && SelectedIndex > 0) + { SelectedIndex--; + e.Handled = true; + } else if (dir == -1 && SelectedIndex < ItemCount - 1) + { SelectedIndex++; + e.Handled = true; + } base.OnPointerWheelChanged(e); } diff --git a/Source/LibationAvalonia/LibationAvalonia.csproj b/Source/LibationAvalonia/LibationAvalonia.csproj index 39448922..00a7bf61 100644 --- a/Source/LibationAvalonia/LibationAvalonia.csproj +++ b/Source/LibationAvalonia/LibationAvalonia.csproj @@ -70,13 +70,13 @@ - - - - - - - + + + + + + + diff --git a/Source/LibationAvalonia/MacAccessKeyHandler.cs b/Source/LibationAvalonia/MacAccessKeyHandler.cs deleted file mode 100644 index bee7eebf..00000000 --- a/Source/LibationAvalonia/MacAccessKeyHandler.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Avalonia; -using Avalonia.Input; - -namespace LibationAvalonia -{ - internal class MacAccessKeyHandler : AccessKeyHandler - { - protected override void OnPreviewKeyDown(object sender, KeyEventArgs e) - { - if (e.Key is Key.LWin or Key.RWin) - { - var newArgs = new KeyEventArgs { Key = Key.LeftAlt, Handled = e.Handled }; - base.OnPreviewKeyDown(sender, newArgs); - e.Handled = newArgs.Handled; - } - else if (e.Key is not Key.LeftAlt and not Key.RightAlt) - base.OnPreviewKeyDown(sender, e); - } - - protected override void OnPreviewKeyUp(object sender, KeyEventArgs e) - { - if (e.Key is Key.LWin or Key.RWin) - { - var newArgs = new KeyEventArgs { Key = Key.LeftAlt, Handled = e.Handled }; - base.OnPreviewKeyUp(sender, newArgs); - e.Handled = newArgs.Handled; - } - else if (e.Key is not Key.LeftAlt and not Key.RightAlt) - base.OnPreviewKeyDown(sender, e); - } - - protected override void OnKeyDown(object sender, KeyEventArgs e) - { - if (e.KeyModifiers.HasAllFlags(KeyModifiers.Meta)) - { - var newArgs = new KeyEventArgs { Key = e.Key, Handled = e.Handled, KeyModifiers = KeyModifiers.Alt }; - base.OnKeyDown(sender, newArgs); - e.Handled = newArgs.Handled; - } - else if (!e.KeyModifiers.HasFlag(KeyModifiers.Alt)) - base.OnPreviewKeyDown(sender, e); - } - } -} diff --git a/Source/LibationAvalonia/Views/ProductsDisplay.axaml.cs b/Source/LibationAvalonia/Views/ProductsDisplay.axaml.cs index 9fe44d1b..bd85f92f 100644 --- a/Source/LibationAvalonia/Views/ProductsDisplay.axaml.cs +++ b/Source/LibationAvalonia/Views/ProductsDisplay.axaml.cs @@ -252,8 +252,8 @@ namespace LibationAvalonia.Views var displayIndices = config.GridColumnsDisplayIndices; var contextMenu = new ContextMenu(); - contextMenu.MenuClosed += ContextMenu_MenuClosed; - contextMenu.ContextMenuOpening += ContextMenu_ContextMenuOpening; + contextMenu.Closed += ContextMenu_MenuClosed; + contextMenu.Opening += ContextMenu_ContextMenuOpening; List menuItems = new(); contextMenu.ItemsSource = menuItems; diff --git a/Source/LibationAvalonia/Walkthrough.cs b/Source/LibationAvalonia/Walkthrough.cs index 8cee6272..850dd1c3 100644 --- a/Source/LibationAvalonia/Walkthrough.cs +++ b/Source/LibationAvalonia/Walkthrough.cs @@ -248,7 +248,7 @@ namespace LibationAvalonia private async Task displayControlAsync(TemplatedControl control) { await UIThread.InvokeAsync(() => control.IsEnabled = false); - await UIThread.InvokeAsync(MainForm.productsDisplay.Focus); + await UIThread.InvokeAsync(() => MainForm.productsDisplay.Focus()); await UIThread.InvokeAsync(() => flashControlAsync(control)); if (control is MenuItem menuItem) await UIThread.InvokeAsync(menuItem.Open); await Task.Delay(500);