This repository has been archived by the owner on Feb 12, 2021. It is now read-only.
forked from Wox-launcher/Wox
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into release_branch
- Loading branch information
Showing
14 changed files
with
411 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Globalization; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Wox.Core; | ||
|
||
namespace Wox.Plugin.Caculator | ||
{ | ||
[TypeConverter(typeof(LocalizationConverter))] | ||
public enum DecimalSeparator | ||
{ | ||
[LocalizedDescription("wox_plugin_calculator_decimal_seperator_use_system_locale")] | ||
UseSystemLocale, | ||
|
||
[LocalizedDescription("wox_plugin_calculator_decimal_seperator_dot")] | ||
Dot, | ||
|
||
[LocalizedDescription("wox_plugin_calculator_decimal_seperator_comma")] | ||
Comma | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace Wox.Plugin.Caculator | ||
{ | ||
public class Settings | ||
{ | ||
public DecimalSeparator DecimalSeparator { get; set; } = DecimalSeparator.UseSystemLocale; | ||
public int MaxDecimalPlaces { get; set; } = 10; | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Plugins/Wox.Plugin.Calculator/ViewModels/SettingsViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Wox.Infrastructure.Storage; | ||
using Wox.Infrastructure.UserSettings; | ||
|
||
namespace Wox.Plugin.Caculator.ViewModels | ||
{ | ||
public class SettingsViewModel : BaseModel, ISavable | ||
{ | ||
private readonly PluginJsonStorage<Settings> _storage; | ||
|
||
public SettingsViewModel() | ||
{ | ||
_storage = new PluginJsonStorage<Settings>(); | ||
Settings = _storage.Load(); | ||
} | ||
|
||
public Settings Settings { get; set; } | ||
|
||
public IEnumerable<int> MaxDecimalPlacesRange => Enumerable.Range(1, 20); | ||
|
||
public void Save() | ||
{ | ||
_storage.Save(); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
Plugins/Wox.Plugin.Calculator/Views/CalculatorSettings.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<UserControl x:Class="Wox.Plugin.Caculator.Views.CalculatorSettings" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
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: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"> | ||
|
||
<UserControl.Resources> | ||
<core:LocalizationConverter x:Key="LocalizationConverter"/> | ||
</UserControl.Resources> | ||
|
||
<Border BorderBrush="Gray" Margin="10" BorderThickness="1"> | ||
<Grid Margin="10"> | ||
<Grid.RowDefinitions> | ||
<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 x:Name="DecimalSeparatorComboBox" | ||
Grid.Column="1" | ||
Grid.Row="0" | ||
Margin="0 5 0 5" | ||
HorizontalAlignment="Left" | ||
SelectedItem="{Binding Settings.DecimalSeparator}" | ||
ItemsSource="{Binding Source={ui:EnumBindingSource {x:Type calculator:DecimalSeparator}}}"> | ||
<ComboBox.ItemTemplate> | ||
<DataTemplate> | ||
<TextBlock Text="{Binding Converter={StaticResource LocalizationConverter}}" /> | ||
</DataTemplate> | ||
</ComboBox.ItemTemplate> | ||
</ComboBox> | ||
|
||
<TextBlock Grid.Column="0" Grid.Row="1" Text="{DynamicResource wox_plugin_calculator_max_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> |
43 changes: 43 additions & 0 deletions
43
Plugins/Wox.Plugin.Calculator/Views/CalculatorSettings.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Data; | ||
using System.Windows.Documents; | ||
using System.Windows.Input; | ||
using System.Windows.Media; | ||
using System.Windows.Media.Imaging; | ||
using System.Windows.Navigation; | ||
using System.Windows.Shapes; | ||
using Wox.Plugin.Caculator.ViewModels; | ||
|
||
namespace Wox.Plugin.Caculator.Views | ||
{ | ||
/// <summary> | ||
/// Interaction logic for CalculatorSettings.xaml | ||
/// </summary> | ||
public partial class CalculatorSettings : UserControl | ||
{ | ||
private readonly SettingsViewModel _viewModel; | ||
private readonly Settings _settings; | ||
|
||
public CalculatorSettings(SettingsViewModel viewModel) | ||
{ | ||
_viewModel = viewModel; | ||
_settings = viewModel.Settings; | ||
DataContext = viewModel; | ||
InitializeComponent(); | ||
} | ||
|
||
private void CalculatorSettings_Loaded(object sender, RoutedEventArgs e) | ||
{ | ||
DecimalSeparatorComboBox.SelectedItem = _settings.DecimalSeparator; | ||
MaxDecimalPlaces.SelectedItem = _settings.MaxDecimalPlaces; | ||
} | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.