Example #1
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);
            }
        }
Example #2
0
        private void Browser_OnDocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            if (sender == null)
            {
                return;
            }
            AxWebBrowser browser = sender as AxWebBrowser;

            if (browser == null)
            {
                return;
            }

            mshtml.IHTMLDocument2 document = browser.Document as mshtml.IHTMLDocument2;
            string title = document.title;

            if (title == string.Empty)
            {
                this.Text = "[Empty]";
            }
            else
            {
                this.Text = title;
            }

            if (OnDocumentComplete != null)
            {
                OnDocumentComplete(this);
            }
        }
Example #3
0
 private void axWebBrowser_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
 {
     if (OnDocumentComplete != null)
     {
         OnDocumentComplete(sender, e);
     }
 }
Example #4
0
        private void axWebBrowser_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            try
            {
                var htmlDocument = (IHTMLDocument2)axWebBrowser.Document;
                if (htmlDocument.frames.length == 0)
                {
                    MessageBox.Show(this, @"Please open Internet Explorer and login on facebook.com. " +
                                    @"(Make sure to enable ""Keep me logged in"")",
                                    "Not logged in");
                    DialogResult = DialogResult.Abort;
                }

                if (e.uRL.ToString() != "https://everybody-edits-su9rn58o40itdbnw69plyw.fb.playerio.com/fb/everybody-edits/") return;
                var frame = (HTMLWindow2) htmlDocument.frames.item(0);
                var doc = (HTMLDocument)CrossFrameIe.GetDocumentFromWindow(frame.window);
                HTMLObjectElement flash = (HTMLObjectElement)doc.all.OfType<IHTMLObjectElement>().First();
                var es = flash.getElementsByTagName("param").OfType<HTMLParamElement>().First(p => p.name == "flashvars");
                var flashVars = es.value;
                NameValueCollection qscoll = HttpUtility.ParseQueryString(flashVars);
                AccessToken = qscoll["fb_access_token"];
                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error trying to get token. " + ex.Message);
                DialogResult = DialogResult.Abort;
            }

        }
Example #5
0
        private void axWebBrowser_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            try
            {
                var htmlDocument = (IHTMLDocument2)this.axWebBrowser.Document;
                if (htmlDocument.frames.length == 0)
                {
                    MessageBox.Show(this, @"Please open Internet Explorer and login on facebook.com. " +
                                    @"(Make sure to enable ""Keep me logged in"")",
                                    "Not logged in");
                    this.DialogResult = DialogResult.Abort;
                }

                if (e.uRL.ToString() != "https://everybody-edits-su9rn58o40itdbnw69plyw.fb.playerio.com/fb/everybody-edits/")
                {
                    return;
                }
                var frame     = (HTMLWindow2)htmlDocument.frames.item(0);
                var doc       = (HTMLDocument)CrossFrameIe.GetDocumentFromWindow(frame.window);
                var flash     = (HTMLObjectElement)doc.all.OfType <IHTMLObjectElement>().First();
                var es        = flash.getElementsByTagName("param").OfType <HTMLParamElement>().First(p => p.name == "flashvars");
                var flashVars = es.value;
                var qscoll    = HttpUtility.ParseQueryString(flashVars);
                this.AccessToken  = qscoll["fb_access_token"];
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error trying to get token. " + ex.Message);
                this.DialogResult = DialogResult.Abort;
            }
        }
        // *********************************************************************

        // *********************************************************************
        // Handle the WebBrowser's document complete event
        private void DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            if (APP_DEFAULTURL == e.uRL.ToString())
            {
                return;
            }

            UpdateEnvInfo(e.uRL.ToString(), false);
            UpdatePageInfo();
        }
Example #7
0
        protected void AxWebBrowser_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
        {
            String sURL  = (String)e.uRL;
            int    index = ComboAddress.FindStringExact(sURL);

            if (index == -1)
            {
                ComboAddress.Items.Add(sURL);
                ComboAddress.SelectedIndex = ComboAddress.FindStringExact(sURL);
            }
            else
            {
                ComboAddress.SelectedIndex = index;
            }
        }
    private void IE_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
    {
        AxWebBrowser wb = (AxWebBrowser)sender;

        // Skip document complete event for embedded frames.
        if (wb.Application != e.pDisp)
        {
            return;
        }

        // Skip the initial about:blank document; this is not necessarily
        // the best thing to do, e.g. if the requested page is about:blank
        // or redirects to it, we might never exit. This could be avoided
        // by remembering whether we saw the first document complete event.
        if (e.uRL.Equals("about:blank"))
        {
            return;
        }

        mTimer.Start();
    }
Example #9
0
 private void templateBrowser_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
 {
     try
     {
         if (this.templateBrowser.Document != null)
         {
             object target = this.templateBrowser.Document.GetType().InvokeMember("body", BindingFlags.GetProperty, null, this.templateBrowser.Document, null);
             if (target != null)
             {
                 object obj3 = target.GetType().InvokeMember("style", BindingFlags.GetProperty, null, target, null);
                 if (obj3 != null)
                 {
                     AppSettingsReader reader = new AppSettingsReader();
                     object[]          args   = new object[] { Convert.ToString(reader.GetValue("ZoomValue", typeof(string))) };
                     obj3.GetType().InvokeMember("zoom", BindingFlags.SetProperty, null, obj3, args);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         BusinessLogic.MyMessageBox(exception.Message);
         BusinessLogic.MyMessageBox("Error in zooming! setting to default zoom.");
         if (Convert.ToUInt32(this.objZoomValue) == 1)
         {
             try
             {
                 this.templateBrowser.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref this.objZoomValue, ref this.missing);
             }
             catch (Exception)
             {
             }
             this.objZoomValue = 0;
         }
     }
 }
Example #10
0
 private void templateBrowser_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
 {
     try
     {
         if (this.templateBrowser.Document != null)
         {
             object target = this.templateBrowser.Document.GetType().InvokeMember("body", BindingFlags.GetProperty, null, this.templateBrowser.Document, null);
             if (target != null)
             {
                 object obj3 = target.GetType().InvokeMember("style", BindingFlags.GetProperty, null, target, null);
                 if (obj3 != null)
                 {
                     AppSettingsReader reader = new AppSettingsReader();
                     object[] args = new object[] { Convert.ToString(reader.GetValue("ZoomValue", typeof(string))) };
                     obj3.GetType().InvokeMember("zoom", BindingFlags.SetProperty, null, obj3, args);
                 }
             }
         }
     }
     catch (Exception exception)
     {
         BusinessLogic.MyMessageBox(exception.Message);
         BusinessLogic.MyMessageBox("Error in zooming! setting to default zoom.");
         if (Convert.ToUInt32(this.objZoomValue) == 1)
         {
             try
             {
                 this.templateBrowser.ExecWB(SHDocVw.OLECMDID.OLECMDID_ZOOM, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER, ref this.objZoomValue, ref this.missing);
             }
             catch (Exception)
             {
             }
             this.objZoomValue = 0;
         }
     }
 }
 static void wBrowser_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
 {
     doAlgorithm();
 }
Example #12
0
    private void IE_DocumentComplete(object sender, DWebBrowserEvents2_DocumentCompleteEvent e)
    {
        AxWebBrowser wb = (AxWebBrowser)sender;

        // Skip document complete event for embedded frames.
        if (wb.Application != e.pDisp) return;

        // Skip the initial about:blank document; this is not necessarily
        // the best thing to do, e.g. if the requested page is about:blank
        // or redirects to it, we might never exit. This could be avoided
        // by remembering whether we saw the first document complete event.
        if (e.uRL.Equals("about:blank")) return;

        mTimer.Start();
    }