Added the balance to the wallet name
Balance is now appended to the end of the wallet name.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
using System;
using System.Collections.ObjectModel;
using System.Composition;
+using System.Linq;
+using System.Reactive.Linq;
using AvalonStudio.Extensibility;
using AvalonStudio.Shell;
+using NBitcoin;
using ReactiveUI;
using WalletWasabi.Gui.ViewModels;
+using WalletWasabi.Models;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -12,9 +16,30 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
private ObservableCollection<WalletActionViewModel> _actions;
+ private string _title;
+ public override string Title
+ {
+ get { return _title; }
+ set { this.RaiseAndSetIfChanged(ref _title, value); }
+ }
public WalletViewModel(string name, bool receiveDominant)
: base(name)
{
+ var coinsChanged = Observable.FromEventPattern(Global.WalletService.Coins, nameof(Global.WalletService.Coins.HashSetChanged));
+ var newBlockProcessed = Observable.FromEventPattern(Global.WalletService, nameof(Global.WalletService.NewBlockProcessed));
+ var coinSpent = Observable.FromEventPattern(Global.WalletService, nameof(Global.WalletService.CoinSpentOrSpenderConfirmed));
+
+ coinsChanged
+ .Merge(newBlockProcessed)
+ .Merge(coinSpent)
+ .ObserveOn(RxApp.MainThreadScheduler)
+ .Subscribe(o =>
+ {
+ SetBalance(name);
+ });
+
+ SetBalance(name);
+
if (receiveDominant)
{
_actions = new ObservableCollection<WalletActionViewModel>
@@ -49,5 +74,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
get { return _actions; }
set { this.RaiseAndSetIfChanged(ref _actions, value); }
}
+
+ private void SetBalance(string walletName)
+ {
+ Money balance = Global.WalletService.Coins.Where(c => c.Unspent).Sum(c => (long?) c.Amount) ?? 0;
+ Title = $"{walletName} ({balance})";
+ }
}
}

Added the balance to the wallet name

Balance is now appended to the end of the wallet name.