コード例 #1
0
        private static void ApplyTiltEffect(FrameworkElement element, Point touchPoint, Point centerPoint)
        {
            TiltEffect.ResetTiltReturnStoryboard();
            Point point = new Point(Math.Min(Math.Max(touchPoint.X / (centerPoint.X * 2.0), 0.0), 1.0), Math.Min(Math.Max(touchPoint.Y / (centerPoint.Y * 2.0), 0.0), 1.0));

            if (double.IsNaN(point.X) || double.IsNaN(point.Y))
            {
                return;
            }
            double          num1            = Math.Abs(point.X - 0.5);
            double          num2            = Math.Abs(point.Y - 0.5);
            double          num3            = (double)-Math.Sign(point.X - 0.5);
            double          num4            = (double)Math.Sign(point.Y - 0.5);
            double          num5            = num1 + num2;
            double          num6            = num1 + num2 > 0.0 ? num1 / (num1 + num2) : 0.0;
            double          num7            = num5 * 0.3 * 180.0 / Math.PI;
            double          num8            = (1.0 - num5) * 25.0;
            PlaneProjection planeProjection = element.Projection as PlaneProjection;
            double          num9            = num7 * num6 * num3;

            planeProjection.RotationY = num9;
            double num10 = num7 * (1.0 - num6) * num4;

            planeProjection.RotationX = num10;
            double num11 = -num8;

            planeProjection.GlobalOffsetZ = num11;
        }
コード例 #2
0
 private static void TryStartTiltEffect(FrameworkElement source, ManipulationStartedEventArgs e)
 {
     foreach (FrameworkElement visualAncestor in (e.OriginalSource as FrameworkElement).GetVisualAncestors())
     {
         foreach (Type tiltableItem in TiltEffect.TiltableItems)
         {
             if (tiltableItem.IsAssignableFrom(visualAncestor.GetType()))
             {
                 FrameworkElement frameworkElement1 = !(visualAncestor.ReadLocalValue(TiltEffect.SuppressTiltProperty) is bool) ? visualAncestor.GetVisualAncestors().FirstOrDefault <FrameworkElement>((Func <FrameworkElement, bool>)(x => x.ReadLocalValue(TiltEffect.SuppressTiltProperty) is bool)) : visualAncestor;
                 if (frameworkElement1 == null || !(bool)frameworkElement1.ReadLocalValue(TiltEffect.SuppressTiltProperty))
                 {
                     FrameworkElement element           = VisualTreeHelper.GetChild((DependencyObject)visualAncestor, 0) as FrameworkElement;
                     FrameworkElement frameworkElement2 = e.ManipulationContainer as FrameworkElement;
                     if (element == null || frameworkElement2 == null)
                     {
                         return;
                     }
                     Point touchPoint          = frameworkElement2.TransformToVisual((UIElement)element).Transform(e.ManipulationOrigin);
                     Point centerPoint         = new Point(element.ActualWidth / 2.0, element.ActualHeight / 2.0);
                     Point centerToCenterDelta = TiltEffect.GetCenterToCenterDelta(element, source);
                     TiltEffect.BeginTiltEffect(element, touchPoint, centerPoint, centerToCenterDelta);
                     return;
                 }
             }
         }
     }
 }
コード例 #3
0
 private static void TiltReturnStoryboard_Completed(object sender, EventArgs e)
 {
     if (TiltEffect.wasPauseAnimation)
     {
         TiltEffect.ResetTiltEffect(TiltEffect.currentTiltElement);
     }
     else
     {
         TiltEffect.StopTiltReturnStoryboardAndCleanup();
     }
 }
コード例 #4
0
 private static void StopTiltReturnStoryboardAndCleanup()
 {
     if (TiltEffect.tiltReturnStoryboard != null)
     {
         TiltEffect.tiltReturnStoryboard.Stop();
     }
     if (TiltEffect.currentTiltElement == null)
     {
         return;
     }
     TiltEffect.RevertPrepareControlForTilt(TiltEffect.currentTiltElement);
     TiltEffect.currentTiltElement = null;
 }
コード例 #5
0
 private static void BeginTiltEffect(FrameworkElement element, Point touchPoint, Point centerPoint, Point centerDelta)
 {
     if (TiltEffect.tiltReturnStoryboard != null)
     {
         TiltEffect.StopTiltReturnStoryboardAndCleanup();
     }
     if (!TiltEffect.PrepareControlForTilt(element, centerDelta))
     {
         return;
     }
     TiltEffect.currentTiltElement       = element;
     TiltEffect.currentTiltElementCenter = centerPoint;
     TiltEffect.PrepareTiltReturnStoryboard(element);
     TiltEffect.ApplyTiltEffect(TiltEffect.currentTiltElement, touchPoint, TiltEffect.currentTiltElementCenter);
 }
コード例 #6
0
ファイル: TiltEffect.cs プロジェクト: Makzz90/VKClient_re
        private static void TryStartTiltEffect(FrameworkElement source, ManipulationStartedEventArgs e)
        {
            IEnumerator <FrameworkElement> enumerator1 = (((RoutedEventArgs)e).OriginalSource as FrameworkElement).GetVisualAncestors().GetEnumerator();

            try
            {
                while (((IEnumerator)enumerator1).MoveNext())
                {
                    FrameworkElement        current     = enumerator1.Current;
                    List <Type> .Enumerator enumerator2 = TiltEffect.TiltableItems.GetEnumerator();
                    try
                    {
                        while (enumerator2.MoveNext())
                        {
                            if (enumerator2.Current.IsAssignableFrom((current).GetType()))
                            {
                                FrameworkElement frameworkElement = !(current.ReadLocalValue(TiltEffect.SuppressTiltProperty) is bool) ? current.GetVisualAncestors().FirstOrDefault <FrameworkElement>((Func <FrameworkElement, bool>)(x => x.ReadLocalValue(TiltEffect.SuppressTiltProperty) is bool)) : current;
                                if (frameworkElement == null || !(bool)((DependencyObject)frameworkElement).ReadLocalValue(TiltEffect.SuppressTiltProperty))
                                {
                                    FrameworkElement child = VisualTreeHelper.GetChild((DependencyObject)current, 0) as FrameworkElement;
                                    FrameworkElement manipulationContainer = e.ManipulationContainer as FrameworkElement;
                                    if (child == null || manipulationContainer == null)
                                    {
                                        return;
                                    }
                                    Point touchPoint          = ((UIElement)manipulationContainer).TransformToVisual((UIElement)child).Transform(e.ManipulationOrigin);
                                    Point centerPoint         = new Point(child.ActualWidth / 2.0, child.ActualHeight / 2.0);
                                    Point centerToCenterDelta = TiltEffect.GetCenterToCenterDelta(child, source);
                                    TiltEffect.BeginTiltEffect(child, touchPoint, centerPoint, centerToCenterDelta);
                                    return;
                                }
                            }
                        }
                    }
                    finally
                    {
                        enumerator2.Dispose();
                    }
                }
            }
            finally
            {
                if (enumerator1 != null)
                {
                    ((IDisposable)enumerator1).Dispose();
                }
            }
        }
コード例 #7
0
        private static void ContinueTiltEffect(FrameworkElement element, ManipulationDeltaEventArgs e)
        {
            FrameworkElement frameworkElement = e.ManipulationContainer as FrameworkElement;

            if (frameworkElement == null || element == null)
            {
                return;
            }
            Point point = frameworkElement.TransformToVisual((UIElement)element).Transform(e.ManipulationOrigin);

            if (!new Rect(0.0, 0.0, TiltEffect.currentTiltElement.ActualWidth, TiltEffect.currentTiltElement.ActualHeight).Contains(point))
            {
                TiltEffect.PauseTiltEffect();
            }
            else
            {
                TiltEffect.ApplyTiltEffect(TiltEffect.currentTiltElement, point, TiltEffect.currentTiltElementCenter);
            }
        }
コード例 #8
0
 private static void EndTiltEffect(FrameworkElement element)
 {
     if (element != null)
     {
         element.ManipulationCompleted -= new EventHandler <ManipulationCompletedEventArgs>(TiltEffect.TiltEffect_ManipulationCompleted);
         element.ManipulationDelta     -= new EventHandler <ManipulationDeltaEventArgs>(TiltEffect.TiltEffect_ManipulationDelta);
     }
     if (TiltEffect.tiltReturnStoryboard != null)
     {
         TiltEffect.wasPauseAnimation = false;
         if (TiltEffect.tiltReturnStoryboard.GetCurrentState() == ClockState.Active)
         {
             return;
         }
         TiltEffect.tiltReturnStoryboard.Begin();
     }
     else
     {
         TiltEffect.StopTiltReturnStoryboardAndCleanup();
     }
 }
コード例 #9
0
ファイル: TiltEffect.cs プロジェクト: Makzz90/VKClient_re
        private static void ContinueTiltEffect(FrameworkElement element, ManipulationDeltaEventArgs e)
        {
            FrameworkElement manipulationContainer = e.ManipulationContainer as FrameworkElement;

            if (manipulationContainer == null || element == null)
            {
                return;
            }
            Point touchPoint = ((UIElement)manipulationContainer).TransformToVisual((UIElement)element).Transform(e.ManipulationOrigin);
            Rect  rect       = new Rect(0.0, 0.0, TiltEffect.currentTiltElement.ActualWidth, TiltEffect.currentTiltElement.ActualHeight);

            // ISSUE: explicit reference operation
            if (!rect.Contains(touchPoint))
            {
                TiltEffect.PauseTiltEffect();
            }
            else
            {
                TiltEffect.ApplyTiltEffect(TiltEffect.currentTiltElement, touchPoint, TiltEffect.currentTiltElementCenter);
            }
        }
コード例 #10
0
 private static void TiltEffect_ManipulationDelta(object sender, ManipulationDeltaEventArgs e)
 {
     TiltEffect.ContinueTiltEffect(sender as FrameworkElement, e);
 }
コード例 #11
0
 private static void TiltEffect_ManipulationStarted(object sender, ManipulationStartedEventArgs e)
 {
     TiltEffect.TryStartTiltEffect(sender as FrameworkElement, e);
 }
コード例 #12
0
 private static void TiltEffect_ManipulationCompleted(object sender, ManipulationCompletedEventArgs e)
 {
     TiltEffect.EndTiltEffect(TiltEffect.currentTiltElement);
 }