Skip to content
Permalink
Browse files

exclude OSX from feature that can remember last window position

  • Loading branch information...
molnard committed Nov 12, 2018
1 parent 4d85ab5 commit e1ba710a7c883330b23a6c1cfcdf5c201c1df4b4
Showing with 16 additions and 23 deletions.
  1. +16 −23 WalletWasabi.Gui/MainWindow.xaml.cs
@@ -40,24 +40,35 @@ public MainWindow()
private void InitializeComponent()
{
Activated += OnActivated;
Initialized += MainWindow_Initialized;
Closing += MainWindow_ClosingAsync;
AvaloniaXamlLoader.Load(this);
}

#pragma warning disable IDE1006 // Naming Styles
private async void MainWindow_ClosingAsync(object sender, CancelEventArgs e)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
UiConfig.WindowState = WindowState;
UiConfig.Width = Width;
UiConfig.Height = Height;
await UiConfig.ToFileAsync();
Logging.Logger.LogInfo<UiConfig>("UiConfig is saved.");
}
}

private async void MainWindow_Initialized(object sender, EventArgs e)
#pragma warning disable IDE1006 // Naming Styles
private async void OnActivated(object sender, EventArgs e)
#pragma warning restore IDE1006 // Naming Styles
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
Activated -= OnActivated;

if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var uiConfigFilePath = Path.Combine(Global.DataDir, "UiConfig.json");
var uiConfig = new UiConfig(uiConfigFilePath);
await uiConfig.LoadOrCreateDefaultFileAsync();
Logging.Logger.LogInfo<UiConfig>("UiConfig is successfully initialized.");
UiConfig = uiConfig;

MainWindowViewModel.Instance.Width = (double)uiConfig.Width;
MainWindowViewModel.Instance.Height = (double)uiConfig.Height;
MainWindowViewModel.Instance.WindowState = (WindowState)uiConfig.WindowState;
@@ -66,24 +77,6 @@ private async void MainWindow_Initialized(object sender, EventArgs e)
{
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();
}

0 comments on commit e1ba710

Please sign in to comment.
You can’t perform that action at this time.