DualCurrencyEntryBox - Caret offset fixes
MODIFY
WalletWasabi.Fluent/Controls/CurrencyEntryBox.axaml
WalletWasabi.Fluent/Controls/CurrencyEntryBox.axaml
<Setter Property="Foreground" Value="{DynamicResource TextControlForegroundFocused}" />
</Style>
- <Style
- Selector="c|CurrencyEntryBox:focus /template/ TextBlock#PART_Watermark">
+ <Style Selector="c|CurrencyEntryBox:focus /template/ TextBlock#PART_Watermark">
<Setter Property="Foreground" Value="{DynamicResource TextControlPlaceholderForegroundFocused}" />
</Style>
+
+ <Style Selector="c|CurrencyEntryBox:isrightside">
+ <Setter Property="TextAlignment" Value="Right"/>
+ <Setter Property="HorizontalContentAlignment" Value="Right"/>
+ </Style>
+
+ <!-- Correct caret offset for empty boxes so that it fits nicely with the different watermarks -->
+ <Style Selector="c|CurrencyEntryBox:empty /template/ TextPresenter#PART_TextPresenter">
+ <Setter Property="Margin" Value="0 0 0 0"/>
+ </Style>
+ <Style Selector="c|CurrencyEntryBox:empty:isfiat /template/ TextPresenter#PART_TextPresenter">
+ <Setter Property="Margin" Value="13 0 0 0"/>
+ </Style>
+ <Style Selector="c|CurrencyEntryBox:empty:isrightside /template/ TextPresenter#PART_TextPresenter">
+ <Setter Property="Margin" Value="0 0 40 0"/>
+ </Style>
+ <Style Selector="c|CurrencyEntryBox:empty:isrightside:isfiat /template/ TextPresenter#PART_TextPresenter">
+ <Setter Property="Margin" Value="0 0 63 0"/>
+ </Style>
+
</Styles>

MODIFY
WalletWasabi.Fluent/Controls/CurrencyEntryBox.axaml.cs
WalletWasabi.Fluent/Controls/CurrencyEntryBox.axaml.cs
@@ -26,7 +26,10 @@ public class CurrencyEntryBox : TextBox
AvaloniaProperty.Register<CurrencyEntryBox, bool>(nameof(IsApproximate));
public static readonly StyledProperty<decimal> ConversionRateProperty =
- AvaloniaProperty.Register<DualCurrencyEntryBox, decimal>(nameof(ConversionRate));
+ AvaloniaProperty.Register<CurrencyEntryBox, decimal>(nameof(ConversionRate));
+
+ public static readonly StyledProperty<bool> IsRightSideProperty =
+ AvaloniaProperty.Register<CurrencyEntryBox, bool>(nameof(IsRightSide));
private readonly CultureInfo _customCultureInfo;
private readonly char _decimalSeparator = '.';
@@ -69,11 +72,16 @@ public class CurrencyEntryBox : TextBox
$"[{_groupSeparator}{_decimalSeparator}]+", RegexOptions.Compiled);
PseudoClasses.Set(":noexchangerate", true);
+ PseudoClasses.Set(":isrightside", false);
+
+ this.GetObservable(IsRightSideProperty)
+ .Subscribe(x => PseudoClasses.Set(":isrightside", x));
ModifiedPaste = ReactiveCommand.Create(ModifiedPasteAsync, this.GetObservable(CanPasteProperty));
}
public ICommand ModifiedPaste { get; }
+
public decimal ConversionRate
{
get => GetValue(ConversionRateProperty);
@@ -98,6 +106,12 @@ public class CurrencyEntryBox : TextBox
set => SetValue(IsApproximateProperty, value);
}
+ public bool IsRightSide
+ {
+ get => GetValue(IsRightSideProperty);
+ set => SetValue(IsRightSideProperty, value);
+ }
+
private decimal FiatToBitcoin(decimal fiatValue)
{
return fiatValue / ConversionRate;
@@ -293,5 +307,9 @@ public class CurrencyEntryBox : TextBox
{
PseudoClasses.Set(":noexchangerate", change.NewValue.GetValueOrDefault<decimal>() == 0m);
}
+ else if (change.Property == IsFiatProperty)
+ {
+ PseudoClasses.Set(":isfiat", change.NewValue.GetValueOrDefault<bool>());
+ }
}
}

MODIFY
WalletWasabi.Fluent/Controls/DualCurrencyEntryBox.axaml
WalletWasabi.Fluent/Controls/DualCurrencyEntryBox.axaml
IsApproximate="False"
Grid.Column="{TemplateBinding LeftColumn}"
Background="Transparent"
- BorderThickness="0"/>
+ BorderThickness="0"
+ IsRightSide="{TemplateBinding IsConversionReversed}"/>
<Button x:Name="PART_SwapButton" Focusable="False"
HorizontalAlignment="Center" VerticalAlignment="Center" Background="Transparent"
IsApproximate="{TemplateBinding IsConversionApproximate}"
Grid.Column="{TemplateBinding RightColumn}"
Background="Transparent"
- BorderThickness="0"/>
+ BorderThickness="0"
+ IsRightSide="{TemplateBinding IsConversionReversed, Converter={x:Static BoolConverters.Not}}"/>
</Grid>
</Panel>
</Panel>

MODIFY
WalletWasabi.Fluent/Controls/DualCurrencyEntryBox.axaml.cs
WalletWasabi.Fluent/Controls/DualCurrencyEntryBox.axaml.cs
@@ -372,20 +372,11 @@ public class DualCurrencyEntryBox : UserControl
if (IsConversionReversed)
{
- _leftEntryBox.TextAlignment = Avalonia.Media.TextAlignment.Right;
- _rightEntryBox.TextAlignment = Avalonia.Media.TextAlignment.Left;
- _leftEntryBox.HorizontalContentAlignment = Avalonia.Layout.HorizontalAlignment.Right;
- _rightEntryBox.HorizontalContentAlignment = Avalonia.Layout.HorizontalAlignment.Left;
-
grid?.Children.Add(_rightEntryBox);
grid?.Children.Add(_leftEntryBox);
}
else
{
- _leftEntryBox.TextAlignment = Avalonia.Media.TextAlignment.Left;
- _rightEntryBox.TextAlignment = Avalonia.Media.TextAlignment.Right;
- _leftEntryBox.HorizontalContentAlignment = Avalonia.Layout.HorizontalAlignment.Left;
- _rightEntryBox.HorizontalContentAlignment = Avalonia.Layout.HorizontalAlignment.Right;
grid?.Children.Add(_leftEntryBox);
grid?.Children.Add(_rightEntryBox);
}

DualCurrencyEntryBox - Caret offset fixes