Exemplo n.º 1
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;
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
        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();
                }
            }
        }