Show amount in USD in tooltip
MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlView.xaml
WalletWasabi.Gui/Controls/WalletExplorer/SendControlView.xaml
<converters:AmountForegroundConverter x:Key="AmountForegroundConverter" />
<converters:BooleanStringConverter x:Key="BooleanStringConverter" />
<converters:FeeTargetTimeConverter x:Key="FeeTargetTimeConverter" />
- <converters:UsdExchangeRateAmountToolTipConverter x:Key="UsdExchangeRateAmountToolTipConverter" />
</UserControl.Resources>
<i:Interaction.Behaviors>
<behaviors:ClearPropertyOnLostFocusBehavior TargetProperty="{Binding SelectedCoin}" />
Foreground="{Binding AmountText, Converter={StaticResource AmountForegroundConverter}}"
IsReadOnly="{Binding IsMax}"
Text="{Binding AmountText, Mode=TwoWay}"
- ToolTip.Tip="{Binding UsdExchangeRate, Converter={StaticResource UsdExchangeRateAmountToolTipConverter}}"
- Watermark="{Binding AmountWatermarkText}"
+ ToolTip.Tip="{Binding AmountTip}"
+ Watermark="Amount (BTC)"
UseFloatingWatermark="True"
MinWidth="124">
<i:Interaction.Behaviors>

MODIFY
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
WalletWasabi.Gui/Controls/WalletExplorer/SendControlViewModel.cs
@@ -54,10 +54,10 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private string _customChangeAddress;
private string _labelToolTip;
private string _feeToolTip;
- private string _amountWaterMarkText;
private bool _isBusy;
private bool _isHardwareBusy;
private bool _isCustomFee;
+ private string _amountTip;
private const string WaitingForHardwareWalletButtonTextString = "Waiting for Hardware Wallet...";
@@ -80,7 +80,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
this.ValidateProperty(x => x.UserFeeText, ValidateUserFeeText);
ResetUi();
- SetAmountWatermark(Money.Zero);
CoinList = new CoinListViewModel(Wallet, displayCommonOwnershipWarning: true);
@@ -102,11 +101,11 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
{
if (Money.TryParse(x.TrimStart('~', ' '), out Money amountBtc))
{
- SetAmountWatermark(amountBtc);
+ AmountTip = amountBtc.ToUsdString(Wallet.Synchronizer.UsdExchangeRate, Global.UiConfig.LurkingWifeMode);
}
else
{
- SetAmountWatermark(Money.Zero);
+ AmountTip = "0 USD";
}
SetFees();
@@ -558,12 +557,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
set => this.RaiseAndSetIfChanged(ref _feeToolTip, value);
}
- public string AmountWatermarkText
- {
- get => _amountWaterMarkText;
- set => this.RaiseAndSetIfChanged(ref _amountWaterMarkText, value);
- }
-
public bool IsSliderFeeUsed
{
get => _isSliderFeeUsed;
@@ -582,6 +575,12 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
private set => this.RaiseAndSetIfChanged(ref _isCustomFee, value);
}
+ public string AmountTip
+ {
+ get => _amountTip;
+ set => this.RaiseAndSetIfChanged(ref _amountTip, value);
+ }
+
public bool IsCustomChangeAddressVisible => Global.UiConfig.IsCustomChangeAddress && !IsMax;
public ReactiveCommand<Unit, Unit> BuildTransactionCommand { get; }
@@ -612,30 +611,6 @@ namespace WalletWasabi.Gui.Controls.WalletExplorer
AmountText = "0.0";
}
- private void SetAmountWatermark(Money amount)
- {
- if (amount == Money.Zero)
- {
- AmountWatermarkText = "Amount (BTC)";
- }
- else
- {
- long amountUsd = 0;
- try
- {
- amountUsd = (long)amount.ToUsd(UsdExchangeRate);
- }
- catch (OverflowException ex)
- {
- Logger.LogTrace(ex);
- }
-
- AmountWatermarkText = amountUsd != 0
- ? $"Amount (BTC) ~ ${amountUsd}"
- : "Amount (BTC)";
- }
- }
-
private void ChangeFeeRateDisplay()
{
var nextval = (from FeeDisplayFormat val in Enum.GetValues(typeof(FeeDisplayFormat))

DELETE
WalletWasabi.Gui/Converters/UsdExchangeRateAmountToolTipConverter.cs
-using Avalonia.Data.Converters;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Text;
-using WalletWasabi.Exceptions;
-
-namespace WalletWasabi.Gui.Converters
-{
- public class UsdExchangeRateAmountToolTipConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is decimal usdExchangeRate)
- {
- return $"Exchange Rate: {(long)usdExchangeRate} USD/BTC.";
- }
- else
- {
- throw new TypeArgumentException(value, typeof(decimal), nameof(value));
- }
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotSupportedException();
- }
- }
-}

Show amount in USD in tooltip