aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Touch/Components
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2018-05-30 19:12:04 +0300
committerRoy Ben-Shabat <Roy@Twine-s.com>2018-05-30 19:12:04 +0300
commit9169a318121f8919e9b54cc076f63ef9a65d5b2b (patch)
tree1dd46f263b835225a930255687583e3f2fd1e7f6 /Software/Visual_Studio/Tango.Touch/Components
parentcf5d8ed0f510792196e0153d9f9008cdce02d523 (diff)
downloadTango-9169a318121f8919e9b54cc076f63ef9a65d5b2b.tar.gz
Tango-9169a318121f8919e9b54cc076f63ef9a65d5b2b.zip
Implemented SQLite db on PPC.
Working on PPC.
Diffstat (limited to 'Software/Visual_Studio/Tango.Touch/Components')
-rw-r--r--Software/Visual_Studio/Tango.Touch/Components/Ripple.cs84
-rw-r--r--Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml2
-rw-r--r--Software/Visual_Studio/Tango.Touch/Components/TransformationHelper.cs146
3 files changed, 224 insertions, 8 deletions
diff --git a/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs b/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs
index ae0b693af..88e6d24a7 100644
--- a/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs
+++ b/Software/Visual_Studio/Tango.Touch/Components/Ripple.cs
@@ -63,6 +63,58 @@ namespace Tango.Touch.Components
public static readonly DependencyProperty SynchedScrollViewerProperty =
DependencyProperty.Register("SynchedScrollViewer", typeof(ScrollViewer), typeof(Ripple), new PropertyMetadata(null));
+ public double RippleFactor
+ {
+ get { return (double)GetValue(RippleFactorProperty); }
+ set { SetValue(RippleFactorProperty, value); }
+ }
+ public static readonly DependencyProperty RippleFactorProperty =
+ DependencyProperty.Register("RippleFactor", typeof(double), typeof(Ripple), new PropertyMetadata(5.0));
+
+ public bool Centered
+ {
+ get { return (bool)GetValue(CenteredProperty); }
+ set { SetValue(CenteredProperty, value); }
+ }
+ public static readonly DependencyProperty CenteredProperty =
+ DependencyProperty.Register("Centered", typeof(bool), typeof(Ripple), new PropertyMetadata(false));
+
+ #region Attached Properties
+
+ #region PreventRipple
+
+ /// <summary>
+ /// Determines whether an element is a dropable target by the drag and drop service.
+ /// </summary>
+ public static readonly DependencyProperty PreventRippleProperty =
+ DependencyProperty.RegisterAttached("PreventRipple",
+ typeof(bool), typeof(Ripple),
+ new FrameworkPropertyMetadata(false));
+
+ /// <summary>
+ /// Sets the PreventRipple attached property.
+ /// </summary>
+ /// <param name="element">The element.</param>
+ /// <param name="value">if set to <c>true</c> [value].</param>
+ public static void SetPreventRipple(FrameworkElement element, bool value)
+ {
+ element.SetValue(PreventRippleProperty, value);
+ }
+
+ /// <summary>
+ /// Gets the PreventRipple attached property.
+ /// </summary>
+ /// <param name="element">The element.</param>
+ /// <returns></returns>
+ public static bool GetPreventRipple(FrameworkElement element)
+ {
+ return (bool)element.GetValue(PreventRippleProperty);
+ }
+
+ #endregion
+
+ #endregion
+
static Ripple()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(Ripple), new FrameworkPropertyMetadata(typeof(Ripple)));
@@ -104,12 +156,22 @@ namespace Tango.Touch.Components
//parent.TouchMove += (_, __) => CancelRipple();
//parent.PreviewTouchUp += Parent_PreviewTouchUp;
- parent.RegisterForPreviewMouseOrTouchDown(this, (x, e) => OnRippleDown(e.Location));
+ if (parent != null)
+ {
+
+ parent.RegisterForPreviewMouseOrTouchDown(this, (x, e) =>
+ {
+ if (!GetPreventRipple(e.OriginalSource as FrameworkElement))
+ {
+ OnRippleDown(e.Location);
+ }
+ });
+ parent.PreviewMouseUp += Parent_PreviewMouseUp;
+ }
+
//parent.PreviewMouseDown += Parent_PreviewMouseDown;
//parent.PreviewTouchDown += Parent_PreviewTouchDown;
-
//parent.TouchMove += (_, __) => CancelRipple();
- parent.PreviewMouseUp += Parent_PreviewMouseUp;
//parent.PreviewTouchUp += Parent_PreviewTouchUp;
}
@@ -158,14 +220,22 @@ namespace Tango.Touch.Components
{
_isAnimating = true;
- Canvas.SetLeft(_ellipse, position.X - (_ellipse.Width / 2));
- Canvas.SetTop(_ellipse, position.Y - (_ellipse.Height / 2));
+ if (!Centered)
+ {
+ Canvas.SetLeft(_ellipse, position.X - (_ellipse.Width / 2));
+ Canvas.SetTop(_ellipse, position.Y - (_ellipse.Height / 2));
+ }
+ else
+ {
+ Canvas.SetLeft(_ellipse, (ActualWidth / 2) - (_ellipse.Width / 2));
+ Canvas.SetTop(_ellipse, (ActualHeight / 2) - (_ellipse.Height / 2));
+ }
DoubleAnimation ani = new DoubleAnimation();
ani.From = 0;
- ani.To = 5;
+ ani.To = RippleFactor;
ani.AutoReverse = true;
- ani.Duration = TimeSpan.FromSeconds(0.5);
+ ani.Duration = TimeSpan.FromSeconds(0.3);
ani.AccelerationRatio = 0.2;
ani.DecelerationRatio = 0.2;
_scale.BeginAnimation(ScaleTransform.ScaleXProperty, ani);
diff --git a/Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml b/Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml
index 353f106cf..9b115d757 100644
--- a/Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml
+++ b/Software/Visual_Studio/Tango.Touch/Components/Ripple.xaml
@@ -26,7 +26,6 @@
<RectangleGeometry RadiusX="{Binding RelativeSource={RelativeSource AncestorType=local:Ripple},Path=CornerRadius.TopLeft}" RadiusY="{Binding RelativeSource={RelativeSource AncestorType=local:Ripple},Path=CornerRadius.BottomRight}" Rect="{Binding RelativeSource={RelativeSource AncestorType=local:Ripple},Path=RenderSize,Converter={StaticResource SizeToRectConverter}}"></RectangleGeometry>
</Border.Clip>
<Grid x:Name="PART_grid">
- <ContentPresenter Content="{TemplateBinding Content}" />
<Canvas IsHitTestVisible="False">
<Ellipse IsHitTestVisible="False" x:Name="PART_ellipse" RenderTransformOrigin="0.5,0.5" Fill="{TemplateBinding RippleBrush}" HorizontalAlignment="Center" VerticalAlignment="Center" Height="{TemplateBinding ActualHeight}" Width="{TemplateBinding ActualHeight}">
<Ellipse.RenderTransform>
@@ -34,6 +33,7 @@
</Ellipse.RenderTransform>
</Ellipse>
</Canvas>
+ <ContentPresenter Content="{TemplateBinding Content}" />
</Grid>
</Border>
</ControlTemplate>
diff --git a/Software/Visual_Studio/Tango.Touch/Components/TransformationHelper.cs b/Software/Visual_Studio/Tango.Touch/Components/TransformationHelper.cs
new file mode 100644
index 000000000..a565e3b84
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Touch/Components/TransformationHelper.cs
@@ -0,0 +1,146 @@
+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.Media;
+using System.Windows.Media.Animation;
+using Tango.SharedUI.Helpers;
+
+namespace Tango.Touch.Components
+{
+ public static class TransformationHelper
+ {
+ #region TransformWhenPressed
+
+ /// <summary>
+ /// Determines whether an element is TransformWhenPressed by the drag and drop service.
+ /// </summary>
+ public static readonly DependencyProperty TransformWhenPressedProperty =
+ DependencyProperty.RegisterAttached("TransformWhenPressed",
+ typeof(bool), typeof(TransformationHelper),
+ new FrameworkPropertyMetadata(false, TransformWhenPressedChanged));
+
+ /// <summary>
+ /// TransformWhenPressed changed.
+ /// </summary>
+ /// <param name="d">The d.</param>
+ /// <param name="e">The <see cref="DependencyPropertyChangedEventArgs"/> instance containing the event data.</param>
+ private static void TransformWhenPressedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ if ((bool)e.NewValue)
+ {
+ RegisterTransformWhenPressed(d as FrameworkElement);
+ }
+ else
+ {
+ UnRegisterTransformWhenPressed(d as FrameworkElement);
+ }
+ }
+
+ private static void UnRegisterTransformWhenPressed(FrameworkElement element)
+ {
+ element.PreviewMouseDown -= Element_PreviewMouseDown;
+ element.PreviewMouseUp -= Element_PreviewMouseUp;
+ }
+
+ private static void RegisterTransformWhenPressed(FrameworkElement element)
+ {
+ element.RenderTransformOrigin = new Point(0.5, 0.5);
+ element.RenderTransform = new ScaleTransform(1, 1);
+ element.PreviewMouseDown += Element_PreviewMouseDown;
+ element.PreviewMouseUp += Element_PreviewMouseUp;
+ var scrollViewer = UIHelper.FindAncestor<ScrollViewer>(element);
+
+ if (scrollViewer != null)
+ {
+ scrollViewer.ScrollChanged += (x, y) =>
+ {
+ ScaleTransform scale = element.RenderTransform as ScaleTransform;
+ scale.BeginAnimation(ScaleTransform.ScaleXProperty, null);
+ scale.BeginAnimation(ScaleTransform.ScaleYProperty, null);
+ };
+ }
+ }
+
+ private static void Element_PreviewMouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ DoubleAnimation ani = new DoubleAnimation();
+ ani.To = 1;
+ ani.Duration = TimeSpan.FromSeconds(0.1);
+ ScaleTransform scale = (sender as FrameworkElement).RenderTransform as ScaleTransform;
+ scale.BeginAnimation(ScaleTransform.ScaleXProperty, ani);
+ scale.BeginAnimation(ScaleTransform.ScaleYProperty, ani);
+ }
+
+ private static void Element_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
+ {
+ if (!GetPreventTransform(e.OriginalSource as FrameworkElement))
+ {
+ DoubleAnimation ani = new DoubleAnimation();
+ ani.To = 1.1;
+ ani.Duration = TimeSpan.FromSeconds(0.2);
+ ani.AutoReverse = true;
+ ScaleTransform scale = (sender as FrameworkElement).RenderTransform as ScaleTransform;
+ scale.BeginAnimation(ScaleTransform.ScaleXProperty, ani);
+ scale.BeginAnimation(ScaleTransform.ScaleYProperty, ani);
+ }
+ }
+
+ /// <summary>
+ /// Sets the TransformWhenPressed attached property.
+ /// </summary>
+ /// <param name="element">The element.</param>
+ /// <param name="value">if set to <c>true</c> [value].</param>
+ public static void SetTransformWhenPressed(FrameworkElement element, bool value)
+ {
+ element.SetValue(TransformWhenPressedProperty, value);
+ }
+
+ /// <summary>
+ /// Gets the TransformWhenPressed attached property.
+ /// </summary>
+ /// <param name="element">The element.</param>
+ /// <returns></returns>
+ public static bool GetTransformWhenPressed(FrameworkElement element)
+ {
+ return (bool)element.GetValue(TransformWhenPressedProperty);
+ }
+
+ #endregion
+
+ #region PreventTransform
+
+ /// <summary>
+ /// Determines whether an element is PreventTransform by the drag and drop service.
+ /// </summary>
+ public static readonly DependencyProperty PreventTransformProperty =
+ DependencyProperty.RegisterAttached("PreventTransform",
+ typeof(bool), typeof(TransformationHelper),
+ new FrameworkPropertyMetadata(false));
+
+ /// <summary>
+ /// Sets the PreventTransform attached property.
+ /// </summary>
+ /// <param name="element">The element.</param>
+ /// <param name="value">if set to <c>true</c> [value].</param>
+ public static void SetPreventTransform(FrameworkElement element, bool value)
+ {
+ element.SetValue(PreventTransformProperty, value);
+ }
+
+ /// <summary>
+ /// Gets the PreventTransform attached property.
+ /// </summary>
+ /// <param name="element">The element.</param>
+ /// <returns></returns>
+ public static bool GetPreventTransform(FrameworkElement element)
+ {
+ return (bool)element.GetValue(PreventTransformProperty);
+ }
+
+ #endregion
+ }
+}