diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-18 11:36:30 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2018-06-18 11:36:30 +0300 |
| commit | 647548244947e71aedb0770be0b12bd74bcf4c93 (patch) | |
| tree | 85894320ebafc29ac5cd443cf9c666b697acddd7 /Software/Visual_Studio | |
| parent | 51f5ba90ccdba8793a0ce600a8c42264d3770623 (diff) | |
| download | Tango-647548244947e71aedb0770be0b12bd74bcf4c93.tar.gz Tango-647548244947e71aedb0770be0b12bd74bcf4c93.zip | |
Implemented manipulation delta on TouchNotificationBar.
Implemented touch device detection.
Diffstat (limited to 'Software/Visual_Studio')
7 files changed, 73 insertions, 16 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs index 26fe06c5f..ecb37654d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml.cs @@ -1,7 +1,9 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -13,6 +15,7 @@ using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; +using Tango.Touch.Helpers; namespace Tango.PPC.UI { @@ -29,12 +32,12 @@ namespace Tango.PPC.UI InitializeComponent(); - //WindowStartupLocation = WindowStartupLocation.Manual; - //var lastMonitor = Screen.AllScreens.LastOrDefault(); - //Left = lastMonitor.Bounds.Left; - //Top = lastMonitor.Bounds.Top; - //Width = lastMonitor.Bounds.Width; - //Height = lastMonitor.Bounds.Height; + if (TouchHelper.IsTouchEnabled()) + { + WindowStyle = WindowStyle.None; + ResizeMode = ResizeMode.NoResize; + WindowState = WindowState.Maximized; + } } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml index 7ce525337..ccb6618e7 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Notifications/NotificationItems/EmptyCartridgesNotificationView.xaml @@ -8,7 +8,7 @@ d:DesignHeight="60" d:DesignWidth="400" MinHeight="50" Background="Transparent" Foreground="#FF7777" d:DataContext="{d:DesignInstance Type=local:EmptyCartridgesNotification, IsDesignTimeCreatable=True}"> <Grid Margin="10"> <DockPanel> - <Image Source="/Images/warning-test.png" Width="24" /> + <Image Source="/Images/warning-test.png" Margin="5" /> <TextBlock Margin="10 0 0 0" VerticalAlignment="Center" TextWrapping="Wrap" Text="{Binding Message}"></TextBlock> </DockPanel> </Grid> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml index 524550b94..a3f7d70e1 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml @@ -19,12 +19,12 @@ <localConverters:NotificationItemConverter x:Key="NotificationItemConverter" /> </UserControl.Resources> - <touch:TouchNotificationBar HasNotifications="{Binding NotificationProvider.HasNotificationItems}" Notifications="{Binding NotificationProvider.NotificationItems}"> + <touch:TouchNotificationBar MinNotificationHeight="60" HasNotifications="{Binding NotificationProvider.HasNotificationItems}" Notifications="{Binding NotificationProvider.NotificationItems}"> <touch:TouchNotificationBar.NotificationTemplate> <DataTemplate> <Grid> <ContentControl Content="{Binding Converter={StaticResource NotificationItemConverter}}" /> - <touch:TouchIconButton Background="Transparent" Padding="20" Style="{StaticResource TangoRoundTouchIconButton}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.NotificationProvider.PopNotificationCommand}" CommandParameter="{Binding}" HorizontalAlignment="Right" Width="60" Icon="Close" Foreground="White" /> + <touch:TouchIconButton Background="Transparent" Padding="20" Style="{StaticResource TangoRoundTouchIconButton}" Command="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.NotificationProvider.PopNotificationCommand}" CommandParameter="{Binding}" HorizontalAlignment="Right" MaxHeight="60" Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" Icon="Close" Foreground="White" /> </Grid> </DataTemplate> </touch:TouchNotificationBar.NotificationTemplate> diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs index d544af8c9..9a2ca465f 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs @@ -26,6 +26,7 @@ namespace Tango.Touch.Controls private bool _isMoving; private Point _downLocation; private TouchDevice _touchDevice; + private double _last_manipulation_delta; private Border border_notifications; private Grid grid_container; @@ -65,7 +66,7 @@ namespace Tango.Touch.Controls set { SetValue(HasNotificationsProperty, value); } } public static readonly DependencyProperty HasNotificationsProperty = - DependencyProperty.Register("HasNotifications", typeof(bool), typeof(TouchNotificationBar), new PropertyMetadata(false,(d,e) => (d as TouchNotificationBar).OnHasNotificationsChanged())); + DependencyProperty.Register("HasNotifications", typeof(bool), typeof(TouchNotificationBar), new PropertyMetadata(false, (d, e) => (d as TouchNotificationBar).OnHasNotificationsChanged())); public IList Notifications { @@ -83,23 +84,43 @@ namespace Tango.Touch.Controls public static readonly DependencyProperty NotificationTemplateProperty = DependencyProperty.Register("NotificationTemplate", typeof(DataTemplate), typeof(TouchNotificationBar), new PropertyMetadata(null)); + public double NotificationHeight + { + get { return (double)GetValue(NotificationHeightProperty); } + set { SetValue(NotificationHeightProperty, value); } + } + public static readonly DependencyProperty NotificationHeightProperty = + DependencyProperty.Register("NotificationHeight", typeof(double), typeof(TouchNotificationBar), new PropertyMetadata(0.0)); + + public override void OnApplyTemplate() { base.OnApplyTemplate(); border_notifications = GetTemplateChild("PART_BorderNotifications") as Border; grid_container = GetTemplateChild("PART_Grid_Container") as Grid; + border_notifications.IsManipulationEnabled = true; border_notifications.RegisterForPreviewMouseOrTouchDown(GridNotificationMouseDown); 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 = 20; - NotificationPadding = new Thickness((border_notifications.ActualHeight / ActualHeight) * maxPadding); + double maxPadding = 150; + NotificationHeight = (border_notifications.ActualHeight / ActualHeight) * maxPadding; } private void OnHasNotificationsChanged() @@ -123,6 +144,7 @@ namespace Tango.Touch.Controls private void OpenNotifications() { DoubleAnimation ani = new DoubleAnimation(); + ani.DecelerationRatio = 1; ani.Duration = TimeSpan.FromSeconds(0.2); if (double.IsNaN(border_notifications.Height)) @@ -139,6 +161,7 @@ namespace Tango.Touch.Controls { DoubleAnimation ani = new DoubleAnimation(); ani.Duration = TimeSpan.FromSeconds(0.2); + ani.AccelerationRatio = 1; ani.From = border_notifications.ActualHeight; ani.To = MinNotificationHeight; @@ -180,11 +203,11 @@ namespace Tango.Touch.Controls DoubleAnimation ani = new DoubleAnimation(); ani.Duration = TimeSpan.FromSeconds(0.2); - if (e.GetPosition(this).Y > ActualHeight / 2) + if (e.GetPosition(this).Y > ActualHeight / 2 || _last_manipulation_delta > 20) { OpenNotifications(); } - else + else if (e.GetPosition(this).Y < ActualHeight / 2 || _last_manipulation_delta < 20) { CloseNotifications(); } diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml index 40b0a2779..ac0d09e24 100644 --- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml +++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml @@ -24,11 +24,11 @@ <Grid x:Name="PART_Grid_Container" VerticalAlignment="Top" Background="Transparent" ClipToBounds="False"> <Canvas> - <Border x:Name="PART_BorderNotifications" BorderBrush="Silver" Background="#83000000" MaxHeight="{Binding RelativeSource={RelativeSource TemplatedParent},Path=MinNotificationHeight}" Width="{Binding RelativeSource={RelativeSource AncestorType=Canvas},Path=ActualWidth}"> + <Border x:Name="PART_BorderNotifications" BorderBrush="Silver" Background="#96000000" MaxHeight="{Binding RelativeSource={RelativeSource TemplatedParent},Path=MinNotificationHeight}" Width="{Binding RelativeSource={RelativeSource AncestorType=Canvas},Path=ActualWidth}"> <ItemsControl x:Name="notificationsItemsControl" ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Notifications}"> <ItemsControl.ItemTemplate> <DataTemplate> - <Border BorderBrush="#595959" BorderThickness="0 0 0 5" Padding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=NotificationPadding}" MinHeight="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=MinNotificationHeight}" MaxHeight="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=MaxNotificationHeight}"> + <Border BorderBrush="#757373" BorderThickness="0 0 0 5" Height="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=NotificationHeight}" MinHeight="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=MinNotificationHeight}" MaxHeight="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=MaxNotificationHeight}"> <Border.Background> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="#FF282828"/> diff --git a/Software/Visual_Studio/Tango.Touch/Helpers/TouchHelper.cs b/Software/Visual_Studio/Tango.Touch/Helpers/TouchHelper.cs new file mode 100644 index 000000000..4247f37e9 --- /dev/null +++ b/Software/Visual_Studio/Tango.Touch/Helpers/TouchHelper.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace Tango.Touch.Helpers +{ + public static class TouchHelper + { + [DllImport("user32.dll")] + private static extern int GetSystemMetrics(int nIndex); + + /// <summary> + /// Determines whether the current machine is touch enabled. + /// </summary> + public static bool IsTouchEnabled() + { + foreach (TabletDevice tabletDevice in Tablet.TabletDevices) + { + if (tabletDevice.Type == TabletDeviceType.Touch && !String.IsNullOrWhiteSpace(tabletDevice.Name)) + return true; + } + + return false; + } + } +} diff --git a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj index c950696d5..79e84b2c4 100644 --- a/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj +++ b/Software/Visual_Studio/Tango.Touch/Tango.Touch.csproj @@ -56,6 +56,7 @@ <Reference Include="PresentationFramework" /> </ItemGroup> <ItemGroup> + <Compile Include="Helpers\TouchHelper.cs" /> <Page Include="Components\Ripple.xaml"> <SubType>Designer</SubType> <Generator>MSBuild:Compile</Generator> |
