Move WindowSizeBehavior logic to ApplicationStateManager
MODIFY
WalletWasabi.Fluent/ApplicationStateManager.cs
WalletWasabi.Fluent/ApplicationStateManager.cs
@@ -165,6 +165,8 @@ public class ApplicationStateManager : IMainWindowService
SetWindowSize(result);
}
+ ObserveWindowSize(result, _compositeDisposable);
+
result.Show();
ApplicationViewModel.IsMainWindowShown = true;
@@ -191,6 +193,28 @@ public class ApplicationStateManager : IMainWindowService
}
}
+ private void ObserveWindowSize(Window window, CompositeDisposable disposables)
+ {
+ window?
+ .WhenAnyValue(x => x.Bounds)
+ .Where(b => !b.IsEmpty)
+ .Take(1)
+ .Subscribe(_ =>
+ {
+ window
+ .WhenAnyValue(x => x.Bounds)
+ .Skip(1)
+ .Where(b => !b.IsEmpty && window.WindowState == WindowState.Normal)
+ .Subscribe(b =>
+ {
+ Services.UiConfig.WindowWidth = b.Width;
+ Services.UiConfig.WindowHeight = b.Height;
+ })
+ .DisposeWith(disposables);
+ })
+ .DisposeWith(disposables);
+ }
+
void IMainWindowService.Show()
{
_stateMachine.Fire(Trigger.Show);

DELETE
WalletWasabi.Fluent/Behaviors/WindowSizeBehavior.cs
-using System.Reactive.Disposables;
-using System.Reactive.Linq;
-using Avalonia.Controls;
-using Avalonia.Threading;
-using ReactiveUI;
-
-namespace WalletWasabi.Fluent.Behaviors;
-
-public class WindowSizeBehavior : DisposingBehavior<Window>
-{
- protected override void OnAttached(CompositeDisposable disposables)
- {
- AssociatedObject?
- .WhenAnyValue(x => x.Bounds)
- .Where(b => !b.IsEmpty)
- .Take(1)
- .Subscribe(_ =>
- {
- AssociatedObject
- .WhenAnyValue(x => x.Bounds)
- .Skip(1)
- .Where(b => !b.IsEmpty && AssociatedObject.WindowState == WindowState.Normal)
- .Subscribe(b =>
- {
- Services.UiConfig.WindowWidth = b.Width;
- Services.UiConfig.WindowHeight = b.Height;
- })
- .DisposeWith(disposables);
- })
- .DisposeWith(disposables);
- }
-}

MODIFY
WalletWasabi.Fluent/Views/MainWindow.axaml
WalletWasabi.Fluent/Views/MainWindow.axaml
<i:Interaction.Behaviors>
<behaviors:RegisterNotificationHostBehavior />
<behaviors:ShowWalletCoinsOnKeyCombinationBehavior Key1="LeftCtrl" Key2="D" Key3="C" />
- <behaviors:WindowSizeBehavior />
</i:Interaction.Behaviors>
<Panel Margin="{Binding #MainWindow.OffScreenMargin}">

Move WindowSizeBehavior logic to ApplicationStateManager