/// <summary> /// Добавит новую вкладку с WebControl(ом) и с Uri на который кликнули /// </summary> /// <param name="e">e, объект класса ShowCreatedWebViewEventArgs</param> public void AddPage_ClickReference(ShowCreatedWebViewEventArgs e) { WebControl webControl = new_WebControl(); webControl.Source = e.TargetURL; CreateTabPage(webControl); }
void OnShowCreatedWebView(object sender, ShowCreatedWebViewEventArgs e) { throw new NotImplementedException(); // no support for multiple browser instances/tabs/windows, so open external links in the same window //if (e.Url.Length > 0) //{ // this.Control.Web.LoadURL(e.Url); //} }
// Token: 0x0601587E RID: 88190 RVA: 0x0057BCF4 File Offset: 0x00579EF4 protected override void OnShowCreatedWebView(WebUIComponent sender, ShowCreatedWebViewEventArgs e) { e.Cancel = true; if (e.TargetURL != null && string.Compare(e.TargetURL.Host, sender.Source.Host, true) == 0) { global::Debug.Log(string.Format("Navigating to: {0}", e.TargetURL)); base.webUI.Source = e.TargetURL; } }
private void OnShowNewView( object sender, ShowCreatedWebViewEventArgs e ) { if ( !webControl.IsLive ) return; // Let the new view be destroyed. It is important to set Cancel to true // if you are not wrapping the new view, to avoid keeping it alive along // with a reference to its parent. e.Cancel = true; // Load the url to the existing view. webControl.LoadURL( e.TargetURL ); }
public static void ShowCreatedWebView(object sender, ShowCreatedWebViewEventArgs e) { if (e.TargetURL == null) return; var file = e.TargetURL.ToString(); if (file.StartsWith(LocalRequestUrlBase)) { file = GetResourceFileName(file.Replace(LocalRequestUrlBase, "")) ?? ""; if (!File.Exists(file)) return; } if (string.IsNullOrWhiteSpace(file)) return; Process.Start(file); }
private void OnShowNewView(object sender, ShowCreatedWebViewEventArgs e) { if ((webView == null) || !webView.IsLive) { return; } if (e.IsPopup) { // Create a WebView wrapping the view created by Awesomium. WebView view = new WebView(e.NewViewInstance); // ShowCreatedWebViewEventArgs.InitialPos indicates screen coordinates. Rectangle screenRect = e.Specs.InitialPosition.ToRectangle(); // Create a new WebForm to render the new view and size it. WebForm childForm = new WebForm(view, screenRect.Width, screenRect.Height) { ShowInTaskbar = false, FormBorderStyle = FormBorderStyle.FixedToolWindow, ClientSize = screenRect.Size != Size.Empty ? screenRect.Size : new Size(640, 480) }; // Show the form. childForm.Show(this); if (screenRect.Location != Point.Empty) { // Move it to the specified coordinates. childForm.DesktopLocation = screenRect.Location; } } else if (e.IsWindowOpen || e.IsPost) { // Create a WebView wrapping the view created by Awesomium. WebView view = new WebView(e.NewViewInstance); // Create a new WebForm to render the new view and size it. WebForm childForm = new WebForm(view, 640, 480); // Show the form. childForm.Show(this); } else { // Let the new view be destroyed. It is important to set Cancel to true // if you are not wrapping the new view, to avoid keeping it alive along // with a reference to its parent. e.Cancel = true; // Load the url to the existing view. webView.Source = e.TargetURL; } }
// We do not need to handle IWebView.ShowCreatedWebView. WebUIScript handles this and // we can simply override OnShowCreatedWebView. protected override void OnShowCreatedWebView( WebUIComponent sender, ShowCreatedWebViewEventArgs e ) { // Note that, if you do not override OnShowCreatedWebView, // IWebView.ShowCreatedWebView will be canceled by default. e.Cancel = true; // For this sample, we simply load the page to the same view, // if the target URL is from the same domain. if ( ( e.TargetURL != null ) && ( String.Compare( e.TargetURL.Host, sender.Source.Host, true ) == 0 ) ) { Debug.Log( String.Format( "Navigating to: {0}", e.TargetURL ) ); webUI.Source = e.TargetURL; } }
private void OnShowNewView(object sender, ShowCreatedWebViewEventArgs e) { if ((webView == null) || !webView.IsLive) { return; } if (e.IsPopup && !e.IsUserSpecsOnly) { // Create a WebView wrapping the view created by Awesomium. WebView view = new WebView(e.NewViewInstance); // ShowCreatedWebViewEventArgs.InitialPos indicates screen coordinates. Rectangle screenRect = e.Specs.InitialPosition.ToRectangle(); // Create a new WebForm to render the new view and size it. WebForm childForm = new WebForm(view, screenRect.Width, screenRect.Height) { ShowInTaskbar = false, FormBorderStyle = FormBorderStyle.FixedToolWindow, ClientSize = screenRect.Size }; // Show the form. childForm.Show(this); // Move it to the specified coordinates. childForm.DesktopLocation = screenRect.Location; } else if (e.IsWindowOpen || e.IsPost) { // Still window.open or an HTML form with target="_blank" and method="post" // but not a popup which means that no specs have been specified to a // window.open call. // Create a WebView wrapping the view created by Awesomium. WebView view = new WebView(e.NewViewInstance); // Create a new WebForm to render the new view and size it. WebForm childForm = new WebForm(view, 640, 480); // Show the form. childForm.Show(this); } else { // Let the new view be destroyed. It is important to set Cancel to true // if you are not wrapping the new view, to avoid keeping it alive along // with a reference to its parent. e.Cancel = true; // Load the url to the existing view. webView.Source = e.TargetURL; } }
internal static void OnShowCreatedWebView(object sender, ShowCreatedWebViewEventArgs e) { IWebView view = sender as IWebView; if (null == view) { return; } if (!view.IsLive) { return; } frmMain mainForm = Application.OpenForms.OfType <frmMain>().FirstOrDefault(); if (null == mainForm) { return; } if (e.IsPopup && !e.IsUserSpecsOnly) { Rectangle screenRect = e.Specs.InitialPosition.ToRectangle(); frmChild newWindow = new frmChild(e.NewViewInstance) { ShowInTaskbar = true, ClientSize = screenRect.Size != Size.Empty ? screenRect.Size : new Size(640, 480) }; if (0 < screenRect.Width && 0 < screenRect.Height) { newWindow.Width = screenRect.Width; newWindow.Height = screenRect.Height; } newWindow.Show(); if (Point.Empty != screenRect.Location) { newWindow.DesktopLocation = screenRect.Location; } } else if (e.IsWindowOpen || e.IsPost) { frmChild doc = new frmChild(e.NewViewInstance); } else { e.Cancel = true; frmChild doc = new frmChild(e.TargetURL); } }
private void OnShowNewView(object sender, ShowCreatedWebViewEventArgs e) { if (!webControl.IsLive) { return; } // Let the new view be destroyed. It is important to set Cancel to true // if you are not wrapping the new view, to avoid keeping it alive along // with a reference to its parent. e.Cancel = true; // Load the url to the existing view. webControl.LoadURL(e.TargetURL); }
public static void ShowCreatedWebView(object sender, ShowCreatedWebViewEventArgs e) { if (e.TargetURL == null) { return; } var file = e.TargetURL.ToString(); if (file.StartsWith(LocalRequestUrlBase)) { file = GetResourceFileName(file.Replace(LocalRequestUrlBase, "")) ?? ""; if (!File.Exists(file)) { return; } } if (string.IsNullOrWhiteSpace(file)) { return; } Process.Start(file); }
internal static void OnShowNewView(object sender, ShowCreatedWebViewEventArgs e) { Debug.Write("\n " + e.ToString()); System.Diagnostics.Process.Start(e.TargetURL.ToString()); }
private void webControl_ShowCreatedWebView(object sender, ShowCreatedWebViewEventArgs e) { if (webControl == null) return; if (!webControl.IsLive) return; // An instance of our application's web window, // that will host the new view instance, either // we wrap the created child view, or we let the // WebControl create a new underlying web-view. BrowserView newWindow; // Treat popups differently. If IsPopup is true, // the event is always the result of 'window.open' // (IsWindowOpen is also true, so no need to check it). // Our application does not recognize user defined, // non-standard specs. Therefore child views opened // with non-standard specs, will not be presented as // popups but as regular new windows (still wrapping // the child view however -- see below). if (e.IsPopup && !e.IsUserSpecsOnly) { // JSWindowOpenSpecs.InitialPosition indicates screen coordinates. Int32Rect screenRect = e.Specs.InitialPosition.GetInt32Rect(); // Set the created native view as the underlying view of the // WebControl. This will maintain the relationship between // the parent view and the child, usually required when the // new view is the result of 'window.open' (JS can access // the parent window through 'window.opener'; the parent window // can manipulate the child through the 'window' object returned // from the 'window.open' call). newWindow = new BrowserView(new BrowserViewModel(), e.NewViewInstance); // Do not show in the taskbar. newWindow.ShowInTaskbar = false; // Set a border-style to indicate a popup. newWindow.WindowStyle = WindowStyle.None; // Set resizing mode depending on the indicated specs. newWindow.ResizeMode = e.Specs.Resizable ? ResizeMode.CanResizeWithGrip : ResizeMode.NoResize; // If the caller has not indicated a valid size for the // new popup window, let it be opened with the default // size specified at design time. if ((screenRect.Width > 0) && (screenRect.Height > 0)) { // The indicated size, is client size. double horizontalBorderHeight = SystemParameters.ResizeFrameHorizontalBorderHeight; double verticalBorderWidth = SystemParameters.ResizeFrameVerticalBorderWidth; double captionHeight = SystemParameters.CaptionHeight; // Set the indicated size. newWindow.Width = screenRect.Width + (verticalBorderWidth * 2); newWindow.Height = screenRect.Height + captionHeight + (horizontalBorderHeight * 2); } // Show the window. newWindow.Show(); // If the caller has not indicated a valid position for // the new popup window, let it be opened in the default // position specified at design time. if ((screenRect.Y > 0) && (screenRect.X > 0)) { // Move it to the indicated coordinates. newWindow.Top = screenRect.Y; newWindow.Left = screenRect.X; } } else if (e.IsWindowOpen || e.IsPost) { // No specs or only non-standard specs were specified, // but the event is still the result of 'window.open' // or of an HTML form with tagret="_blank" and method="post". // We will open a normal window but we will still wrap // the new native child view, maintaining its relationship // with the parent window. newWindow = new BrowserView(new BrowserViewModel(), e.NewViewInstance); // Show the window. newWindow.Show(); } else { // The event is not the result of 'window.open' or of an // HTML form with tagret="_blank" and method="post"., // therefore it's most probably the result of a link with // target='_blank'. We will not be wrapping the created view; // we let the WebControl hosted in MainWindow create its own // underlying view. Setting Cancel to true tells the core // to destroy the created child view. // // Why don't we always wrap the native view passed to // ShowCreatedWebView? // // - In order to maintain the relationship with their parent // view, child views execute and render under the same process // (awesomium_process) as their parent view. If for any reason // this child process crashes, all views related to it will be // affected. When maintaining a parent-child relationship is not // important, we prefer taking advantage of the isolated process // architecture of Awesomium and let each view be rendered in // a separate process. e.Cancel = true; // Note that we only explicitly navigate to the target URL, // when a new view is about to be created, not when we wrap the // created child view. This is because navigation to the target // URL (if any), is already queued on created child views. // We must not interrupt this navigation as we would still be // breaking the parent-child relationship. newWindow = new BrowserView(new BrowserViewModel(), e.TargetURL); // Show the window. newWindow.Show(); } }
// Common handler of all ShowCreatedWebView events. internal static void OnShowNewView(object sender, ShowCreatedWebViewEventArgs e) { IWebView view = sender as IWebView; if (view == null) { return; } if (!view.IsLive) { return; } MainForm mainForm = Application.OpenForms.OfType <MainForm>().FirstOrDefault(); if (mainForm == null) { return; } // Treat popups differently. If IsPopup is true, the event is always // the result of 'window.open' (IsWindowOpen is also true, so no need to check it). // Our application does not recognize user defined, non-standard specs. // Therefore child views opened with non-standard specs, will not be presented as // popups but as regular new windows (still wrapping the child view however -- see below). if (e.IsPopup && !e.IsUserSpecsOnly) { // JSWindowOpenSpecs.InitialPosition indicates screen coordinates. Rectangle screenRect = e.Specs.InitialPosition.ToRectangle(); // Set the created native view as the underlying view of the // WebControl. This will maintain the relationship between // the parent view and the child, usually required when the new view // is the result of 'window.open' (JS can access the parent window through // 'window.opener'; the parent window can manipulate the child through the 'window' // object returned from the 'window.open' call). WebDocument newWindow = new WebDocument(e.NewViewInstance) { ShowInTaskbar = false, ClientSize = screenRect.Size != Size.Empty ? screenRect.Size : new Size(640, 480) }; // If the caller has not indicated a valid size for the new popup window, // let it be opened with the default size specified at design time. if ((screenRect.Width > 0) && (screenRect.Height > 0)) { // Assign the indicated size. newWindow.Width = screenRect.Width; newWindow.Height = screenRect.Height; } // Show the window. newWindow.Show(); // If the caller has not indicated a valid position for the new popup window, // let it be opened in the default position specified at design time. if (screenRect.Location != Point.Empty) { // Move it to the specified coordinates. newWindow.DesktopLocation = screenRect.Location; } } else if (e.IsWindowOpen || e.IsPost) { // No specs or only non-standard specs were specified, but the event is still // the result of 'window.open' or of an HTML form with target="_blank" and method="post". // We will open a normal window but we will still wrap the new native child view, // maintaining its relationship with the parent window. WebDocument doc = new WebDocument(e.NewViewInstance); mainForm.OpenTab(doc); } else { // The event is not the result of 'window.open' or of an HTML form with target="_blank" // and method="post"., therefore it's most probably the result of a link with target='_blank'. // We will not be wrapping the created view; we let the WebControl hosted in ChildWindow // create its own underlying view. Setting Cancel to true tells the core to destroy the // created child view. // // Why don't we always wrap the native view passed to ShowCreatedWebView? // // - In order to maintain the relationship with their parent view, // child views execute and render under the same process (awesomium_process) // as their parent view. If for any reason this child process crashes, // all views related to it will be affected. When maintaining a parent-child // relationship is not important, we prefer taking advantage of the isolated process // architecture of Awesomium and let each view be rendered in a separate process. e.Cancel = true; // Note that we only explicitly navigate to the target URL, when a new view is // about to be created, not when we wrap the created child view. This is because // navigation to the target URL (if any), is already queued on created child views. // We must not interrupt this navigation as we would still be breaking the parent-child // relationship. WebDocument doc = new WebDocument(e.TargetURL); mainForm.OpenTab(doc); } }
// -------------------------------------------------- // OnShowCreatedWebView // -------------------------------------------------- public void OnShowCreatedWebView(Object sender, ShowCreatedWebViewEventArgs e) { log.Info("New Web View"); // Wrap the view and add to children to prevent garbage collection childViews.Add(new Browser(new WebView(e.NewViewInstance)) { log = log, postScripts = postScripts, }); }
/// <summary> /// Метод для события webControl.ShowCreatedWebView. При клике по ссылке, создает новую вкладку с WebControl(ом) и с Uri, на который кликнули /// </summary> private void webControl_ShowCreatedWebView(object sender, ShowCreatedWebViewEventArgs e) { AddPage_ClickReference(e); }
private void webControl_ShowCreatedWebView(object sender, ShowCreatedWebViewEventArgs e) { if (webControl == null) return; if (!webControl.IsLive) return; MainWindow newWindow; if (e.IsPopup && !e.IsUserSpecsOnly) { Int32Rect screenRect = e.Specs.InitialPosition.GetInt32Rect(); newWindow = new MainWindow(e.NewViewInstance); newWindow.ShowInTaskbar = false; newWindow.WindowStyle = WindowStyle.ToolWindow; newWindow.ResizeMode = e.Specs.Resizable ? ResizeMode.CanResizeWithGrip : ResizeMode.NoResize; if ((screenRect.Width > 0) && (screenRect.Height > 0)) { double horizontalBorderHeight = SystemParameters.ResizeFrameHorizontalBorderHeight; double verticalBorderWidth = SystemParameters.ResizeFrameVerticalBorderWidth; double captionHeight = SystemParameters.CaptionHeight; newWindow.Width = screenRect.Width + (verticalBorderWidth * 2); newWindow.Height = screenRect.Height + captionHeight + (horizontalBorderHeight * 2); } newWindow.Show(); if ((screenRect.Y > 0) && (screenRect.X > 0)) { newWindow.Top = screenRect.Y; newWindow.Left = screenRect.X; } } else if (e.IsWindowOpen || e.IsPost) { newWindow = new MainWindow(e.NewViewInstance); newWindow.Show(); } else { e.Cancel = true; newWindow = new MainWindow(e.TargetURL); newWindow.Show(); } }
//Browser code protected void webBrower_ShowCreatedWebView(Object sender, ShowCreatedWebViewEventArgs e) { if (e.TargetURL != null) BuildBrowserInScatterView(e.TargetURL.ToString(), ((CustomBrowser)sender).scatter); }
private void OnShowNewView(object sender, ShowCreatedWebViewEventArgs e) { if ((_aweWebView == null) || !_aweWebView.IsLive) return; if (e.IsPopup) { // Create a WebView wrapping the view created by Awesomium. var view = new WebView(e.NewViewInstance); // ShowCreatedWebViewEventArgs.InitialPos indicates screen coordinates. var screenRect = e.InitialPos.ToRectangle(); // Create a new WebForm to render the new view and size it. var childForm = new ChildForm(view, screenRect.Width, screenRect.Height) { ShowInTaskbar = false, FormBorderStyle = FormBorderStyle.SizableToolWindow, ClientSize = screenRect.Size }; // Show the form. childForm.Show(this); // Move it to the specified coordinates. childForm.DesktopLocation = screenRect.Location; } else { // Let the new view be destroyed. It is important to set Cancel to true // if you are not wrapping the new view, to avoid keeping it alive along // with a reference to its parent. e.Cancel = true; // Load the url to the existing view. _aweWebView.Source = e.TargetURL; } }
private static void OnWebControlShowCreatedWebView(object sender, ShowCreatedWebViewEventArgs e) { // Nada ... }
private void webControl_ShowCreatedWebView(object sender, ShowCreatedWebViewEventArgs e) { if (webControl == null) { return; } if (!webControl.IsLive) { return; } // An instance of our application's web window, that will // host the new view instance, either we wrap the created child view, // or we let the WebControl create a new underlying web-view. MainWindow newWindow; // Treat popups differently. If IsPopup is true, the event is always // the result of 'window.open' (IsWindowOpen is also true, so no need to check it). // Our application does not recognize user defined, non-standard specs. // Therefore child views opened with non-standard specs, will not be presented as // popups but as regular new windows (still wrapping the child view however -- see below). if (e.IsPopup && !e.IsUserSpecsOnly) { // JSWindowOpenSpecs.InitialPosition indicates screen coordinates. var screenRect = e.Specs.InitialPosition.GetInt32Rect(); // Set the created native view as the underlying view of the // WebControl. This will maintain the relationship between // the parent view and the child, usually required when the new view // is the result of 'window.open' (JS can access the parent window through // 'window.opener'; the parent window can manipulate the child through the 'window' // object returned from the 'window.open' call). newWindow = new MainWindow(e.NewViewInstance); // Do not show in the taskbar. newWindow.ShowInTaskbar = false; newWindow.Topmost = true; // Set a border-style to indicate a popup. newWindow.WindowStyle = WindowStyle.ToolWindow; // Set resizing mode depending on the indicated specs. newWindow.ResizeMode = e.Specs.Resizable ? ResizeMode.CanResizeWithGrip : ResizeMode.NoResize; // If the caller has not indicated a valid size for the new popup window, // let it be opened with the default size specified at design time. if ((screenRect.Width > 0) && (screenRect.Height > 0)) { // The indicated size, is client size. var horizontalBorderHeight = SystemParameters.ResizeFrameHorizontalBorderHeight; var verticalBorderWidth = SystemParameters.ResizeFrameVerticalBorderWidth; var captionHeight = SystemParameters.CaptionHeight; // Set the indicated size. newWindow.Width = screenRect.Width + verticalBorderWidth * 2; newWindow.Height = screenRect.Height + captionHeight + horizontalBorderHeight * 2; } // Show the window. newWindow.Show(); // If the caller has not indicated a valid position for the new popup window, // let it be opened in the default position specified at design time. if ((screenRect.Y >= 0) && (screenRect.X >= 0)) { // Move it to the indicated coordinates. newWindow.Top = screenRect.Y; newWindow.Left = screenRect.X; } } else if (e.IsWindowOpen || e.IsPost) { // No specs or only non-standard specs were specified, but the event is still // the result of 'window.open' or of an HTML form with target="_blank" and method="post". // We will open a normal window but we will still wrap the new native child view, // maintaining its relationship with the parent window. newWindow = new MainWindow(e.NewViewInstance); // Show the window. newWindow.Show(); } else { // The event is not the result of 'window.open' or of an HTML form with target="_blank" // and method="post"., therefore it's most probably the result of a link with target='_blank'. // We will not be wrapping the created view; we let the WebControl hosted in ChildWindow // create its own underlying view. Setting Cancel to true tells the core to destroy the // created child view. // // Why don't we always wrap the native view passed to ShowCreatedWebView? // // - In order to maintain the relationship with their parent view, // child views execute and render under the same process (awesomium_process) // as their parent view. If for any reason this child process crashes, // all views related to it will be affected. When maintaining a parent-child // relationship is not important, we prefer taking advantage of the isolated process // architecture of Awesomium and let each view be rendered in a separate process. e.Cancel = true; // Note that we only explicitly navigate to the target URL, when a new view is // about to be created, not when we wrap the created child view. This is because // navigation to the target URL (if any), is already queued on created child views. // We must not interrupt this navigation as we would still be breaking the parent-child // relationship. newWindow = new MainWindow(e.TargetURL); // Show the window. newWindow.Show(); } }
// We do not need to handle IWebView.ShowCreatedWebView. WebUIScript handles this and // we can simply override OnShowCreatedWebView. protected override void OnShowCreatedWebView( WebUIComponent sender, ShowCreatedWebViewEventArgs e ) { // Bars do not contain links and do not open popups. e.Cancel = true; }