예제 #1
0
        private void GoBackInternal()
        {
            var previousPage = this.backStack.Peek();
            var previousPageType = previousPage.GetType();

            // navigating from
            var navigatingCancelEventArgs = new NavigatingCancelEventArgs(previousPageType, NavigationMode.Back);
            this.CurrentPage.InternalOnNavigatingFrom(navigatingCancelEventArgs);
            if (navigatingCancelEventArgs.Cancel)
            {
                return;
            }

            // navigated from
            this.backStack.Pop();
            this.visualRoot.Child = null;
            this.CurrentPage.InternalOnNavigatedFrom(new NavigationEventArgs(previousPageType, null, NavigationMode.Back, true));

            // navigation
            this.visualRoot.Child = previousPage;
            this.NativeShowPage(previousPage, NavigationMode.Back, this.modalIsDisplayed ? NavigationType.Modal : NavigationType.Default);
            this.modalIsDisplayed = false;
            this.CurrentPage = previousPage;

            // navigated to
            previousPage.InternalOnNavigatedTo(new NavigationEventArgs(previousPageType, null, NavigationMode.Back, true));
        }
예제 #2
0
 private void OnNavigating(NavigatingCancelEventArgs e)
 {
     if (this.Navigating != null)
     {
         this.Navigating(this, e);
     }
 }
예제 #3
0
#pragma warning disable 108

        public void GoBack()
        { 
#if __ANDROID__ || WINDOWS_PHONE
         
            if (this.IsNavigationInProgress)
            {
                return;
            }
            this.IsNavigationInProgress = true;

            AppercodePage previosPage = this.BackStack.FirstOrDefault();
            if (previosPage == null)
            {
                this.CloseApplication();
                this.IsNavigationInProgress = false;
                return;
            }
            Type previosPageType = previosPage.GetType();

            // navigating from
            NavigatingCancelEventArgs navigatingCancelEventArgs = new NavigatingCancelEventArgs(previosPageType, NavigationMode.Back);
            this.CurrentPage.InternalOnNavigatingFrom(navigatingCancelEventArgs);
            if (navigatingCancelEventArgs.Cancel == true)
            {
                this.IsNavigationInProgress = false;
                return;
            }

            if(backStack.Count == 1)
            {
                this.NativeBackToTabs();

                this.CurrentPage.InternalOnNavigatedFrom(new NavigationEventArgs(previosPageType, null, NavigationMode.Back, true));
                this.CurrentPage = previosPage;
                // navigated to
                previosPage.InternalOnNavigatedTo(new NavigationEventArgs(previosPageType, null, NavigationMode.Back, true));
                this.IsNavigationInProgress = false;
                return;
            }

            // navigated from
            this.backStack.Pop();
            this.CurrentPage.InternalOnNavigatedFrom(new NavigationEventArgs(previosPageType, null, NavigationMode.Back, true));

            // navigation
            //this.visualRoot.Child = previosPage;
            this.NativeShowPage(previosPage, NavigationMode.Back, false);

            this.CurrentPage = previosPage;
            // navigated to
            previosPage.InternalOnNavigatedTo(new NavigationEventArgs(previosPageType, null, NavigationMode.Back, true));
            this.IsNavigationInProgress = false;
#else
            if (this.currentTabIndex < 0 || this.currentTabIndex >= this.navigationStacks.Count)
            {
                return;
            }
            this.navigationStacks[this.currentTabIndex].GoBack();
#endif
        }
예제 #4
0
        private object NavigateInternal(Type sourcePageType, object parameter, NavigationType navigationType)
        {
            this.IsNavigationInProgress = true;

            // navigating from
            if (this.CurrentPage != null)
            {
                var navigatingCancelEventArgs = new NavigatingCancelEventArgs(sourcePageType, NavigationMode.New);
                this.CurrentPage.InternalOnNavigatingFrom(navigatingCancelEventArgs);
                if (navigatingCancelEventArgs.Cancel)
                {
                    this.IsNavigationInProgress = false;
                    return BooleanBoxes.FalseBox;
                }
            }

            // navigated from
            var navigationEventArgs = new NavigationEventArgs(sourcePageType, parameter);
            if (this.CurrentPage != null)
            {
                this.CurrentPage.InternalOnNavigatedFrom(navigationEventArgs);
                this.backStack.Push(this.CurrentPage);
            }

            // Create page
            var pageConstructorInfo = sourcePageType.GetConstructor(new Type[] { });
            AppercodePage pageInstance;
            try
            {
                pageInstance = (AppercodePage)pageConstructorInfo.Invoke(new object[] { });
            }
            catch (TargetInvocationException e)
            {
                this.IsNavigationInProgress = false;
                throw e.InnerException;
            }

            pageInstance.NavigationService = this.NavigationService;
            this.visualRoot.Child = pageInstance;
            this.NativeShowPage(pageInstance, NavigationMode.New, navigationType);
            this.modalIsDisplayed |= navigationType == NavigationType.Modal;

            // navigated to
            pageInstance.InternalOnNavigatedTo(navigationEventArgs);

            this.CurrentPage = pageInstance;
            this.IsNavigationInProgress = false;
            return BooleanBoxes.TrueBox;
        }
예제 #5
0
        private bool Navigate(Type sourcePageType, object parameter, bool isTabSwitching, NavigationType navigationType, AppercodePage tabPage = null)
        {
#if __ANDROID__ || WINDOWS_PHONE
            if (sourcePageType == null)
            {
                throw new ArgumentNullException("sourcePageType", "sourcePageType must not be null");
            }
            if (!sourcePageType.IsSubclassOf(typeof(AppercodePage)) && sourcePageType != typeof(AppercodePage))
            {
                throw new ArgumentException("sourcePageType must be an AppercodePage", "sourcePageType");
            }

            if (this.IsNavigationInProgress)
            {
                return false;
            }
            this.IsNavigationInProgress = true;

            // navigating from with check
            NavigatingCancelEventArgs navigatingCancelEventArgs = new NavigatingCancelEventArgs(sourcePageType, NavigationMode.New);

            if (this.CurrentPage != null)
            {
                this.CurrentPage.InternalOnNavigatingFrom(navigatingCancelEventArgs);
                if (navigatingCancelEventArgs.Cancel == true)
                {
                    this.IsNavigationInProgress = false;
                    return false;
                }
            }
            AppercodePage pageInstance;

            // navigated from
            if (this.CurrentPage != null)
            {
                this.CurrentPage.InternalOnNavigatedFrom(new NavigationEventArgs(sourcePageType, parameter));
                this.backStack.Push(this.CurrentPage);
            }

            // Create page
            if (isTabSwitching && backStack.Any())
            {
                this.backStack.Clear();
            }

            if (isTabSwitching && tabPage != null)
            {
                pageInstance = tabPage;
            }
            else
            {
                pageInstance = InstantiatePage(sourcePageType);
            }

            pageInstance.NavigationService = this.navigationService;
            //this.visualRoot.Child = pageInstance;
            this.NativeShowPage(pageInstance, NavigationMode.New, isTabSwitching);

            // navigated to
            pageInstance.InternalOnNavigatedTo(new NavigationEventArgs(sourcePageType, parameter));

            this.CurrentPage = pageInstance;

            this.IsNavigationInProgress = false;
            return true;
#else
            if (this.currentTabIndex < 0 || this.currentTabIndex >= this.navigationStacks.Count)
            {
                return false; 
            }
            return this.navigationStacks[this.currentTabIndex].Navigate(sourcePageType, parameter, navigationType);
#endif
        }
        private bool Navigate(Type sourcePageType, object parameter, bool isTabSwitching, NavigationType navigationType, AppercodePage tabPage = null)
        {
#if __ANDROID__ || WINDOWS_PHONE
            if (sourcePageType == null)
            {
                throw new ArgumentNullException("sourcePageType", "sourcePageType must not be null");
            }
            if (!sourcePageType.IsSubclassOf(typeof(AppercodePage)) && sourcePageType != typeof(AppercodePage))
            {
                throw new ArgumentException("sourcePageType must be an AppercodePage", "sourcePageType");
            }

            if (this.IsNavigationInProgress)
            {
                return(false);
            }
            this.IsNavigationInProgress = true;

            // navigating from with check
            NavigatingCancelEventArgs navigatingCancelEventArgs = new NavigatingCancelEventArgs(sourcePageType, NavigationMode.New);

            if (this.CurrentPage != null)
            {
                this.CurrentPage.InternalOnNavigatingFrom(navigatingCancelEventArgs);
                if (navigatingCancelEventArgs.Cancel == true)
                {
                    this.IsNavigationInProgress = false;
                    return(false);
                }
            }
            AppercodePage pageInstance;

            // navigated from
            if (this.CurrentPage != null)
            {
                this.CurrentPage.InternalOnNavigatedFrom(new NavigationEventArgs(sourcePageType, parameter));
                this.backStack.Push(this.CurrentPage);
            }

            // Create page
            if (isTabSwitching && backStack.Any())
            {
                this.backStack.Clear();
            }

            if (isTabSwitching && tabPage != null)
            {
                pageInstance = tabPage;
            }
            else
            {
                pageInstance = InstantiatePage(sourcePageType);
            }

            pageInstance.NavigationService = this.navigationService;
            //this.visualRoot.Child = pageInstance;
            this.NativeShowPage(pageInstance, NavigationMode.New, isTabSwitching);

            // navigated to
            pageInstance.InternalOnNavigatedTo(new NavigationEventArgs(sourcePageType, parameter));

            this.CurrentPage = pageInstance;

            this.IsNavigationInProgress = false;
            return(true);
#else
            if (this.currentTabIndex < 0 || this.currentTabIndex >= this.navigationStacks.Count)
            {
                return(false);
            }
            return(this.navigationStacks[this.currentTabIndex].Navigate(sourcePageType, parameter, navigationType));
#endif
        }
        /// <summary>
        /// Go to previous <see cref="AppercodePage"/>
        /// </summary>
        public void GoBack()
        {
            AppercodePage previosPage = this.BackStack.FirstOrDefault();
            if (previosPage == null)
            {
                this.CloseApplication();
                return;
            }
            Type previosPageType = previosPage.GetType();

            // navigating from
            NavigatingCancelEventArgs navigatingCancelEventArgs = new NavigatingCancelEventArgs(previosPageType, NavigationMode.Back);
            this.CurrentPage.InternalOnNavigatingFrom(navigatingCancelEventArgs);
            if (navigatingCancelEventArgs.Cancel == true)
            {
                return;
            }

            // navigated from
            this.backStack.Pop();
            this.visualRoot.Child = null;
            this.CurrentPage.InternalOnNavigatedFrom(new NavigationEventArgs(previosPageType, null, NavigationMode.Back, true));

            // navigation
            this.visualRoot.Child = previosPage;
            this.NativeShowPage(previosPage, NavigationMode.Back, this.modalIsDisplayed ? NavigationType.Modal : NavigationType.Default);
            this.modalIsDisplayed = false;

            this.CurrentPage = previosPage;

            // navigated to
            previosPage.InternalOnNavigatedTo(new NavigationEventArgs(previosPageType, null, NavigationMode.Back, true));
        }
예제 #8
0
파일: Page.cs 프로젝트: evnik/UIFramework
 protected virtual void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
 }
예제 #9
0
파일: Page.cs 프로젝트: evnik/UIFramework
 internal void InternalOnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     this.OnNavigatingFrom(e);
 }