use helper to display errors, warnings and success messages.
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/CoinJoinTabViewModel.cs
@@ -18,6 +18,7 @@ using WalletWasabi.Services;
using WalletWasabi.Models;
using WalletWasabi.CoinJoin.Common.Models;
using WalletWasabi.CoinJoin.Client.Rounds;
+using WalletWasabi.Gui.Helpers;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -182,11 +183,9 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
IsDequeueBusy = true;
try
{
- SetWarningMessage("");
-
if (!selectedCoins.Any())
{
- SetWarningMessage("No coins are selected to dequeue.");
+ NotificationHelpers.Warning("No coins are selected to dequeue.");
return;
}
@@ -205,7 +204,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
builder.Append(Environment.NewLine + iex.ToTypeMessageString());
}
}
- SetWarningMessage(builder.ToString());
+ NotificationHelpers.Error(builder.ToString());
}
}
finally
@@ -219,11 +218,9 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
IsEnqueueBusy = true;
try
{
- SetWarningMessage("");
-
if (!selectedCoins.Any())
{
- SetWarningMessage("No coins are selected to enqueue.");
+ NotificationHelpers.Warning("No coins are selected to enqueue.");
return;
}
try
@@ -233,7 +230,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (compatiblityPassword != null)
{
Password = compatiblityPassword;
- SetWarningMessage(PasswordHelper.CompatibilityPasswordWarnMessage);
+ NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage);
}
await Global.ChaumianClient.QueueCoinsToMixAsync(Password, selectedCoins.Select(c => c.Model).ToArray());
@@ -249,7 +246,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
builder.Append(Environment.NewLine + iex.ToTypeMessageString());
}
}
- SetWarningMessage(builder.ToString());
+ NotificationHelpers.Warning(builder.ToString());
}
Password = string.Empty;

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/PinPadViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/PinPadViewModel.cs
@@ -12,6 +12,7 @@ using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using WalletWasabi.Gui.Helpers;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Hwi;
using WalletWasabi.Hwi.Models;
@@ -71,7 +72,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private void OnException(Exception ex)
{
- SetWarningMessage(ex.ToTypeMessageString());
+ NotificationHelpers.Error(ex.ToTypeMessageString());
}
public static async Task UnlockAsync(Global global)

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/ReceiveTabViewModel.cs
@@ -13,6 +13,7 @@ using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.Analysis.Clustering;
using WalletWasabi.Blockchain.Keys;
+using WalletWasabi.Gui.Helpers;
using WalletWasabi.Gui.Tabs.WalletManager;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Hwi;
@@ -174,7 +175,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.Merge(CopyAddress.ThrownExceptions)
.Merge(CopyLabel.ThrownExceptions)
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(ex => SetWarningMessage(ex.ToTypeMessageString()))
+ .Subscribe(ex => NotificationHelpers.Error(ex.ToTypeMessageString()))
.DisposeWith(Disposables);
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendTabViewModel.cs
@@ -23,6 +23,7 @@ using WalletWasabi.Blockchain.TransactionBuilding;
using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Blockchain.Transactions;
using WalletWasabi.Exceptions;
+using WalletWasabi.Gui.Helpers;
using WalletWasabi.Gui.Models;
using WalletWasabi.Gui.Tabs.WalletManager;
using WalletWasabi.Gui.ViewModels;
@@ -244,7 +245,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Label = label;
if (!IsMax && label.IsEmpty)
{
- SetWarningMessage($"{nameof(Label)} is required.");
+ NotificationHelpers.Warning($"{nameof(Label)} is required.");
return;
}
@@ -253,7 +254,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (!selectedCoinReferences.Any())
{
- SetWarningMessage("No coins are selected to spend.");
+ NotificationHelpers.Warning("No coins are selected to spend.");
return;
}
@@ -264,7 +265,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (FormatException)
{
- SetWarningMessage("Invalid address.");
+ NotificationHelpers.Warning("Invalid address.");
return;
}
@@ -277,13 +278,13 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
if (!Money.TryParse(AmountText, out Money amount) || amount == Money.Zero)
{
- SetWarningMessage("Invalid amount.");
+ NotificationHelpers.Warning("Invalid amount.");
return;
}
if (amount == selectedCoinViewModels.Sum(x => x.Amount))
{
- SetWarningMessage("Looks like you want to spend a whole coin. Try Max button instead.");
+ NotificationHelpers.Warning("Looks like you want to spend a whole coin. Try Max button instead.");
return;
}
moneyRequest = MoneyRequest.Create(amount);
@@ -291,7 +292,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (FeeRate is null || FeeRate.SatoshiPerByte < 1)
{
- SetWarningMessage("Invalid fee rate, must be greater than or equal to one.");
+ NotificationHelpers.Warning("Invalid fee rate, must be greater than or equal to one.");
return;
}
@@ -309,7 +310,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch
{
- SetWarningMessage("Spending coins that are being actively mixed is not allowed.");
+ NotificationHelpers.Warning("Spending coins that are being actively mixed is not allowed.");
return;
}
finally
@@ -330,7 +331,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (Exception ex)
{
- SetWarningMessage(ex.ToTypeMessageString());
+ NotificationHelpers.Error(ex.ToTypeMessageString());
return;
}
}
@@ -384,7 +385,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (Exception ex)
{
- SetWarningMessage(ex.ToTypeMessageString());
+ NotificationHelpers.Error(ex.ToTypeMessageString());
return;
}
finally
@@ -407,15 +408,15 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
catch (InsufficientBalanceException ex)
{
Money needed = ex.Minimum - ex.Actual;
- SetWarningMessage($"Not enough coins selected. You need an estimated {needed.ToString(false, true)} BTC more to make this transaction.");
+ NotificationHelpers.Warning($"Not enough coins selected. You need an estimated {needed.ToString(false, true)} BTC more to make this transaction.");
}
catch (HttpRequestException ex)
{
- SetWarningMessage(ex.ToUserFriendlyString());
+ NotificationHelpers.Error(ex.ToUserFriendlyString());
}
catch (Exception ex)
{
- SetWarningMessage(ex.ToTypeMessageString());
+ NotificationHelpers.Error(ex.ToTypeMessageString());
}
finally
{
@@ -456,7 +457,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
.Merge(FeeSliderClickedCommand.ThrownExceptions)
.Merge(HighLightFeeSliderCommand.ThrownExceptions)
.ObserveOn(RxApp.MainThreadScheduler)
- .Subscribe(ex => SetWarningMessage(ex.ToTypeMessageString()));
+ .Subscribe(ex => NotificationHelpers.Error(ex.ToTypeMessageString()));
}
private void SetSendText()
@@ -706,7 +707,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
ResetUi();
- SetSuccessMessage(successMessage);
+ NotificationHelpers.Success(successMessage);
}
catch (Exception ex)
{
@@ -738,13 +739,9 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
if (!selectedCoins.Any())
{
- SetWarningMessage("No coins are selected to dequeue.");
+ NotificationHelpers.Warning("No coins are selected to dequeue.");
return;
}
- else
- {
- SetWarningMessage("");
- }
try
{
@@ -761,7 +758,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
builder.Append(Environment.NewLine + iex.ToTypeMessageString());
}
}
- SetWarningMessage(builder.ToString());
+ NotificationHelpers.Error(builder.ToString());
}
}

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionBroadcasterViewModel.cs
@@ -14,6 +14,7 @@ using System.Reactive.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.Transactions;
+using WalletWasabi.Gui.Helpers;
using WalletWasabi.Gui.Models;
using WalletWasabi.Gui.ViewModels;
using WalletWasabi.Helpers;
@@ -142,7 +143,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (Exception ex)
{
- SetWarningMessage(ex.ToTypeMessageString());
+ NotificationHelpers.Error(ex.ToTypeMessageString());
Logger.LogError(ex);
}
},
@@ -155,7 +156,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private void OnException(Exception ex)
{
- SetWarningMessage(ex.ToTypeMessageString());
+ NotificationHelpers.Error(ex.ToTypeMessageString());
}
public override void OnOpen()
@@ -201,12 +202,12 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
MainWindowViewModel.Instance.StatusBar.TryAddStatus(StatusBarStatus.BroadcastingTransaction);
await Task.Run(async () => await Global.TransactionBroadcaster.SendTransactionAsync(transaction));
- SetSuccessMessage("Transaction is successfully sent!");
+ NotificationHelpers.Success("Transaction is successfully sent!");
TransactionString = "";
}
catch (PSBTException ex)
{
- SetWarningMessage($"The PSBT cannot be finalized: {ex.Errors.FirstOrDefault()}");
+ NotificationHelpers.Error($"The PSBT cannot be finalized: {ex.Errors.FirstOrDefault()}");
}
catch (Exception ex)
{

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/TransactionViewerViewModel.cs
@@ -12,6 +12,7 @@ using System.Reactive.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
using WalletWasabi.Blockchain.TransactionBuilding;
+using WalletWasabi.Gui.Helpers;
using WalletWasabi.Logging;
using WalletWasabi.Models;
@@ -102,7 +103,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (Exception ex)
{
- SetWarningMessage(ex.ToTypeMessageString());
+ NotificationHelpers.Error(ex.ToTypeMessageString());
Logger.LogError(ex);
}
},
@@ -111,7 +112,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private void OnException(Exception ex)
{
- SetWarningMessage(ex.ToTypeMessageString());
+ NotificationHelpers.Error(ex.ToTypeMessageString());
}
public override void OnOpen()

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletInfoViewModel.cs
@@ -11,6 +11,7 @@ using WalletWasabi.Gui.ViewModels.Validation;
using WalletWasabi.Helpers;
using WalletWasabi.Services;
using WalletWasabi.Models;
+using WalletWasabi.Gui.Helpers;
namespace WalletWasabi.Gui.Controls.WalletExplorer
{
@@ -28,7 +29,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
public WalletInfoViewModel(WalletViewModel walletViewModel) : base(walletViewModel.Name, walletViewModel)
{
ClearSensitiveData(true);
- SetWarningMessage("");
ToggleSensitiveKeysCommand = ReactiveCommand.Create(() =>
{
@@ -45,7 +45,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
if (isCompatibilityPasswordUsed != null)
{
- SetWarningMessage(PasswordHelper.CompatibilityPasswordWarnMessage);
+ NotificationHelpers.Warning(PasswordHelper.CompatibilityPasswordWarnMessage);
}
string master = secret.GetWif(Global.Network).ToWif();
@@ -57,7 +57,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
}
catch (Exception ex)
{
- SetWarningMessage(ex.ToTypeMessageString());
+ NotificationHelpers.Error(ex.ToTypeMessageString());
}
});
}

use helper to display errors, warnings and success messages.