internal NavigationEventArgsAdapter( NavigationFailedEventArgs source )
        {
            Contract.Requires( source != null );

            this.source = source;
            IsSuccess = false;
        }
Пример #2
0
 // Code to execute if a navigation fails
 private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
 {
     if (Debugger.IsAttached)
     {
         // A navigation has failed; break into the debugger
         Debugger.Break();
     }
 }
Пример #3
0
		HResult IExplorerBrowserEvents.OnNavigationFailed(IntPtr pidlFolder) {
			if (NavigationFailed != null) {
				NavigationFailedEventArgs args = new NavigationFailedEventArgs();
				args.FailedLocation = ShellObjectFactory.Create(pidlFolder);
				NavigationFailed(this, args);
			}
			return HResult.Ok;
		}
Пример #4
0
		/// <summary>
		/// Clears the Explorer Browser of existing content, fills it with
		/// content from the specified container, and adds a new point to the Travel Log.
		/// </summary>
		/// <param name="shellObject">The shell container to navigate to.</param>
		/// <exception cref="System.Runtime.InteropServices.COMException">Will throw if navigation fails for any other reason.</exception>
		public void Navigate(ShellObject shellObject) {
			if (shellObject == null) {
				throw new ArgumentNullException("shellObject");
			}

			if (explorerBrowserControl == null) {
				antecreationNavigationTarget = shellObject;
			} else {
				HResult hr = explorerBrowserControl.BrowseToObject(shellObject.NativeShellItem, 0);
				if (hr != HResult.Ok) {
					if ((hr == HResult.ResourceInUse || hr == HResult.Canceled) && NavigationFailed != null) {
						NavigationFailedEventArgs args = new NavigationFailedEventArgs();
						args.FailedLocation = shellObject;
						NavigationFailed(this, args);
					} else {
						throw new CommonControlException(LocalizedMessages.ExplorerBrowserBrowseToObjectFailed, hr);
					}
				}
			}
		}
Пример #5
0
 /// <summary>
 /// Clears the Explorer Browser of existing content, fills it with
 /// content from the specified container, and adds a new point to the Travel Log.
 /// </summary>
 /// <param name="shellObject">The shell container to navigate to.</param>
 /// <exception cref="System.Runtime.InteropServices.COMException">Will throw if navigation fails for any other reason.</exception>
 public void Navigate(ShellObject shellObject)
 {
     if (explorerBrowserControl == null)
     {
         antecreationNavigationTarget = shellObject;
     }
     else
     {
         HRESULT hr = explorerBrowserControl.BrowseToObject(shellObject.NativeShellItem, 0);
         if (hr != HRESULT.S_OK)
         {
             if (hr == HRESULT.RESOURCE_IN_USE)
             {
                 if (NavigationFailed != null)
                 {
                     NavigationFailedEventArgs args = new NavigationFailedEventArgs();
                     args.FailedLocation = shellObject;
                     NavigationFailed(this, args);
                 }
             }
             else
                 throw new COMException("BrowseToObject failed", (int)hr);
         }
     }
 }
Пример #6
0
 void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
 {
     throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
 }
Пример #7
0
 private void OnNavigationFailed(NavigationFailedEventArgs e)
 {
     if (NavigationFailed != null){
         NavigationFailed(this, e);
     }
 }
Пример #8
0
        private void Navigate(Uri oldValue, Uri newValue, NavigationType navigationType)
        {
            Debug.WriteLine("Navigating from '{0}' to '{1}'", oldValue, newValue);

            // set IsLoadingContent state
            SetValue(IsLoadingContentPropertyKey, true);

            // cancel previous load content task (if any)
            // note: no need for thread synchronization, this code always executes on the UI thread
            if (this.tokenSource != null) {
                this.tokenSource.Cancel();
                this.tokenSource = null;
            }

            // push previous source onto the history stack (only for new navigation types)
            if (oldValue != null && navigationType == NavigationType.New) {
                this.history.Push(oldValue);
            }

            object newContent = null;

            if (newValue != null) {
                // content is cached on uri without fragment
                var newValueNoFragment = NavigationHelper.RemoveFragment(newValue);

                if (navigationType == NavigationType.Refresh || !this.contentCache.TryGetValue(newValueNoFragment, out newContent)) {
                    var localTokenSource = new CancellationTokenSource();
                    this.tokenSource = localTokenSource;
                    // load the content (asynchronous!)
                    var scheduler = TaskScheduler.FromCurrentSynchronizationContext();
                    var task = this.ContentLoader.LoadContentAsync(newValue, this.tokenSource.Token);

                    task.ContinueWith(t => {
                        try {
                            if (t.IsCanceled || localTokenSource.IsCancellationRequested) {
                                Debug.WriteLine("Cancelled navigation to '{0}'", newValue);
                            }
                            else if (t.IsFaulted) {
                                // raise failed event
                                var failedArgs = new NavigationFailedEventArgs {
                                    Frame = this,
                                    Source = newValue,
                                    Error = t.Exception.InnerException,
                                    Handled = false
                                };

                                OnNavigationFailed(failedArgs);

                                // if not handled, show error as content
                                newContent = failedArgs.Handled ? null : failedArgs.Error;

                                SetContent(newValue, navigationType, newContent, true);
                            }
                            else {
                                newContent = t.Result;
                                if (ShouldKeepContentAlive(newContent)) {
                                    // keep the new content in memory
                                    this.contentCache[newValueNoFragment] = newContent;
                                }

                                SetContent(newValue, navigationType, newContent, false);
                            }
                        }
                        finally {
                            // clear global tokenSource to avoid a Cancel on a disposed object
                            if (this.tokenSource == localTokenSource) {
                                this.tokenSource = null;
                            }

                            // and dispose of the local tokensource
                            localTokenSource.Dispose();
                        }
                    }, scheduler);
                    return;
                }
            }

            // newValue is null or newContent was found in the cache
            SetContent(newValue, navigationType, newContent, false);
        }
Пример #9
0
 private void Frame_NavigationFailed(object sender, NavigationFailedEventArgs e)
 {
     NavigationFailed?.Invoke(sender, e);
 }
 /// <summary>
 /// Invoked when Navigation to a certain page fails
 /// </summary>
 /// <param name="sender">The Frame which failed navigation</param>
 /// <param name="e">Details about the navigation failure</param>
 void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
 {
     throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
 }
Пример #11
0
 private void Frame_NavigationFailed(object sender, NavigationFailedEventArgs e)
 {
     throw e.Exception;
 }
Пример #12
0
 /// <summary>
 /// 导航到特定页失败时调用
 /// </summary>
 ///<param name="sender">导航失败的框架</param>
 ///<param name="e">有关导航失败的详细信息</param>
 private void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
 {
     Conf.Log($"unable to load page: {e.SourcePageType.FullName}.", LogLevel.Warning);
 }
Пример #13
0
 // Код для выполнения в случае ошибки навигации
 private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
 {
     if (System.Diagnostics.Debugger.IsAttached)
     {
         // Ошибка навигации; перейти в отладчик
         System.Diagnostics.Debugger.Break();
     }
 }
Пример #14
0
 /// <summary>
 /// Invoked when Navigation to a certain page fails
 /// </summary>
 /// <param name="sender">The Frame which failed navigation</param>
 /// <param name="e">Details about the navigation failure</param>
 private static void OnNavigationFailed(object sender, NavigationFailedEventArgs e) => throw new Exception($"Failed to load {e.SourcePageType.FullName}: {e.Exception}");
Пример #15
0
 /// <summary>
 /// Invoked when Navigation to a certain page fails
 /// </summary>
 /// <param name="sender">The Frame which failed navigation</param>
 /// <param name="e">Details about the navigation failure</param>
 void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
 {
     throw new Exception($"Failed to load Page {e.SourcePageType}: {e.Exception}");
 }