Skip to content

Commit f18256a

Browse files
committed
Add "Max. decimal places" setting
1 parent 54191d6 commit f18256a

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

Plugins/Wox.Plugin.Calculator/Settings.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ namespace Wox.Plugin.Caculator
99
public class Settings
1010
{
1111
public DecimalSeparator DecimalSeparator { get; set; } = DecimalSeparator.UseSystemLocale;
12+
public int MaxDecimalPlaces { get; set; } = 10;
1213
}
1314
}

Plugins/Wox.Plugin.Calculator/ViewModels/SettingsViewModel.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public SettingsViewModel()
2020

2121
public Settings Settings { get; set; }
2222

23+
public IEnumerable<int> MaxDecimalPlacesRange => Enumerable.Range(1, 20);
24+
2325
public void Save()
2426
{
2527
_storage.Save();

Plugins/Wox.Plugin.Calculator/Views/CalculatorSettings.xaml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:local="clr-namespace:Wox.Plugin.Caculator.Views"
7-
xmlns:infrastructure="clr-namespace:Wox.Infrastructure;assembly=Wox.Infrastructure"
86
xmlns:ui="clr-namespace:Wox.Infrastructure.UI;assembly=Wox.Infrastructure"
97
xmlns:calculator="clr-namespace:Wox.Plugin.Caculator"
108
xmlns:core="clr-namespace:Wox.Core;assembly=Wox.Core"
9+
xmlns:viewModels="clr-namespace:Wox.Plugin.Caculator.ViewModels"
1110
mc:Ignorable="d"
1211
Loaded="CalculatorSettings_Loaded"
1312
d:DesignHeight="450" d:DesignWidth="800">
@@ -19,18 +18,19 @@
1918
<Border BorderBrush="Gray" Margin="10" BorderThickness="1">
2019
<Grid Margin="10">
2120
<Grid.RowDefinitions>
22-
<RowDefinition Height="25"/>
21+
<RowDefinition Height="auto"/>
22+
<RowDefinition Height="auto"/>
2323
</Grid.RowDefinitions>
2424
<Grid.ColumnDefinitions>
2525
<ColumnDefinition Width="*"/>
2626
<ColumnDefinition Width="3*"/>
2727
</Grid.ColumnDefinitions>
28-
28+
2929
<TextBlock Grid.Column="0" Grid.Row="0" Text="{DynamicResource wox_plugin_calculator_output_decimal_seperator}" VerticalAlignment="Center" />
30-
<ComboBox Grid.Column="1"
30+
<ComboBox x:Name="DecimalSeparatorComboBox"
31+
Grid.Column="1"
3132
Grid.Row="0"
32-
x:Name="DecimalSeparatorComboBox"
33-
Width="200"
33+
Margin="0 5 0 5"
3434
HorizontalAlignment="Left"
3535
SelectedItem="{Binding Settings.DecimalSeparator}"
3636
ItemsSource="{Binding Source={ui:EnumBindingSource {x:Type calculator:DecimalSeparator}}}">
@@ -40,6 +40,17 @@
4040
</DataTemplate>
4141
</ComboBox.ItemTemplate>
4242
</ComboBox>
43+
44+
<TextBlock Grid.Column="0" Grid.Row="1" Text="Decimal places" VerticalAlignment="Center" />
45+
<ComboBox x:Name="MaxDecimalPlaces"
46+
Grid.Column="1"
47+
Grid.Row="1"
48+
Margin="0 5 0 5"
49+
HorizontalAlignment="Left"
50+
SelectedItem="{Binding Settings.MaxDecimalPlaces}"
51+
ItemsSource="{Binding MaxDecimalPlacesRange}">
52+
</ComboBox>
53+
4354
</Grid>
4455
</Border>
4556
</UserControl>

Plugins/Wox.Plugin.Calculator/Views/CalculatorSettings.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ namespace Wox.Plugin.Caculator.Views
2121
/// </summary>
2222
public partial class CalculatorSettings : UserControl
2323
{
24-
private SettingsViewModel _viewModel;
25-
private Settings _settings;
24+
private readonly SettingsViewModel _viewModel;
25+
private readonly Settings _settings;
2626

2727
public CalculatorSettings(SettingsViewModel viewModel)
2828
{
@@ -35,6 +35,7 @@ public CalculatorSettings(SettingsViewModel viewModel)
3535
private void CalculatorSettings_Loaded(object sender, RoutedEventArgs e)
3636
{
3737
DecimalSeparatorComboBox.SelectedItem = _settings.DecimalSeparator;
38+
MaxDecimalPlaces.SelectedItem = _settings.MaxDecimalPlaces;
3839
}
3940
}
4041

0 commit comments

Comments
 (0)