Example #1
0
        public string GetResponse(string url)
        {
            _loading = true;
            try
            {
                _browser.Navigate(url, false);
            }
            catch (Exception)
            {
                _loading = false;
            }

            var t1 = DateTime.Now;

            while (_loading)
            {
                Application.DoEvents();
                Thread.Sleep(1);

                var t2 = DateTime.Now;
                if ((t2 - t1).TotalSeconds > TimeOut)
                {
                    break;
                }
            }
            var result = _browser.DocumentText;

            _browser.Stop();
            _browser.Dispose();

            return(result);
        }
Example #2
0
        private void Wb2_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (ct)
            {
                ct = false;
                button1.Enabled  = true;
                textBox1.Enabled = true;

                //label1.Font=new Font("Times New Roman", 12);
                if (Findid() == null)
                {
                    MessageBox.Show("Sorry the entered code was not found.", "Please try another id");
                    ProgressBar1.Value = 0;      //  Reset
                    wb2.Dispose();
                    return;
                }
                words    = pagelink.Split('/');
                words[4] = words[4].Replace('-', ' ').ToUpper().Trim();

                MessageBox.Show(words[4] + Environment.NewLine + "Opening now!", "Found");
                string data = wb2.Document.GetElementById(Findid()).InnerText;
                label1.Visible = true;
                if (data[0] == 'C' || data[1] == 'C')
                {
                    data = data.Substring(3);
                }
                data = Removecrap(data);
                label1.Focus();
                label1.Text = data;
                saveToolStripMenuItem.Enabled = true;
                ProgressBar1.Value            = 100; //   Set 100 %
                wb2.Dispose();
            }
        }
Example #3
0
        private void DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            // Now that the page is loaded, save it to a bitmap
            WebBrowser browser = sender as WebBrowser;

            browser.Visible = false;
            try
            {
                // Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
                Rectangle bounds = Screen.PrimaryScreen.Bounds;
                using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
                {
                    browser.DrawToBitmap(bitmap, bounds);
                    bitmap.Save(imgPathInternal);
                }
            }
            catch (ThreadAbortException)
            {
                Console.WriteLine("Error aborting thread, returning");
                browser.Dispose();
                return;
            }
            finally
            {
                browser.Dispose();
            }
        }
Example #4
0
        private void _GenerateHtmlToImage()
        {
            WebBrowser browser = new WebBrowser();

            try
            {
                browser.ScriptErrorsSuppressed = false;
                browser.ScrollBarsEnabled      = false;
                browser.Navigate(this.m_Url);
                browser.Size = new Size(this.m_BrowserWidth, this.m_BrowserHeight);
                browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(this.WebBrowser_DocumentCompleted);
                while (browser.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents();
                }
                browser.Stop();
                if (browser.ActiveXInstance == null)
                {
                    throw new Exception("实例不能为空");
                }
                this.m_Bitmap = this.TakeSnapshot(browser.ActiveXInstance, new Rectangle(0, 0, this.m_ThumbnailWidth, this.m_ThumbnailHeight));
                browser.Dispose();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.Message);
                browser.Dispose();
                throw exception;
            }
        }
Example #5
0
        private void Wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (ct)
            {
                var links = wb.Document.GetElementsByTagName("a");
                foreach (HtmlElement link in links)
                {
                    if (link.GetAttribute("className") == "btn dark medium")
                    {
                        pagelink = link.GetAttribute("href");
                        break;
                    }
                }
                ProgressBar1.Increment(20);     //  Incremented 20

                if (pagelink == "")
                {
                    ProgressBar1.Value = 0;
                    MessageBox.Show("Sorry the entered code was not found.", "Please try another id");
                    button1.Enabled  = true;
                    textBox1.Enabled = true;
                    wb.Dispose();
                    return;
                }
                wb2.ScriptErrorsSuppressed = true;
                wb2.Navigate(pagelink.Trim());

                wb2.DocumentCompleted += Wb2_DocumentCompleted;
                wb.Dispose();
            }
        }
        private void buttonVistaPrevia_Click(object sender, EventArgs e)
        {
            System.Uri a;
            if (webBrowser1 != null)
            {
                this.tabPageCurriculum.Controls.Remove(webBrowser1);
                webBrowser1.Dispose();
                File.Delete(@Application.StartupPath.ToString() + "\\aux1.pdf");
                webBrowser1 = null;
            }

            buttonWord.Enabled        = false;
            buttonPDF.Enabled         = false;
            buttonVistaPrevia.Enabled = false;

            this.tabPageCurriculum.Cursor = Cursors.WaitCursor;

            webBrowser1                    = new System.Windows.Forms.WebBrowser();
            webBrowser1.Location           = new System.Drawing.Point(190, 16);
            webBrowser1.MinimumSize        = new System.Drawing.Size(20, 20);
            webBrowser1.Name               = "webBrowser1";
            webBrowser1.Size               = new System.Drawing.Size(600, 450);
            webBrowser1.TabIndex           = 51;
            webBrowser1.Url                = new System.Uri("", System.UriKind.Relative);
            webBrowser1.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.webBrowser1_DocumentCompleted);
            webBrowser1.Show();
            this.tabPageCurriculum.Controls.Add(webBrowser1);
            //this.tabControl1.Refresh();

            arc = new Curriculum(p, 3);

            a = new System.Uri(@Application.StartupPath.ToString() + "\\aux1.pdf");
            //webBrowser1.Url = a ;
            webBrowser1.Navigate(a);
        }
Example #7
0
        public void RetrievedNexonToken(string token)
        {
            this.token = token;
            InternetSetOption(IntPtr.Zero, INTERNET_OPTION_END_BROWSER_SESSION, IntPtr.Zero, 0);

            browser.Dispose();
            GC.WaitForPendingFinalizers();
            GC.Collect();
            googleForm.Close();
        }
Example #8
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            lock (disposeLocker)
            {
                if (disposing)
                {
                    if (thread != null)
                    {
                        if (thread.IsAlive)
                        {
                            thread.Abort();
                        }

                        thread = null;
                    }

                    string path = GetWorkPath();

                    if (Directory.Exists(path))
                    {
                        try
                        {
                            Directory.Delete(path, true);
                        }
                        catch
                        { }
                    }

                    if (webBrowser != null && !webBrowser.Disposing && !webBrowser.IsDisposed)
                    {
                        if (webBrowser.InvokeRequired)
                        {
                            webBrowser.Invoke(new MethodInvoker(() => webBrowser.Dispose()));
                        }
                        else
                        {
                            webBrowser.Dispose();
                        }

                        webBrowser = null;
                    }

                    if (components != null)
                    {
                        components.Dispose();
                    }
                }
                base.Dispose(disposing);
            }
        }
Example #9
0
        // WebBrowser 방식을 쓸때 로그인시 끝까지 기다리기 위해서.
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            //NewLogManager2.Instance.Log(e.Url.ToString());

            if (e.Url.ToString().IndexOf("about:blank") >= 0)
            {
                return;
            }
            //if (e.Url.ToString().IndexOf("https://login.soffice.11st.co.kr/login/LoginOk") >= 0)
            if (e.Url.ToString().IndexOf("LoginOk") >= 0)
            {
                foreach (string cookie in wb_.Document.Cookie.Split(';'))
                {
                    string name   = cookie.Split('=')[0];
                    string value  = cookie.Substring(name.Length + 1);
                    string domain = @"soffice.11st.co.kr";
                    string wow    = wb_.Document.Domain;
                    string path   = "/";
                    Cookie pC     = new Cookie(name.Trim(), value.Trim(), path, domain);
                    Cookie_.Add(pC);
                }

                wb_.Document.ExecCommand("ClearAuthenticationCache", false, null);
                wb_.Navigate(@"about:blank");
                wb_.Dispose();
                wb_ = null;
                GC.Collect();
                bLoginSucceed_ = true;
            }
            else if (e.Url.ToString().IndexOf("partner.11st.co.kr/Index.tmall") >= 0)
            {
                foreach (string cookie in wb_.Document.Cookie.Split(';'))
                {
                    string name   = cookie.Split('=')[0];
                    string value  = cookie.Substring(name.Length + 1);
                    string domain = @"partner.11st.co.kr";
                    string wow    = wb_.Document.Domain;
                    string path   = "/";
                    Cookie pC     = new Cookie(name.Trim(), value.Trim(), path, domain);
                    Cookie_.Add(pC);
                }

                wb_.Document.ExecCommand("ClearAuthenticationCache", false, null);
                wb_.Navigate(@"about:blank");
                wb_.Dispose();
                wb_ = null;
                GC.Collect();
                bLoginSucceed_ = true;
            }
        }
Example #10
0
        /// <summary>
        /// Dispose of this text item
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            Debug.WriteLine("Disposing of " + _filePath, "IeWebMedia - Dispose");

            if (disposing)
            {
                // Remove the webbrowser control
                try
                {
                    // Remove the web browser control
                    Controls.Remove(_webBrowser);

                    // Workaround to remove COM object
                    PerformLayout();

                    // Detatch event and remove
                    if (_webBrowser != null && !_disposed)
                    {
                        _webBrowser.DocumentCompleted -= _webBrowser_DocumentCompleted;
                        _webBrowser.Navigate("about:blank");
                        _webBrowser.Dispose();

                        _disposed = true;
                    }
                }
                catch (Exception e)
                {
                    Trace.WriteLine(new LogMessage("IeWebMedia - Dispose", "Cannot dispose of web browser. E = " + e.Message), LogType.Info.ToString());
                }
            }

            base.Dispose(disposing);
        }
Example #11
0
        public static void SetIeCompatibility()
        {
            WebBrowser webBrowserInstance = new WebBrowser();
            int        iEnumber           = webBrowserInstance.Version.Major; //reference: http://support.microsoft.com/kb/969393/en-us
            int        compatibilityCode  = iEnumber * 1000;                  //Reference:http://msdn.microsoft.com/en-us/library/ee330730%28VS.85%29.aspx#browser_emulation

            webBrowserInstance.Dispose();
            Trace.TraceInformation("Using Internet Explorer {0}", iEnumber);

            var fileName = Path.GetFileName(Application.ExecutablePath);

            try
            {
                //Note: write to HKCU (HKEY_CURRENT_USER) instead of HKLM (HKEY_LOCAL_MACHINE) because HKLM need admin privilege while HKCU do not. Ref:http://stackoverflow.com/questions/4612255/regarding-ie9-webbrowser-control
                Registry.SetValue(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION",
                                  fileName,
                                  compatibilityCode);
            }
            catch (Exception ex)
            {
                Trace.TraceError(string.Format("Error setting IE compatibility: {0}", ex));
            }
            try //for 32 bit IE on 64 bit windows
            {
                Registry.SetValue(
                    @"HKEY_CURRENT_USER\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION",
                    fileName,
                    compatibilityCode);
            }
            catch (Exception ex)
            {
                Trace.TraceError(string.Format("Error setting IE compatibility: {0}", ex));
            }
        }
Example #12
0
 void worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     App.Status.Status = "Messages Sent Successfully";
     webBrowser.Dispose();
     worker.Dispose();
     EventWaitHandle.OpenExisting("mainResetEvent").Set();
 }
Example #13
0
        /// <summary>
        /// Dispose of this text item
        /// </summary>
        /// <param name="disposing"></param>
        protected override void Dispose(bool disposing)
        {
            _disposed = true;

            if (disposing)
            {
                // Remove the webbrowser control
                try
                {
                    // Remove the web browser control
                    Controls.Remove(_webBrowser);

                    // Workaround to remove COM object
                    PerformLayout();

                    // Detatch event and remove
                    _webBrowser.DocumentCompleted -= _webBrowser_DocumentCompleted;
                    _webBrowser.Dispose();
                }
                catch
                {
                    Debug.WriteLine(new LogMessage("WebBrowser still in use.", String.Format("Dispose")));
                }
            }

            base.Dispose(disposing);
        }
Example #14
0
        void frmMap_Disposed(object sender, EventArgs e)
        {
            // Unregister callbacks
            UnregisterClientEvents(client);
            instance.ClientChanged -= new EventHandler <ClientChangedEventArgs>(instance_ClientChanged);

            if (map != null)
            {
                if (instance.MonoRuntime)
                {
                    map.Navigating -= new WebBrowserNavigatingEventHandler(map_Navigating);
                }
                else
                {
                    map.Dispose();
                }
                map = null;
            }

            if (mmap != null)
            {
                mmap.Dispose();
                mmap = null;
            }
        }
        public static string TransformUsingJS(string inputText, bool SafeMode, bool ExtraMode, bool MarkdownInHtml, bool AutoHeadingIDs)
        {
            // Find test page
            var url = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;

            url = System.IO.Path.GetDirectoryName(url);
            url = url.Replace("file:\\", "file:\\\\");
            url = url.Replace("\\", "/");
            url = url + "/JSTestResources/JSHost.html";

            // Create browser, navigate and wait
            WebBrowser b = new WebBrowser();

            b.Navigate(url);
            b.ScriptErrorsSuppressed = true;

            while (b.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }

            var o = b.Document.InvokeScript("transform", new object[] { inputText, SafeMode, ExtraMode, MarkdownInHtml, AutoHeadingIDs });

            string result = o as string;

            // Clean up
            b.Dispose();

            return(result);
        }
Example #16
0
        protected void Dispose(bool disposing)
        {
            if (!disposing)
            {
                return;
            }

            if (observer != null)
            {
                observer.Dispose();
            }
            observer = null;
            if (this.dynamoWindow != null)
            {
                dynamoWindow.StateChanged -= DynamoWindowStateChanged;
                dynamoWindow.SizeChanged  -= DynamoWindow_SizeChanged;
                dynamoWindow = null;
            }
            if (this.browser != null)
            {
                browser.SizeChanged -= Browser_SizeChanged;
                browser.Loaded      -= Browser_Loaded;
                browser.Dispose();
                browser = null;
            }
        }
        public void CaptureScreenShot(string url, int width, int height)
        {
            Thread thread = new Thread(delegate()
            {
                WebBrowser wb             = new WebBrowser();
                wb.ScrollBarsEnabled      = false;
                wb.ScriptErrorsSuppressed = true;
                wb.Navigate(url);
                wb.Width  = width;
                wb.Height = height;
                wb.Document.Body.SetAttribute("contentEditable", "true");

                wb.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(DocumentCompleted);
                while (wb.ReadyState != WebBrowserReadyState.Complete)
                {
                    System.Windows.Forms.Application.DoEvents();
                }

                wb.Dispose();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();
        }
Example #18
0
        internal void Delete(int index)
        {
            WebBrowser browser = items[index];

            items.Remove(browser);
            browser.Dispose();
        }
        /// <summary>
        /// Makes screenshot.
        /// </summary>
        protected void MakeScreenshot()
        {
            // Load the webpage into a WebBrowser control
            WebBrowser wb = new WebBrowser();

            wb.ScrollBarsEnabled      = _scrollingEnabled;
            wb.ScriptErrorsSuppressed = true;
            wb.Navigate(_uri);
            while (wb.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }

            // Set the size of the WebBrowser control
            wb.Width  = _imageWidth;
            wb.Height = _imageHeight;

            // Take Screenshot of the web pages full width
            if (_imageHeight < 0)
            {
                wb.Width  = wb.Document.Body.ScrollRectangle.Width;
                wb.Height = wb.Document.Body.ScrollRectangle.Height;
            }

            // Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
            Bitmap bitmap = new Bitmap(wb.Width, wb.Height);

            wb.DrawToBitmap(bitmap, new Rectangle(0, 0, wb.Width, wb.Height));
            wb.Dispose();

            _image = bitmap;
        }
Example #20
0
        protected override void Dispose(bool disposing)
        {
            if (!Disposed)
            {
                if (disposing)
                {
                    DisposePrinter();
                    if (HtmlBrowser?.Document != null)
                    {
                        int newerBrowsers = 0;
                        try
                        {
                            newerBrowsers = HtmlBrowser.Document.GetElementsByTagName("HTML")[0].ScrollTop;
                        }
                        catch (Exception)
                        {
                        }
                        BrowserScrollPosition = newerBrowsers > HtmlBrowser.Document.Body?.ScrollTop
                            ? newerBrowsers
                            : HtmlBrowser.Document.Body.ScrollTop;

                        HtmlBrowser.Dispose();
                        HtmlBrowser = null;
                    }
                }
                base.Dispose(disposing);
                Disposed = true;
            }
        }
        public void Open(byte[] postData)
        {
            Application.Current.Dispatcher.Invoke(() =>
            {
                var reportWindow = new Window {
                    WindowState = WindowState.Maximized
                };

                // отправка POST`ом
                // готовим данные для отправки
                const string ServerUrl = @"http://worksite.vz/Halfblood.Reporting/GetReport.aspx";
                var additionalHeaders  = "Content-Type: application/x-www-form-urlencoded" + Environment.NewLine;

                var webBrowser       = new WebBrowser();
                reportWindow.Content = webBrowser;
                webBrowser.Navigate(ServerUrl, string.Empty, postData, additionalHeaders);
                reportWindow.ShowDialog();

                EventHandler handler = delegate { };
                handler = (sender, args) =>
                {
                    reportWindow.Closed -= handler;
                    webBrowser.Dispose();
                };
                reportWindow.Closed += handler;
            });
        }
Example #22
0
        public Bitmap DrawBitmap(int theight, int twidth)
        {
            Bitmap    myBitmap = new Bitmap(Width, Height);
            Rectangle DrawRect = new Rectangle(0, 0, Width, Height);

            MyBrowser.DrawToBitmap(myBitmap, DrawRect);
            System.Drawing.Image imgOutput  = myBitmap;
            System.Drawing.Image oThumbNail = new Bitmap(twidth, theight, imgOutput.PixelFormat);
            Graphics             g          = Graphics.FromImage(oThumbNail);

            g.CompositingQuality = CompositingQuality.HighSpeed;
            g.SmoothingMode      = SmoothingMode.HighSpeed;
            g.InterpolationMode  = InterpolationMode.HighQualityBilinear;
            Rectangle orectangle = new Rectangle(0, 0, twidth, theight);

            g.DrawImage(imgOutput, orectangle);
            try
            {
                return((Bitmap)oThumbNail);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(null);
            }
            finally
            {
                imgOutput.Dispose();
                imgOutput = null;
                MyBrowser.Dispose();
                MyBrowser = null;
            }
        }
Example #23
0
        /// <summary>
        /// Dispose
        /// </summary>
        /// <param name="disposing"></param>
        public override void Dispose()
        {
            // Remove the webbrowser control
            try
            {
                _webBrowser.Dispose();
            }
            catch
            {
                System.Diagnostics.Trace.WriteLine(new LogMessage("WebBrowser still in use.", String.Format("Dispose")));
            }

            // Remove the temporary file we created
            try
            {
                _tempHtml.Dispose();
            }
            catch (Exception ex)
            {
                Trace.WriteLine(new LogMessage("Dispose",
                                               String.Format("Unable to dispose TemporaryHtml with exception {0}",
                                                             ex.Message)));
            }


            base.Dispose();
        }
Example #24
0
        public void BitmapThreadWorker(object url)
        {
            try
            {
                DateTime   started = DateTime.Now;
                WebBrowser browser = new WebBrowser();
                browser.ScrollBarsEnabled  = false;
                browser.ClientSize         = new Size(800, 600);
                browser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted);
                browser.Navigate((string)url);

                while (bmp == null)
                {
                    Thread.Sleep(1000);
                    Application.DoEvents();
                    TimeSpan elapsed = DateTime.Now.Subtract(started);
                    if (elapsed.TotalMilliseconds > s_RequestTimeout / 2)
                    {
                        browser.Dispose();
                        mre.Set();
                        break;
                    }
                }
            }
            catch
            {
                mre.Set();
            }
        }
Example #25
0
        private Bitmap ExportUrlToImage(string url, int width, int height)
        {
            // Load the webpage into a WebBrowser control
            WebBrowser wb = new WebBrowser();

            wb.ScrollBarsEnabled      = false;
            wb.ScriptErrorsSuppressed = true;

            // wb.Navigate(url);
            wb.Navigate(url, null, null,
                        "User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36");
            while (wb.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }

            // Set the size of the WebBrowser control
            wb.Width  = width;
            wb.Height = height;

            Bitmap bitmap = new Bitmap(wb.Width, wb.Height);

            wb.DrawToBitmap(bitmap, new System.Drawing.Rectangle(0, 0, wb.Width, wb.Height));

            wb.Dispose();

            return(bitmap);
        }
Example #26
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged
        /// resources; <c>false</c> to release only unmanaged resources.
        /// </param>
        /// -----------------------------------------------------------------------------------
        protected override void Dispose(bool disposing)
        {
            //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************");
            // Must not be run more than once.
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (m_browser != null)
                {
#if Old
                    SHDocVw.WebBrowser_V1 axDocumentV1 = m_browser.GetOcx() as SHDocVw.WebBrowser_V1;
                    if (axDocumentV1 != null)
                    {
                        axDocumentV1.BeforeNavigate -= new SHDocVw.DWebBrowserEvents_BeforeNavigateEventHandler(OnBeforeNavigate);
                    }
#endif
                    m_browser.Dispose();
                }
                if (components != null)
                {
                    components.Dispose();
                }
            }
            m_url     = null;
            m_browser = null;

            base.Dispose(disposing);
        }
Example #27
0
        public Bitmap GenerateScreenshot(string url)
        {
            try
            {
                // Load the webpage into a WebBrowser control
                WebBrowser wb = new WebBrowser();
                wb.ScrollBarsEnabled      = false;
                wb.ScriptErrorsSuppressed = true;
                wb.Navigate(url);

                // waits for the page to be completely loaded
                while (wb.ReadyState != WebBrowserReadyState.Complete)
                {
                    Application.DoEvents();
                }

                // Take Screenshot of the web pages full width + some padding
                wb.Width = wb.Document.Body.ScrollRectangle.Height;
                // Take Screenshot of the web pages full height
                wb.Height = wb.Document.Body.ScrollRectangle.Height;

                // Get a Bitmap representation of the webpage as it's rendered in the WebBrowser control
                Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
                wb.DrawToBitmap(bitmap, new System.Drawing.Rectangle(0, 0, wb.Width, wb.Height));
                wb.Dispose();

                return(bitmap);
            }
            catch (Exception ex)
            {
                EpointMessage.MsgOk(ex.ToString());
                return(null);
            }
        }
Example #28
0
        /// <summary>
        /// This method creates a new form with a webbrowser of correct size on it,
        /// to make a fullsize website screenhot.
        /// </summary>
        /// <param name="navigatingArgs">The <see cref="WebBrowserNavigatingEventArgs"/> instance containing the event data,
        /// especially the url.</param>
        /// <param name="filename">The filename to save the screenshot to.</param>
        public static void DoScreenshot(WebBrowserNavigatingEventArgs navigatingArgs, string filename)
        {
            newTargetUrl          = navigatingArgs.Url;
            newScreenshotFilename = filename;

            var tempBrowser = new WebBrowser();
            var dummyForm   = new Form {
                ClientSize = new Size(1, 1), FormBorderStyle = FormBorderStyle.None
            };

            dummyForm.ShowInTaskbar = false;
            dummyForm.Controls.Add(tempBrowser);
            dummyForm.Show();
            tempBrowser.ScrollBarsEnabled      = true;
            tempBrowser.ScriptErrorsSuppressed = true;
            tempBrowser.DocumentCompleted     += WebBrowserDocumentCompleted;

            if (navigatingArgs.TargetFrameName != string.Empty)
            {
                tempBrowser.Navigate(navigatingArgs.Url, navigatingArgs.TargetFrameName);
            }
            else
            {
                tempBrowser.Navigate(newTargetUrl);
            }

            while (tempBrowser.ReadyState != WebBrowserReadyState.Complete)
            {
                Application.DoEvents();
            }

            tempBrowser.Dispose();
        }
Example #29
0
 public void Dispose()
 {
     if (!web.IsDisposed)
     {
         web.Dispose();
     }
 }
Example #30
0
 public void Dispose()
 {
     if (webBrowser != null)
     {
         webBrowser.Dispose();
     }
 }
Example #31
0
    private void _Generate()
    {
        var browser = new WebBrowser { ScrollBarsEnabled = false };
        browser.Navigate(m_Url);
        browser.DocumentCompleted += WebBrowser_DocumentCompleted;

        while (browser.ReadyState != WebBrowserReadyState.Complete)
        {
            Application.DoEvents();
        }

        browser.Dispose();
    }
Example #32
0
File: test.cs Project: mono/gert
	static void Main ()
	{
		WebBrowser wb = new WebBrowser ();
		wb.Navigate ("http://www.mono-project.com");
		wb.Dispose ();
	}