summaryrefslogtreecommitdiff
path: root/grapher/Models
diff options
context:
space:
mode:
authora1xd <[email protected]>2020-12-22 21:52:28 -0500
committerGitHub <[email protected]>2020-12-22 21:52:28 -0500
commit755403708953d8acf860d1f8ab471e8896c72a6a (patch)
tree0be89da26c895d9a52dffde02409bf75952441c8 /grapher/Models
parentMerge pull request #48 from a1xd/improve-docs (diff)
parentrename tryparse, add type (diff)
downloadrawaccel-755403708953d8acf860d1f8ab471e8896c72a6a.tar.xz
rawaccel-755403708953d8acf860d1f8ab471e8896c72a6a.zip
Merge pull request #51 from a1xd/fp-parse
fallback on invariant format when parsing fields
Diffstat (limited to 'grapher/Models')
-rw-r--r--grapher/Models/Fields/Field.cs9
1 files changed, 8 insertions, 1 deletions
diff --git a/grapher/Models/Fields/Field.cs b/grapher/Models/Fields/Field.cs
index 345f814..fe5171b 100644
--- a/grapher/Models/Fields/Field.cs
+++ b/grapher/Models/Fields/Field.cs
@@ -1,5 +1,6 @@
using System;
using System.Drawing;
+using System.Globalization;
using System.Windows.Forms;
namespace grapher
@@ -274,9 +275,15 @@ 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 (double.TryParse(Box.Text, out double value) &&
+ if (TryParseDouble(Box.Text, out double value) &&
value <= MaxData && value >= MinData)
{
_data = value;