Esempio n. 1
0
        public override void OnNavigatedFrom(NavigationMode mode, Type sourceType)
        {
            State.StopTasks();

            if (mode == NavigationMode.Back)
            {
                Page.NavigationCacheMode = NavigationCacheMode.Disabled;
                PageStateStack.Pop();
            }
            else if (mode == NavigationMode.New)
            {
                if (SaveState != null)
                {
                    State.StateObject = SaveState();
                }

                //var cachedPage = PageStateStack.SameCachedPage(sourceType);
                //if (cachedPage != null)
                //{
                //    cachedPage.Page.NavigationCacheMode = NavigationCacheMode.Disabled;
                //}
            }
            else
            {
                throw new NotImplementedException("Not allowed navigation mode:" + mode);
            }

#if WINDOWS_PHONE_APP
            StatusBar.GetForCurrentView().ForegroundColor   = null;
            StatusBar.GetForCurrentView().BackgroundOpacity = 0.0;
#endif
            Logging.Save();
        }
Esempio n. 2
0
        public override void OnNavigatedTo(NavigationEventArgs e, bool setStatusBar = true)
        {
#if WINDOWS_PHONE_APP
            if (setStatusBar)
            {
                SetStatusBarColor((FrameworkElement)e.Content);
            }
#endif

            if (e.NavigationMode == NavigationMode.New)
            {
                PageStateStack.Push(this.State);
                if (InitializeState != null)
                {
                    InitializeState(e.Parameter);
                }
            }
            else if (e.NavigationMode == NavigationMode.Back)
            {
                var currentState = PageStateStack.Top();
                if (State.PageType != currentState.PageType)
                {
                    throw new InvalidOperationException();
                }

                if (currentState != this.State)
                {
                    this.state = currentState;
                    State.UpdateTasks(this.Page);
                    PageStateStack.Pop();
                    PageStateStack.Push(State);
                    if (RestoreState != null)
                    {
                        RestoreState(State.StateObject);
                    }
                }
                State.ResumeTasks();
            }
            else
            {
                throw new NotImplementedException("Not allowed navigation mode:" + e.NavigationMode);
            }
        }