fix FancyZonesEditor CLI dpi parsing with comma decimal locales

This commit is contained in:
Antti Kuntsi
2019-10-09 07:27:14 +03:00
committed by Enrico Giordani
parent 67c139cae9
commit c069f6a555
2 changed files with 19 additions and 7 deletions

View File

@@ -6,6 +6,7 @@ using System.Threading.Tasks;
using System.ComponentModel;
using System.Collections;
using System.Collections.ObjectModel;
using System.Globalization;
using FancyZonesEditor.Models;
using System.Windows.Documents;
using System.Windows;
@@ -292,7 +293,20 @@ namespace FancyZonesEditor
var height = int.Parse(parsedLocation[3]);
_workAreaKey = args[5];
_dpi = float.Parse(args[6]);
// Try invariant culture first, caller likely uses invariant i.e. "C" locale to construct parameters
foreach (var cultureInfo in new[] { CultureInfo.InvariantCulture, CultureInfo.CurrentCulture, CultureInfo.CurrentUICulture })
{
try
{
_dpi = float.Parse(args[6], cultureInfo);
break;
}
catch (FormatException)
{
}
}
_workArea = new Rect(x, y, width, height);
uint monitor = 0;