Пример #1
0
            //The NewWindow2 event, used on Windows XP SP1 and below
// ReSharper disable RedundantAssignment
            public void NewWindow2(ref object pDisp, ref bool cancel)
// ReSharper restore RedundantAssignment
            {
                var args =
                    new BrowserExtendedNavigatingEventArgs(pDisp, null, null, UrlContexts.None);

                _browser.OnStartNewWindow(args);
                cancel = args.Cancel;
                pDisp  = args.AutomationObject;
            }
Пример #2
0
        /// <summary>
        /// Raises the <see cref="StartNewWindow"/> event
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown when BrowserExtendedNavigatingEventArgs is null</exception>
        protected void OnStartNewWindow(BrowserExtendedNavigatingEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            if (StartNewWindow != null)
            {
                StartNewWindow(this, e);
            }
        }
Пример #3
0
            // NewWindow3 event, used on Windows XP SP2 and higher
            public void NewWindow3(
                ref object ppDisp,
// ReSharper disable RedundantAssignment
                ref bool cancel,
// ReSharper restore RedundantAssignment
                uint dwFlags,
                string bstrUrlContext,
                string bstrUrl)
            {
                var args =
                    new BrowserExtendedNavigatingEventArgs(ppDisp, new Uri(bstrUrl), null, (UrlContexts)dwFlags);

                _browser.OnStartNewWindow(args);
                cancel = args.Cancel;
                ppDisp = args.AutomationObject;
            }
			// NewWindow3 event, used on Windows XP SP2 and higher
			public void NewWindow3(
				ref object ppDisp,
// ReSharper disable RedundantAssignment
				ref bool cancel,
// ReSharper restore RedundantAssignment
				uint dwFlags,
				string bstrUrlContext,
				string bstrUrl )
			{
				var args =
					new BrowserExtendedNavigatingEventArgs( ppDisp, new Uri( bstrUrl ), null, (UrlContexts)dwFlags );
				_browser.OnStartNewWindow( args );
				cancel = args.Cancel;
				ppDisp = args.AutomationObject;
			}
			//The NewWindow2 event, used on Windows XP SP1 and below
// ReSharper disable RedundantAssignment
			public void NewWindow2( ref object pDisp, ref bool cancel )
// ReSharper restore RedundantAssignment
			{
				var args =
					new BrowserExtendedNavigatingEventArgs( pDisp, null, null, UrlContexts.None );
				_browser.OnStartNewWindow( args );
				cancel = args.Cancel;
				pDisp = args.AutomationObject;
			}
			//Implement whichever events you wish
			public void BeforeNavigate2(
				object pDisp,
				ref object url,
				ref object flags,
				ref object targetFrameName,
				ref object postData,
				ref object headers,
// ReSharper disable RedundantAssignment
				ref bool cancel )
// ReSharper restore RedundantAssignment
			{
				var urlUri = new Uri( url.ToString() );

				string tFrame = null;
				if ( targetFrameName != null )
				{
					tFrame = targetFrameName.ToString();
				}

				var args =
					new BrowserExtendedNavigatingEventArgs( pDisp, urlUri, tFrame, UrlContexts.None );

				_browser.OnStartNavigate( args );

				cancel = args.Cancel;
				//pDisp = args.AutomationObject;
			}
		/// <summary>
		/// Raises the <see cref="StartNavigate"/> event
		/// </summary>
		/// <exception cref="ArgumentNullException">Thrown when BrowserExtendedNavigatingEventArgs is null</exception>
		protected void OnStartNavigate(
			BrowserExtendedNavigatingEventArgs e )
		{
			if ( e == null )
			{
				throw new ArgumentNullException( @"e" );
			}

			if ( StartNavigate != null )
			{
				StartNavigate( this, e );
			}
		}