Adjusting to force all instances to use rounded vs result due to Mage's quirks (#7164)

This commit is contained in:
Clint Rutkas
2020-10-08 08:57:17 -07:00
committed by GitHub
parent cfe2bbd75e
commit 9928579364
4 changed files with 21 additions and 11 deletions

View File

@@ -14,10 +14,10 @@ namespace Microsoft.Plugin.Calculator
{
public static Result CreateResult(CalculateResult result, string iconPath)
{
return CreateResult(result.Result, result.RoundedResult, iconPath);
return CreateResult(result.RoundedResult, iconPath);
}
public static Result CreateResult(decimal result, decimal roundedResult, string iconPath)
public static Result CreateResult(decimal roundedResult, string iconPath)
{
return new Result
{
@@ -25,18 +25,19 @@ namespace Microsoft.Plugin.Calculator
IcoPath = iconPath,
Score = 300,
SubTitle = Properties.Resources.wox_plugin_calculator_copy_number_to_clipboard,
Action = c => Action(result),
Action = c => Action(roundedResult),
};
}
public static bool Action(decimal result)
public static bool Action(decimal roundedResult)
{
var ret = false;
var thread = new Thread(() =>
{
try
{
Clipboard.SetText(result.ToString(CultureInfo.CurrentUICulture.NumberFormat));
Clipboard.SetText(roundedResult.ToString(CultureInfo.CurrentUICulture.NumberFormat));
ret = true;
}
catch (ExternalException)
@@ -44,9 +45,11 @@ namespace Microsoft.Plugin.Calculator
MessageBox.Show(Properties.Resources.wox_plugin_calculator_copy_failed);
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
return ret;
}
}