diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-10 11:38:50 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-10 11:38:50 +0300 |
| commit | afd359b383a09f720d512dbf1f3bb6707dc4b83e (patch) | |
| tree | 950435d3dd35a268f44576330a2c9b0996ae97c2 /Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.cs | |
| parent | 17edf0cd108fb4a27dade328eaa294d352909b8f (diff) | |
| download | Tango-afd359b383a09f720d512dbf1f3bb6707dc4b83e.tar.gz Tango-afd359b383a09f720d512dbf1f3bb6707dc4b83e.zip | |
Implemented job type picker dialog.
Implemented "native" touch listbox.
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.cs | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.cs new file mode 100644 index 000000000..ea464e8db --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNativeListBox.cs @@ -0,0 +1,95 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.Touch.Controls +{ + public class TouchNativeListBox : ListBox + { + + /// <summary> + /// Gets or sets the ripple factor. + /// </summary> + public double RippleFactor + { + get { return (double)GetValue(RippleFactorProperty); } + set { SetValue(RippleFactorProperty, value); } + } + public static readonly DependencyProperty RippleFactorProperty = + DependencyProperty.Register("RippleFactor", typeof(double), typeof(TouchNativeListBox), new PropertyMetadata(30.0)); + + + + /// <summary> + /// Gets or sets the scroll viewer. + /// </summary> + public LightTouchScrollViewer ScrollViewer + { + get { return (LightTouchScrollViewer)GetValue(ScrollViewerProperty); } + set { SetValue(ScrollViewerProperty, value); } + } + public static readonly DependencyProperty ScrollViewerProperty = + DependencyProperty.Register("ScrollViewer", typeof(LightTouchScrollViewer), typeof(TouchNativeListBox), new PropertyMetadata(null)); + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + ScrollViewer = GetTemplateChild("PART_ScrollViewer") as LightTouchScrollViewer; + } + + protected override void OnMouseUp(MouseButtonEventArgs e) + { + if (ScrollViewer.IsAfterScrolling) return; + + if (e.ChangedButton == MouseButton.Left) + { + DependencyObject obj = this.ContainerFromElement((Visual)e.OriginalSource); + if (obj != null) + { + FrameworkElement element = obj as FrameworkElement; + if (element != null) + { + if (SelectedValuePath == null) + { + ListBoxItem item = element as ListBoxItem; + if (item != null && this.Items.Contains(item)) + { + this.SelectedItem = item; + } + } + else + { + object context = element.DataContext; + if (context != null) + { + SelectedValue = context.GetPropertyValueByPath(SelectedValuePath); + } + } + } + } + } + } + + protected override void OnPreviewMouseDown(MouseButtonEventArgs e) + { + e.Handled = true; + } + + static TouchNativeListBox() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchNativeListBox), new FrameworkPropertyMetadata(typeof(TouchNativeListBox))); + } + } +} |
