Allow Confirmed property to be observed via INPC
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinViewModel.cs
@@ -3,20 +3,23 @@ using System.Collections.Generic;
using System.Text;
using WalletWasabi.Gui.ViewModels;
using ReactiveUI;
+using WalletWasabi.Models;
+using NBitcoin;
+using System.Reactive.Linq;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
public class CoinViewModel : ViewModelBase
{
- private bool _confirmed;
private bool _isSelected;
- private string _amountBtc;
- private string _label;
+ private SmartCoin _model;
private int _privacyLevel;
private string _history;
- public CoinViewModel(CoinListViewModel owner)
+ public CoinViewModel(CoinListViewModel owner, SmartCoin model)
{
+ _model = model;
+
this.WhenAnyValue(x => x.IsSelected).Subscribe(selected =>
{
if (selected)
@@ -31,31 +34,26 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
owner.SelectedCoins.Remove(this);
}
});
- }
- public bool Confirmed
+ model.WhenAnyValue(x => x.Confirmed).ObserveOn(RxApp.MainThreadScheduler).Subscribe(confirmed =>
{
- get { return _confirmed; }
- set { this.RaiseAndSetIfChanged(ref _confirmed, value); }
+ this.RaisePropertyChanged(nameof(Confirmed));
+ });
}
+ public bool Confirmed => _model.Confirmed;
+
public bool IsSelected
{
get { return _isSelected; }
set { this.RaiseAndSetIfChanged(ref _isSelected, value); }
}
- public string AmountBtc
- {
- get { return _amountBtc; }
- set { this.RaiseAndSetIfChanged(ref _amountBtc, value); }
- }
+ public Money Amount => _model.Amount;
- public string Label
- {
- get { return _label; }
- set { this.RaiseAndSetIfChanged(ref _label, value); }
- }
+ public string AmountBtc => _model.Amount.ToString(false, true);
+
+ public string Label => _model.Label;
public int PrivacyLevel
{

MODIFY
WalletWasabi/Models/SmartCoin.cs
WalletWasabi/Models/SmartCoin.cs
@@ -3,6 +3,7 @@ using WalletWasabi.Helpers;
using NBitcoin;
using Newtonsoft.Json;
using System;
+using System.ComponentModel;
namespace WalletWasabi.Models
{
@@ -10,8 +11,10 @@ namespace WalletWasabi.Models
/// An UTXO that knows more.
/// </summary>
[JsonObject(MemberSerialization.OptIn)]
- public class SmartCoin : IEquatable<SmartCoin>
+ public class SmartCoin : IEquatable<SmartCoin>, INotifyPropertyChanged
{
+ private Height _height;
+
[JsonProperty(Order = 1)]
[JsonConverter(typeof(Uint256JsonConverter))]
public uint256 TransactionId { get; }
@@ -29,7 +32,19 @@ namespace WalletWasabi.Models
[JsonProperty(Order = 5)]
[JsonConverter(typeof(HeightJsonConverter))]
- public Height Height { get; set; }
+ public Height Height
+ {
+ get { return _height; }
+ set
+ {
+ if (value != _height)
+ {
+ _height = value;
+
+ PropertyChanged(this, new PropertyChangedEventArgs(nameof(Confirmed)));
+ }
+ }
+ }
[JsonProperty(Order = 6)]
public string Label { get; set; }
@@ -103,6 +118,8 @@ namespace WalletWasabi.Models
Secret = null;
}
+ public event PropertyChangedEventHandler PropertyChanged;
+
public Coin GetCoin()
{
return new Coin(TransactionId, Index, Amount, ScriptPubKey);

Allow Confirmed property to be observed via INPC