Don't tell Dan
MODIFY
WalletWasabi.Gui/MainWindow.xaml.cs
WalletWasabi.Gui/MainWindow.xaml.cs
using System;
+using System.IO;
+using System.Linq;
using Avalonia;
using Avalonia.Markup.Xaml;
using AvalonStudio.Extensibility;
@@ -23,10 +25,23 @@ namespace WalletWasabi.Gui
AvaloniaXamlLoader.Load(this);
}
- void OnActivated(object sender, EventArgs e)
+ private void OnActivated(object sender, EventArgs e)
{
Activated -= OnActivated;
- IoC.Get<IShell>().AddOrSelectDocument<WalletManagerViewModel>(new WalletManagerViewModel());
+ if (Directory.Exists(Global.WalletsDir) && Directory.EnumerateFiles(Global.WalletsDir).Any())
+ {
+ // Load
+ var document = new WalletManagerViewModel();
+ IoC.Get<IShell>().AddDocument(document);
+ document.SelectedCategory = document.Categories.First(x => x is LoadWalletViewModel);
+ }
+ else
+ {
+ // Generate
+ var document = new WalletManagerViewModel();
+ IoC.Get<IShell>().AddDocument(document);
+ document.SelectedCategory = document.Categories.First(x => x is GenerateWalletViewModel);
+ }
}
}
}

RENAME
WalletWasabi.Gui/Shell/Commands/FileCommands.cs
WalletWasabi.Gui/Shell/Commands/ExitCommands.cs
MODIFY
WalletWasabi.Gui/Shell/Commands/ToolCommands.cs
WalletWasabi.Gui/Shell/Commands/ToolCommands.cs
@@ -3,6 +3,7 @@ using AvalonStudio.Documents;
using AvalonStudio.Extensibility;
using AvalonStudio.Shell;
using ReactiveUI;
+using System.IO;
using System.Linq;
using WalletWasabi.Gui.Tabs.WalletManager;
@@ -20,7 +21,42 @@ namespace WalletWasabi.Gui.Shell.Commands
private void OnWalletManager()
{
- IoC.Get<IShell>().AddOrSelectDocument<WalletManagerViewModel>(new WalletManagerViewModel());
+ if (Directory.Exists(Global.WalletsDir) && Directory.EnumerateFiles(Global.WalletsDir).Any())
+ {
+ // Load
+ IShell tabs = IoC.Get<IShell>();
+ IDocumentTabViewModel doc = tabs.Documents.FirstOrDefault(x => x is WalletManagerViewModel);
+ if (doc != default)
+ {
+ var document = doc as WalletManagerViewModel;
+ tabs.SelectedDocument = doc;
+ document.SelectedCategory = document.Categories.First(x => x is LoadWalletViewModel);
+ }
+ else
+ {
+ var document = new WalletManagerViewModel();
+ tabs.AddDocument(document);
+ document.SelectedCategory = document.Categories.First(x => x is LoadWalletViewModel);
+ }
+ }
+ else
+ {
+ // Generate
+ IShell tabs = IoC.Get<IShell>();
+ IDocumentTabViewModel doc = tabs.Documents.FirstOrDefault(x => x is WalletManagerViewModel);
+ if (doc != default)
+ {
+ var document = doc as WalletManagerViewModel;
+ tabs.SelectedDocument = doc;
+ document.SelectedCategory = document.Categories.First(x => x is GenerateWalletViewModel);
+ }
+ else
+ {
+ var document = new WalletManagerViewModel();
+ tabs.AddDocument(document);
+ document.SelectedCategory = document.Categories.First(x => x is GenerateWalletViewModel);
+ }
+ }
}
[ExportCommandDefinition("Tools.WalletManager")]

MODIFY
WalletWasabi.Gui/Tabs/WalletManager/WalletManagerView.xaml.cs
WalletWasabi.Gui/Tabs/WalletManager/WalletManagerView.xaml.cs
@@ -17,25 +17,7 @@ namespace WalletWasabi.Gui.Tabs.WalletManager
private void InitializeComponent()
{
- Initialized += OnInitilized;
AvaloniaXamlLoader.Load(this);
}
-
- void OnInitilized(object sender, EventArgs e)
- {
- Initialized -= OnInitilized;
- var ctx = (WalletManagerViewModel)DataContext;
- if(Directory.Exists(Global.WalletsDir) && Directory.EnumerateFiles(Global.WalletsDir).Any())
- {
- // Load
- ctx.SelectedCategory = ctx.Categories.First(x=>x is LoadWalletViewModel);
- }
- else
- {
- // Generate
- ctx.SelectedCategory = ctx.Categories.First(x=>x is GenerateWalletViewModel);
- }
- }
-
}
}

Don't tell Dan