From f1df0c2d94f71c4cc38e4fe3ad23c04807be4eb2 Mon Sep 17 00:00:00 2001 From: MaxED Date: Tue, 4 Jun 2013 13:59:24 +0000 Subject: [PATCH] Vertex edit form: it was impossible to enter fractional position and zOffset values even if map format supported it. --- Source/Core/Controls/NumericTextbox.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Source/Core/Controls/NumericTextbox.cs b/Source/Core/Controls/NumericTextbox.cs index 7b53f812..000e7e8a 100644 --- a/Source/Core/Controls/NumericTextbox.cs +++ b/Source/Core/Controls/NumericTextbox.cs @@ -215,8 +215,10 @@ namespace CodeImp.DoomBuilder.Controls } else { - // Return the new value - return int.TryParse(this.Text, out result) ? result : original; + //mxd. Return the new value + if(!int.TryParse(this.Text, out result)) return original; + if(!allownegative && (result < 0)) return 0; + return result; } } else @@ -243,22 +245,24 @@ namespace CodeImp.DoomBuilder.Controls if(this.Text.StartsWith("++")) { // Add number to original - if(!float.TryParse(textpart, out result)) result = 0; + if(!float.TryParse(textpart, NumberStyles.Float, CultureInfo.CurrentCulture, out result)) result = 0; return original + result; } // Prefixed with --? else if(this.Text.StartsWith("--")) { // Subtract number from original - if(!float.TryParse(textpart, out result)) result = 0; + if(!float.TryParse(textpart, NumberStyles.Float, CultureInfo.CurrentCulture, out result)) result = 0; float newvalue = original - result; if(!allownegative && (newvalue < 0)) newvalue = 0; return newvalue; } else { - // Return the new value - return float.TryParse(this.Text, out result) ? result : original; + //mxd. Return the new value + if(!float.TryParse(this.Text, NumberStyles.Float, CultureInfo.CurrentCulture, out result)) return original; + if(!allownegative && (result < 0)) return 0; + return result; } } else