Beispiel #1
0
 /// <summary>
 /// Raises the FrameComplete event.
 /// </summary>
 /// <param name="e">An event args that contains the event data.</param>
 protected virtual void OnFrameComplete(BrowserDocumentEventArgs e)
 {
     if (FrameComplete != null)
     {
         FrameComplete(this, e);
     }
 }
Beispiel #2
0
        /// <summary>
        /// Event handler for DocumentComplete. We fire 2 events out of this event handler:
        ///		FrameComplete -- frame within a frameset completes
        ///		DocumentComplete -- entire document (page or frameset) completes
        ///	Both of these events provide the URL and the IDispatch of the document
        ///	object as part of their event arguments.
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event parameters</param>
        private void AxWebBrowser_DocumentComplete(
            object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            // Create native event args based on the passed event args
            BrowserDocumentEventArgs evtArgs =
                new BrowserDocumentEventArgs(e.uRL.ToString(), e.pDisp);

            // Check to see if this is the full document (page or frameset). This
            // technique is based on the article "HOWTO: Determine When a Page Is
            // Done Loading in WebBrowser Control" at:
            //  http://support.microsoft.com/default.aspx?scid=KB;en-us;q180366
            IntPtr thisPtr    = Marshal.GetIDispatchForObject(e.pDisp);
            IntPtr browserPtr = Marshal.GetIDispatchForObject(m_browser.GetOcx());
            bool   isDocument = (thisPtr == browserPtr);

            Marshal.Release(thisPtr);
            Marshal.Release(browserPtr);

            if (isDocument)
            {
                // TODO: update address bar on DocumentComplete

                // fire to listeners
                OnDocumentComplete(evtArgs);
            }
            else // this was a frame within a frameset
            {
                // fire to listeners
                OnFrameComplete(evtArgs);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Raises the DocumentComplete event.
        /// </summary>
        /// <param name="e">An event args that contains the event data.</param>
        protected virtual void OnDocumentComplete(BrowserDocumentEventArgs e)
        {
            //loading docs in LocalMachine security zone is generally a no-no since it is either much more
            //restrictive, or much less restrictive than the Internet security zone.  This assertion is
            //in here to help catch bugs where we accidentally load code in the LocalMachine zone.  If it
            //turns out there is a real need to support this, we can remove it.
            //Debug.Assert(GetSecurityZone() != InternetSecurityZone.LocalMachine, "Warning!, document was loaded in the LocalMachine security zone");

            if (DocumentComplete != null)
            {
                DocumentComplete(this, e);
            }
        }
        private void explorerBrowserControl_DocumentComplete(object sender, BrowserDocumentEventArgs e)
        {
            IHTMLDocument2 document = (IHTMLDocument2)explorerBrowserControl.Document;

            // turn off borders
            (document.body as IHTMLElement).style.borderStyle = "none";

            //MapActiveObject.ClearEvents();
            if (_address != null)
            {
                MapActiveObject.FindLocation(_address);
                _address = null;
            }

            MapActiveObject.AttachToMapDocument(document);
        }
        /// <summary>
        /// Event handler for DocumentComplete. We fire 2 events out of this event handler:
        ///		FrameComplete -- frame within a frameset completes
        ///		DocumentComplete -- entire document (page or frameset) completes
        ///	Both of these events provide the URL and the IDispatch of the document
        ///	object as part of their event arguments.
        /// </summary>
        /// <param name="sender">object sending the event</param>
        /// <param name="e">event parameters</param>
        private void AxWebBrowser_DocumentComplete(
            object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            // Create native event args based on the passed event args
            BrowserDocumentEventArgs evtArgs =
                new BrowserDocumentEventArgs(e.uRL.ToString(), e.pDisp);

            // Check to see if this is the full document (page or frameset). This
            // technique is based on the article "HOWTO: Determine When a Page Is
            // Done Loading in WebBrowser Control" at:
            //  http://support.microsoft.com/default.aspx?scid=KB;en-us;q180366
            IntPtr thisPtr = Marshal.GetIDispatchForObject(e.pDisp);
            IntPtr browserPtr = Marshal.GetIDispatchForObject(m_browser.GetOcx());
            bool isDocument = (thisPtr == browserPtr);
            Marshal.Release(thisPtr);
            Marshal.Release(browserPtr);

            if (isDocument)
            {
                // TODO: update address bar on DocumentComplete

                // fire to listeners
                OnDocumentComplete(evtArgs);
            }
            else // this was a frame within a frameset
            {
                // fire to listeners
                OnFrameComplete(evtArgs);
            }
        }
        private void _browserControl_DocumentComplete(object sender, BrowserDocumentEventArgs e)
        {
            Timer timer = null;
            try
            {
                // unsubscribe from the event
                _browserControl.DocumentComplete -= new BrowserDocumentEventHandler(_browserControl_DocumentComplete);

                // get the document
                IHTMLDocument2 document = _browserControl.Document as IHTMLDocument2;

                // eliminate borders, scroll bars, and margins
                IHTMLElement element = document.body;
                element.style.borderStyle = "none";
                IHTMLBodyElement body = element as IHTMLBodyElement;
                body.scroll = "no";
                body.leftMargin = 0;
                body.rightMargin = 0;
                body.topMargin = 0;
                body.bottomMargin = 0;

                // set the width and height of the browser control to the correct
                // values for the snapshot

                // width specified by the caller
                _browserControl.Width = _htmlScreenCaptureCore.ContentWidth;

                if (_htmlScreenCaptureCore.MaximumHeight > 0)
                    _browserControl.Height = _htmlScreenCaptureCore.MaximumHeight;
                else
                {
                    // height of the content calculated based on this width
                    IHTMLElement2 element2 = element as IHTMLElement2;
                    _browserControl.Height = element2.scrollHeight;
                }

                // release UI thread to load the video thumbnail on screen
                // (the Tick may need to fire more than once to allow enough
                // time and message processing for an embedded object to
                // be fully initialized)
                timer = new Timer();
                timer.Interval = WAIT_INTERVAL;
                timer.Tick += new EventHandler(timer_Tick);
                timer.Start();
            }
            catch (Exception ex)
            {
                _htmlScreenCaptureCore.SetException(ex);
                CleanupAndExit(timer);
            }
        }
 /// <summary>
 /// Raises the FrameComplete event.
 /// </summary>
 /// <param name="e">An event args that contains the event data.</param>
 protected virtual void OnFrameComplete(BrowserDocumentEventArgs e)
 {
     if (FrameComplete != null)
         FrameComplete(this, e);
 }
        /// <summary>
        /// Raises the DocumentComplete event.
        /// </summary>
        /// <param name="e">An event args that contains the event data.</param>
        protected virtual void OnDocumentComplete(BrowserDocumentEventArgs e)
        {
            //loading docs in LocalMachine security zone is generally a no-no since it is either much more
            //restrictive, or much less restrictive than the Internet security zone.  This assertion is
            //in here to help catch bugs where we accidentally load code in the LocalMachine zone.  If it
            //turns out there is a real need to support this, we can remove it.
            //Debug.Assert(GetSecurityZone() != InternetSecurityZone.LocalMachine, "Warning!, document was loaded in the LocalMachine security zone");

            if (DocumentComplete != null)
                DocumentComplete(this, e);
        }
        /// <summary>
        /// Handle document complete event
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">event args</param>
        private void browserControl_DocumentComplete(object sender, BrowserDocumentEventArgs e)
        {
            // verify ready-state complete
            Debug.Assert(browserControl.Browser.ReadyState == tagREADYSTATE.READYSTATE_COMPLETE);

            UnHookEvents(false);

            // propagate event
            DownloadIsComplete = true;

            if (UrlHelper.IsUrl(browserControl.LocationURL) && IsDangerousSSLBoundaryCrossing())
                _result = new WebPageDownloaderResult(599, browserControl.LocationURL); //599 is hack placeholder, nothing official
            else if (_result == null)
                _result = WebPageDownloaderResult.Ok;

            OnDownloadComplete(e);
        }
        private void _explorerBrowserControl_AboutBlankDocumentComplete(object sender, BrowserDocumentEventArgs e)
        {
            try
            {
                // unsubscribe from the event
                _explorerBrowserControl.DocumentComplete -= new BrowserDocumentEventHandler(_explorerBrowserControl_AboutBlankDocumentComplete);

                // set borders to none
                IHTMLDocument2 document = _explorerBrowserControl.Document as IHTMLDocument2;
                if (document != null)
                {
                    ICustomDoc customDoc = (ICustomDoc)document;
                    customDoc.SetUIHandler(new BrowserDocHostUIHandler());

                    if (document.body != null && document.body.style != null)
                        document.body.style.borderStyle = "none";
                    else
                        Debug.Fail("Couldn't set document body style after document completed!");
                }
                else
                {
                    Debug.Fail("Couldn't get document after document completed!");
                }
            }
            catch (Exception ex)
            {
                Trace.Fail("Unexpected exception in BrowserMiniForm.AboutBlankDocumentComplete: " + ex.ToString());
            }
        }
        private void _explorerBrowserControl_ProgressDocumentComplete(object sender, BrowserDocumentEventArgs e)
        {
            try
            {
                // unsubscribe from the event
                _explorerBrowserControl.DocumentComplete -= new BrowserDocumentEventHandler(_explorerBrowserControl_ProgressDocumentComplete);

                // navigate to the actual target (pulse)
                BeginInvoke(new InvokeInUIThreadDelegate(NavigateBrowser));
            }

            catch (Exception ex)
            {
                Trace.Fail("Unexpected exception in BrowserMiniForm.ProgressDocumentComplete: " + ex.ToString());
            }
        }