/// <summary> /// 跳转到指定栈序号中的页。如果该页不存在,那么返回false。在历史记录中跳转不会影响现有历史记录及其排序。 /// </summary> /// <param name="goal"></param> /// <returns></returns> public bool Goto(int goal) { if (goal < 0 || goal >= navigation.Count) { return(false); } var before = now; var after = factory.Create(navigation[index = goal]); if (after != null) { if (!after.NavigatingToEvent(this, null)) { return(false); } var args = new NavigationEventArgs(before, after); Navigating?.Invoke(this, args); before?.NavigatingFromEvent(this, null); frame.NavigationService.Content = after; after.NavigatedToEvent(this, null); index = goal; now = after; //更新名称列表中的名称。 UpdateName_One(goal, now.Title); Navigated?.Invoke(this, args); setBackButtonEnable(); return(true); } else { return(false); } }
bool OnNavigating(bool isBack = false) { var args = new ViewNavigationEventArgs(CurrentViewModel, null, isBack); Navigating?.Invoke(this, args); return(args.Cancel); }
private void Webview_NavigationStarting(object sender, CoreWebView2NavigationStartingEventArgs e) { var args = new NavigatingEventArgs(new Uri(e.Uri)); Navigating?.Invoke(this, args); e.Cancel = args.Cancel; }
private void Webview_Navigating(object sender, WebBrowserNavigatingEventArgs e) { var args = new NavigatingEventArgs(e.Url); Navigating?.Invoke(this, args); e.Cancel = args.Cancel; }
private void LoadCallback(IntPtr webview, WebKitLoadEvent type, IntPtr userdata) { if (type == WebKitLoadEvent.Started) { loadEventHandled = false; } // this callback gets called in this order: // Started: initially defined URL // Redirected (optional, multiple): new URL to which the redirect points // Committed: final URL that gets loaded, either initial URL or same as last redirect URL // Finished: same URL as committed, page has fully loaded if (type == WebKitLoadEvent.Started || type == WebKitLoadEvent.Redirected) { string url = GLibString.FromPointer(WebKit.GetCurrentUri(webview)); var args = new NavigatingEventArgs(new Uri(url)); Navigating?.Invoke(this, args); if (args.Cancel) { WebKit.StopLoading(webview); } } else if (type == WebKitLoadEvent.Finished && !loadEventHandled) { if (EnableDevTools) { ShowDevTools(); } loadEventHandled = true; } }
/// <summary> /// Navigates to the specified <see cref="ShellItem" />. /// </summary> /// <param name="folder"> /// The folder to navigate to. /// </param> public void Navigate(ShellItem folder) { var e = new NavigatingEventArgs(folder); Navigating?.Invoke(this, e); if (e.Cancel) { return; } var previous = ShellItem; ShellItem = folder; try { RecreateShellView(); History.Add(folder); OnNavigated(); } catch (Exception) { ShellItem = previous; RecreateShellView(); throw; } }
private void Webview_NavigationStarting(IWebViewControl sender, WebViewControlNavigationStartingEventArgs e) { var args = new NavigatingEventArgs(e.Uri); Navigating?.Invoke(this, args); e.Cancel = args.Cancel; }
private Task <bool> WaitOnNavigatingCancelResponseAsync(object target) { Navigating?.Invoke(this, target); return(TaskCompletionSource != null ? TaskCompletionSource.Task : Task.FromResult(false)); }
private void OnFrameLoadStart(object sender, FrameLoadStartEventArgs e) { if (e.Frame.IsMain) { ActionExtension.InvokeInMainThreadAsync(() => { Navigating?.Invoke(this, PageLoadingEventArgs.Indetermitate); }); } }
public void NavigateBack() { if (_viewModelStack.Count > 1) { _viewModelStack.Pop(); } Navigating?.Invoke(this, _viewModelStack.Peek()); }
protected virtual void OnBeforeBrowse(BeforeBrowseEventArgs e) { BeforeBrowse?.Invoke(this, e); CefFrame frame = e.Frame; if (frame != null && frame.IsMain) { Navigating?.Invoke(this, e); } }
public void HandleNavigating(ShellNavigatingEventArgs args) { if (!args.DeferredEventArgs) { Navigating?.Invoke(this, args); } else { return; } }
private bool RaiseNavigatingRemove(IDataContext context) { var args = new RemoveNavigatingCancelEventArgs(context); Navigating?.Invoke(this, args); if (args.Cancel) { return(false); } return(true); }
private void OnFrameLoadEnd(object sender, FrameLoadEndEventArgs e) { if (e.Frame.IsMain) { ActionExtension.InvokeInMainThread(() => { Navigating?.Invoke(this, PageLoadingEventArgs.Ready); ModifyPage(); Navigated?.Invoke(this, new PageLoadedEventArgs(_inner.Address)); }); } }
public void ClearNavigatingInvocationList() { if (Navigating != null) { Delegate[] associatedDelegates = Navigating.GetInvocationList(); foreach (var d in associatedDelegates) { Navigating -= (d as NavigatingCancelEventHandler); } } }
/// <summary> /// 跳转到页面 /// </summary> /// <param name="paramter"></param> /// <param name="view"></param> /// <param name="content"></param> /// <returns></returns> private async Task Navigate(object paramter, ViewModelPage view, Frame content) { Navigating?.Invoke(this, view); if (content == null) { content = Content; } _viewModel?.NavigatedFrom(this, null); await view.Navigate(content, this, paramter); _viewModel = view.ViewModel; Navigated?.Invoke(this, view); }
private void OnNavigating(object content, NavigatingCancelEventArgs e) { e.IsParentFrameNavigating = e.Frame != Frame; // invoke IContent.OnNavigatingFrom on View (content as IContent)?.OnNavigatingFrom(e); // invoke IContent.OnNavigatingFrom on View. var frameworkElement = content as FrameworkElement; (frameworkElement?.DataContext as IContent)?.OnNavigatingFrom(e); Navigating?.Invoke(this, e); }
void INavigationService2.RaiseNavigatingCancels(object parameter, bool suspending, NavigationMode mode, NavigationInfo toInfo, out ContinueResult cancel) { var navigatingDeferral = new Common.DeferralExManager(); var navigatingEventArgs = new NavigatingEventArgs(navigatingDeferral) { Parameter = parameter, Suspending = suspending, NavigationMode = mode, TargetPageType = toInfo.PageType, TargetPageParameter = toInfo.Parameter, }; Navigating?.Invoke(this, navigatingEventArgs); cancel = navigatingEventArgs.Cancel ? ContinueResult.Stop : ContinueResult.Continue; }
public void RaiseNavigatingCancels(object parameter, bool suspending, NavigationMode mode, NavigationInfo toInfo, out bool cancel) { var navigatingDeferral = new Common.DeferralManager(); var navigatingEventArgs = new NavigatingEventArgs(navigatingDeferral) { Parameter = parameter, Suspending = suspending, NavigationMode = mode, TargetPageType = toInfo.PageType, TargetPageParameter = toInfo.Parameter, }; Navigating?.Invoke(this, navigatingEventArgs); cancel = navigatingEventArgs.Cancel; }
/// <summary> /// Raises the navigating event. /// </summary> /// <param name="content">The content.</param> /// <param name="e">The navigating cancel event arguments.</param> private void OnNavigating(IContent content, NavigatingCancelEventArgs e) { // first invoke child frame navigation events foreach (var f in GetChildFrames()) { f.OnNavigating(f.Content as IContent, e); } e.IsParentFrameNavigating = !Equals(e.Frame, this); // invoke IContent.OnNavigating (only if content implements IContent) content?.OnNavigatingFrom(e); // raise the Navigating event Navigating?.Invoke(this, e); }
private void playNavigationAnimation(bool aniamtion) { var index = ViewModel.DocumentTabs.IndexOf(checkedTab); if (index < 0) { tabTagTransform.To = ViewModel.DocumentTabs.Count * 48 + splitViewGrid.RowDefinitions[3].ActualHeight + splitViewGrid.RowDefinitions[4].ActualHeight; } else { tabTagTransform.To = index * 48; } Navigating.Begin(); if (!aniamtion) { Navigating.SkipToFill(); } }
public void NavigateTo(ViewModelEnum key) { var vmToNavigateTo = NavItems[key]; if (_viewModelStack.Count == 0) { _viewModelStack.Push(vmToNavigateTo); } else { if (_viewModelStack.Peek() != vmToNavigateTo) { _viewModelStack.Push(vmToNavigateTo); } } Navigating?.Invoke(this, vmToNavigateTo); }
/// <summary> /// 跳转到具有指定代号的新页面。这将会将新页面压栈,并影响现有历史记录。 /// </summary> /// <param name="name">页面的标识名称.</param> /// <param name="kwargs">要跳转到某个页面时,向页面传递的请求参数。</param> /// <returns></returns> public bool Goto(string name, IDictionary <string, object> kwargs = null) { var before = now; var after = factory.Create(name); //此处涉及历史记录的覆盖逻辑:新的页面总是从当前页面位号的后一位开始覆盖。 if (after != null) { var args = new NavigationEventArgs(before, after); if (!after.NavigatingToEvent(this, kwargs)) { return(false); //如果该事件返回了false,表示取消本次导航操作。 } if (index >= 0 && index + 1 < navigation.Count) { navigation.RemoveRange(index + 1, navigation.Count - index - 1);//将从before开始的所有项目全部删除。 navigation_name.RemoveRange(index + 1, navigation_name.Count - index - 1); } if (navigation.Contains(name)) { var name_index = navigation.IndexOf(name); navigation.RemoveRange(name_index, navigation.Count - name_index);//如果已有当前项目,那么从该项目开始的所有项目全部删除。 navigation_name.RemoveRange(name_index, navigation_name.Count - name_index); } Navigating?.Invoke(this, args); before?.NavigatingFromEvent(this, null); frame.NavigationService.Content = after; after.NavigatedToEvent(this, kwargs); navigation.Add(name); navigation_name.Add(after.Title); index = navigation.IndexOf(name); now = after; UpdateName_All(); Navigated?.Invoke(this, args); setBackButtonEnable(); return(true); } else { return(false); } }
private void TryNavForwardUntil(Page page) { NavigatingEventArgs navigatingEventArgs = new(CurrentPage !, page); Navigating?.Invoke(this, navigatingEventArgs); if (navigatingEventArgs.Cancel) { return; } while (CurrentPage != page) { backStack.Push((CurrentPage as Page) !); CurrentPage = forwardStack.Pop(); } OnPropertyChanged(); CurrentPage.Refresh(); Navigated?.Invoke(this, navigatingEventArgs); }
public static void Initialize(IScheduler scheduler) { WebView.Implementation.UrlFactory += (uri, onNavigating) => Control.Create(control => { var webBrowser = new WebBrowser(); webBrowser.Navigating += (sender, args) => { var navigatingArgs = new Navigating(args.Uri); onNavigating(navigatingArgs); args.Cancel = navigatingArgs.Cancel; }; DataBinding.ObservableFromNativeEvent <EventArgs>(webBrowser, "LoadCompleted") .CombineLatest(webBrowser.GetDpi(), Tuple.Create) .Subscribe((_, density) => webBrowser.SetZoom(density)); scheduler.Schedule(() => webBrowser.Navigate(uri)); control.BindNativeDefaults(webBrowser, scheduler); return(webBrowser); }); WebView.Implementation.StringFactory += (content) => Control.Create(control => { var webBrowser = new WebBrowser(); content.Subscribe(c => { if (!string.IsNullOrEmpty(c)) { scheduler.Schedule(() => webBrowser.NavigateToString(c)); } }); control.BindNativeDefaults(webBrowser, scheduler); return(webBrowser); }); }
public static void Initialize(IScheduler dispatcher) { // Need to initialize HttpEncoder.Current because it doesn't default to HttpEncoder.Default. // See #3385 for more details. System.Web.Util.HttpEncoder.Current = System.Web.Util.HttpEncoder.Default; WebView.Implementation.UrlFactory = (uri, onNavigating) => Control.Create(self => { var webView = new WebKit.WebView(); webView.DecidePolicyForNavigation += (sender, eventArgs) => { var listener = new WebPolicyListener(eventArgs.DecisionToken.Handle); listener.Use(); var navigatingArgs = new Navigating(new Uri(eventArgs.Request.Url.AbsoluteString)); onNavigating(navigatingArgs); if (navigatingArgs.Cancel) listener.Ignore(); }; webView.MainFrame.LoadRequest(new NSUrlRequest(new NSUrl(uri.AbsoluteUri))); self.BindNativeDefaults(webView, dispatcher); return webView; }); WebView.Implementation.StringFactory = (content) => Control.Create (self => { var webView = new WebKit.WebView(); self.BindNativeProperty(dispatcher, "content", content, c => webView.MainFrame.LoadHtmlString(c, new NSUrl(""))); self.BindNativeDefaults(webView, dispatcher); return webView; }); }
private async Task NavigateImplAsync(NavigationMode navigationMode, ActivityModel currentActivity, ActivityModel nextActivity, int nextIndex) { IsHitTestVisible = false; InvokeLifecycleBeforeContentChanged(navigationMode, currentActivity, nextActivity); _activityStackManager.ChangeCurrentActivity(nextActivity, nextIndex); OnCurrentActivityChanged(currentActivity?.Activity, nextActivity?.Activity); Navigating?.Invoke(this, EventArgs.Empty); await UpdateContent(navigationMode, currentActivity, nextActivity); InvokeLifecycleAfterContentChanged(navigationMode, currentActivity, nextActivity); IsHitTestVisible = true; ReleaseActivity(currentActivity); Navigated?.Invoke(this, EventArgs.Empty); }
private bool TryNavTo(Page page) { NavigatingEventArgs?navigatingEventArgs = null; if (CurrentPage is not null) { navigatingEventArgs = new(CurrentPage, page); Navigating?.Invoke(this, navigatingEventArgs); if (navigatingEventArgs.Cancel) { return(false); } } while (forwardStack.Count > 0) { forwardStack.Pop()?.Dispose(); } if (CurrentPage is not null) { var pg = CurrentPage as Page; backStack.Push(pg !); } CurrentPage = page; OnPropertyChanged(); page.Refresh(); if (navigatingEventArgs is not null) { Navigated?.Invoke(this, navigatingEventArgs); } return(true); }
internal void RaiseNavigating(Portable.NavigatingEventArgs e) => Navigating?.Invoke(this, e);
private void OnLoadCompleted(object sender, NavigationEventArgs e) { Navigating?.Invoke(this, PageLoadingEventArgs.Ready); }