mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-09 12:46:47 +02:00
[PTRun]Add setting for different trigonometric units in Calculator (#36717)
* Added angle units to PowerToys Run Calculator plugin. * Update Resources.resx * Added GitHub SpellCheck rule for 'gradians'. --------- Co-authored-by: Heiko <61519853+htcfreek@users.noreply.github.com>
This commit is contained in:
@@ -21,6 +21,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
||||
private const string InputUseEnglishFormat = nameof(InputUseEnglishFormat);
|
||||
private const string OutputUseEnglishFormat = nameof(OutputUseEnglishFormat);
|
||||
private const string ReplaceInput = nameof(ReplaceInput);
|
||||
private const string TrigMode = nameof(TrigMode);
|
||||
|
||||
private static readonly CalculateEngine CalculateEngine = new CalculateEngine();
|
||||
|
||||
@@ -31,6 +32,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
||||
private bool _inputUseEnglishFormat;
|
||||
private bool _outputUseEnglishFormat;
|
||||
private bool _replaceInput;
|
||||
private static CalculateEngine.TrigMode _trigMode;
|
||||
|
||||
public string Name => Resources.wox_plugin_calculator_plugin_name;
|
||||
|
||||
@@ -67,6 +69,20 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
||||
DisplayDescription = Resources.wox_plugin_calculator_replace_input_description,
|
||||
Value = true,
|
||||
},
|
||||
new PluginAdditionalOption
|
||||
{
|
||||
Key = TrigMode,
|
||||
DisplayLabel = Resources.wox_plugin_calculator_trig_unit_mode,
|
||||
DisplayDescription = Resources.wox_plugin_calculator_trig_unit_mode_description,
|
||||
PluginOptionType = PluginAdditionalOption.AdditionalOptionType.Combobox,
|
||||
ComboBoxValue = (int)CalculateEngine.TrigMode.Radians,
|
||||
ComboBoxItems =
|
||||
[
|
||||
new KeyValuePair<string, string>(Resources.wox_plugin_calculator_trig_unit_radians, "0"),
|
||||
new KeyValuePair<string, string>(Resources.wox_plugin_calculator_trig_unit_degrees, "1"),
|
||||
new KeyValuePair<string, string>(Resources.wox_plugin_calculator_trig_unit_gradians, "2"),
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
public List<Result> Query(Query query)
|
||||
@@ -183,6 +199,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
||||
var inputUseEnglishFormat = false;
|
||||
var outputUseEnglishFormat = false;
|
||||
var replaceInput = true;
|
||||
var trigMode = CalculateEngine.TrigMode.Radians;
|
||||
|
||||
if (settings != null && settings.AdditionalOptions != null)
|
||||
{
|
||||
@@ -194,11 +211,20 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator
|
||||
|
||||
var optionReplaceInput = settings.AdditionalOptions.FirstOrDefault(x => x.Key == ReplaceInput);
|
||||
replaceInput = optionReplaceInput?.Value ?? replaceInput;
|
||||
|
||||
var optionTrigMode = settings.AdditionalOptions.FirstOrDefault(x => x.Key == TrigMode);
|
||||
trigMode = (CalculateEngine.TrigMode)int.Parse(optionTrigMode.ComboBoxValue.ToString(CultureInfo.InvariantCulture), CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
_inputUseEnglishFormat = inputUseEnglishFormat;
|
||||
_outputUseEnglishFormat = outputUseEnglishFormat;
|
||||
_replaceInput = replaceInput;
|
||||
_trigMode = trigMode;
|
||||
}
|
||||
|
||||
public static CalculateEngine.TrigMode GetTrigMode()
|
||||
{
|
||||
return _trigMode;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
||||
Reference in New Issue
Block a user