/// <summary> /// Does actual navigation - adds journal entry if necessary, etc. /// </summary> /// <param name="e">Details of the navigation event.</param> private void DoNavigation(ViewManagerNavigatedEventArgs e) { DateTime newTimeOfNavigation = DateTime.UtcNow; TimeSpan timeSinceLastNavigation = newTimeOfNavigation - _lastNavigation; if (_contentStateToSave != null && this.IsNewNavigation(e.NavigationMode)) { NavigationService navigationService = NavigationService.GetNavigationService(this); if (navigationService != null) { CustomContentState contentStateToSave = _contentStateToSave; _contentStateToSave = null; if (timeSinceLastNavigation > TimeSpan.FromSeconds(3) || !e.NewNavigator.ShouldReplaceNavigatorInJournal(e.OldNavigator)) { navigationService.AddBackEntry(contentStateToSave); } } } if (e.ContentStateToSave != null) { _contentStateToSave = e.ContentStateToSave; } Content = e.Content; _lastNavigation = newTimeOfNavigation; }
/// <summary> /// Navigation may also take place through the journal when the application is hosted in a NavigationWindow, as is normal. /// On navigation through journal, the ViewContentState object gives the path of the navigation target. /// </summary> /// <remarks> /// When navigation takes place through the journal, the navigation mode reported by the navigaiton service is the platform's /// NavigationMode. It must be converted into ScePhoto's custom navigation mode type here. /// </remarks> /// <param name="path">The journal path to use.</param> /// <param name="mode">The journal navigation mode (NavigationMode.Back or .Forward).</param> private void _NavigateByJournal(string path, NavigationMode mode) { // Journal navigation must be back or forward if (mode == NavigationMode.Back || mode == NavigationMode.Forward) { NavigationMode readerNavigationMode = (mode == NavigationMode.Back) ? NavigationMode.Back : NavigationMode.Forward; if (!string.IsNullOrEmpty(path)) { Navigator currentNavigator = MasterNavigator.GetNavigatorFromPath(path); if (currentNavigator != null) { // Current navigator found, raise Navigating event object content = this._GetNavigatorContent(currentNavigator); CustomContentState customContent = null; if (currentNavigator.IncludeInJournal) { customContent = new _ViewContentState(currentNavigator); } var args = new ViewManagerNavigatedEventArgs(content, readerNavigationMode, customContent, this.CurrentNavigator, currentNavigator); CurrentNavigator = currentNavigator; _OnNavigated(args); } else { // Object is gone. Return error var error = new MissingItemError(path); var args = new ViewManagerNavigatedEventArgs(error, readerNavigationMode, null, this.CurrentNavigator, null); _OnNavigated(args); } } } }
/// <summary> /// Perform new navigation. /// </summary> /// <param name="navigator">Navigator which is the target of new navigation.</param> /// <param name="mode">Navigation mode, whether back, forward, etc.</param> private void _NavigateNew(Navigator navigator, NavigationMode mode) { if (navigator != null) { ViewManagerNavigatedEventArgs args = null; object content = _GetNavigatorContent(navigator); CustomContentState customContent = null; if (navigator.IncludeInJournal) { customContent = new _ViewContentState(navigator); } if (Object.ReferenceEquals(navigator, this.CurrentNavigator)) { // Navigating to the same content. Args should show Refresh mode since this should not be separate journal entry. // Ignore navigation mode passed in this case args = new ViewManagerNavigatedEventArgs(content, NavigationMode.Refresh, customContent, CurrentNavigator, navigator); } else { // Raise event indicating new navigation args = new ViewManagerNavigatedEventArgs(content, mode, customContent, CurrentNavigator, navigator); } CurrentNavigator = navigator; _OnNavigated(args); } }
/// <summary> /// When navigating via the journal, the last viewed content state has not been /// saved to the journal. We can listen for the navigating event on the navigation service to store the content state. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">Details of the cancelled navigation.</param> private void OnNavigationServiceNavigating(object sender, NavigatingCancelEventArgs e) { if (_contentStateToSave != null) { e.ContentStateToSave = _contentStateToSave; _contentStateToSave = null; } }
/// <summary> /// Initializes a new instance of the ViewManagerNavigatedEventArgs class. /// </summary> /// <param name="content">Content to which navigation has taken place.</param> /// <param name="navigationMode">Navigation mode.</param> /// <param name="contentStateToSave">CustomContentState to be persisted to the navigation journal for this navigation.</param> /// <param name="oldNavigator">Navigator for previously navigated content before navigation took place.</param> /// <param name="newNavigator">Navigator for current content after navigation.</param> public ViewManagerNavigatedEventArgs(object content, NavigationMode navigationMode, CustomContentState contentStateToSave, Navigator oldNavigator, Navigator newNavigator) { Content = content; NavigationMode = navigationMode; ContentStateToSave = contentStateToSave; OldNavigator = oldNavigator; NewNavigator = newNavigator; }
// Token: 0x06007997 RID: 31127 RVA: 0x0022770D File Offset: 0x0022590D public void AddBackEntry(CustomContentState state) { this._host.VerifyContextAndObjectState(); this._rootNavSvc.AddBackEntry(state); }
public void AddBackEntry(CustomContentState state) { PART_Frame.AddBackEntry(state); }