Ejemplo n.º 1
0
        private void RunHideStoryboard(FrameworkElement element, DialogService.AnimationTypes animation, Action completionCallback)
        {
            if (element == null)
            {
                return;
            }
            Storyboard storyboard = (Storyboard)null;

            switch (animation)
            {
            case DialogService.AnimationTypes.Slide:
                storyboard = XamlReader.Load("\r\n        <Storyboard  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TranslateTransform.Y)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"0\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.25\" Value=\"-150\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimation Storyboard.TargetProperty=\"(UIElement.Opacity)\" From=\"1\" To=\"0\" Duration=\"0:0:0.25\">\r\n                <DoubleAnimation.EasingFunction>\r\n                    <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                </DoubleAnimation.EasingFunction>\r\n            </DoubleAnimation>\r\n        </Storyboard>") as Storyboard;
                break;

            case DialogService.AnimationTypes.SlideInversed:
                storyboard = XamlReader.Load("\r\n        <Storyboard  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TranslateTransform.Y)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"0\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.35\" Value=\"800\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n        </Storyboard>") as Storyboard;
                break;

            case DialogService.AnimationTypes.SlideHorizontal:
                storyboard = XamlReader.Load("\r\n        <Storyboard  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TranslateTransform.X)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"0\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.25\" Value=\"150\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimation Storyboard.TargetProperty=\"(UIElement.Opacity)\" From=\"1\" To=\"0\" Duration=\"0:0:0.25\">\r\n                <DoubleAnimation.EasingFunction>\r\n                    <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                </DoubleAnimation.EasingFunction>\r\n            </DoubleAnimation>\r\n        </Storyboard>") as Storyboard;
                break;

            case DialogService.AnimationTypes.Swivel:
            case DialogService.AnimationTypes.SwivelHorizontal:
                storyboard = XamlReader.Load("<Storyboard xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.Projection).(PlaneProjection.RotationX)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"0\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.25\" Value=\"45\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseIn\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.Opacity)\">\r\n                <DiscreteDoubleKeyFrame KeyTime=\"0\" Value=\"1\" />\r\n                <DiscreteDoubleKeyFrame KeyTime=\"0:0:0.267\" Value=\"0\" />\r\n            </DoubleAnimationUsingKeyFrames>\r\n        </Storyboard>") as Storyboard;
                FrameworkElement frameworkElement = element;
                PlaneProjection  planeProjection  = new PlaneProjection();
                planeProjection.RotationX = 0.0;
                double num = element.ActualHeight / 2.0;
                planeProjection.CenterOfRotationX = num;
                frameworkElement.Projection       = (Projection)planeProjection;
                break;

            case DialogService.AnimationTypes.Fade:
                storyboard = XamlReader.Load("<Storyboard xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimation \r\n\t\t\t\tDuration=\"0:0:0.267\"\r\n\t\t\t\tStoryboard.TargetProperty=\"(UIElement.Opacity)\" \r\n                To=\"0\"/>\r\n        </Storyboard>") as Storyboard;
                break;
            }
            try
            {
                if (storyboard != null)
                {
                    storyboard.Completed += (EventHandler)((s, e) => completionCallback());
                    foreach (Timeline child in (PresentationFrameworkCollection <Timeline>)storyboard.Children)
                    {
                        Storyboard.SetTarget(child, (DependencyObject)element);
                    }
                    storyboard.Begin();
                }
                else
                {
                    completionCallback();
                }
            }
            catch
            {
                completionCallback();
            }
        }
Ejemplo n.º 2
0
        private void RunShowStoryboard(FrameworkElement element, DialogService.AnimationTypes animation, Action completionCallback)
        {
            if (element == null)
            {
                Action action = completionCallback;
                if (action == null)
                {
                    return;
                }
                action();
            }
            else
            {
                Storyboard storyboard = (Storyboard)null;
                switch (animation)
                {
                case DialogService.AnimationTypes.Slide:
                    storyboard = XamlReader.Load("\r\n        <Storyboard  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TranslateTransform.Y)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"-150\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.35\" Value=\"0\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseOut\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimation Storyboard.TargetProperty=\"(UIElement.Opacity)\" From=\"0\" To=\"1\" Duration=\"0:0:0.350\">\r\n                <DoubleAnimation.EasingFunction>\r\n                    <ExponentialEase EasingMode=\"EaseOut\" Exponent=\"6\"/>\r\n                </DoubleAnimation.EasingFunction>\r\n            </DoubleAnimation>\r\n        </Storyboard>") as Storyboard;
                    element.RenderTransform = (Transform) new TranslateTransform();
                    break;

                case DialogService.AnimationTypes.SlideInversed:
                    storyboard = XamlReader.Load("\r\n        <Storyboard  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TranslateTransform.Y)\">\r\n                <SplineDoubleKeyFrame KeyTime=\"0\" Value=\"800\"/>\r\n                <SplineDoubleKeyFrame KeyTime=\"0:0:0.35\" Value=\"0\">\r\n                    <SplineDoubleKeyFrame.KeySpline>\r\n                        <KeySpline>\r\n                            <KeySpline.ControlPoint1>\r\n                                <Point X=\"0.10000000149011612\" Y=\"0.89999997615811421\" />\r\n                            </KeySpline.ControlPoint1>\r\n                            <KeySpline.ControlPoint2>\r\n                                <Point X=\"0.20000000298023224\" Y=\"1\" />\r\n                            </KeySpline.ControlPoint2>\r\n                        </KeySpline>\r\n                    </SplineDoubleKeyFrame.KeySpline>\r\n                </SplineDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimation Storyboard.TargetProperty=\"(UIElement.Opacity)\" From=\"0\" To=\"1\" Duration=\"0\" />\r\n        </Storyboard>") as Storyboard;
                    element.RenderTransform = (Transform) new TranslateTransform();
                    break;

                case DialogService.AnimationTypes.SlideHorizontal:
                    storyboard = XamlReader.Load("\r\n        <Storyboard  xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.RenderTransform).(TranslateTransform.X)\" >\r\n                    <EasingDoubleKeyFrame KeyTime=\"0\" Value=\"-150\"/>\r\n                    <EasingDoubleKeyFrame KeyTime=\"0:0:0.35\" Value=\"0\">\r\n                        <EasingDoubleKeyFrame.EasingFunction>\r\n                            <ExponentialEase EasingMode=\"EaseOut\" Exponent=\"6\"/>\r\n                        </EasingDoubleKeyFrame.EasingFunction>\r\n                    </EasingDoubleKeyFrame>\r\n                </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimation Storyboard.TargetProperty=\"(UIElement.Opacity)\" From=\"0\" To=\"1\" Duration=\"0:0:0.350\" >\r\n                <DoubleAnimation.EasingFunction>\r\n                    <ExponentialEase EasingMode=\"EaseOut\" Exponent=\"6\"/>\r\n                </DoubleAnimation.EasingFunction>\r\n            </DoubleAnimation>\r\n        </Storyboard>") as Storyboard;
                    element.RenderTransform = (Transform) new TranslateTransform();
                    break;

                case DialogService.AnimationTypes.Swivel:
                case DialogService.AnimationTypes.SwivelHorizontal:
                    storyboard = XamlReader.Load("<Storyboard xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.Projection).(PlaneProjection.RotationX)\">\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.0\" Value=\"-45\"/>\r\n                <EasingDoubleKeyFrame KeyTime=\"0:0:0.35\" Value=\"0\">\r\n                    <EasingDoubleKeyFrame.EasingFunction>\r\n                        <ExponentialEase EasingMode=\"EaseOut\" Exponent=\"6\"/>\r\n                    </EasingDoubleKeyFrame.EasingFunction>\r\n                </EasingDoubleKeyFrame>\r\n            </DoubleAnimationUsingKeyFrames>\r\n            <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty=\"(UIElement.Opacity)\">\r\n                <DiscreteDoubleKeyFrame KeyTime=\"0\" Value=\"1\" />\r\n            </DoubleAnimationUsingKeyFrames>\r\n        </Storyboard>") as Storyboard;
                    FrameworkElement frameworkElement = element;
                    PlaneProjection  planeProjection  = new PlaneProjection();
                    planeProjection.RotationX = -45.0;
                    double num = element.ActualHeight / 2.0;
                    planeProjection.CenterOfRotationX = num;
                    frameworkElement.Projection       = (Projection)planeProjection;
                    break;

                case DialogService.AnimationTypes.Fade:
                    storyboard = XamlReader.Load("<Storyboard xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">\r\n            <DoubleAnimation \r\n\t\t\t\tDuration=\"0:0:0.267\" \r\n\t\t\t\tStoryboard.TargetProperty=\"(UIElement.Opacity)\" \r\n                To=\"1\"/>\r\n        </Storyboard>") as Storyboard;
                    break;
                }
                if (storyboard != null)
                {
                    element.Opacity = 0.0;
                    this.CurrentPage.Dispatcher.BeginInvoke((Action)(() =>
                    {
                        storyboard.Completed += (EventHandler)((s, e) =>
                        {
                            Action action = completionCallback;
                            if (action == null)
                            {
                                return;
                            }
                            action();
                        });
                        foreach (Timeline child in (PresentationFrameworkCollection <Timeline>)storyboard.Children)
                        {
                            Storyboard.SetTarget(child, (DependencyObject)element);
                        }
                        storyboard.Begin();
                    }));
                }
                else
                {
                    element.Opacity = 1.0;
                    Action action = completionCallback;
                    if (action == null)
                    {
                        return;
                    }
                    action();
                }
            }
        }