Exemple #1
0
        private void OnHomeButtonPressed(object sender, RoutedEventArgs e)
        {
            if (!_isContentDisplayed)
            {
                return;
            }

            ScopedBatchHelper.CreateScopedBatch(_compositor, CompositionBatchTypes.Animation,
                                                () => // Action
            {
                transitionBGVisual.StartAnimation(nameof(transitionBGVisual.Offset), _offsetDownAnimation);
                transitionBGVisual.StartAnimation("Scale.XY", _scaleDownAnimation);
                transitionBGVisual.StartAnimation(nameof(transitionBGVisual.Opacity), _fadeOutAnimation);
                menuGridVisual.StartAnimation("Scale.XY", _scaleDownMenuAnimation);
                menuGridVisual.StartAnimation(nameof(menuGridVisual.Opacity), _fadeInMenuAnimation);
                transitionContentVisual.CenterPoint = new Vector3();
                transitionContentVisual.StartAnimation(nameof(transitionBGVisual.Offset), _offsetDownAnimation);
                transitionContentVisual.StartAnimation("Scale.XY", _scaleDownContentAnimation);
                transitionContentVisual.StartAnimation(nameof(transitionBGVisual.Opacity), _fadeOutContentAnimation);
            },
                                                () => // Post Action
            {
                ElementCompositionPreview.SetElementChildVisual(CompositionGrid, null);
                _isContentDisplayed         = false;
                ContentFrame.Content        = null;
                ContentContainer.Visibility = Visibility.Collapsed;
            });
        }
Exemple #2
0
        private void OnMenuButtonClicked(object sender, PointerRoutedEventArgs e)
        {
            var control = sender as MenuButton;

            if (control == null)
            {
                return;
            }

            // Find location of control within MenuGrid
            GeneralTransform coordinate = control.TransformToVisual(MenuGrid);
            Point            position   = coordinate.TransformPoint(new Point(0, 0));
            var offset      = new Vector3((float)position.X, (float)position.Y, 0);
            var centerPoint = new Vector3((float)(position.X + (control.Width / 2.0)),
                                          (float)(position.Y + (control.Height / 2.0)),
                                          0);

            // MenuGrid Center Point
            menuGridVisual.CenterPoint = centerPoint;
            // Transition Content Visual
            transitionContentVisual        = ElementCompositionPreview.GetElementVisual(ContentGrid);
            transitionContentVisual.Scale  = new Vector3(1 / _scaleX, 1 / _scaleY, 0);
            transitionContentVisual.Offset = offset;
            //transitionContentVisual.CenterPoint = centerPoint;
            // Transition Background Visual
            transitionBGVisual        = _compositor.CreateSpriteVisual();
            transitionBGVisual.Brush  = _compositor.CreateColorBrush(Colors.White);
            transitionBGVisual.Size   = new Vector2((float)ItemSize, (float)ItemSize);
            transitionBGVisual.Offset = offset;
            ElementCompositionPreview.SetElementChildVisual(CompositionGrid, transitionBGVisual);
            // Set _offsetDownAnimation's final keyframe
            _offsetDownAnimation.InsertKeyFrame(1, transitionBGVisual.Offset);
            ContentFrame.Content        = null;
            ContentContainer.Visibility = Visibility.Visible;



            ScopedBatchHelper.CreateScopedBatch(_compositor, CompositionBatchTypes.Animation,
                                                () => // Action
            {
                if (_loadContentDuringAnimation)
                {
                    ContentFrame.Navigate(control.PageType, control.AppName);
                }
                transitionBGVisual.StartAnimation(nameof(transitionBGVisual.Offset), _offsetUpAnimation);
                transitionBGVisual.StartAnimation("Scale.XY", _scaleUpAnimation);
                transitionBGVisual.StartAnimation(nameof(transitionBGVisual.Opacity), _fadeInAnimation);
                menuGridVisual.StartAnimation("Scale.XY", _scaleUpMenuAnimation);
                menuGridVisual.StartAnimation("Opacity", _fadeOutMenuAnimation);
                transitionContentVisual.StartAnimation(nameof(transitionBGVisual.Offset), _offsetUpAnimation);
                transitionContentVisual.StartAnimation("Scale.XY", _scaleUpContentAnimation);
                transitionContentVisual.StartAnimation(nameof(transitionBGVisual.Opacity), _fadeInContentAnimation);
            },
                                                () => // Post Action
            {
                _isContentDisplayed = true;
                if (!_loadContentDuringAnimation)
                {
                    ContentFrame.Navigate(control.PageType, control.AppName);
                }
            });
        }