diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-28 00:50:47 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-12-28 00:50:47 +0200 |
| commit | 028cca5fd51b4e5edb183e41e4e6831028a39e44 (patch) | |
| tree | eda1e3ac087073eaba532ddb3a977dd51cccd853 /Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs | |
| parent | ad969db71a39b4854d744412eb6482c0391a4dd9 (diff) | |
| parent | 0fdbc932838bb6e007cfa8a0079d1880c800ed81 (diff) | |
| download | Tango-028cca5fd51b4e5edb183e41e4e6831028a39e44.tar.gz Tango-028cca5fd51b4e5edb183e41e4e6831028a39e44.zip | |
Merged Urgent-Color-Space Branch.
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs index 2a0caf13e..ccb66d009 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNumericTextBox.cs @@ -21,7 +21,7 @@ namespace Tango.Touch.Controls { private TextBox _text_box; private bool _prevent_text_change; - private TextBlock _text_block; + private FastTextBlock _text_block; private double _lastValue; Regex regex_integer = new Regex(@"^-?[0-9]\d*(\d+)?$"); Regex regex_double = new Regex(@"^-?[0-9]\d*(\.\d+)?$"); @@ -109,12 +109,22 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty AutoCalculateJogStepProperty = DependencyProperty.Register("AutoCalculateJogStep", typeof(bool), typeof(TouchNumericTextBox), new PropertyMetadata(true)); + public bool UpdateBindingOnlyWhenFocused + { + get { return (bool)GetValue(UpdateBindingOnlyWhenFocusedProperty); } + set { SetValue(UpdateBindingOnlyWhenFocusedProperty, value); } + } + public static readonly DependencyProperty UpdateBindingOnlyWhenFocusedProperty = + DependencyProperty.Register("UpdateBindingOnlyWhenFocused", typeof(bool), typeof(TouchNumericTextBox), new PropertyMetadata(false)); + + + public override void OnApplyTemplate() { base.OnApplyTemplate(); _text_box = GetTemplateChild("PART_TextBox") as TextBox; - _text_block = GetTemplateChild("PART_TextDisplay") as TextBlock; + _text_block = GetTemplateChild("PART_TextDisplay") as FastTextBlock; _text_box.PreviewTextInput += _text_box_PreviewTextInput; _text_box.PreviewKeyDown += _text_box_PreviewKeyDown; _text_box.LostFocus += _text_box_LostFocus; @@ -222,8 +232,11 @@ namespace Tango.Touch.Controls _lastValue = Value; - DoubleValueChangedEventArgs args = new DoubleValueChangedEventArgs(ValueChangedEvent, this, Value); - RaiseEvent(args); + if (!UpdateBindingOnlyWhenFocused || (_text_box != null && _text_box.IsKeyboardFocused)) + { + DoubleValueChangedEventArgs args = new DoubleValueChangedEventArgs(ValueChangedEvent, this, Value); + RaiseEvent(args); + } } } |
