diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-16 13:47:20 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-07-16 13:47:20 +0300 |
| commit | fdfa740288568dba27877a5ef5c817be323cfbb0 (patch) | |
| tree | 933ee1cb2769d43c982596f50ff8b7ec791f3be7 /Software/Visual_Studio/Tango.Touch | |
| parent | d376387fa28a2091a21e2fc7193812d1f8a40ef2 (diff) | |
| download | Tango-fdfa740288568dba27877a5ef5c817be323cfbb0.tar.gz Tango-fdfa740288568dba27877a5ef5c817be323cfbb0.zip | |
Working on PPC.
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch')
4 files changed, 59 insertions, 13 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs index d2a935fe1..b58158fd0 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs @@ -15,6 +15,7 @@ using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using System.Windows.Threading; using Tango.Core.EventArguments; namespace Tango.Touch.Controls @@ -27,6 +28,9 @@ namespace Tango.Touch.Controls private Point _downLocation; private TouchDevice _touchDevice; private double _last_manipulation_delta; + private DateTime _last_delta_measure_time; + private double _last_mouse_y; + private Border border_notifications; private Grid grid_container; @@ -36,6 +40,14 @@ namespace Tango.Touch.Controls DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchNotificationBar), new FrameworkPropertyMetadata(typeof(TouchNotificationBar))); } + public String ItemExpandedPropertyPath + { + get { return (String)GetValue(ItemExpandedPropertyPathProperty); } + set { SetValue(ItemExpandedPropertyPathProperty, value); } + } + public static readonly DependencyProperty ItemExpandedPropertyPathProperty = + DependencyProperty.Register("ItemExpandedPropertyPath", typeof(String), typeof(TouchNotificationBar), new PropertyMetadata(null)); + public double MinNotificationHeight { get { return (double)GetValue(MinNotificationHeightProperty); } @@ -104,19 +116,9 @@ namespace Tango.Touch.Controls border_notifications.RegisterForMouseOrTouchMove(GridNotificationMouseMove); border_notifications.RegisterForPreviewMouseOrTouchUp(GridNotificationMouseUp); - border_notifications.ManipulationDelta += Border_notifications_ManipulationDelta; - border_notifications.SizeChanged += Border_notifications_SizeChanged; } - private void Border_notifications_ManipulationDelta(object sender, ManipulationDeltaEventArgs e) - { - if (e.DeltaManipulation.Translation.Y != 0) - { - _last_manipulation_delta = e.DeltaManipulation.Translation.Y; - } - } - private void Border_notifications_SizeChanged(object sender, SizeChangedEventArgs e) { double maxPadding = 150; @@ -155,6 +157,14 @@ namespace Tango.Touch.Controls border_notifications.MaxHeight = this.ActualHeight; ani.To = this.ActualHeight; border_notifications.BeginAnimation(Grid.HeightProperty, ani); + + if (ItemExpandedPropertyPath != null) + { + foreach (var item in Notifications) + { + item.SetPropertyValueByPath(ItemExpandedPropertyPath, true); + } + } } private void CloseNotifications() @@ -180,6 +190,14 @@ namespace Tango.Touch.Controls tAni.Duration = TimeSpan.FromSeconds(0.3); tAni.To = new Thickness(0); border_notifications.BeginAnimation(Border.BorderThicknessProperty, tAni); + + if (ItemExpandedPropertyPath != null) + { + foreach (var item in Notifications) + { + item.SetPropertyValueByPath(ItemExpandedPropertyPath, false); + } + } } private void GridNotificationMouseUp(object sender, MouseOrTouchEventArgs e) @@ -203,11 +221,11 @@ namespace Tango.Touch.Controls DoubleAnimation ani = new DoubleAnimation(); ani.Duration = TimeSpan.FromSeconds(0.2); - if (e.GetPosition(this).Y > ActualHeight / 2 || _last_manipulation_delta > 20) + if ((e.GetPosition(this).Y > ActualHeight / 2 && _last_manipulation_delta > 0) || _last_manipulation_delta > 20) { OpenNotifications(); } - else if (e.GetPosition(this).Y < ActualHeight / 2 || _last_manipulation_delta < 20) + else if ((e.GetPosition(this).Y < ActualHeight / 2 && _last_manipulation_delta < 0) || _last_manipulation_delta < 20) { CloseNotifications(); } @@ -225,6 +243,22 @@ namespace Tango.Touch.Controls if (_isMoving) { + DateTime curTime = DateTime.Now; + + if (curTime > _last_delta_measure_time.AddMilliseconds(10)) + { + _last_delta_measure_time = curTime; + + double delta = e.Location.Y - _last_mouse_y; + + if (delta != 0) + { + _last_manipulation_delta = delta; + } + + _last_mouse_y = e.Location.Y; + } + if (e.TouchDevice != null) { border_notifications.CaptureTouch(e.TouchDevice); @@ -255,6 +289,9 @@ namespace Tango.Touch.Controls { _mouseDownLocation = new Point(e.Location.X, border_notifications.MaxHeight - e.Location.Y); _downLocation = e.Location; + _last_mouse_y = _downLocation.Y; + _last_delta_measure_time = DateTime.Now; + _last_manipulation_delta = 0; _isMouseDown = true; } } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs index ad09349c3..756dc3cac 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.cs @@ -162,6 +162,14 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty NotificationTemplateProperty = DependencyProperty.Register("NotificationTemplate", typeof(DataTemplate), typeof(TouchPanel), new PropertyMetadata(null)); + public String ItemExpandedPropertyPath + { + get { return (String)GetValue(ItemExpandedPropertyPathProperty); } + set { SetValue(ItemExpandedPropertyPathProperty, value); } + } + public static readonly DependencyProperty ItemExpandedPropertyPathProperty = + DependencyProperty.Register("ItemExpandedPropertyPath", typeof(String), typeof(TouchPanel), new PropertyMetadata(null)); + #region Attached Properties #region Prevent Focus Steal diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml index dffca3511..f3cd31f7d 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchPanel.xaml @@ -38,7 +38,7 @@ <Grid> <!--Notification Bar--> - <local:TouchNotificationBar NotificationTemplate="{TemplateBinding NotificationTemplate}" MinNotificationHeight="{TemplateBinding MinNotificationHeight}" HasNotifications="{TemplateBinding HasNotifications}" Notifications="{TemplateBinding Notifications}"> + <local:TouchNotificationBar NotificationTemplate="{TemplateBinding NotificationTemplate}" MinNotificationHeight="{TemplateBinding MinNotificationHeight}" HasNotifications="{TemplateBinding HasNotifications}" Notifications="{TemplateBinding Notifications}" ItemExpandedPropertyPath="{TemplateBinding ItemExpandedPropertyPath}"> <Grid> <!--Content--> <ContentPresenter Content="{TemplateBinding Content}" /> diff --git a/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml b/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml index 7dad89c17..898d30cf7 100644 --- a/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml +++ b/Software/Visual_Studio/Tango.Touch/Styles/TouchButton.xaml @@ -29,6 +29,7 @@ <Style x:Key="TangoLinkButton" TargetType="{x:Type controls:TouchButton}"> <Setter Property="Background" Value="Transparent"></Setter> + <Setter Property="Foreground" Value="{StaticResource TangoPrimaryAccentBrush}"></Setter> <Setter Property="CornerRadius" Value="20"></Setter> <Setter Property="BorderThickness" Value="0"></Setter> <Setter Property="EnableDropShadow" Value="False"></Setter> |
