Upgrade Avalonia to 11 rc1

This commit is contained in:
Robert committed 2023-06-05 23:39:57 +02:00
1 parent 70b6035b0d
commit f249f80d19
16 files changed
+64 -95

No files matched your search

@@ -10,14 +10,14 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia" Version="11.0.0-rc1.1" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-preview8" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-rc1.1" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-rc1.1" />
<PackageReference Include="DynamicData" Version="7.13.1" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview8" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.0.0-preview3" />
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-rc1" />
<PackageReference Include="Material.Icons.Avalonia" Version="2.0.1" />
<PackageReference Include="ReactiveUI" Version="18.4.26" />
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />
<PackageReference Include="RGB.NET.Core" Version="2.0.0-prerelease.69" />
@@ -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<IInputElement>().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);
@@ -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<InputElement>()?.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<InputElement>()?.Focus();
UpdateDisplayTextBox();
}
+1 -1
View File
@@ -48,7 +48,7 @@ public class ReactiveAppWindow<TViewModel> : AppWindow, IViewFor<TViewModel> whe
return;
TransparencyBackgroundFallback = Brushes.Transparent;
TransparencyLevelHint = WindowTransparencyLevel.Mica;
TransparencyLevelHint = new[] {WindowTransparencyLevel.Mica};
TryEnableMicaEffect();
}
+2 -17
View File
@@ -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;
/// </summary>
public static class UI
{
private static readonly BehaviorSubject<bool> 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);
}
/// <summary>
@@ -35,15 +30,5 @@ public static class UI
/// <summary>
/// Gets a boolean indicating whether hotkeys are to be disabled.
/// </summary>
public static IObservable<bool> 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<bool> KeyBindingsEnabled { get; }
}