Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BooleanStringConverter #1823

Merged
merged 4 commits into from Jul 7, 2019
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -8,7 +8,7 @@
xmlns:local="clr-namespace:WalletWasabi.Gui.Controls.WalletExplorer;assembly=WalletWasabi.Gui">
<UserControl.Resources>
<converters:AmountForegroundConverter x:Key="AmountForegroundConverter" />
<converters:MaxClearBoolStringConverter x:Key="MaxClearBoolStringConverter" />
<converters:BooleanStringConverter x:Key="BooleanStringConverter" />
</UserControl.Resources>
<i:Interaction.Behaviors>
<behaviors:ClearPropertyOnLostFocusBehavior TargetProperty="{Binding SelectedCoin}" />
@@ -58,7 +58,7 @@
</ItemsControl>
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10">
<Button Content="{Binding IsMax, Converter={StaticResource MaxClearBoolStringConverter}}" Command="{Binding MaxCommand}" VerticalAlignment="Top" Height="40" />
<Button Content="{Binding IsMax, Converter={StaticResource BooleanStringConverter}, ConverterParameter=Clear:Max}" Command="{Binding MaxCommand}" VerticalAlignment="Top" Height="40" />
<controls:ExtendedTextBox Foreground="{Binding IsMax, Converter={StaticResource AmountForegroundConverter}}" IsReadOnly="{Binding IsMax}" Text="{Binding Amount}" ToolTip.Tip="{Binding AmountToolTip}" Watermark="{Binding AmountWatermarkText}" UseFloatingWatermark="True" MinWidth="124" MinHeight="46" />
<StackPanel>
<StackPanel Orientation="Horizontal" Spacing="10">
@@ -6,7 +6,7 @@
xmlns:converters="clr-namespace:WalletWasabi.Gui.Converters;assembly=WalletWasabi.Gui">
<UserControl.Resources>
<converters:LurkingWifeModeStringConverter x:Key="LurkingWifeModeStringConverter" />
<converters:ShowHideSensitiveKeysBoolConverter x:Key="ShowHideSensitiveKeysBoolConverter" />
<converters:BooleanStringConverter x:Key="BooleanStringConverter" />
</UserControl.Resources>
<controls:GroupBox Title="{Binding Title}" BorderThickness="0" Classes="docTabContainer">
<StackPanel>
@@ -60,7 +60,8 @@
</i:Interaction.Behaviors>
</controls:NoparaPasswordBox>
<DockPanel VerticalAlignment="Top" LastChildFill="True">
<Button Content="{Binding ShowSensitiveKeys, Converter={StaticResource ShowHideSensitiveKeysBoolConverter}}" Command="{Binding ToggleSensitiveKeysCommand}" DockPanel.Dock="Right" />
<Button Content="{Binding ShowSensitiveKeys, StringFormat=\{0\} Sensitive Keys, Converter={StaticResource BooleanStringConverter}, ConverterParameter=Hide:Show}"
Command="{Binding ToggleSensitiveKeysCommand}" DockPanel.Dock="Right" />
<Grid></Grid>
</DockPanel>
<TextBlock Text="{Binding WarningMessage}" Classes="warningMessage" />
@@ -4,13 +4,26 @@

namespace WalletWasabi.Gui.Converters
{
public class BooleanOnOffConverter : IValueConverter
public class BooleanStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool on)
{
return on ? "On" : "Off";
if (parameter is string str)
{
var options = str.Split(':');
if (options.Length < 2)
{
throw new ArgumentException("Two options are required by the converter.", nameof(parameter));
}

return on ? options[0] : options[1];
}
else
{
throw new TypeArgumentException(parameter, typeof(string), nameof(parameter));
}
}
else
{

This file was deleted.

This file was deleted.

@@ -3,7 +3,7 @@
xmlns:controls="clr-namespace:WalletWasabi.Gui.Controls;assembly=WalletWasabi.Gui"
xmlns:converters="clr-namespace:WalletWasabi.Gui.Converters;assembly=WalletWasabi.Gui">
<UserControl.Resources>
<converters:BooleanOnOffConverter x:Key="BooleanOnOffConverter" />
<converters:BooleanStringConverter x:Key="BooleanStringConverter" />
</UserControl.Resources>

<ScrollViewer>
@@ -41,7 +41,7 @@
<controls:GroupBox Title="Tor" TextBlock.FontSize="16" Padding="10" Margin="0 5 10 5">
<StackPanel Orientation="Vertical" Spacing="5">
<StackPanel Margin="0 10" Orientation="Horizontal" Spacing="5">
<ToggleButton IsChecked="{Binding UseTor}" Content="{Binding UseTor, Converter={StaticResource BooleanOnOffConverter}}" Margin="0 0 10 0" />
<ToggleButton IsChecked="{Binding UseTor}" Content="{Binding UseTor, Converter={StaticResource BooleanStringConverter}, ConverterParameter=On:Off}" Margin="0 0 10 0" />
<TextBlock VerticalAlignment="Center">Tor can be turned off for debugging.</TextBlock>
</StackPanel>
<StackPanel Margin="0 10" Spacing="5">
@@ -58,11 +58,11 @@
<controls:GroupBox Title="UI" TextBlock.FontSize="16" Padding="10" Margin="0 5 10 5">
<StackPanel Orientation="Vertical" Spacing="5">
<StackPanel Margin="0 10" Orientation="Horizontal" Spacing="5">
<ToggleButton IsChecked="{Binding Autocopy}" Content="{Binding Autocopy, Converter={StaticResource BooleanOnOffConverter}}}" Margin="0 0 10 0" />
<ToggleButton IsChecked="{Binding Autocopy}" Content="{Binding Autocopy, Converter={StaticResource BooleanStringConverter}, ConverterParameter=On:Off}" Margin="0 0 10 0" />
<TextBlock VerticalAlignment="Center">Autocopy on Receive and History wallet tabs.</TextBlock>
</StackPanel>
<StackPanel Margin="0 10" Orientation="Horizontal" Spacing="5">
<ToggleButton IsChecked="{Binding LurkingWifeMode}" Content="{Binding LurkingWifeMode, Converter={StaticResource BooleanOnOffConverter}}}" Margin="0 0 10 0" Command="{Binding LurkingWifeModeCommand}" />
<ToggleButton IsChecked="{Binding LurkingWifeMode}" Content="{Binding LurkingWifeMode, Converter={StaticResource BooleanStringConverter}, ConverterParameter=On:Off}" Margin="0 0 10 0" Command="{Binding LurkingWifeModeCommand}" />
<TextBlock VerticalAlignment="Center">Lurking Wife Mode hides sensitive content.</TextBlock>
</StackPanel>
</StackPanel>
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.