From cff4a8079c4d352cfd47793c701650e62337ed6e Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Wed, 6 Jun 2018 18:39:17 +0300 Subject: Working on PPC.. --- .../PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs | 31 +++++++++++----------- .../PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs | 5 ---- .../PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs | 12 +++++---- 3 files changed, 23 insertions(+), 25 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs index b5e3e18fc..2af15b1ad 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs @@ -51,20 +51,6 @@ namespace Tango.PPC.UI.ViewModels public RelayCommand OnDragAndDropCommand { get; set; } - public JobsViewVM(IPPCApplicationManager application, IAuthenticationProvider authentication, INavigationManager navigation, INotificationProvider notification) : base(application, authentication, navigation, notification) - { - Jobs = new ObservableCollection(); - - JobSelectedCommand = new RelayCommand((x) => JobSelected(x as Job)); - OnDragAndDropCommand = new RelayCommand((e) => - { - Job draggedJob = e.Draggable.DataContext as Job; - Job droppedJob = e.Droppable.DataContext as Job; - - OnDragAndDropJobs(draggedJob, droppedJob); - }); - } - private void OnDragAndDropJobs(Job draggedJob, Job droppedJob) { Debug.WriteLine(draggedJob.Name + " Dragged on to " + droppedJob.Name); @@ -88,9 +74,24 @@ namespace Tango.PPC.UI.ViewModels JobsCollectionView.Refresh(); } - private void JobSelected(Job job) + private async void JobSelected(Job job) { Debug.WriteLine(job.Name); + await NotificationProvider.ShowInfo("Job details not yet implemented..."); + } + + public JobsViewVM() + { + Jobs = new ObservableCollection(); + + JobSelectedCommand = new RelayCommand((x) => JobSelected(x as Job)); + OnDragAndDropCommand = new RelayCommand((e) => + { + Job draggedJob = e.Draggable.DataContext as Job; + Job droppedJob = e.Droppable.DataContext as Job; + + OnDragAndDropJobs(draggedJob, droppedJob); + }); } public override void OnApplicationStarted() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs index 37940b2f8..a33dc25d7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/LoadingViewVM.cs @@ -17,11 +17,6 @@ namespace Tango.PPC.UI.ViewModels { public class LoadingViewVM : PPCViewModel { - public LoadingViewVM(IPPCApplicationManager application, IAuthenticationProvider authentication, INavigationManager navigation, INotificationProvider notification) : base(application, authentication, navigation, notification) - { - - } - public async override void OnApplicationStarted() { await Task.Delay(500); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs index c75e031f1..d1fc4c015 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs @@ -3,18 +3,20 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PPC.Common; using Tango.PPC.Common.Application; +using Tango.PPC.Common.Authentication; +using Tango.PPC.Common.Navigation; +using Tango.PPC.Common.Notifications; using Tango.SharedUI; namespace Tango.PPC.UI.ViewModels { - public class MainViewVM : ViewModel + public class MainViewVM : PPCViewModel { - public String Test { get; set; } - - public MainViewVM(IPPCApplicationManager application) + public override void OnApplicationStarted() { - Test = "This is a binding test"; + } } } -- cgit v1.3.1 From e051d309be2153f60b32c12022cfd0fe8f2ab913 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 7 Jun 2018 18:19:55 +0300 Subject: Working on PPC. --- .../PPC/Tango.PPC.UI/Notifications/MessageBox.xaml | 2 +- .../PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs | 9 + .../PPC/Tango.PPC.UI/Views/JobsView.xaml | 52 ++++- .../Visual_Studio/Tango.Touch/Components/Ripple.cs | 13 +- .../Visual_Studio/Tango.Touch/Controls/Shared.xaml | 78 ------- .../Tango.Touch/Controls/TouchDataGrid.cs | 17 +- .../Tango.Touch/Controls/TouchDataGrid.xaml | 61 +++-- .../Tango.Touch/Controls/TouchDataGridRow.cs | 252 ++++++++++++++++++--- .../Tango.Touch/Controls/TouchIconButton.xaml | 3 +- .../Tango.Touch/Controls/TouchScrollViewer.cs | 69 ++++++ .../Tango.Touch/Controls/TouchScrollViewer.xaml | 86 +++++++ .../Tango.Touch/Controls/TouchThumb.cs | 58 +++++ .../Tango.Touch/Keyboard/TouchKeyboard.cs | 1 - .../Visual_Studio/Tango.Touch/Tango.Touch.csproj | 6 + .../Visual_Studio/Tango.Touch/Themes/Generic.xaml | 1 + .../Tango.Stubs.Installer.vdproj | 30 +-- .../Tango.Stubs.UI/Properties/AssemblyInfo.cs | 4 +- 17 files changed, 578 insertions(+), 164 deletions(-) create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchScrollViewer.cs create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchScrollViewer.xaml create mode 100644 Software/Visual_Studio/Tango.Touch/Controls/TouchThumb.cs (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/MessageBox.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/MessageBox.xaml index 07d3b11ac..b1fe7ddcc 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/MessageBox.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/MessageBox.xaml @@ -15,7 +15,7 @@ - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs index 2af15b1ad..75ef7a2ac 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs @@ -51,6 +51,8 @@ namespace Tango.PPC.UI.ViewModels public RelayCommand OnDragAndDropCommand { get; set; } + public RelayCommand RemoveJobCommand { get; set; } + private void OnDragAndDropJobs(Job draggedJob, Job droppedJob) { Debug.WriteLine(draggedJob.Name + " Dragged on to " + droppedJob.Name); @@ -92,6 +94,13 @@ namespace Tango.PPC.UI.ViewModels OnDragAndDropJobs(draggedJob, droppedJob); }); + + RemoveJobCommand = new RelayCommand(RemoveJob); + } + + private void RemoveJob(Job job) + { + NotificationProvider.ShowQuestion("Are you sure you want to remove " + job.Name); } public override void OnApplicationStarted() diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml index c67d09445..3e54d45f3 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/JobsView.xaml @@ -43,12 +43,6 @@ - - - - - - READY TO DYE NOT READY @@ -57,6 +51,16 @@ + + + + + + + + + + @@ -68,17 +72,41 @@ - - - + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + - - - - - - - \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.cs index 2564c6c9c..d72e4fc12 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.cs @@ -20,6 +20,8 @@ namespace Tango.Touch.Controls { public class TouchDataGrid : DataGrid, ITouchControl { + public TouchScrollViewer ScrollViewer { get; set; } + public CornerRadius CornerRadius { get { return (CornerRadius)GetValue(CornerRadiusProperty); } @@ -113,10 +115,19 @@ namespace Tango.Touch.Controls get { return (IList)GetValue(SelectedItemsListProperty); } set { SetValue(SelectedItemsListProperty, value); } } - public static readonly DependencyProperty SelectedItemsListProperty = DependencyProperty.Register(nameof(SelectedItemsList), typeof(IList), typeof(TouchDataGrid), new PropertyMetadata(null)); + public DataTemplate SlideContentTemplate + { + get { return (DataTemplate)GetValue(SlideContentTemplateProperty); } + set { SetValue(SlideContentTemplateProperty, value); } + } + public static readonly DependencyProperty SlideContentTemplateProperty = + DependencyProperty.Register("SlideContentTemplate", typeof(DataTemplate), typeof(TouchDataGrid), new PropertyMetadata(null)); + + + protected override void OnSelectionChanged(SelectionChangedEventArgs e) { base.OnSelectionChanged(e); @@ -143,8 +154,8 @@ namespace Tango.Touch.Controls DraggingSurface = GetTemplateChild("PART_DraggingSurface") as DraggingSurface; ScrollViewer scrollViewer = GetTemplateChild("DG_ScrollViewer") as ScrollViewer; - - scrollViewer.IsManipulationEnabled = false; + ScrollViewer = scrollViewer as TouchScrollViewer; + scrollViewer.IsManipulationEnabled = true; } public IEnumerable GetRows() diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml index ae058bb98..92073b25d 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml @@ -4,6 +4,7 @@ xmlns:surface="http://schemas.microsoft.com/surface/2008" xmlns:components="clr-namespace:Tango.Touch.Components" xmlns:dragAndDrop="clr-namespace:Tango.DragAndDrop;assembly=Tango.DragAndDrop" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:local="clr-namespace:Tango.Touch.Controls"> @@ -11,6 +12,11 @@ + + + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - + @@ -208,8 +219,8 @@ - - + + @@ -238,9 +249,9 @@ - + - + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGridRow.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGridRow.cs index 5ae18d540..7f023831f 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGridRow.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGridRow.cs @@ -6,10 +6,14 @@ using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; +using System.Windows.Controls.Primitives; using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; using Tango.Core.EventArguments; using Tango.DragAndDrop; using Tango.SharedUI.Helpers; +using Tango.Touch.Components; namespace Tango.Touch.Controls { @@ -20,15 +24,34 @@ namespace Tango.Touch.Controls private bool _canSelect = false; private TouchDataGrid _grid; private bool _isLoaded; + private Thumb _thumbSlide; + private Ripple _ripple; + private TranslateTransform _translate; + private ContentControl _slideContentControl; + private bool _touchDown; + private Point _touchDownLocation; + private bool isMoving; + private bool _okToMove; + + + + public bool IsSlideMode + { + get { return (bool)GetValue(IsSlideModeProperty); } + set { SetValue(IsSlideModeProperty, value); } + } + public static readonly DependencyProperty IsSlideModeProperty = + DependencyProperty.Register("IsSlideMode", typeof(bool), typeof(TouchDataGridRow), new PropertyMetadata(false)); + + public TouchDataGridRow() { - this.RegisterForPreviewMouseOrTouchDown(OnMouseDown); + this.PreviewMouseUp += TouchDataGridRow_PreviewMouseUp; this.Loaded += (_, __) => { if (!_isLoaded) { - _grid = UIHelper.FindAncestor(this); _isLoaded = true; DragAndDropService.AddDropHandler(this, OnDragAndDrop); @@ -36,58 +59,235 @@ namespace Tango.Touch.Controls }; } + private void TouchDataGridRow_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + if (!IsSlideMode && Math.Abs((e.GetPosition(this).X - _touchDownLocation.X)) < 5) + { + _grid.ItemSelectedCommand?.Execute(DataContext); + } + } + private void OnDragAndDrop(object sender, DropEventArgs e) { _grid.OnDragAndDropCommand?.Execute(e); } - private async void OnMouseDown(object sender, MouseOrTouchEventArgs e) + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _thumbSlide = GetTemplateChild("PART_Thumb") as Thumb; + _ripple = GetTemplateChild("PART_Ripple") as Ripple; + _translate = GetTemplateChild("PART_Translate") as TranslateTransform; + _slideContentControl = GetTemplateChild("PART_SlideContentControl") as ContentControl; + Border border = GetTemplateChild("DGR_Border") as Border; + + _grid = UIHelper.FindAncestor(this); + + //_thumbSlide.AddHandler(Thumb.DragCompletedEvent, new DragCompletedEventHandler(_thumbSlide_DragCompleted), true); + //_thumbSlide.AddHandler(Thumb.DragDeltaEvent, new DragDeltaEventHandler(_thumbSlide_DragDelta), true); + + //_thumbSlide.DragDelta += _thumbSlide_DragDelta; + //_thumbSlide.DragCompleted += _thumbSlide_DragCompleted; + + border.PreviewTouchDown += ((_, e) => + { + _okToMove = false; + + if (e.OriginalSource.GetType() == typeof(DragThumb)) + { + border.IsManipulationEnabled = false; + return; + } + else + { + border.IsManipulationEnabled = true; + } + + _touchDownLocation = new Point(e.GetTouchPoint(this).Position.X - _translate.X, e.GetTouchPoint(this).Position.Y); + _touchDown = true; + }); + border.PreviewTouchMove += ((_, e) => + { + if (!_touchDown) return; + + double offsetX = e.GetTouchPoint(this).Position.X - _touchDownLocation.X; + double offsetY = e.GetTouchPoint(this).Position.Y - _touchDownLocation.Y; + + if (Math.Abs(offsetX) < 50 && !_okToMove) + { + return; + } + else + { + _okToMove = true; + } + + if (offsetX >= 0 || Math.Abs(offsetY) > ActualHeight) + { + return; + } + + if (e.OriginalSource.GetType() == typeof(DragThumb)) + { + return; + } + + _grid.ScrollViewer.FixPosition(); + + isMoving = true; + + _ripple.CancelRipple(true); + + IsSlideMode = true; + + _translate.BeginAnimation(TranslateTransform.XProperty, null); + + if (offsetX <= 0) + { + _translate.X = offsetX; + } + + var otherRow = _grid.GetRows().FirstOrDefault(x => x != this && x.IsSlideMode); + + if (otherRow != null) + { + otherRow.IsSlideMode = false; + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(0.2); + ani.To = 0; + otherRow._translate.BeginAnimation(TranslateTransform.XProperty, ani); + } + }); + + _grid.ScrollViewer.AddHandler(PreviewTouchUpEvent, new EventHandler((_, __) => + { + if (!_touchDown) return; + + _touchDown = false; + isMoving = false; + + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(0.2); + + if (_translate.X > -(_slideContentControl.ActualWidth + 10)) + { + IsSlideMode = false; + ani.To = 0; + } + else + { + IsSlideMode = true; + ani.To = -(_slideContentControl.ActualWidth + 10); + } + + _translate.BeginAnimation(TranslateTransform.XProperty, ani); + }), true); + } + + private void _thumbSlide_DragCompleted(object sender, DragCompletedEventArgs e) + { + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(0.2); + + if (_translate.X > -(_slideContentControl.ActualWidth + 10)) + { + IsSlideMode = false; + ani.To = 0; + } + else + { + IsSlideMode = true; + ani.To = -(_slideContentControl.ActualWidth + 10); + } + + _translate.BeginAnimation(TranslateTransform.XProperty, ani); + } + + private void _thumbSlide_DragDelta(object sender, DragDeltaEventArgs e) { if (e.OriginalSource.GetType() == typeof(DragThumb)) { - _grid.GetRows().ToList().ForEach(x => x.IsSelected = false); return; } - Keyboard.TouchKeyboard.PressCtrl(); + _ripple.CancelRipple(true); - IsSelected = false; + IsSlideMode = true; - _downTime = DateTime.Now; - await Task.Delay(_grid.SelectionDelay); + _translate.BeginAnimation(TranslateTransform.XProperty, null); - if (DateTime.Now > _downTime.AddMilliseconds(_grid.SelectionDelay)) + if (_translate.X + e.HorizontalChange <= 0) { - _canSelect = true; - IsSelected = !IsSelected; - _canSelect = false; + _translate.X += e.HorizontalChange; } - else - { - _canSelect = true; - IsSelected = true; - _canSelect = false; - _grid.GetRows().Where(x => x != this).ToList().ForEach(x => x.IsSelected = false); - _grid.ItemSelectedCommand?.Execute(DataContext); + var otherRow = _grid.GetRows().FirstOrDefault(x => x != this && x.IsSlideMode); + + if (otherRow != null) + { + otherRow.IsSlideMode = false; + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(0.2); + ani.To = 0; + otherRow._translate.BeginAnimation(TranslateTransform.XProperty, ani); } + } - Keyboard.TouchKeyboard.ReleaseCtrl(); + private async void OnMouseDown(object sender, MouseOrTouchEventArgs e) + { + //if (_thumbSlide.IsDragging) + //{ + // e.Handled = true; + //} + + //if (e.OriginalSource.GetType() == typeof(DragThumb)) + //{ + // //_grid.GetRows().ToList().ForEach(x => x.IsSelected = false); + // //e.Handled = true; + // return; + //} + + //Keyboard.TouchKeyboard.PressCtrl(); + + //IsSelected = false; + + //_downTime = DateTime.Now; + //await Task.Delay(_grid.SelectionDelay); + + //if (DateTime.Now > _downTime.AddMilliseconds(_grid.SelectionDelay)) + //{ + // _canSelect = true; + // IsSelected = !IsSelected; + // _canSelect = false; + //} + //else + //{ + // _canSelect = true; + // IsSelected = true; + // _canSelect = false; + // _grid.GetRows().Where(x => x != this).ToList().ForEach(x => x.IsSelected = false); + + // _grid.ItemSelectedCommand?.Execute(DataContext); + //} + + //await Task.Delay(200); + //Keyboard.TouchKeyboard.ReleaseCtrl(); } protected override void OnPreviewMouseUp(MouseButtonEventArgs e) { - Keyboard.TouchKeyboard.ReleaseCtrl(); + //Keyboard.TouchKeyboard.ReleaseCtrl(); base.OnPreviewMouseUp(e); - _downTime = DateTime.Now; + //_downTime = DateTime.Now; } protected override void OnSelected(RoutedEventArgs e) { - if (!_canSelect) - { - IsSelected = false; - } + //if (!_canSelect) + //{ + // IsSelected = false; + //} } } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchIconButton.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchIconButton.xaml index f0c3b5f7f..5619b9136 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchIconButton.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchIconButton.xaml @@ -9,7 +9,8 @@ + + + + + \ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchThumb.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchThumb.cs new file mode 100644 index 000000000..e96f92d5b --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchThumb.cs @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls.Primitives; +using System.Windows.Input; + +namespace Tango.Touch.Controls +{ + public class TouchThumb : Thumb + { + private TouchDevice currentDevice = null; + + protected override void OnPreviewTouchDown(TouchEventArgs e) + { + // Release any previous capture + ReleaseCurrentDevice(); + // Capture the new touch + CaptureCurrentDevice(e); + } + + protected override void OnPreviewTouchUp(TouchEventArgs e) + { + ReleaseCurrentDevice(); + } + + protected override void OnLostTouchCapture(TouchEventArgs e) + { + // Only re-capture if the reference is not null + // This way we avoid re-capturing after calling ReleaseCurrentDevice() + if (currentDevice != null) + { + CaptureCurrentDevice(e); + } + } + + private void ReleaseCurrentDevice() + { + if (currentDevice != null) + { + // Set the reference to null so that we don't re-capture in the OnLostTouchCapture() method + var temp = currentDevice; + currentDevice = null; + ReleaseTouchCapture(temp); + } + } + + private void CaptureCurrentDevice(TouchEventArgs e) + { + bool gotTouch = CaptureTouch(e.TouchDevice); + if (gotTouch) + { + currentDevice = e.TouchDevice; + } + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs index b0728e087..ab5191fe0 100644 --- a/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs +++ b/Software/Visual_Studio/Tango.Touch/Keyboard/TouchKeyboard.cs @@ -353,7 +353,6 @@ namespace Tango.Touch.Keyboard private Task SendKeys(String key) { Application.Current.MainWindow.Activate(); - ReleaseCtrl(); var isSpecialChar = IsSpecialCharactersOn; var definition = CurrentKeyboardDefinition; diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index af184b187..e4627ecbe 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -88,6 +88,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -141,7 +145,9 @@ + + diff --git a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml index 2aa811b10..339473f7b 100644 --- a/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml +++ b/Software/Visual_Studio/Tango.Touch/Themes/Generic.xaml @@ -9,6 +9,7 @@ + diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.Installer/Tango.Stubs.Installer.vdproj b/Software/Visual_Studio/Utilities/Tango.Stubs.Installer/Tango.Stubs.Installer.vdproj index 13a3a3c1c..29fc98da1 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.Installer/Tango.Stubs.Installer.vdproj +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.Installer/Tango.Stubs.Installer.vdproj @@ -465,7 +465,7 @@ "DisplayName" = "8:Debug" "IsDebugOnly" = "11:TRUE" "IsReleaseOnly" = "11:FALSE" - "OutputFilename" = "8:..\\..\\Build\\Debug\\Installers\\Tango Stubs Installer v1.8.msi" + "OutputFilename" = "8:..\\..\\Build\\Debug\\Installers\\Tango Stubs Installer v1.9.msi" "PackageFilesAs" = "3:2" "PackageFileSize" = "3:-2147483648" "CabType" = "3:1" @@ -556,7 +556,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.Scripting, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.Scripting, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_0712ECEB4DE24D8B9E9936D94BDC61B4" @@ -644,7 +644,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.PMR, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.PMR, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_25CD57B9CA3242F18E33F548DDB13C14" @@ -706,7 +706,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.PMR, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.PMR, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_5397E5B2CD05015FD556CF7136D97D21" @@ -737,7 +737,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:StubsExecutionGUI, Version=1.8.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:StubsExecutionGUI, Version=1.9.0.0, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_61BDC9339D1440BCBC454CC904BCE79C" @@ -768,7 +768,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.Scripting, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.Scripting, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_6290C6253BE08D5AEAF445DC538F5A32" @@ -861,7 +861,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.Settings, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.Settings, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_78C9B7DB89C8CFF3E6F812DBDAF18DC7" @@ -892,7 +892,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.SharedUI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.SharedUI, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_8F0D060313A40E3D6C4B196C5819AA1F" @@ -923,7 +923,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.Transport, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.Transport, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_92474495A2F0D65A21D2BFF4587358D8" @@ -954,7 +954,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.Stubs, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.Stubs, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_94CDF51D67BB69C2699CEC4485EBCA30" @@ -1078,7 +1078,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.Logging, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.Logging, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_BFCEC942CF3BF1B9FB6AEACA2A8753C3" @@ -1264,7 +1264,7 @@ { "AssemblyRegister" = "3:1" "AssemblyIsInGAC" = "11:FALSE" - "AssemblyAsmDisplayName" = "8:Tango.Core, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" + "AssemblyAsmDisplayName" = "8:Tango.Core, Version=1.0.0.1, Culture=neutral, processorArchitecture=MSIL" "ScatterAssemblies" { "_F35F069FCC8C9B6808AAD45B8039A4FB" @@ -1347,15 +1347,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Tango Stubs GUI" - "ProductCode" = "8:{CC56E442-9CBC-4D3A-BB41-90A952C25758}" - "PackageCode" = "8:{40459E65-A8AA-46F8-B259-5BE1128CABED}" + "ProductCode" = "8:{67EC0E77-000C-4CEF-9BBB-F89B0FB94FEA}" + "PackageCode" = "8:{E7855B80-5D28-4959-8728-9BFCD16D94D2}" "UpgradeCode" = "8:{72B680FB-E47D-486A-A81E-6C035F2EBA42}" "AspNetVersion" = "8:4.0.30319.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:FALSE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:1.8" + "ProductVersion" = "8:1.9" "Manufacturer" = "8:Twine" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:" diff --git a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Properties/AssemblyInfo.cs index 3c587548f..107c7d0b4 100644 --- a/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/Utilities/Tango.Stubs.UI/Properties/AssemblyInfo.cs @@ -9,6 +9,6 @@ using System.Runtime.InteropServices; [assembly: AssemblyProduct("Stubs execution utility")] [assembly: AssemblyCopyright("Twine LTD 2018")] [assembly: AssemblyTrademark("Twine LTD")] -[assembly: AssemblyVersion("1.8")] -[assembly: AssemblyFileVersion("1.8")] +[assembly: AssemblyVersion("1.9")] +[assembly: AssemblyFileVersion("1.9")] -- cgit v1.3.1 From 456a74d3dc0fd3853f0e55f35f999895e23aa7a5 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Thu, 7 Jun 2018 19:05:05 +0300 Subject: Split DataGridRow to SlideMode true/false. --- .../PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs | 2 +- .../Tango.Touch/Controls/TouchDataGrid.xaml | 13 +- .../Tango.Touch/Controls/TouchDataGridRow.cs | 333 ++++++++++----------- 3 files changed, 162 insertions(+), 186 deletions(-) (limited to 'Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels') diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs index 75ef7a2ac..14204da7d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/JobsViewVM.cs @@ -122,7 +122,7 @@ namespace Tango.PPC.UI.ViewModels _jobsContext = ObservablesContext.CreateDefault(); Jobs = _jobsContext.Jobs.Where(x => x.Machine.SerialNumber == Settings.MachineSerialNumber).ToObservableCollection(); - JobsCollectionView = CollectionViewSource.GetDefaultView(Jobs); + JobsCollectionView = CollectionViewSource.GetDefaultView(Jobs.Concat(Jobs).Concat(Jobs).Concat(Jobs).Concat(Jobs).Concat(Jobs).Concat(Jobs)); JobsCollectionView.SortDescriptions.Add(new SortDescription(nameof(Job.LastUpdated), ListSortDirection.Descending)); }); } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml index 92073b25d..11f59f016 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGrid.xaml @@ -85,7 +85,9 @@ + + @@ -140,8 +142,7 @@ - - + @@ -163,10 +164,14 @@ - + diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGridRow.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGridRow.cs index 7f023831f..ed9de7d0e 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGridRow.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchDataGridRow.cs @@ -20,50 +20,56 @@ namespace Tango.Touch.Controls public class TouchDataGridRow : DataGridRow { private DateTime _downTime = DateTime.Now; - private TimeSpan _minDownTime = TimeSpan.FromSeconds(0.3); private bool _canSelect = false; private TouchDataGrid _grid; private bool _isLoaded; private Thumb _thumbSlide; private Ripple _ripple; - private TranslateTransform _translate; + private TranslateTransform _slideContentTranslate; private ContentControl _slideContentControl; private bool _touchDown; private Point _touchDownLocation; - private bool isMoving; private bool _okToMove; + private Border _border; + #region Properties + public bool SlideMode + { + get { return (bool)GetValue(SlideModeProperty); } + set { SetValue(SlideModeProperty, value); } + } + public static readonly DependencyProperty SlideModeProperty = + DependencyProperty.Register("SlideMode", typeof(bool), typeof(TouchDataGridRow), new PropertyMetadata(null)); - public bool IsSlideMode + public bool SlideOpened { - get { return (bool)GetValue(IsSlideModeProperty); } - set { SetValue(IsSlideModeProperty, value); } + get { return (bool)GetValue(SlideOpenedProperty); } + set { SetValue(SlideOpenedProperty, value); } } - public static readonly DependencyProperty IsSlideModeProperty = - DependencyProperty.Register("IsSlideMode", typeof(bool), typeof(TouchDataGridRow), new PropertyMetadata(false)); + public static readonly DependencyProperty SlideOpenedProperty = + DependencyProperty.Register("SlideOpened", typeof(bool), typeof(TouchDataGridRow), new PropertyMetadata(false)); + #endregion + #region Constructors public TouchDataGridRow() { - this.PreviewMouseUp += TouchDataGridRow_PreviewMouseUp; - this.Loaded += (_, __) => - { - if (!_isLoaded) - { - _isLoaded = true; - - DragAndDropService.AddDropHandler(this, OnDragAndDrop); - } - }; + this.RegisterForPreviewMouseOrTouchDown(MouseOrTouchDownHandler); + this.Loaded += TouchDataGridRow_Loaded; } - private void TouchDataGridRow_PreviewMouseUp(object sender, MouseButtonEventArgs e) + #endregion + + #region Event Handlers + + private void TouchDataGridRow_Loaded(object sender, RoutedEventArgs e) { - if (!IsSlideMode && Math.Abs((e.GetPosition(this).X - _touchDownLocation.X)) < 5) + if (!_isLoaded) { - _grid.ItemSelectedCommand?.Execute(DataContext); + _isLoaded = true; + DragAndDropService.AddDropHandler(this, OnDragAndDrop); } } @@ -72,222 +78,187 @@ namespace Tango.Touch.Controls _grid.OnDragAndDropCommand?.Execute(e); } - public override void OnApplyTemplate() + private void ScrollViewerTouchUpHandler(object sender, TouchEventArgs e) { - base.OnApplyTemplate(); - - _thumbSlide = GetTemplateChild("PART_Thumb") as Thumb; - _ripple = GetTemplateChild("PART_Ripple") as Ripple; - _translate = GetTemplateChild("PART_Translate") as TranslateTransform; - _slideContentControl = GetTemplateChild("PART_SlideContentControl") as ContentControl; - Border border = GetTemplateChild("DGR_Border") as Border; + if (!_touchDown) return; - _grid = UIHelper.FindAncestor(this); - - //_thumbSlide.AddHandler(Thumb.DragCompletedEvent, new DragCompletedEventHandler(_thumbSlide_DragCompleted), true); - //_thumbSlide.AddHandler(Thumb.DragDeltaEvent, new DragDeltaEventHandler(_thumbSlide_DragDelta), true); + _touchDown = false; - //_thumbSlide.DragDelta += _thumbSlide_DragDelta; - //_thumbSlide.DragCompleted += _thumbSlide_DragCompleted; + DoubleAnimation ani = new DoubleAnimation(); + ani.Duration = TimeSpan.FromSeconds(0.2); - border.PreviewTouchDown += ((_, e) => + if (_slideContentTranslate.X > -(_slideContentControl.ActualWidth + 10)) { - _okToMove = false; - - if (e.OriginalSource.GetType() == typeof(DragThumb)) - { - border.IsManipulationEnabled = false; - return; - } - else - { - border.IsManipulationEnabled = true; - } - - _touchDownLocation = new Point(e.GetTouchPoint(this).Position.X - _translate.X, e.GetTouchPoint(this).Position.Y); - _touchDown = true; - }); - border.PreviewTouchMove += ((_, e) => + SlideOpened = false; + ani.To = 0; + } + else { - if (!_touchDown) return; - - double offsetX = e.GetTouchPoint(this).Position.X - _touchDownLocation.X; - double offsetY = e.GetTouchPoint(this).Position.Y - _touchDownLocation.Y; + SlideOpened = true; + ani.To = -(_slideContentControl.ActualWidth + 10); + } - if (Math.Abs(offsetX) < 50 && !_okToMove) - { - return; - } - else - { - _okToMove = true; - } + _slideContentTranslate.BeginAnimation(TranslateTransform.XProperty, ani); + } - if (offsetX >= 0 || Math.Abs(offsetY) > ActualHeight) - { - return; - } + private void Border_PreviewTouchMove(object sender, TouchEventArgs e) + { + if (!_touchDown) return; - if (e.OriginalSource.GetType() == typeof(DragThumb)) - { - return; - } + double offsetX = e.GetTouchPoint(this).Position.X - _touchDownLocation.X; + double offsetY = e.GetTouchPoint(this).Position.Y - _touchDownLocation.Y; - _grid.ScrollViewer.FixPosition(); + if (Math.Abs(offsetX) < 50 && !_okToMove) + { + return; + } + else + { + _okToMove = true; + } - isMoving = true; + if (offsetX >= 0 || Math.Abs(offsetY) > ActualHeight) + { + return; + } - _ripple.CancelRipple(true); + if (e.OriginalSource.GetType() == typeof(DragThumb)) + { + return; + } - IsSlideMode = true; + _grid.ScrollViewer.FixPosition(); - _translate.BeginAnimation(TranslateTransform.XProperty, null); + _ripple.CancelRipple(true); - if (offsetX <= 0) - { - _translate.X = offsetX; - } + SlideOpened = true; - var otherRow = _grid.GetRows().FirstOrDefault(x => x != this && x.IsSlideMode); + _slideContentTranslate.BeginAnimation(TranslateTransform.XProperty, null); - if (otherRow != null) - { - otherRow.IsSlideMode = false; - DoubleAnimation ani = new DoubleAnimation(); - ani.Duration = TimeSpan.FromSeconds(0.2); - ani.To = 0; - otherRow._translate.BeginAnimation(TranslateTransform.XProperty, ani); - } - }); - - _grid.ScrollViewer.AddHandler(PreviewTouchUpEvent, new EventHandler((_, __) => + if (offsetX <= 0) { - if (!_touchDown) return; + _slideContentTranslate.X = offsetX; + } - _touchDown = false; - isMoving = false; + var otherRow = _grid.GetRows().FirstOrDefault(x => x != this && x.SlideOpened); + if (otherRow != null) + { + otherRow.SlideOpened = false; DoubleAnimation ani = new DoubleAnimation(); ani.Duration = TimeSpan.FromSeconds(0.2); - - if (_translate.X > -(_slideContentControl.ActualWidth + 10)) - { - IsSlideMode = false; - ani.To = 0; - } - else - { - IsSlideMode = true; - ani.To = -(_slideContentControl.ActualWidth + 10); - } - - _translate.BeginAnimation(TranslateTransform.XProperty, ani); - }), true); + ani.To = 0; + otherRow._slideContentTranslate.BeginAnimation(TranslateTransform.XProperty, ani); + } } - private void _thumbSlide_DragCompleted(object sender, DragCompletedEventArgs e) + private void Border_PreviewTouchDown(object sender, TouchEventArgs e) { - DoubleAnimation ani = new DoubleAnimation(); - ani.Duration = TimeSpan.FromSeconds(0.2); + _okToMove = false; - if (_translate.X > -(_slideContentControl.ActualWidth + 10)) + if (e.OriginalSource.GetType() == typeof(DragThumb)) { - IsSlideMode = false; - ani.To = 0; + _border.IsManipulationEnabled = false; + return; } else { - IsSlideMode = true; - ani.To = -(_slideContentControl.ActualWidth + 10); + _border.IsManipulationEnabled = true; } - _translate.BeginAnimation(TranslateTransform.XProperty, ani); + _touchDownLocation = new Point(e.GetTouchPoint(this).Position.X - _slideContentTranslate.X, e.GetTouchPoint(this).Position.Y); + _touchDown = true; } - private void _thumbSlide_DragDelta(object sender, DragDeltaEventArgs e) + private async void MouseOrTouchDownHandler(object sender, MouseOrTouchEventArgs e) { + if (SlideMode) return; + if (e.OriginalSource.GetType() == typeof(DragThumb)) { + //_grid.GetRows().ToList().ForEach(x => x.IsSelected = false); + //e.Handled = true; return; } - _ripple.CancelRipple(true); + Keyboard.TouchKeyboard.PressCtrl(); - IsSlideMode = true; + IsSelected = false; - _translate.BeginAnimation(TranslateTransform.XProperty, null); + _downTime = DateTime.Now; + await Task.Delay(_grid.SelectionDelay); - if (_translate.X + e.HorizontalChange <= 0) + if (DateTime.Now > _downTime.AddMilliseconds(_grid.SelectionDelay)) { - _translate.X += e.HorizontalChange; + _canSelect = true; + IsSelected = !IsSelected; + _canSelect = false; } - - var otherRow = _grid.GetRows().FirstOrDefault(x => x != this && x.IsSlideMode); - - if (otherRow != null) + else { - otherRow.IsSlideMode = false; - DoubleAnimation ani = new DoubleAnimation(); - ani.Duration = TimeSpan.FromSeconds(0.2); - ani.To = 0; - otherRow._translate.BeginAnimation(TranslateTransform.XProperty, ani); + _canSelect = true; + IsSelected = true; + _canSelect = false; + _grid.GetRows().Where(x => x != this).ToList().ForEach(x => x.IsSelected = false); + + _grid.ItemSelectedCommand?.Execute(DataContext); } - } - private async void OnMouseDown(object sender, MouseOrTouchEventArgs e) - { - //if (_thumbSlide.IsDragging) - //{ - // e.Handled = true; - //} - - //if (e.OriginalSource.GetType() == typeof(DragThumb)) - //{ - // //_grid.GetRows().ToList().ForEach(x => x.IsSelected = false); - // //e.Handled = true; - // return; - //} - - //Keyboard.TouchKeyboard.PressCtrl(); - - //IsSelected = false; - - //_downTime = DateTime.Now; - //await Task.Delay(_grid.SelectionDelay); - - //if (DateTime.Now > _downTime.AddMilliseconds(_grid.SelectionDelay)) - //{ - // _canSelect = true; - // IsSelected = !IsSelected; - // _canSelect = false; - //} - //else - //{ - // _canSelect = true; - // IsSelected = true; - // _canSelect = false; - // _grid.GetRows().Where(x => x != this).ToList().ForEach(x => x.IsSelected = false); - - // _grid.ItemSelectedCommand?.Execute(DataContext); - //} - - //await Task.Delay(200); - //Keyboard.TouchKeyboard.ReleaseCtrl(); + await Task.Delay(200); + Keyboard.TouchKeyboard.ReleaseCtrl(); } + #endregion + + #region Override Methods + protected override void OnPreviewMouseUp(MouseButtonEventArgs e) { - //Keyboard.TouchKeyboard.ReleaseCtrl(); - base.OnPreviewMouseUp(e); - //_downTime = DateTime.Now; + if (!SlideMode) + { + Keyboard.TouchKeyboard.ReleaseCtrl(); + base.OnPreviewMouseUp(e); + _downTime = DateTime.Now; + } + else + { + if (!SlideOpened && Math.Abs((e.GetPosition(this).X - _touchDownLocation.X)) < 5) + { + _grid.ItemSelectedCommand?.Execute(DataContext); + } + } } protected override void OnSelected(RoutedEventArgs e) { - //if (!_canSelect) - //{ - // IsSelected = false; - //} + if (SlideMode) return; + + if (!_canSelect) + { + IsSelected = false; + } + } + + #endregion + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + _thumbSlide = GetTemplateChild("PART_Thumb") as Thumb; + _ripple = GetTemplateChild("PART_Ripple") as Ripple; + _slideContentTranslate = GetTemplateChild("PART_Translate") as TranslateTransform; + _slideContentControl = GetTemplateChild("PART_SlideContentControl") as ContentControl; + _border = GetTemplateChild("DGR_Border") as Border; + + _grid = UIHelper.FindAncestor(this); + + if (SlideMode) + { + _border.PreviewTouchDown += Border_PreviewTouchDown; + _border.PreviewTouchMove += Border_PreviewTouchMove; + _grid.ScrollViewer.AddHandler(PreviewTouchUpEvent, new EventHandler(ScrollViewerTouchUpHandler), true); + } } } } -- cgit v1.3.1