Only apply UI remembring for Windows and OSX
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -74,18 +74,12 @@ 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)
{
Config = Guard.NotNull(nameof(config), config);
}
- public static void InitializeUiConfig(UiConfig uiConfig)
- {
- UiConfig = Guard.NotNull(nameof(uiConfig), uiConfig);
- }
-
private static long _triedDesperateDequeuing = 0;
private static async Task TryDesperateDequeueAllCoinsAsync()

MODIFY
WalletWasabi.Gui/MainWindow.xaml.cs
WalletWasabi.Gui/MainWindow.xaml.cs
@@ -4,6 +4,7 @@ using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Avalonia;
+using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using AvalonStudio.Extensibility;
@@ -17,6 +18,8 @@ namespace WalletWasabi.Gui
{
public class MainWindow : MetroWindow
{
+ public UiConfig UiConfig { get; private set; }
+
public MainWindow()
{
InitializeComponent();
@@ -37,33 +40,51 @@ namespace WalletWasabi.Gui
private void InitializeComponent()
{
Activated += OnActivated;
+ Initialized += MainWindow_Initialized;
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();
- }
-
#pragma warning disable IDE1006 // Naming Styles
- private async void OnActivated(object sender, EventArgs e)
+ private async void MainWindow_Initialized(object sender, EventArgs e)
#pragma warning restore IDE1006 // Naming Styles
{
- Activated -= OnActivated;
- DisplayWalletManager();
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
var uiConfigFilePath = Path.Combine(Global.DataDir, "UiConfig.json");
var uiConfig = new UiConfig(uiConfigFilePath);
await uiConfig.LoadOrCreateDefaultFileAsync();
Logging.Logger.LogInfo<UiConfig>("UiConfig is successfully initialized.");
- Global.InitializeUiConfig(uiConfig);
- MainWindowViewModel.Instance.RefreshUiFromConfig(Global.UiConfig);
+ UiConfig = uiConfig;
+
+ MainWindowViewModel.Instance.Width = (double)uiConfig.Width;
+ MainWindowViewModel.Instance.Height = (double)uiConfig.Height;
+ MainWindowViewModel.Instance.WindowState = (WindowState)uiConfig.WindowState;
+ }
+ else
+ {
+ MainWindowViewModel.Instance.WindowState = WindowState.Maximized;
+ }
+ }
+
+ private async void MainWindow_ClosingAsync(object sender, CancelEventArgs e)
+ {
+ if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
+ {
+ UiConfig.WindowState = WindowState;
+ UiConfig.Width = Width;
+ UiConfig.Height = Height;
+
+ await UiConfig.ToFileAsync();
+ Logging.Logger.LogInfo<UiConfig>("UiConfig is saved.");
+ }
+ }
+
+ private void OnActivated(object sender, EventArgs e)
+ {
+ Activated -= OnActivated;
+ DisplayWalletManager();
}
private void DisplayWalletManager()

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -49,12 +49,6 @@ 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}";

MODIFY
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
WalletWasabi.Gui/ViewModels/MainWindowViewModel.cs
@@ -88,12 +88,5 @@ namespace WalletWasabi.Gui.ViewModels
get { return _canClose; }
set { this.RaiseAndSetIfChanged(ref _canClose, value); }
}
-
- public void RefreshUiFromConfig(UiConfig config)
- {
- Width = (double)config.Width;
- Height = (double)config.Height;
- WindowState = (WindowState)config.WindowState;
- }
}
}

Only apply UI remembring for Windows and OSX