diff options
| author | a1xd <[email protected]> | 2020-12-22 21:52:28 -0500 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-12-22 21:52:28 -0500 |
| commit | 755403708953d8acf860d1f8ab471e8896c72a6a (patch) | |
| tree | 0be89da26c895d9a52dffde02409bf75952441c8 /grapher/Models | |
| parent | Merge pull request #48 from a1xd/improve-docs (diff) | |
| parent | rename tryparse, add type (diff) | |
| download | rawaccel-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.cs | 9 |
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; |