コード例 #1
0
 void tready_Tick(object sender, EventArgs e)
 {
     try
     {
         //stop the timer
         tready.Stop();
         mshtml.IHTMLDocument2 docs2 = (mshtml.IHTMLDocument2)web.Document.DomDocument;
         mshtml.IHTMLDocument3 docs3 = (mshtml.IHTMLDocument3)web.Document.DomDocument;
         mshtml.IHTMLElement2  body2 = (mshtml.IHTMLElement2)docs2.body;
         mshtml.IHTMLElement2  root2 = (mshtml.IHTMLElement2)docs3.documentElement;
         // Determine dimensions for the image; we could add minWidth here
         // to ensure that we get closer to the minimal width (the width
         // computed might be a few pixels less than what we want).
         int width  = Math.Max(body2.scrollWidth, root2.scrollWidth);
         int height = Math.Max(root2.scrollHeight, body2.scrollHeight);
         //get the size of the document's body
         Rectangle docRectangle = new Rectangle(0, 0, width, height);
         web.Width  = docRectangle.Width;
         web.Height = docRectangle.Height;
         //if the imgsize is null, the size of the image will
         //be the same as the size of webbrowser object
         //otherwise  set the image size to imgsize
         Rectangle imgRectangle;
         if (imgsize == null)
         {
             imgRectangle = docRectangle;
         }
         else
         {
             imgRectangle = new Rectangle()
             {
                 Location = new Point(0, 0), Size = imgsize.Value
             }
         };
         //create a bitmap object
         Bitmap bitmap = new Bitmap(imgRectangle.Width, imgRectangle.Height);
         //get the viewobject of the WebBrowser
         IViewObject ivo = web.Document.DomDocument as IViewObject;
         using (Graphics g = Graphics.FromImage(bitmap))
         {
             //get the handle to the device context and draw
             IntPtr hdc = g.GetHdc();
             ivo.Draw(1, -1, IntPtr.Zero, IntPtr.Zero,
                      IntPtr.Zero, hdc, ref imgRectangle,
                      ref docRectangle, IntPtr.Zero, 0);
             g.ReleaseHdc(hdc);
         }
         //invoke the HtmlImageCapture event
         bitmap.Save(fileName);
         bitmap.Dispose();
     }
     catch
     {
         //System.Diagnostics.Process.GetCurrentProcess().Kill();
     }
     if (HtmlImageCapture != null)
     {
         HtmlImageCapture(this, web.Url);
     }
 }
コード例 #2
0
        /// <summary>
        /// After the content is loaded for a feed item set the Height so that all the content is visable.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void WebBrowser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
        {
            WebBrowser webBrowser = sender as WebBrowser;

            if (webBrowser == null)
            {
                logger.Warn("Unable to determine the web browser that complted loading.");
                return;
            }

            mshtml.HTMLDocument doc = webBrowser.Document as mshtml.HTMLDocument;
            if (doc == null)
            {
                logger.Warn("Unable to get the HTMLDocument from the web browser.");
                return;
            }

            mshtml.IHTMLElement2 elem = doc.activeElement as mshtml.IHTMLElement2;
            if (elem == null)
            {
                logger.Warn("Unable to get the internal html element from the web browser.");
                return;
            }

            doc.body.style.overflow = "hidden";
            webBrowser.Height       = elem.scrollHeight;
        }
コード例 #3
0
 private void UpdateSize(object sender, NavigationEventArgs e)
 {
     mshtml.HTMLDocument htmlDoc = webBrowser.Document as mshtml.HTMLDocument;
     if (htmlDoc != null && htmlDoc.body != null)
     {
         mshtml.IHTMLElement2 body = (mshtml.IHTMLElement2)htmlDoc.body;
         this.Height = body.scrollHeight + 51;
     }
 }
コード例 #4
0
 /// <summary>
 /// Callback when HTML is loaded in WebBrowser control
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void toolTip_LoadCompleted(object sender, NavigationEventArgs e)
 {
     mshtml.HTMLDocument htmlDoc = toolTip.Document as mshtml.HTMLDocument;
     if (htmlDoc != null && htmlDoc.body != null)
     {
         mshtml.IHTMLElement2 body = (mshtml.IHTMLElement2)htmlDoc.body;
         //webBrowser.Width = body.scrollWidth;
         toolTip.Height     = body.scrollHeight;
         toolTip.Visibility = System.Windows.Visibility.Visible;
     }
 }
コード例 #5
0
ファイル: Login.cs プロジェクト: powe0101/MNet-Player
        private void ClickElement(mshtml.IHTMLElement element, string innerText = null)
        {
            mshtml.IHTMLElement2 _el = element as mshtml.IHTMLElement2;
            _el.focus();

            if (innerText != null)
            {
                element.innerText = innerText;
            }
            else
            {
                Console.WriteLine("아이디 또는 비밀번호가 올바르지 않습니다.");
            }
        }
コード例 #6
0
        /// <summary>
        /// Метод модификации WebBrowser для отображения под WPF
        /// </summary>
        /// <param name="webbrowser"></param>
        private void ModifyWebBrowser(ref WebBrowser webbrowser)
        {
            htmlDoc = webbrowser.Document as mshtml.HTMLDocument;

            mshtml.IHTMLDocument2 doc2  = (mshtml.IHTMLDocument2)webbrowser.Document;
            mshtml.IHTMLDocument3 doc3  = (mshtml.IHTMLDocument3)webbrowser.Document;
            mshtml.IHTMLElement2  body2 = (mshtml.IHTMLElement2)doc2.body;
            mshtml.IHTMLElement2  root2 = (mshtml.IHTMLElement2)doc3.documentElement;

            HeightWebView    = root2.scrollHeight;
            HeightWebFull    = body2.scrollHeight;
            HeightWebMaximum = Math.Max(HeightWebView, HeightWebFull);

            dH = HeightWebMaximum / 20;
        }