/// <summary>Raises the <see cref="CreateWindow"/> event.</summary>
        /// <param name="e">The data for the event.</param>
        protected virtual void OnCreateWindow2(GeckoCreateWindow2EventArgs e)
        {
            var evnt = (EventHandler <GeckoCreateWindow2EventArgs>)Events[CreateWindow2Event];

            if (evnt != null)
            {
                evnt(this, e);
            }
        }
		/// <summary>Raises the <see cref="CreateWindow"/> event.</summary>
		/// <param name="e">The data for the event.</param>
		protected virtual void OnCreateWindow2( GeckoCreateWindow2EventArgs e )
		{
			var evnt = ( EventHandler<GeckoCreateWindow2EventArgs> ) Events[ CreateWindow2Event ];
			if ( evnt != null ) evnt( this, e );
		}
示例#3
0
			private nsIWebBrowserChrome DoCreateChromeWindow(nsIWebBrowserChrome parent, uint chromeFlags, uint contextFlags, nsIURI uri, ref bool cancel)
			{
				var url = "";
				if (uri != null)
					url = (nsString.Get(uri.GetSpecAttribute)).ToString();
				else
					url = "about:blank";

				// for chrome windows, we can use the AppShellService to create the window using some built-in xulrunner code
				GeckoWindowFlags flags = (GeckoWindowFlags)chromeFlags;
				if ((flags & GeckoWindowFlags.OpenAsChrome) != 0)
				{
				      // obtain the services we need
				     // nsIAppShellService appShellService = Xpcom.GetService<nsIAppShellService>("@mozilla.org/appshell/appShellService;1");
				      
				      // create the child window
				      nsIXULWindow xulChild = AppShellService.CreateTopLevelWindow(null, null, chromeFlags, -1, -1);
				      
				      // this little gem allows the GeckoWebBrowser to be properly activated when it gains the focus again
				      if (parent is GeckoWebBrowser && (flags & GeckoWindowFlags.OpenAsDialog) != 0)
				      {
						EventHandler gotFocus = null;
						gotFocus = delegate (object sender, EventArgs e)
						{
							var geckoWebBrowser = (GeckoWebBrowser)sender;
							geckoWebBrowser.GotFocus -= gotFocus;
							
							if (geckoWebBrowser.WebBrowserFocus != null)
								geckoWebBrowser.WebBrowserFocus.Activate();
						};
						(parent as GeckoWebBrowser).GotFocus += gotFocus;
				      }
				      
				      // return the chrome
				      return Xpcom.QueryInterface<nsIWebBrowserChrome>(xulChild);
				}
				
				GeckoWebBrowser browser = parent as GeckoWebBrowser;
				if (browser != null)
				{
					var e = new GeckoCreateWindow2EventArgs(flags, url);
					if (uri != null) // called by CreateChromeWindow2()
						browser.OnCreateWindow2(e);
					browser.OnCreateWindow(e);

					if (e.Cancel)
					{
					    cancel = true;
					    return null;
					}

					if (e.WebBrowser != null)
					{
						// set flags
						((nsIWebBrowserChrome)e.WebBrowser).SetChromeFlagsAttribute(chromeFlags);
						return e.WebBrowser;
					}
					
					nsIXULWindow xulChild = AppShellService.CreateTopLevelWindow(null, null, chromeFlags, e.InitialWidth, e.InitialHeight);
					return Xpcom.QueryInterface<nsIWebBrowserChrome>(xulChild);									
				}
				return null;
			}
            public nsIWebBrowserChrome CreateChromeWindow2(nsIWebBrowserChrome parent, uint chromeFlags, uint contextFlags, nsIURI uri, ref bool cancel)
            {
                GeckoWebBrowser browser = parent as GeckoWebBrowser;
                if (browser != null)
                {
                    var url = "";
                    if (uri != null)
                    {
                        url = (nsString.Get(uri.GetSpecAttribute)).ToString();
                    }
                    else
                    {
                        url = "about:blank";
                    }

                    GeckoCreateWindow2EventArgs e = new GeckoCreateWindow2EventArgs((GeckoWindowFlags)chromeFlags, url);
                    e.WebBrowser = browser;

                    browser.OnCreateWindow2(e);

                    if (e.Cancel)
                    {
                        cancel = true;
                        return null;
                    }
                }

                return CreateChromeWindow(parent, chromeFlags);
            }
示例#5
0
 private void GeckoWebBrowser1_CreateWindow2(object sender, Gecko.GeckoCreateWindow2EventArgs e)
 {
     Process.Start(e.Uri);
     e.Cancel = true;
 }