public bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags) { // React to the first ID (show dev tools method) // working but not useful as some pages disable right click //if (commandId == (CefMenuCommand)26501) //{ // browser.GetHost().ShowDevTools(); // return true; //} if (commandId == (CefMenuCommand)26501) //Export as PDF { string filepath = AppDomain.CurrentDomain.BaseDirectory + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"; //ChromiumWebBrowser current_browser = (ChromiumWebBrowser)browserControl; //current_browser.PrintToPdfAsync(filepath, null); printToPdfCallback callback = new printToPdfCallback(); browser.GetHost().PrintToPdf(filepath, null, callback); return(true); } if (commandId == (CefMenuCommand)26504) //Copy link address { string url = clean_url(parameters.LinkUrl); General.Copy2Clipboard(url); return(true); } // React to the second ID (show dev tools method) // Open in new tab w/ cookies -- Open in new tab -- Open in default browser if (commandId == (CefMenuCommand)26502 || commandId == (CefMenuCommand)26503 || commandId == (CefMenuCommand)26505) { if (!string.IsNullOrEmpty(parameters.LinkUrl) && parameters.LinkUrl.StartsWith("http", StringComparison.OrdinalIgnoreCase)) { if (commandId == (CefMenuCommand)26505) { //System.Diagnostics.Process.Start(clean_url(parameters.LinkUrl)); ChromiumWebBrowser current_browser = (ChromiumWebBrowser)browserControl; CefControl1 current_CEF_comtrol = (CefControl1)current_browser.Parent; current_CEF_comtrol.open_to_browser(clean_url(parameters.LinkUrl)); } else { ChromiumWebBrowser current_browser = (ChromiumWebBrowser)browserControl; CefControl1 current_CEF_comtrol = (CefControl1)current_browser.Parent; current_CEF_comtrol.open_child_tab(parameters.LinkUrl, commandId == (CefMenuCommand)26502); } } //browser.GetHost().CloseDevTools(); return(true); } return(false); }
private void toolStripOpenInContainer_Click(object sender, EventArgs e) { CefControl1 user_ctl = (CefControl1)tabControl1.SelectedTab.Controls[0]; string cookies_jar = user_ctl.get_cache_name(); WebsiteDetail x = new WebsiteDetail() { cookiesJar = cookies_jar, noAtStartup = false, notificationIcon = "", notificationKeyword = "", notificationShowWindow = false, title = "child", url = clipboard_url }; add_tab(x); }
private void add_tab(WebsiteDetail item) { TabPage tp = new TabPage(item.title); tabControl1.TabPages.Add(tp); CefControl1 x = new CefControl1(tabControl1.TabPages.Count - 1, General.cfg.g, item); x.StatusChanged += new CefControl1.status_changed(StatusUpdated); x.TabText += new CefControl1.tab_text(TabText); x.OpenChild += new CefControl1.open_child(OpenChildTab); x.Dock = DockStyle.Fill; tp.Controls.Add(x); //CEF start render when is visible tabControl1.SelectedIndex = tabControl1.TabPages.Count - 1; }
private void toolStripCookies_Click(object sender, EventArgs e) { CefControl1 user_ctl = (CefControl1)tabControl1.SelectedTab.Controls[0]; List <Tuple <string, string> > del = null; frmCookies f = new frmCookies(user_ctl.get_cookies()); f.ShowDialog(out del); if (del != null) { foreach (Tuple <string, string> item in del) { user_ctl.del_cookie("https://" + item.Item1, item.Item2); } } new MemoryManagement().FlushMemory(); }
private void toolStripCopyURL_Click(object sender, EventArgs e) { CefControl1 user_ctl = (CefControl1)tabControl1.SelectedTab.Controls[0]; General.Copy2Clipboard(user_ctl.get_url()); }
private void toolStripMenuItem5_Click(object sender, EventArgs e) { CefControl1 user_ctl = (CefControl1)tabControl1.SelectedTab.Controls[0]; user_ctl.dev_tools(); }
private void toolStripMenuItem6_Click(object sender, EventArgs e) { CefControl1 user_ctl = (CefControl1)tabControl1.SelectedTab.Controls[0]; user_ctl.refresh_page(); }