Пример #1
0
        /// <summary>
        /// Handles the completion of the exit transition, automatically
        /// continuing to bring in the new element's transition as well if it is
        /// ready.
        /// </summary>
        /// <param name="sender">The source object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnExitTransitionCompleted(object sender, System.EventArgs e)
        {
            _readyToTransitionToNewContent = true;
            _performingExitTransition      = false;

            if (_navigationStopped)
            {
                // Restore the old content presenter's interactivity if the navigation is cancelled.
                CompleteTransition(_storedNavigationOutTransition, _oldContentPresenter, _storedOldTransition);
                _navigationStopped = false;
            }
            else
            {
                CompleteTransition(_storedNavigationOutTransition, /*_oldContentPresenter*/ null, _storedOldTransition);
            }

            _storedNavigationOutTransition = null;
            _storedOldTransition           = null;

            if (_contentReady)
            {
                ITransition newTransition = _storedNewTransition;
                TelegramNavigationInTransition navigationInTransition = _storedNavigationInTransition;

                _storedNewTransition          = null;
                _storedNavigationInTransition = null;

                TransitionNewContent(newTransition, navigationInTransition);
            }
        }
Пример #2
0
        /// <summary>
        /// Stops the last navigation transition if it's active and a new navigation occurs.
        /// </summary>
        private void EnsureLastTransitionIsComplete()
        {
            _readyToTransitionToNewContent = false;
            _contentReady = false;

            if (_performingExitTransition)
            {
                Debug.Assert(_storedOldTransition != null && _storedNavigationOutTransition != null);

                // If the app calls GoBack on NavigatedTo, we want the old content to be null
                // because you can't have the same content in two spots on the visual tree.
                if (_oldContentPresenter != null)
                {
                    _oldContentPresenter.Content = null;
                }

                if (_storedOldTransition != null)
                {
                    _storedOldTransition.Stop();
                }

                _storedNavigationOutTransition = null;
                _storedOldTransition           = null;

                if (_storedNewTransition != null)
                {
                    _storedNewTransition.Stop();

                    _storedNewTransition          = null;
                    _storedNavigationInTransition = null;
                }

                _performingExitTransition = false;
            }
        }
 /// <summary>
 /// Sets a
 /// <see cref="T:Microsoft.Phone.Controls.NavigationTransition"/>s
 /// to
 /// <see cref="M:Microsoft.Phone.Controls.TransitionService.NavigationOutTransitionProperty"/>
 /// for a
 /// <see cref="T:System.Windows.UIElement"/>.
 /// </summary>
 /// <param name="element">The <see cref="T:System.Windows.UIElement"/>.</param>
 /// <param name="value">The <see cref="T:Microsoft.Phone.Controls.NavigationTransition"/>.</param>
 /// <returns>The </returns>
 public static void SetNavigationOutTransition(UIElement element, TelegramNavigationOutTransition value)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(NavigationOutTransitionProperty, value);
 }
Пример #4
0
        /// <summary>
        /// Handles the Navigating event of the frame, the immediate way to
        /// begin a transition out before the new page has loaded or had its
        /// layout pass.
        /// </summary>
        /// <param name="sender">The source object.</param>
        /// <param name="e">The event arguments.</param>
        private void OnNavigating(object sender, NavigatingCancelEventArgs e)
        {
            //if (e.NavigationMode == NavigationMode.Reset
            //    || e.Uri.OriginalString == "app://external/"
            //    || e.Uri.OriginalString.StartsWith("/Protocol?encodedLaunchUri"))
            //|| e.Uri.OriginalString.Contains("msg_id"))
            //    return;

            // If the current application is not the origin
            // and destination of the navigation, ignore it.
            // e.g. do not play a transition when the
            // application gets deactivated because the shell
            // will animate the frame out automatically.
            if (!e.IsNavigationInitiator)
            {
                return;
            }

            _isForwardNavigation = e.NavigationMode != NavigationMode.Back;

            var oldElement = Content as UIElement;

            if (oldElement == null)
            {
                return;
            }

            EnsureLastTransitionIsComplete();

            FlipPresenters();

            TransitionElement oldTransitionElement = null;
            TelegramNavigationOutTransition navigationOutTransition = null;
            ITransition oldTransition = null;

            if (!e.Uri.OriginalString.Contains("msg_id") &&
                !e.Uri.OriginalString.Contains("SecondaryTile") &&
                !e.Uri.OriginalString.StartsWith("/Protocol?encodedLaunchUri") &&
                !e.Uri.OriginalString.Contains("rndParam") &&
                !(e.Uri.OriginalString == "/Views/ShellView.xaml" && e.NavigationMode == NavigationMode.New) &&
                !(e.Uri.OriginalString.StartsWith("/Views/Additional/SettingsView.xaml?Action=DC_UPDATE")))
            {
                navigationOutTransition = TelegramTransitionService.GetNavigationOutTransition(oldElement);
            }

            if (navigationOutTransition != null)
            {
                oldTransitionElement = _isForwardNavigation ? navigationOutTransition.Forward : navigationOutTransition.Backward;
            }
            if (oldTransitionElement != null)
            {
                oldTransition = oldTransitionElement.GetTransition(oldElement);
            }
            if (oldTransition != null)
            {
                EnsureStoppedTransition(oldTransition);

                _storedNavigationOutTransition = navigationOutTransition;
                _storedOldTransition           = oldTransition;
                oldTransition.Completed       += OnExitTransitionCompleted;

                _performingExitTransition = true;

                PerformTransition(navigationOutTransition, _oldContentPresenter, oldTransition);

                PrepareContentPresenterForCompositor(_oldContentPresenter);
            }
            else
            {
                _readyToTransitionToNewContent = true;
            }
        }