From ec4997c6be3f794699eebf00bbe795c23626f9c7 Mon Sep 17 00:00:00 2001 From: a1xd <68629610+a1xd@users.noreply.github.com> Date: Sun, 29 Aug 2021 19:44:48 -0400 Subject: remove culture specific float parsing make app/default culture invariant --- grapher/Models/Fields/Field.cs | 8 +------- grapher/Program.cs | 4 ++++ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs index fe5171b..a75882d 100644 --- a/grapher/Models/Fields/Field.cs +++ b/grapher/Models/Fields/Field.cs @@ -275,15 +275,9 @@ namespace grapher } } - public static bool TryParseDouble(string s, out double res) - { - return double.TryParse(s, Constants.FloatStyle, NumberFormatInfo.CurrentInfo, out res) || - double.TryParse(s, Constants.FloatStyle, NumberFormatInfo.InvariantInfo, out res); - } - private void TextToData() { - if (TryParseDouble(Box.Text, out double value) && + if (double.TryParse(Box.Text, out double value) && value <= MaxData && value >= MinData) { _data = value; diff --git a/grapher/Program.cs b/grapher/Program.cs index 894d1cd..bd7d2f9 100644 --- a/grapher/Program.cs +++ b/grapher/Program.cs @@ -1,4 +1,5 @@ using System; +using System.Globalization; using System.Windows.Forms; namespace grapher @@ -19,6 +20,9 @@ namespace grapher return; } + CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; + CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture; + AppDomain.CurrentDomain.UnhandledException += GlobalUnhandledExceptionHandler; Application.EnableVisualStyles(); -- cgit v1.2.3