Add UiConfig. Remember windows state and size at shutdown.
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -74,12 +74,18 @@ namespace WalletWasabi.Gui
public static TorProcessManager TorManager { get; private set; }
public static Config Config { get; private set; }
+ public static UiConfig UiConfig { get; private set; }
- public static void InitializeConfig(Config config)
+ public static void InitializeConfigs(Config config)
{
Config = Guard.NotNull(nameof(config), config);
}
+ public static void InitializeUiConfigs(UiConfig uiConfig)
+ {
+ UiConfig = Guard.NotNull(nameof(uiConfig), uiConfig);
+ }
+
private static long _triedDesperateDequeuing = 0;
private static async Task TryDesperateDequeueAllCoinsAsync()

MODIFY
WalletWasabi.Gui/MainWindow.xaml
WalletWasabi.Gui/MainWindow.xaml
Title="{Binding Title}" BorderThickness="1" BorderBrush="{DynamicResource AvalonBorderBrush}"
MinWidth="1100" MinHeight="530"
FontFamily="{DynamicResource UiFont}" FontSize="14"
- Foreground="{DynamicResource ThemeForegroundBrush}" WindowState="Maximized"
+ Foreground="{DynamicResource ThemeForegroundBrush}"
+ Width ="{Binding Width}" Height ="{Binding Height}"
+ WindowState ="{Binding WindowState}"
UseLayoutRounding="True" RenderOptions.BitmapInterpolationMode="HighQuality"
id:DragBehavior.IsEnabled="False" id:DropBehavior.IsEnabled="False">
<i:Interaction.Behaviors>

MODIFY
WalletWasabi.Gui/MainWindow.xaml.cs
WalletWasabi.Gui/MainWindow.xaml.cs
using System;
+using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
@@ -10,6 +11,7 @@ using AvalonStudio.Extensibility.Theme;
using AvalonStudio.Shell;
using AvalonStudio.Shell.Controls;
using WalletWasabi.Gui.Tabs.WalletManager;
+using WalletWasabi.Gui.ViewModels;
namespace WalletWasabi.Gui
{
@@ -35,13 +37,25 @@ namespace WalletWasabi.Gui
private void InitializeComponent()
{
Activated += OnActivated;
+ Closing += MainWindow_ClosingAsync;
AvaloniaXamlLoader.Load(this);
}
+ private async void MainWindow_ClosingAsync(object sender, CancelEventArgs e)
+ {
+ UiConfig conf = Global.UiConfig;
+ conf.WindowState = WindowState;
+ conf.Width = Width;
+ conf.Height = Height;
+
+ await conf.ToFileAsync();
+ }
+
private void OnActivated(object sender, EventArgs e)
{
Activated -= OnActivated;
DisplayWalletManager();
+ MainWindowViewModel.Instance.RefreshUiFromConfig(Global.UiConfig);
}
private void DisplayWalletManager()

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -22,6 +22,13 @@ namespace WalletWasabi.Gui
try
{
Platform.BaseDirectory = Path.Combine(Global.DataDir, "Gui");
+
+ var uiConfigFilePath = Path.Combine(Global.DataDir, "UiConfig.json");
+ var uiConfig = new UiConfig(uiConfigFilePath);
+ await uiConfig.LoadOrCreateDefaultFileAsync();
+ Logger.LogInfo<UiConfig>("UiConfig is successfully initialized.");
+ Global.InitializeUiConfigs(uiConfig);
+
BuildAvaloniaApp().BeforeStarting(async builder =>
{
MainWindowViewModel.Instance = new MainWindowViewModel();
@@ -31,7 +38,8 @@ namespace WalletWasabi.Gui
await config.LoadOrCreateDefaultFileAsync();
Logger.LogInfo<Config>("Config is successfully initialized.");
- Global.InitializeConfig(config);
+ Global.InitializeConfigs(config);
+ MainWindowViewModel.Instance.RefreshUiFromConfig(uiConfig);
if (!File.Exists(Global.IndexFilePath)) // Load the index file from working folder if we have it.
{
@@ -47,6 +55,12 @@ namespace WalletWasabi.Gui
MainWindowViewModel.Instance.StatusBar = statusBar;
+ //UiConfig conf = Global.UiConfig;
+ //MainWindowViewModel.Instance..WindowState = (Avalonia.Controls.WindowState)conf.WindowState;
+ //MainWindowViewModel.Instance.Width = (double)conf.Width;
+ //MainWindowViewModel.Instance.Height = (double)conf.Height;
+ //MainWindowViewModel.Instance.Position = new Point((double)conf.Left, (double)conf.Top);
+
if (Global.IndexDownloader.Network != Network.Main)
{
MainWindowViewModel.Instance.Title += $" - {Global.IndexDownloader.Network}";

Add UiConfig. Remember windows state and size at shutdown.