Add "Max. decimal places" setting

This commit is contained in:
SysC0mp 2020-02-26 20:46:27 +01:00
parent 54191d6d88
commit f18256ab39
4 changed files with 24 additions and 9 deletions

View file

@ -9,5 +9,6 @@ namespace Wox.Plugin.Caculator
public class Settings
{
public DecimalSeparator DecimalSeparator { get; set; } = DecimalSeparator.UseSystemLocale;
public int MaxDecimalPlaces { get; set; } = 10;
}
}

View file

@ -20,6 +20,8 @@ namespace Wox.Plugin.Caculator.ViewModels
public Settings Settings { get; set; }
public IEnumerable<int> MaxDecimalPlacesRange => Enumerable.Range(1, 20);
public void Save()
{
_storage.Save();

View file

@ -3,11 +3,10 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Wox.Plugin.Caculator.Views"
xmlns:infrastructure="clr-namespace:Wox.Infrastructure;assembly=Wox.Infrastructure"
xmlns:ui="clr-namespace:Wox.Infrastructure.UI;assembly=Wox.Infrastructure"
xmlns:calculator="clr-namespace:Wox.Plugin.Caculator"
xmlns:core="clr-namespace:Wox.Core;assembly=Wox.Core"
xmlns:viewModels="clr-namespace:Wox.Plugin.Caculator.ViewModels"
mc:Ignorable="d"
Loaded="CalculatorSettings_Loaded"
d:DesignHeight="450" d:DesignWidth="800">
@ -19,18 +18,19 @@
<Border BorderBrush="Gray" Margin="10" BorderThickness="1">
<Grid Margin="10">
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="3*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="{DynamicResource wox_plugin_calculator_output_decimal_seperator}" VerticalAlignment="Center" />
<ComboBox Grid.Column="1"
<ComboBox x:Name="DecimalSeparatorComboBox"
Grid.Column="1"
Grid.Row="0"
x:Name="DecimalSeparatorComboBox"
Width="200"
Margin="0 5 0 5"
HorizontalAlignment="Left"
SelectedItem="{Binding Settings.DecimalSeparator}"
ItemsSource="{Binding Source={ui:EnumBindingSource {x:Type calculator:DecimalSeparator}}}">
@ -40,6 +40,17 @@
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBlock Grid.Column="0" Grid.Row="1" Text="Decimal places" VerticalAlignment="Center" />
<ComboBox x:Name="MaxDecimalPlaces"
Grid.Column="1"
Grid.Row="1"
Margin="0 5 0 5"
HorizontalAlignment="Left"
SelectedItem="{Binding Settings.MaxDecimalPlaces}"
ItemsSource="{Binding MaxDecimalPlacesRange}">
</ComboBox>
</Grid>
</Border>
</UserControl>

View file

@ -21,8 +21,8 @@ namespace Wox.Plugin.Caculator.Views
/// </summary>
public partial class CalculatorSettings : UserControl
{
private SettingsViewModel _viewModel;
private Settings _settings;
private readonly SettingsViewModel _viewModel;
private readonly Settings _settings;
public CalculatorSettings(SettingsViewModel viewModel)
{
@ -35,6 +35,7 @@ namespace Wox.Plugin.Caculator.Views
private void CalculatorSettings_Loaded(object sender, RoutedEventArgs e)
{
DecimalSeparatorComboBox.SelectedItem = _settings.DecimalSeparator;
MaxDecimalPlaces.SelectedItem = _settings.MaxDecimalPlaces;
}
}