Ejemplo n.º 1
0
        protected override void OnDestroy(ref Packet packet)
        {
            m_browser.Dispose();
            CefRuntime.Shutdown();

            base.OnDestroy(ref packet);
        }
Ejemplo n.º 2
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
                {
                    if (_webView != null)
                    {
                        _webView.Dispose();
                    }
                }
                catch
                {
                    Trace.WriteLine(new LogMessage("WebBrowser still in use.", String.Format("Dispose")));
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 3
0
 protected override void OnClosed(EventArgs e)
 {
     _browser.Dispose();
     base.OnClosed(e);
 }
Ejemplo n.º 4
0
        protected void AddToolbarAndBrowserToTab(TabPage tabPage, CefWebBrowser browser)
        {
            TextBox urlbox = new TextBox();

            urlbox.Top   = 0;
            urlbox.Width = 200;
            //urlbox.Text = "https://getfirebug.com/releases/lite/1.2/";
            //urlbox.Text = "file:///G:/en2/build/view/demo.html";
            //urlbox.Text = "file:///G:/en2/build/view/demo.html";

            Button nav = new Button();

            nav.Text = "Go";
            nav.Left = 200;

            Button newTab = new Button();

            newTab.Text = "NewTab";
            newTab.Left = 200 + nav.Width;

            Button closeTab = new Button();

            closeTab.Text = "Close";
            closeTab.Left = 200 + nav.Width + newTab.Width;

            //browser.PropertyChanged += (se, ev) =>
            //{
            //    if (ev.PropertyName != "IsBrowserInitialized") return;

            //    if (html == string.Empty)
            //    {
            //        string url = "https://dictionary.cambridge.org/grammar/british-grammar/above-or-over", text = string.Empty, _fix_lib = string.Empty;

            //        Debug.WriteLine("#-> " + url);

            //        text = f_link_getHtmlOnline(url);

            //        string head = text.Split(new string[] { "<body" }, StringSplitOptions.None)[0], s = "<div" + text.Substring(head.Length + 5);
            //        int posH1 = s.ToLower().IndexOf("<h1");
            //        if (posH1 != -1) s = s.Substring(posH1, s.Length - posH1);

            //        head = Html.f_html_Format(url, head);
            //        s = Html.f_html_Format(url, s);

            //        //if (File.Exists("view/fix.html")) _fix_lib = File.ReadAllText("view/fix.html");
            //        text = head.Replace("<head>", @"<head><meta http-equiv=""Content-Type"" content=""text/html; charset=utf-8"" />" + _fix_lib) + "<body><article id=___body><!--START_BODY-->" + s + "<!--END_BODY--></article></body></html>";
            //        html = s;
            //    }
            //    browser.Reload();

            //    //    browser.Document.Body.InnerHtml = html;

            //    //Debug.WriteLine(browser.Document.Body.InnerHtml)

            //    //string firebuglite_bookmark_run = "javascript:var firebug=document.createElement('script');firebug.setAttribute('src','http://localhost:56789/firebug-lite.1.2.js');document.body.appendChild(firebug);(function(){if(window.firebug.version){firebug.init();}else{setTimeout(arguments.callee);}})();void(firebug);";
            //    //browser.Navigate(firebuglite_bookmark_run);
            //};

            nav.Click += delegate
            {
                // use javascript to warn if url box is empty.
                if (string.IsNullOrEmpty(urlbox.Text.Trim()))
                {
                    browser.Load("javascript:alert('hey try typing a url!');");
                }
                browser.Load(urlbox.Text);
                tabPage.Text = urlbox.Text;
            };

            newTab.Click += delegate { AddTab(); };

            closeTab.Click += delegate
            {
                m_tabControl.Controls.Remove(tabPage);
                browser.Dispose();
            };

            tabPage.Controls.Add(urlbox);
            tabPage.Controls.Add(nav);
            tabPage.Controls.Add(newTab);
            tabPage.Controls.Add(closeTab);
            tabPage.Controls.Add(browser);
        }