From 58f612e03a9bb31c2ada4eb3c5989be458ec4ff5 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 2 Jul 2018 14:36:16 +0300 Subject: Implemented Twine Catalog Control. Implemented TouchStaticListBox. Added Scrollbar visibility, GetMostVisibleElement, Scrolling event - to LightTouchScrollviewer. --- .../Controls/TwineCatalogControl.xaml | 12 ----- .../Controls/TwineCatalogControl.xaml.cs | 28 ---------- .../Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj | 7 --- .../Controls/TwineCatalogControl.xaml | 57 ++++++++++++++++---- .../Controls/TwineCatalogControl.xaml.cs | 60 +++++++++++++++++++++- .../PPC/Tango.PPC.Common/Resources/Styles.xaml | 41 +++++++++++++++ 6 files changed, 146 insertions(+), 59 deletions(-) delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml delete mode 100644 Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml.cs (limited to 'Software/Visual_Studio/PPC') diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml deleted file mode 100644 index 51917b594..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml.cs deleted file mode 100644 index b1a109a75..000000000 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Controls/TwineCatalogControl.xaml.cs +++ /dev/null @@ -1,28 +0,0 @@ -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.PPC.Jobs.Controls -{ - /// - /// Interaction logic for TwineCatalogControl.xaml - /// - public partial class TwineCatalogControl : UserControl - { - public TwineCatalogControl() - { - InitializeComponent(); - } - } -} diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj index 7e8dc94b3..f77a47d37 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Jobs/Tango.PPC.Jobs.csproj @@ -72,10 +72,6 @@ Designer MSBuild:Compile - - Designer - MSBuild:Compile - MSBuild:Compile Designer @@ -112,9 +108,6 @@ JobSummeryViewer.xaml - - TwineCatalogControl.xaml - diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml index 142e1a10c..cc28bfddb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml @@ -15,27 +15,64 @@ - - + + - - + + - - + + + + + - - + + @@ -79,10 +116,10 @@ - + - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs index ad1c8b50c..2b376e855 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Controls/TwineCatalogControl.xaml.cs @@ -22,24 +22,80 @@ namespace Tango.PPC.Common.Controls public partial class TwineCatalogControl : UserControl { private Catalog _catalog; + private bool _loaded; + private bool _preventChange; + + public CatalogItem SelectedItem + { + get { return (CatalogItem)GetValue(SelectedItemProperty); } + set { SetValue(SelectedItemProperty, value); } + } + public static readonly DependencyProperty SelectedItemProperty = + DependencyProperty.Register("SelectedItem", typeof(CatalogItem), typeof(TwineCatalogControl), new PropertyMetadata(null,(d,e) => (d as TwineCatalogControl).OnSelectedItemChanged())); public TwineCatalogControl() { InitializeComponent(); + Loaded += TwineCatalogControl_Loaded; DataContextChanged += (x, y) => { _catalog = DataContext as Catalog; }; } + private void ScrollViewer_Scrolling(object sender, Touch.Controls.DoubleValueChangedEventArgs e) + { + if (!_preventChange) + { + var group = list.ScrollViewer.GetMostVisibleElementDataContext(); + + if (group != null) + { + _preventChange = true; + slider.Value = slider.Maximum - _catalog.Groups.IndexOf(group); + _preventChange = false; + } + } + } + private void TwineCatalogControl_Loaded(object sender, RoutedEventArgs e) { - + if (!_loaded) + { + list.ScrollViewer.Scrolling += ScrollViewer_Scrolling; + + _preventChange = true; + slider.Value = slider.Maximum; + _preventChange = false; + _loaded = true; + } } private void TouchSlider_ValueChanged(object sender, RoutedPropertyChangedEventArgs e) { + if (!_preventChange) + { + if (_catalog != null) + { + _preventChange = true; + list.ScrollToItem(_catalog.Groups.ElementAt(_catalog.Groups.Count - 1 - (int)e.NewValue)); + _preventChange = false; + } + } + if (_catalog != null) { - list.ScrollToItem(_catalog.Groups.ElementAt(_catalog.Groups.Count - 1 - (int)e.NewValue)); + slider.Foreground = new SolidColorBrush(_catalog.Groups.ElementAt(_catalog.Groups.Count - 1 - (int)e.NewValue).Color); + } + } + + private void OnSelectedItemChanged() + { + if (!_preventChange) + { + _preventChange = true; + var item = SelectedItem; + SelectedItem = null; + SelectedItem = item; + _preventChange = false; } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml index adea1481c..426372688 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Resources/Styles.xaml @@ -2,5 +2,46 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:touch="clr-namespace:Tango.Touch.Controls;assembly=Tango.Touch" xmlns:local="clr-namespace:Tango.PPC.Common.Resources"> + + + + \ No newline at end of file -- cgit v1.3.1