aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-12-25 16:11:03 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-12-25 16:11:03 +0200
commitaf48e6f711ecdeae4c3a921656531e61703b70b0 (patch)
treebe2ca146b1ef243fe49c98d82a7228e2201f52d4 /Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs
parentb5692b2f28929e7473ec73be0a1b5124149b8e2e (diff)
downloadTango-af48e6f711ecdeae4c3a921656531e61703b70b0.tar.gz
Tango-af48e6f711ecdeae4c3a921656531e61703b70b0.zip
Implemented negative numbers support for touch numeric up down.
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs')
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs15
1 files changed, 13 insertions, 2 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs
index aee5fae26..fa57169f3 100644
--- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs
@@ -22,8 +22,8 @@ namespace Tango.Touch.Controls
private bool _prevent_text_change;
private TextBlock _text_block;
private double _lastValue;
- Regex regex_integer = new Regex(@"^[0-9]*(?:[0-9]*)?$");
- Regex regex_double = new Regex(@"^[0-9]*(?:\.[0-9]*)?$");
+ Regex regex_integer = new Regex(@"^-?[0-9]\d*(\d+)?$");
+ Regex regex_double = new Regex(@"^-?[0-9]\d*(\.\d+)?$");
public static readonly RoutedEvent ValueChangedEvent = EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble, typeof(DoubleValueChangedEventHandler), typeof(TouchNumericTextBox));
public event DoubleValueChangedEventHandler ValueChanged
@@ -212,6 +212,17 @@ namespace Tango.Touch.Controls
return;
}
+ if (e.Text == "-" && !_text_box.Text.Contains("-"))
+ {
+ e.Handled = false;
+ return;
+ }
+ else if (e.Text == "-")
+ {
+ e.Handled = true;
+ return;
+ }
+
if (HasDecimalPoint)
{
e.Handled = !regex_double.IsMatch(e.Text);