Inheritance: Timeline, IFadeOutThemeAnimation
Exemplo n.º 1
0
        public static void FadeOut(UIElement element)
        {
            var fadeOutStoryboard = new Storyboard();
            var fadeOutAnimation = new FadeOutThemeAnimation();

            Storyboard.SetTarget(fadeOutAnimation, element);
            fadeOutStoryboard.Children.Add(fadeOutAnimation);
            fadeOutStoryboard.Completed += (sender, o) => element.Visibility = Visibility.Collapsed;
            fadeOutStoryboard.Begin();
        }
        public Scenario3()
        {
            this.InitializeComponent();
            ViewChooser.ItemsSource = ((App)App.Current).SecondaryViews;

            var fadeOut = new FadeOutThemeAnimation();
            fadeOutStoryboard.Children.Add(fadeOut);

            // Normally you can point directly to an object named in your XAML. Since
            // the sample hosts multiple pages, it's convenient for this scenario to
            // get the root element
            Storyboard.SetTarget(fadeOut, (DependencyObject) ((FrameworkElement)rootPage.Content).FindName("Splitter"));
        }
        /// <summary>
        /// Fades the element out using the FadeOutThemeAnimation.
        /// </summary>
        /// <remarks>
        /// Opacity property of the element is not affected.<br/>
        /// The duration of the visible animation itself is not affected by the duration parameter. It merely indicates how long the Storyboard will run.<br/>
        /// If FadeOutThemeAnimation was already run before and FadeInThemeAnimation was not run after that - nothing will happen.<br/>
        /// </remarks>
        /// <param name="dob"></param>
        /// <param name="duration"></param>
        /// <returns></returns>
        public static async Task FadeOut(this DependencyObject dob, TimeSpan? duration = null)
        {
            var fadeOutStoryboard = new Storyboard();
            var fadeOutAnimation = new FadeOutThemeAnimation();

            if (duration != null)
            {
                fadeOutAnimation.Duration = duration.Value;
            }

            Storyboard.SetTarget(fadeOutAnimation, dob);
            fadeOutStoryboard.Children.Add(fadeOutAnimation);
            await fadeOutStoryboard.BeginAsync();
        }
Exemplo n.º 4
0
        public TapGrid()
        {
            // Hide the control.
            this.Opacity = 0;

            // Down animation storyboard.
            var downAnim = new FadeInThemeAnimation
            {
                SpeedRatio = 5
            };
            Storyboard.SetTarget(downAnim, this);

            downStory = new Storyboard();
            downStory.Children.Add(downAnim);

            // Up animation storyboard.
            var upAnim = new FadeOutThemeAnimation
            {
                SpeedRatio = 0.5
            };
            Storyboard.SetTarget(upAnim, this);

            upStory = new Storyboard();
            upStory.Children.Add(upAnim);

            // Set event handlers.
            this.PointerPressed += (sender, e) =>
            {
                this.Opacity = 1;
                this.CapturePointer(e.Pointer);
                downStory.Begin();

                if (this.Command.CanExecute(null))
                {
                    this.Command.Execute(null);
                }
            };

            this.PointerReleased += (sender, e) =>
            {
                upStory.Begin();
                this.ReleasePointerCapture(e.Pointer);
            };
        }
Exemplo n.º 5
0
        private void HideGoTopTopButton()
        {
            if (!isHidden)
            {
                isHidden = true;

                var storyboard = new Storyboard();
                var animation = new FadeOutThemeAnimation();
                animation.SetValue(Storyboard.TargetNameProperty, "ScrollToTopButton");
                Storyboard.SetTarget(animation, ScrollToTopButton);
                storyboard.Children.Add(animation);
                storyboard.Completed += (e,a) => { container.Visibility = Visibility.Collapsed; };
                storyboard.Begin();
            }
        }
Exemplo n.º 6
0
    /// <summary>
    /// Fades the element out using the FadeOutThemeAnimation.
    /// </summary>
    /// <remarks>
    /// Opacity property of the element is not affected.<br/>
    /// The duration of the visible animation itself is not affected by the duration parameter. It merely indicates how long the Storyboard will run.<br/>
    /// If FadeOutThemeAnimation was already run before and FadeInThemeAnimation was not run after that - nothing will happen.<br/>
    /// </remarks>
    /// <param name="element"></param>
    /// <param name="duration"></param>
    /// <returns></returns>
    public static async Task FadeOut(this UIElement element, TimeSpan? duration = null)
    {
        //       CleanUpPreviousFadeStoryboard(element);

        var fadeOutStoryboard = new Storyboard();
        var fadeOutAnimation = new FadeOutThemeAnimation();

        if (duration != null)
        {
            fadeOutAnimation.Duration = duration.Value;
        }

        Storyboard.SetTarget(fadeOutAnimation, element);
        fadeOutStoryboard.Children.Add(fadeOutAnimation);
        await fadeOutStoryboard.BeginAsync();
        //          fadeOutStoryboard.Stop();
    }
        private void SearchingFadeOut(bool pivotFadeIn)
        {
            Storyboard sb = new Storyboard() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };

            FadeOutThemeAnimation fadeAnim = new FadeOutThemeAnimation() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
            Storyboard.SetTarget(fadeAnim, SearchingPanel);
            sb.Children.Add(fadeAnim);
            
            sb.Completed += delegate
            {
                SearchingPanel.Visibility = Visibility.Collapsed;
                sb.Stop();
                if (pivotFadeIn) PivotFadeIn();
            };
            sb.Begin();
        }
        private void TypeToSearchFadeOut()
        {
            Storyboard sb = new Storyboard() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };

            FadeOutThemeAnimation fadeAnim = new FadeOutThemeAnimation() { Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
            Storyboard.SetTarget(fadeAnim, TypeToSearchPanel);
            sb.Children.Add(fadeAnim);

            DoubleAnimation doubleAnim = new DoubleAnimation() { To = 20, From = 0, Duration = new Duration(TimeSpan.FromSeconds(0.5)) };
            TranslateTransform translate = new TranslateTransform();
            doubleAnim.EnableDependentAnimation = true;
            TypeToSearchPanel.RenderTransform = translate;
            Storyboard.SetTarget(doubleAnim, translate);
            Storyboard.SetTargetProperty(doubleAnim, "Y");
            sb.Children.Add(doubleAnim);

            sb.Completed += delegate
            {
                TypeToSearchPanel.Visibility = Visibility.Collapsed;
                sb.Stop();
            };
            sb.Begin();
        }
Exemplo n.º 9
0
        private void RemoveDice(DiceViewModel oldDiceViewModel)
        {
            Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                // Find the visual Dice to remove.
                var dice = MainCanvas.Children
                    .Where(u => ((FrameworkElement)u).DataContext == oldDiceViewModel)
                    .FirstOrDefault() as Dice;

                if (dice == null)
                {
                    return;
                }

                // Remove the associated rect from the collection.
                diceRects.Remove(oldDiceViewModel);

                // Build the animation to remove the visual Dice.
                var storyFadeOldDice = new Storyboard();

                var fadeOutAnim = new FadeOutThemeAnimation
                {
                    SpeedRatio = 0.5
                };

                Storyboard.SetTarget(fadeOutAnim, dice);
                storyFadeOldDice.Children.Add(fadeOutAnim);

                // Event to remove the old dice after animation.
                storyFadeOldDice.Completed += (sender2, e2) =>
                {
                    MainCanvas.Children.Remove(dice);
                };

                // Run the animation.
                storyFadeOldDice.Begin();
            });
        }
Exemplo n.º 10
0
        private void LessBtn_Click(object sender, RoutedEventArgs e)
        {
            Storyboard sb = new Storyboard();

            FadeOutThemeAnimation fadeOutTimeline = new FadeOutThemeAnimation();
            FadeOutThemeAnimation fadeOutClipData = new FadeOutThemeAnimation();
            FadeOutThemeAnimation fadeOutVideoControls = new FadeOutThemeAnimation();

            Storyboard.SetTarget(fadeOutTimeline, timelineContainer as DependencyObject);
            Storyboard.SetTarget(fadeOutClipData, ClipDataGrid as DependencyObject);
            Storyboard.SetTarget(fadeOutVideoControls, VideoControls as DependencyObject);

            sb.Children.Add(fadeOutTimeline);
            sb.Children.Add(fadeOutClipData);
            sb.Children.Add(fadeOutVideoControls);

            sb.Begin();

            LessBtn.Visibility = Visibility.Collapsed;
            MoreBtn.Visibility = Visibility.Visible;

            controlsFaded = true;
        }
Exemplo n.º 11
0
        private void AppBarOpened(object sender, object e)
        {
            ApplicationViewState currentViewState = ApplicationView.Value;

            if (currentViewState != ApplicationViewState.Snapped)
            {
                if (timelineContainer == null)
                {
                    try
                    {
                        timelineContainer = (Grid)videoMediaElement.ControlPanel.GetDescendantsOfType<Grid>().ElementAt(2);
                    }
                    catch { }
                }

                try
                {
                    ClipDataGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

                    Storyboard sb = new Storyboard();

                    RepositionThemeAnimation repositionTimelineAnimation = new RepositionThemeAnimation();
                    RepositionThemeAnimation repositionBtnAnimation = new RepositionThemeAnimation();
                    FadeOutThemeAnimation fadeOutAnimation = new FadeOutThemeAnimation();
                    FadeOutThemeAnimation fadeOutBtn = new FadeOutThemeAnimation();

                    Storyboard.SetTarget(fadeOutAnimation, ClipDataGrid as DependencyObject);
                    Storyboard.SetTarget(fadeOutBtn, LessBtn as DependencyObject);

                    Storyboard.SetTarget(repositionTimelineAnimation, timelineContainer as DependencyObject);
                    repositionTimelineAnimation.FromVerticalOffset = 204;

                    Storyboard.SetTarget(repositionBtnAnimation, LessBtn as DependencyObject);
                    repositionBtnAnimation.FromVerticalOffset = 204;

                    sb.Children.Add(repositionTimelineAnimation);
                    sb.Children.Add(repositionBtnAnimation);
                    sb.Children.Add(fadeOutAnimation);
                    sb.Children.Add(fadeOutBtn);

                    timelineContainer.Margin = new Thickness(0, 0, 0, 204);

                    sb.Begin();
                }
                catch { }
            }
        }
        /// <summary>
        /// Fades the element out using the FadeOutThemeAnimation.
        /// </summary>
        /// <remarks>
        /// Opacity property of the element is not affected.<br/>
        /// The duration of the visible animation itself is not affected by the duration parameter. It merely indicates how long the Storyboard will run.<br/>
        /// If FadeOutThemeAnimation was already run before and FadeInThemeAnimation was not run after that - nothing will happen.<br/>
        /// </remarks>
        /// <param name="element"></param>
        /// <param name="duration"></param>
        /// <returns></returns>
        public static void FadeOut(this UIElement element, TimeSpan? duration = null)
        {
            var fadeOutStoryboard = new Storyboard();
            var fadeOutAnimation = new FadeOutThemeAnimation();

            if (duration != null)
            {
                fadeOutAnimation.Duration = duration.Value;
            }

            Storyboard.SetTarget(fadeOutAnimation, element);
            fadeOutStoryboard.Children.Add(fadeOutAnimation);
            fadeOutStoryboard.Begin();
        }