Get WindowState from UiConfig
MODIFY
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
WalletWasabi.Fluent/ViewModels/MainViewModel.cs
@@ -3,6 +3,7 @@ using System.Reactive.Concurrency;
using NBitcoin;
using ReactiveUI;
using System.Reactive.Linq;
+using Avalonia.Controls;
using WalletWasabi.Fluent.ViewModels.AddWallet;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Fluent.ViewModels.Dialogs.Base;
@@ -24,6 +25,11 @@ namespace WalletWasabi.Fluent.ViewModels
{
private readonly Global _global;
private readonly LegalChecker _legalChecker;
+ private readonly SettingsPageViewModel _settingsPage;
+ private readonly SearchPageViewModel _searchPage;
+ private readonly PrivacyModeViewModel _privacyMode;
+ private readonly AddWalletPageViewModel _addWalletPage;
+ private readonly WalletManagerViewModel _walletManagerViewModel;
[AutoNotify] private bool _isMainContentEnabled;
[AutoNotify] private bool _isDialogScreenEnabled;
[AutoNotify] private bool _isFullScreenEnabled;
@@ -33,17 +39,13 @@ namespace WalletWasabi.Fluent.ViewModels
[AutoNotify] private NavBarViewModel _navBar;
[AutoNotify] private StatusBarViewModel _statusBar;
[AutoNotify] private string _title = "Wasabi Wallet";
- private readonly SettingsPageViewModel _settingsPage;
- private readonly SearchPageViewModel _searchPage;
- private readonly PrivacyModeViewModel _privacyMode;
- private readonly AddWalletPageViewModel _addWalletPage;
- private readonly WalletManagerViewModel _walletManagerViewModel;
+ [AutoNotify] private WindowState _windowState;
public MainViewModel(Global global)
{
_global = global;
_legalChecker = global.LegalChecker;
-
+ _windowState = (WindowState) Enum.Parse(typeof(WindowState), _global.UiConfig.WindowState);
_dialogScreen = new DialogScreenViewModel();
_fullScreen = new DialogScreenViewModel(NavigationTarget.FullScreen);
@@ -96,6 +98,10 @@ namespace WalletWasabi.Fluent.ViewModels
_searchPage.Initialise();
+ this.WhenAnyValue(x => x.WindowState)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(windowState => global.UiConfig.WindowState = windowState.ToString());
+
this.WhenAnyValue(x => x.DialogScreen!.IsDialogOpen)
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(x => IsMainContentEnabled = !x);

MODIFY
WalletWasabi.Fluent/Views/MainWindow.axaml
WalletWasabi.Fluent/Views/MainWindow.axaml
TransparencyLevelHint="AcrylicBlur"
ExtendClientAreaToDecorationsHint="True"
ExtendClientAreaChromeHints="PreferSystemChrome"
- Title="Wasabi Wallet">
+ Title="Wasabi Wallet"
+ WindowState="{Binding WindowState, Mode=TwoWay}">
<Panel Margin="{Binding #MainWindow.OffScreenMargin}">
<local:MainView />

MODIFY
WalletWasabi.Gui/Converters/WindowStateAfterStartJsonConverter.cs
WalletWasabi.Gui/Converters/WindowStateAfterStartJsonConverter.cs
@@ -17,24 +17,20 @@ namespace WalletWasabi.Gui.Converters
{
try
{
- // If minimized, then go with Maximized, because at start it shouldn't run with minimized.
var value = reader.Value as string;
- if (string.IsNullOrWhiteSpace(value))
+ // If minimized, then go with Maximized, because at start it shouldn't run with minimized.
+ if (Enum.TryParse(value, out WindowState ws) && ws != WindowState.Minimized)
{
- return WindowState.Maximized.ToString();
+ return ws.ToString();
}
-
- var windowStateString = value.Trim();
-
- return windowStateString.StartsWith("norm", StringComparison.OrdinalIgnoreCase)
- ? WindowState.Normal.ToString()
- : WindowState.Maximized.ToString();
}
catch
{
- return WindowState.Maximized.ToString();
+ // ignored
}
+
+ return WindowState.Maximized.ToString();
}
/// <inheritdoc />

MODIFY
WalletWasabi.Gui/UiConfig.cs
WalletWasabi.Gui/UiConfig.cs
@@ -2,6 +2,7 @@ using System;
using Avalonia.Controls;
using Newtonsoft.Json;
using System.ComponentModel;
+using System.Reactive;
using System.Reactive.Linq;
using ReactiveUI;
using WalletWasabi.Bases;
@@ -22,6 +23,7 @@ namespace WalletWasabi.Gui
private int _feeDisplayFormat;
private bool _darkModeEnabled;
private bool _showCoinJoinInHistory;
+ private string _windowState = "Normal";
public UiConfig() : base()
{
@@ -36,7 +38,9 @@ namespace WalletWasabi.Gui
x => x.IsCustomChangeAddress,
x => x.DarkModeEnabled,
x => x.FeeDisplayFormat,
- x => x.ShowCoinJoinInHistory)
+ x => x.ShowCoinJoinInHistory,
+ x => x.WindowState,
+ (_, _, _, _, _, _, _, _) => Unit.Default)
.Throttle(TimeSpan.FromMilliseconds(500))
.Skip(1) // Won't save on UiConfig creation.
.ObserveOn(RxApp.TaskpoolScheduler)
@@ -45,7 +49,11 @@ namespace WalletWasabi.Gui
[JsonProperty(PropertyName = "WindowState")]
[JsonConverter(typeof(WindowStateAfterStartJsonConverter))]
- public string WindowState { get; internal set; } = Avalonia.Controls.WindowState.Normal.ToString();
+ public string WindowState
+ {
+ get => _windowState;
+ internal set => RaiseAndSetIfChanged(ref _windowState, value);
+ }
[DefaultValue(2)]
[JsonProperty(PropertyName = "FeeTarget", DefaultValueHandling = DefaultValueHandling.Populate)]

Get WindowState from UiConfig