Esempio n. 1
0
        public static void Peel(this IEnumerable <FrameworkElement> elements, Action endAction)
        {
            List <FrameworkElement> list = elements.ToList <FrameworkElement>();
            FrameworkElement        frameworkElement1 = (FrameworkElement)Enumerable.Last <FrameworkElement>(list);
            double num = 0.0;

            List <FrameworkElement> .Enumerator enumerator = ((List <FrameworkElement>)list).GetEnumerator();
            try
            {
                while (enumerator.MoveNext())
                {
                    FrameworkElement current           = enumerator.Current;
                    double           delay             = num;
                    Storyboard       peelAnimation     = MetroInMotion.GetPeelAnimation(current, delay);
                    FrameworkElement frameworkElement2 = frameworkElement1;
                    if ((current).Equals(frameworkElement2))
                    {
                        ((Timeline)peelAnimation).Completed += ((EventHandler)((s, e) => endAction()));
                    }
                    peelAnimation.Begin();
                    num += 50.0;
                }
            }
            finally
            {
                enumerator.Dispose();
            }
        }
Esempio n. 2
0
        private static void OnTiltChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            FrameworkElement   targetElement  = d as FrameworkElement;
            double             tiltFactor     = MetroInMotion.GetTilt(d);
            PlaneProjection    projection     = new PlaneProjection();
            ScaleTransform     scale          = new ScaleTransform();
            TranslateTransform translate      = new TranslateTransform();
            TransformGroup     transformGroup = new TransformGroup();

            transformGroup.Children.Add((Transform)scale);
            transformGroup.Children.Add((Transform)translate);
            targetElement.Projection            = (Projection)projection;
            targetElement.RenderTransform       = (Transform)transformGroup;
            targetElement.RenderTransformOrigin = new Point(0.5, 0.5);
            MouseButtonEventHandler buttonEventHandler = (MouseButtonEventHandler)((s, e) =>
            {
                Point position = e.GetPosition((UIElement)targetElement);
                double num1 = Math.Max(targetElement.ActualWidth, targetElement.ActualHeight);
                if (num1 == 0.0)
                {
                    return;
                }
                double num2 = 2.0 * (targetElement.ActualWidth / 2.0 - position.X) / num1;
                projection.RotationY = num2 * MetroInMotion.TiltAngleFactor * tiltFactor;
                double num3 = 2.0 * (targetElement.ActualHeight / 2.0 - position.Y) / num1;
                projection.RotationX = -num3 * MetroInMotion.TiltAngleFactor * tiltFactor;
                double num4 = tiltFactor * (1.0 - Math.Sqrt(num2 * num2 + num3 * num3)) / MetroInMotion.ScaleFactor;
                scale.ScaleX = 1.0 - num4;
                scale.ScaleY = 1.0 - num4;
                FrameworkElement frameworkElement = Application.Current.RootVisual as FrameworkElement;
                double num5 = (targetElement.GetRelativePosition((UIElement)frameworkElement).Y - frameworkElement.ActualHeight / 2.0) / 2.0;
                translate.Y = -num5;
                projection.LocalOffsetY = num5;
            });
            EventHandler <ManipulationCompletedEventArgs> eventHandler = (EventHandler <ManipulationCompletedEventArgs>)((s, e) =>
            {
                new Storyboard()
                {
                    Children =
                    {
                        (Timeline)MetroInMotion.CreateAnimation(new double?(), new double?(0.0), 0.1, "RotationY", (DependencyObject)projection),
                        (Timeline)MetroInMotion.CreateAnimation(new double?(), new double?(0.0), 0.1, "RotationX", (DependencyObject)projection),
                        (Timeline)MetroInMotion.CreateAnimation(new double?(), new double?(1.0), 0.1, "ScaleX",    (DependencyObject)scale),
                        (Timeline)MetroInMotion.CreateAnimation(new double?(), new double?(1.0), 0.1, "ScaleY",    (DependencyObject)scale)
                    }
                }.Begin();
                translate.Y             = 0.0;
                projection.LocalOffsetY = 0.0;
            });

            targetElement.MouseLeftButtonDown   -= buttonEventHandler;
            targetElement.ManipulationCompleted -= eventHandler;
            if (tiltFactor <= 0.0)
            {
                return;
            }
            targetElement.MouseLeftButtonDown   += buttonEventHandler;
            targetElement.ManipulationCompleted += eventHandler;
        }
Esempio n. 3
0
        private static Storyboard GetSlideAnimation(FrameworkElement element, bool fromRight)
        {
            double             num1 = fromRight ? 80.0 : -80.0;
            double             num2 = (double)MetroInMotion.GetAnimationLevel((DependencyObject)element) * 0.1 + 0.1;
            TranslateTransform translateTransform = new TranslateTransform()
            {
                X = num1
            };

            element.RenderTransform = (Transform)translateTransform;
            Storyboard storyboard = new Storyboard();
            TimeSpan?  nullable   = new TimeSpan?(TimeSpan.FromSeconds(num2));

            storyboard.BeginTime = nullable;
            storyboard.Children.Add((Timeline)MetroInMotion.CreateAnimation(new double?(num1), new double?(0.0), 0.8, "X", (DependencyObject)translateTransform));
            return(storyboard);
        }
Esempio n. 4
0
        private static Storyboard GetSlideAnimation(FrameworkElement element, bool fromRight)
        {
            double             num1 = fromRight ? 80.0 : -80.0;
            double             num2 = (double)MetroInMotion.GetAnimationLevel((DependencyObject)element) * 0.1 + 0.1;
            TranslateTransform translateTransform1 = new TranslateTransform();
            double             num3 = num1;

            translateTransform1.X = num3;
            TranslateTransform translateTransform2 = translateTransform1;

            ((UIElement)element).RenderTransform = ((Transform)translateTransform2);
            Storyboard storyboard = new Storyboard();
            TimeSpan?  nullable   = new TimeSpan?(TimeSpan.FromSeconds(num2));

            ((Timeline)storyboard).BeginTime = nullable;
            ((PresentationFrameworkCollection <Timeline>)storyboard.Children).Add((Timeline)MetroInMotion.CreateAnimation(new double?(num1), new double?(0.0), 0.8, "X", (DependencyObject)translateTransform2));
            return(storyboard);
        }
Esempio n. 5
0
        private static Storyboard GetPeelAnimation(FrameworkElement element, double delay)
        {
            PlaneProjection planeProjection = new PlaneProjection()
            {
                CenterOfRotationX = -0.1
            };

            element.Projection = (Projection)planeProjection;
            double     num        = Math.Atan(1000.0 / (element.ActualWidth / 2.0)) * 180.0 / Math.PI;
            Storyboard storyboard = new Storyboard();
            TimeSpan?  nullable   = new TimeSpan?(TimeSpan.FromMilliseconds(delay));

            storyboard.BeginTime = nullable;
            storyboard.Children.Add((Timeline)MetroInMotion.CreateAnimation(new double?(0.0), new double?(-(180.0 - num)), 0.3, "RotationY", (DependencyObject)planeProjection));
            storyboard.Children.Add((Timeline)MetroInMotion.CreateAnimation(new double?(0.0), new double?(23.0), 0.3, "RotationZ", (DependencyObject)planeProjection));
            storyboard.Children.Add((Timeline)MetroInMotion.CreateAnimation(new double?(0.0), new double?(-23.0), 0.3, "GlobalOffsetZ", (DependencyObject)planeProjection));
            return(storyboard);
        }
Esempio n. 6
0
 private VirtualizableImage(double width, double height, Thickness margin, Action <VirtualizableImage> callbackOnTap, string tag, bool enableTilt = false, bool showPlaceholder = true, Stretch stretch = Stretch.UniformToFill, Brush placeholderBackgroundBrush = null, double placeholderOpacity = -1.0, bool blackRectOnTop = false, bool isRounded = false)
     : base(width, margin, new Thickness())
 {
     ++VirtualizableImage._TotalCount;
     this._height                     = height;
     this._callbackOnTap              = callbackOnTap;
     this._tag                        = tag;
     this._showPlaceholder            = showPlaceholder;
     this._stretch                    = stretch;
     this._placeholderBackgroundBrush = placeholderBackgroundBrush;
     this._placeholderOpacity         = placeholderOpacity;
     this._blackRectOnTop             = blackRectOnTop;
     this._isRounded                  = isRounded;
     if (!enableTilt)
     {
         return;
     }
     MetroInMotion.SetTilt((DependencyObject)this._view, VKConstants.DefaultTilt);
 }
Esempio n. 7
0
        public static void Peel(this IEnumerable <FrameworkElement> elements, Action endAction)
        {
            List <FrameworkElement> list = elements.ToList <FrameworkElement>();
            FrameworkElement        frameworkElement1 = list.Last <FrameworkElement>();
            double num = 0.0;

            foreach (FrameworkElement element in list)
            {
                double           delay             = num;
                Storyboard       peelAnimation     = MetroInMotion.GetPeelAnimation(element, delay);
                FrameworkElement frameworkElement2 = frameworkElement1;
                if (element.Equals((object)frameworkElement2))
                {
                    peelAnimation.Completed += (EventHandler)((s, e) => endAction());
                }
                peelAnimation.Begin();
                num += 50.0;
            }
        }
Esempio n. 8
0
        private static void OnIsPivotAnimatedChanged(DependencyObject d, DependencyPropertyChangedEventArgs args)
        {
            ItemsControl list = d as ItemsControl;

            list.Loaded += (RoutedEventHandler)((s2, e2) =>
            {
                Pivot pivot = list.Ancestors <Pivot>().Single <DependencyObject>() as Pivot;
                int pivotIndex = pivot.Items.IndexOf((object)list.Ancestors <PivotItem>().Single <DependencyObject>());
                bool selectionChanged = false;
                pivot.SelectionChanged += (SelectionChangedEventHandler)((s3, e3) => selectionChanged = true);
                pivot.ManipulationCompleted += (EventHandler <ManipulationCompletedEventArgs>)((s, e) =>
                {
                    if (!selectionChanged)
                    {
                        return;
                    }
                    selectionChanged = false;
                    if (pivotIndex != pivot.SelectedIndex)
                    {
                        return;
                    }
                    bool fromRight = e.TotalManipulation.Translation.X <= 0.0;
                    List <FrameworkElement> list1 = list.GetItemsInView().ToList <FrameworkElement>();
                    for (int index = 0; index < list1.Count; ++index)
                    {
                        FrameworkElement lbi = list1[index];
                        list.Dispatcher.BeginInvoke((Action)(() =>
                        {
                            foreach (FrameworkElement element in lbi.Descendants().Where <DependencyObject>((Func <DependencyObject, bool>)(p => MetroInMotion.GetAnimationLevel(p) > -1)))
                            {
                                MetroInMotion.GetSlideAnimation(element, fromRight).Begin();
                            }
                        }));
                    }
                });
            });
        }
Esempio n. 9
0
        private static Storyboard GetPeelAnimation(FrameworkElement element, double delay)
        {
            PlaneProjection planeProjection1 = new PlaneProjection();
            double          num1             = -0.1;

            planeProjection1.CenterOfRotationX = num1;
            PlaneProjection planeProjection2 = planeProjection1;

            ((UIElement)element).Projection = ((Projection)planeProjection2);
            double     num2       = Math.Atan(1000.0 / (element.ActualWidth / 2.0)) * 180.0 / Math.PI;
            Storyboard storyboard = new Storyboard();
            TimeSpan?  nullable   = new TimeSpan?(TimeSpan.FromMilliseconds(delay));

            ((Timeline)storyboard).BeginTime = nullable;
            ((PresentationFrameworkCollection <Timeline>)storyboard.Children).Add((Timeline)MetroInMotion.CreateAnimation(new double?(0.0), new double?(-(180.0 - num2)), 0.3, "RotationY", (DependencyObject)planeProjection2));
            ((PresentationFrameworkCollection <Timeline>)storyboard.Children).Add((Timeline)MetroInMotion.CreateAnimation(new double?(0.0), new double?(23.0), 0.3, "RotationZ", (DependencyObject)planeProjection2));
            ((PresentationFrameworkCollection <Timeline>)storyboard.Children).Add((Timeline)MetroInMotion.CreateAnimation(new double?(0.0), new double?(-23.0), 0.3, "GlobalOffsetZ", (DependencyObject)planeProjection2));
            return(storyboard);
        }