Add currency formatter
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/WalletViewModel.cs
@@ -11,6 +11,7 @@ using System.Reactive.Disposables;
using System.Reactive.Linq;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Gui.ViewModels;
+using WalletWasabi.Helpers;
using WalletWasabi.Logging;
using WalletWasabi.Wallets;
@@ -43,8 +44,7 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
Money balance = Wallet.Coins.TotalAmount();
Title = $"{WalletName} ({(UiConfig.LurkingWifeMode ? "#########" : balance.ToString(false, true))} BTC)";
- var dollars = Wallet.Synchronizer.UsdExchangeRate * balance.ToDecimal(MoneyUnit.BTC);
- TitleTip = UiConfig.LurkingWifeMode ? "### USD" : Wallet.Synchronizer.UsdExchangeRate == default ? "??? USD" : $"{dollars:.00} USD";
+ TitleTip = balance.ToUsd(Wallet.Synchronizer.UsdExchangeRate, UiConfig.LurkingWifeMode);
}
catch (Exception ex)
{

ADD
WalletWasabi/Helpers/StringFormatHelpers.cs
+using NBitcoin;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Text;
+
+namespace WalletWasabi.Helpers
+{
+ public static class StringFormatHelpers
+ {
+ private static NumberFormatInfo CurrencyNumberFormat = new NumberFormatInfo()
+ {
+ NumberGroupSeparator = " ",
+ NumberDecimalDigits = 0
+ };
+
+ private static string ToCurrency(this Money btc, string currency, decimal exchangeRate, bool lurkingWifeMode = false)
+ {
+ var dollars = exchangeRate * btc.ToDecimal(MoneyUnit.BTC);
+
+ return lurkingWifeMode
+ ? $"### {currency}"
+ : exchangeRate == default
+ ? $"??? {currency}"
+ : $"{dollars.ToString("N", CurrencyNumberFormat)} {currency}";
+ }
+
+ public static string ToUsd(this Money btc, decimal usdExchangeRate, bool lurkingWifeMode = false)
+ {
+ return ToCurrency(btc, "USD", usdExchangeRate, lurkingWifeMode);
+ }
+ }
+}

Add currency formatter