fix wallet tab selection.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletExplorerViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletExplorerViewModel.cs
@@ -50,12 +50,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
WalletViewModel walletViewModel = new WalletViewModel(walletName);
_wallets.Add(walletViewModel);
-
- IoC.Get<IShell>().AddOrSelectDocument<SendActionViewModel>(new SendActionViewModel(walletViewModel));
- IoC.Get<IShell>().AddOrSelectDocument<ReceiveActionViewModel>(new ReceiveActionViewModel(walletViewModel));
- IoC.Get<IShell>().AddOrSelectDocument<CoinJoinActionViewModel>(new CoinJoinActionViewModel(walletViewModel));
- IoC.Get<IShell>().AddOrSelectDocument<HistoryActionViewModel>(new HistoryActionViewModel(walletViewModel));
- IoC.Get<IShell>().SelectedDocument = IoC.Get<IShell>().Documents.FirstOrDefault(x => x is ReceiveActionViewModel);
}
}
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
@@ -10,23 +10,28 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
public class WalletViewModel : DocumentTabViewModel
{
+ private ObservableCollection<WalletActionViewModel> _actions;
+
public WalletViewModel(string name)
: base(name)
{
- _actions = new ObservableCollection<DocumentTabViewModel>
+ _actions = new ObservableCollection<WalletActionViewModel>
{
new SendActionViewModel(this),
new ReceiveActionViewModel(this),
new CoinJoinActionViewModel(this),
new HistoryActionViewModel(this)
};
+
+ foreach (var vm in _actions)
+ {
+ vm.DisplayActionTab();
+ }
}
public string Name { get; }
- private ObservableCollection<DocumentTabViewModel> _actions;
-
- public ObservableCollection<DocumentTabViewModel> Actions
+ public ObservableCollection<WalletActionViewModel> Actions
{
get { return _actions; }
set { this.RaiseAndSetIfChanged(ref _actions, value); }
@@ -48,22 +53,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public void DisplayActionTab()
{
- if (Title == "Send")
- {
- IoC.Get<IShell>().AddOrSelectDocument<SendActionViewModel>(this);
- }
- else if (Title == "Receive")
- {
- IoC.Get<IShell>().AddOrSelectDocument<ReceiveActionViewModel>(this);
- }
- else if (Title == "CoinJoin")
- {
- IoC.Get<IShell>().AddOrSelectDocument<CoinJoinActionViewModel>(this);
- }
- else if (Title == "History")
- {
- IoC.Get<IShell>().AddOrSelectDocument<HistoryActionViewModel>(this);
- }
+ IoC.Get<IShell>().AddOrSelectDocument(this);
}
}

MODIFY
WalletWasabi.Gui/Utils.cs
WalletWasabi.Gui/Utils.cs
@@ -23,6 +23,20 @@ namespace WalletWasabi.Gui
throw new NotSupportedException("This is impossible.");
}
+ public static void AddOrSelectDocument<T>(this IShell me, T document) where T : IDocumentTabViewModel
+ {
+ IDocumentTabViewModel doc = me.Documents.FirstOrDefault(x => x.Equals(document));
+
+ if (doc != default)
+ {
+ me.SelectedDocument = doc;
+ }
+ else
+ {
+ me.AddDocument(doc);
+ }
+ }
+
public static void AddOrSelectDocument<T>(this IShell me, Func<T> factory) where T : IDocumentTabViewModel
{
IDocumentTabViewModel doc = me.Documents.FirstOrDefault(x => x is T);

fix wallet tab selection.