private void RunNavigationJob(NavigationJob nextJob) { // We're going to navigate. IsNavigating = true; // If the job allows it, checks if the back stack // already has a page with this Uri. If so, removes // all back entries before and navigates back to it. if (nextJob.PreferBackNavigation) { // Only navigates back if the back stack contains // an entry with the same Uri. If so, clears the back // stack to but not including this entry. if (this.ClearBackStackFor(nextJob.Uri)) { // Navigates back to the right page. RunNavigateBack(); return; } // If we're here, no similar entry was found in // the back stack. So let's fallback to a forward // navigation. } // Back or Forward navigation. if (nextJob.IsForwardNavigation || nextJob.PreferBackNavigation) { RunNavigateForward(nextJob.Uri); } else { RunNavigateBack(); } }
private bool CanJobRun(Job nextJob) { // Navigation job tests. if (nextJob is NavigationJob) { NavigationJob navJob = (NavigationJob)nextJob; // Checks if the navigation target is already on screen. if (navJob.IsForwardNavigation && navJob.CancelIfCurrentSource && _rootFrame.CurrentSource.OriginalString == navJob.Uri.OriginalString) { return(false); } // Checks if the navigation initiator is not already on screen. if (!navJob.IsForwardNavigation && navJob.CancelIfNotCurrentSource && _rootFrame.CurrentSource.OriginalString != navJob.Uri.OriginalString) { return(false); } // Checks if the previous page is valid (Back navigation only). if (!navJob.IsForwardNavigation && !IsPreviousPageValid()) { return(false); } } // Checks if another navigation was scheduled after this one. // If so, this job cannot run because the last navigation // will take over and lead to a back stack conforming. // (This is because game pages should be left alone on the stack, // per Wherigo specifications.) bool isLastJobInQueue; lock (_syncRoot) { isLastJobInQueue = _queue.LastOrDefault() == nextJob; } if (!isLastJobInQueue) { return(false); } // Conditions are good for the job to run. return(true); }