public BrowserTab(WebbrowserForm parent) { Parent = parent; Browser = new ExtendedWebBrowser(); Browser.Dock = DockStyle.Fill; Controls.Add(Browser); }
public override void DocumentCompleted(HtmlViewPane pane, System.Windows.Forms.WebBrowserDocumentCompletedEventArgs e) { if (pane == null) { throw new ArgumentNullException("pane"); } ExtendedWebBrowser browser = pane.WebBrowser; if (browser == null || browser.Document == null) { return; } HtmlElementCollection divs = browser.Document.GetElementsByTagName("div"); foreach (HtmlElement div in divs) { if (!string.IsNullOrEmpty(div.Id)) { if (div.Id.Equals("LeftNav", StringComparison.InvariantCultureIgnoreCase) || div.Id.Equals("TocResize", StringComparison.InvariantCultureIgnoreCase)) { div.Style = "visibility:hidden;display:none;width:0px"; } } } }
private object poker_add_page(string url = "") { TabPage ex_tab = new TabPage(); ex_tab.Text = "Loading.."; ex_tab.ImageIndex = 0; ExtendedWebBrowser ex_browser = new ExtendedWebBrowser(); ex_browser.Name = "ex"; ex_browser.Parent = ex_tab; ex_browser.Dock = DockStyle.Fill; ex_browser.ScriptErrorsSuppressed = true; ex_browser.Navigated += new System.Windows.Forms.WebBrowserNavigatedEventHandler(this.pk_browser_Navigated); ex_browser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.pk_browser_DocumentCompleted); ex_browser.NewWindow2 += new EventHandler <NewWindow2EventArgs>(pk_browser_NewWindow2); ex_browser.StatusTextChanged += new System.EventHandler(this.wb_StatusTextChanged); Program.log(ex_browser.Version.ToString()); if (url != string.Empty) { ex_browser.Navigate(url); } this.pk_tab.TabPages.Add(ex_tab); return(ex_browser.Application); }
public BrowserTab(WebbrowserForm parent) { Parent = parent; Browser = new ExtendedWebBrowser(); Browser.Dock = DockStyle.Fill; Controls.Add(Browser); }
public static async Task TryGetImage(string url, Action <Bitmap> callback) { Debug.WriteLine("Waiting " + url); await semaphore.WaitAsync(); Debug.WriteLine("Access " + url); browser = new ExtendedWebBrowser { Dock = DockStyle.Fill, ScriptErrorsSuppressed = true }; browser.PageLoaded += (s, e) => { try { urlText.Text = e.Url.ToString(); if (HasCaptcha()) { if (MessageBox.Show("Captcha detected! Please solve it to load pages from this website.", "Captcha") == DialogResult.OK) { ShowPreview(); } } else { var images = browser.Document.Images; if (images.Count > 0) { var el = images[0]; var d = browser.Dock; var en = browser.ScrollBarsEnabled; browser.Dock = DockStyle.None; browser.ScrollBarsEnabled = false; browser.Document.Body.Style = "overflow:hidden"; browser.Size = el.ClientRectangle.Size + new Size(50, 50); Bitmap temp = new Bitmap(browser.Width, browser.Height); browser.DrawToBitmap(temp, new Rectangle(0, 0, temp.Width, temp.Height)); Bitmap bmp = new Bitmap(temp.Width - 50, temp.Height - 60); Graphics gfx = Graphics.FromImage(bmp); gfx.DrawImage(temp, new Rectangle(0, 0, bmp.Width, bmp.Height), new Rectangle(10, 20, bmp.Width, bmp.Height), GraphicsUnit.Pixel); gfx.Dispose(); //string path = Path.GetTempFileName(); //bmp.Save(path); browser.Dock = d; browser.ScrollBarsEnabled = en; callback(bmp); } } } finally { semaphore.Release(); Debug.WriteLine("Done " + url); callback(null); } }; browser.Navigate(url); }
private void pk_browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { ExtendedWebBrowser pk_browser_current = sender as ExtendedWebBrowser; pk_browser_current.Parent.Text = pk_browser_current.Document.Title; this.web_helper.pkh_post_amend(pk_browser_current); pk_browser_current.Document.Body.MouseDown += new HtmlElementEventHandler(pk_play_mousedown_hook); }
private void PrintPreview() { ExtendedWebBrowser brw = _windowManager.ActiveBrowser; if (brw != null) { brw.ShowPrintPreviewDialog(); } }
private void CreateBrowser() { _panelBrowser = new ExtendedWebBrowser { Location = new Point(0, 195), Name = "browserControl1", Size = new Size(708, 528), TabIndex = 0 }; Controls.Add(_panelBrowser); WatinBrowser = new IE(_panelBrowser.ActiveXInstance, false); }
public static async Task GetImageURLs(string url, Action <string, Size> callback) { Debug.WriteLine("Waiting " + url); await semaphore.WaitAsync(); Debug.WriteLine("Access " + url); browser = new ExtendedWebBrowser { Dock = DockStyle.Fill, ScriptErrorsSuppressed = true }; browser.PageLoaded += (s, e) => { try { urlText.Text = e.Url.ToString(); HashSet <string> urls = new HashSet <string>(); if (HasCaptcha()) { if (MessageBox.Show("Captcha detected! Please solve it to load pages from this website.", "Captcha") == DialogResult.OK) { ShowPreview(); } } foreach (HtmlElement el in browser.Document.Images) { string imgUrl = el.GetAttribute("src"); if (imgUrl == string.Empty) { imgUrl = el.GetAttribute("data-src"); } if (imgUrl != string.Empty && !urls.Contains(imgUrl)) { if (imgUrl.Contains("w_auto")) { imgUrl = imgUrl.Replace("w_auto", "w_800"); } urls.Add(imgUrl); callback(imgUrl, el.ClientRectangle.Size); } } } finally { semaphore.Release(); Debug.WriteLine("Done " + url); callback(null, new Size(0, 0)); } }; browser.Navigate(url); }
/// <summary> /// browser title,browser status text change event /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void webBrowser_ExTitleChanged(object sender, STAChangeEventArgs e) { ExtendedWebBrowser ewb = sender as ExtendedWebBrowser; switch (e.Command) { case BrowSTACommand.TitleChanged: BrowActionController.GetInstance().OnBrowStaChanged(new BrowserStaChangeArgs(BrowSTACommand.TitleChanged, _browserUniqueID, e.Title)); break; case BrowSTACommand.StatusChanged: this.lbMsgState.Text = e.Title; break; } }
public void pkh_post_amend(ExtendedWebBrowser browser) { // amend the a href to open in new tab try { if (browser.Url.ToString().Contains("home.html")) { //Thread thread = new Thread(() => pkh_post_amend_thread(browser)); //thread.Start(); pkh_post_amend_thread(browser); // cross-thread isn't working } } catch (Exception ex) { } }
// File -> Open URL private void openUrlToolStripMenuItem_Click(object sender, EventArgs e) { try { using (OpenUrlForm ouf = new OpenUrlForm()) { if (ouf.ShowDialog() == DialogResult.OK) { ExtendedWebBrowser brw = _windowManager.New(false); brw.Navigate(ouf.Url); } } } catch (Exception ex) { Program.ShowMessageBox("FrmWebBrowser.openUrlToolStripMenuItem_Click", ex); } }
private void InternetExplorerOnStartNewWindow(object sender, BrowserExtendedNavigatingEventArgs browserExtendedNavigatingEventArgs) { Logging(string.Format("Browser::InternetExplorerOnStartNewWindow (Title={0}, argUrl={1}) - ..." , this.Title , browserExtendedNavigatingEventArgs.Url.ToString())); if ((browserExtendedNavigatingEventArgs.Url == null) || (browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("about:blank") == false)) { if (ValidateUrlToNavigating(browserExtendedNavigatingEventArgs.Url) == false) { browserExtendedNavigatingEventArgs.Cancel = true; } else { if ((!(browserExtendedNavigatingEventArgs.Url == null)) && (browserExtendedNavigatingEventArgs.Url.LocalPath.Contains(CatalogApi.Catalogs.Blanket) == true)) { base.Close(); } else { ; } if ((!(browserExtendedNavigatingEventArgs.Url == null)) && (browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("navlevel=year&action=navigate&aid=epc&fid=nav"))) { base.Close(); } else { ; } ExtendedWebBrowser extendedWebBrowser = this.WindowManager.New(false, base.Title); browserExtendedNavigatingEventArgs.AutomationObject = extendedWebBrowser.Application; } } else { ; } }
private void update_front() { string url = ""; pk_browser_front = (ExtendedWebBrowser)this.pk_tab.SelectedTab.Controls["ex"]; this.pk_tool_btn_back.Enabled = pk_browser_front.CanGoBack; this.pk_tool_btn_forward.Enabled = pk_browser_front.CanGoForward; this.pk_browser_front.Focus(); if (pk_browser_front.Url != null) { if (!pk_browser_front.Url.ToString().Contains(Properties.Resources.PK_STR_HIDE_URL)) { url = pk_browser_front.Url.ToString(); } this.pk_tool_txt_url.Text = url; } }
private void pk_browser_Navigated(object sender, WebBrowserNavigatedEventArgs e) { ExtendedWebBrowser pk_browser_current = sender as ExtendedWebBrowser; TabPage pk_tab_parent; // if current browser is active if (pk_browser_current == pk_browser_front) { update_front(); } pk_tab_parent = (TabPage)pk_browser_current.Parent; if (pk_tab_parent.ImageIndex != (int)EXEC_ICON.EXEC_IE) { pk_tab_parent.ImageIndex = (int)EXEC_ICON.EXEC_IE; } Program.log(Properties.Resources.PK_STR_LOG_NAV + pk_browser_current.Url.ToString()); }
private void bbBtn_Click(object sender, EventArgs e) { TabPage NewTabPage = new TabPage(); ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser() { Parent = NewTabPage, Dock = DockStyle.Fill, Tag = NewTabPage }; NewTabBrowser.Navigate("http://bb.unist.ac.kr"); InitializeBrowserEvents(NewTabBrowser); tabControl.TabPages.Add(NewTabPage); tabControl.SelectedTab = NewTabPage; // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]); // ex.Navigate("http://bb.unist.ac.kr"); }
private void pkh_post_amend_thread(ExtendedWebBrowser browser) { for (int tries = 0; tries < 3; tries++) { if (browser != null) { foreach (HtmlElement pk_elem in browser.Document.All) { if (pk_elem.GetAttribute("className") == "btn btn-yellow") { Program.log("_blank set"); pk_elem.SetAttribute("target", "_blank"); tries = 3; // exit outer loop } } Application.DoEvents(); Thread.Sleep(250); } } }
// all data in this file are hardcoded public void pkh_login(ExtendedWebBrowser browser) { try { browser.Navigate("http://zhongbao.10085.cn:18080/module/public/reg/user_login.html"); while (browser.ReadyState != WebBrowserReadyState.Complete) { // TODO: need add timeout Application.DoEvents(); } browser.Document.GetElementById("mobile").Focus(); browser.Document.GetElementById("mobile").InnerText = Properties.Settings.Default.PK_DEFAULT_USER; browser.Document.GetElementById("password").InnerText = Properties.Settings.Default.PK_DEFAULT_PASS; browser.Document.GetElementById("regcheckcode").Focus(); } catch (Exception ex) { } }
private void InternetExplorerOnStartNewWindow(object sender, BrowserExtendedNavigatingEventArgs browserExtendedNavigatingEventArgs) { if (!(browserExtendedNavigatingEventArgs.Url != null) || !browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("about:blank")) { if (browserExtendedNavigatingEventArgs.Url != null && (browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("fid=notify") || browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("fid=news") || browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("fid=bulletinboard") || browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("fid=feedback") || browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("fid=about") || browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("fid=downloads") || browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("fid=ug") || browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("/privacy/") || browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("fid=help"))) { browserExtendedNavigatingEventArgs.Cancel = true; } else { if (browserExtendedNavigatingEventArgs.Url != null && browserExtendedNavigatingEventArgs.Url.LocalPath.Contains("http://10.0.0.10:351/PQMace/login.fve")) { base.Close(); } if (browserExtendedNavigatingEventArgs.Url != null && browserExtendedNavigatingEventArgs.Url.AbsoluteUri.Contains("navlevel=year&action=navigate&aid=epc&fid=nav")) { base.Close(); } ExtendedWebBrowser extendedWebBrowser = this.WindowManager.New(false, base.Title); browserExtendedNavigatingEventArgs.AutomationObject = extendedWebBrowser.Application; } } }
private void wb_StatusTextChanged(object sender, EventArgs e) { ExtendedWebBrowser pk_browser_current = sender as ExtendedWebBrowser; this.pk_status_txt_stat.Text = pk_browser_current.StatusText; }
public MyWebBrowserSite(ExtendedWebBrowser host) : base(host) { _host = host; }
public WebBrowserExtendedEvents(ExtendedWebBrowser browser) { _Browser = browser; }
// get the ticket public int pkh_play(ExtendedWebBrowser browser) { int icon_exec_index = 0; try { if (browser.Url.ToString().Contains("project_detail.html")) { foreach (HtmlElement pk_elem in browser.Document.All) { if (pk_elem.GetAttribute("className") == "data-loading") { if (pk_elem.Style == "display:block") { icon_exec_index = (int)EXEC_ICON.EXEC_RED; break; } } switch (pk_elem.GetAttribute("className")) { case "ui-dialog-content": Program.log("对话框"); if ((pk_elem.InnerText.Contains("抢完")) || // 亲,很抱歉项目已被抢完了哦~ (pk_elem.InnerText.Contains("很抱歉"))) // 很抱歉,您拥有的资格数量已达到上限值1 { icon_exec_index = (int)EXEC_ICON.EXEC_GREY; } else if ((pk_elem.InnerText.Contains("超时")) || // 网络异常或超时,请稍候再试! (pk_elem.InnerText.Contains("外呼的人员已满"))) // 当前项目参与外呼的人员已满,请稍后再试 { browser.Refresh(WebBrowserRefreshOption.Completely); icon_exec_index = (int)EXEC_ICON.EXEC_RED; } if (pk_elem.InnerText.Contains("超过10次")) { // 5分钟内抢单超过10次(含10次) Program.log("验证码识别!"); string code = pkh_code(browser.Document); Program.log(code, 1); HtmlElement pk_elem_code = browser.Document.GetElementById("regcheckcode"); pk_elem_code.SetAttribute("value", code); Application.DoEvents(); Thread.Sleep(50); Application.DoEvents(); foreach (HtmlElement pk_elem_ok in browser.Document.All) { if (pk_elem_ok.GetAttribute("i-id") == "ok") { pk_elem_ok.InvokeMember("Click"); break; } } icon_exec_index = (int)EXEC_ICON.EXEC_RED; } else if (Properties.Settings.Default.PK_CODETEST > 0) { Program.log("关闭对话框"); // foreach (HtmlElement pk_elem_close in browser.Document.All) // { // if (pk_elem_close.GetAttribute("className") == "ui-dialog-close") // { // pk_elem_close.InvokeMember("Click"); // break; // } // } icon_exec_index = (int)EXEC_ICON.EXEC_RED; browser.Refresh(WebBrowserRefreshOption.Normal); } break; case "btn btn-yellow btn-mid J_start_work mt-5": // "开始工作" case "btn btn-yellow btn-mid J_grab_single mt-5": // "开始抢单" if (pk_elem.GetAttribute("clicked") != "true") { Program.log("点击按钮"); pk_elem.SetAttribute("clicked", "true"); pk_elem.InvokeMember("Click"); icon_exec_index = (int)EXEC_ICON.EXEC_RED; } break; case "btn btn-yellow btn-disabled btn-mid mt-5": // button disabled Program.log("刷新"); browser.Refresh(WebBrowserRefreshOption.Completely); icon_exec_index = (int)EXEC_ICON.EXEC_RED; break; default: break; } } } } catch (Exception ex) { Program.log(ex.Message); } return(icon_exec_index); }
private void CreateNewTab(TabType tt, string tourl, bool delayed) { if (!string.IsNullOrEmpty(tourl)) { for (var index = 1; index < tabControlLeft.TabPages.Count; index++) { if (!tourl.Equals(TabGetUrl(index), StringComparison.OrdinalIgnoreCase)) { continue; } if (!delayed) { tabControlLeft.SelectedIndex = index; } return; } } var tabc = new TabClass { MyType = tt, Address = tourl, AddressInit = tourl, Delayed = delayed }; var tabpage = new TabPage(); ExtendedWebBrowser browser = null; TextBox textbox = null; if (tabc.MyType != TabType.Notepad) { browser = new ExtendedWebBrowser { Dock = DockStyle.Fill, ScriptErrorsSuppressed = true, ObjectForScripting = new ScriptManager() }; // !!! browser.BeforeNewWindow += wbTab_BeforeNewWindow; tabc.WB = browser; } else { textbox = new TextBox { BorderStyle = BorderStyle.None, Dock = DockStyle.Fill, Font = new Font("Courier New", 9F, FontStyle.Regular, GraphicsUnit.Point, 204), Multiline = true, ScrollBars = ScrollBars.Both, }; textbox.Leave += (sender, e) => AppVars.Profile.Notepad = ((TextBox)sender).Text; textbox.Text = AppVars.Profile.Notepad; textbox.SelectionStart = textbox.Text.Length; textbox.SelectionLength = 1; tabc.Note = textbox; } // panel var panel = new Panel(); if (browser != null) { panel.Controls.Add(browser); } else { panel.Controls.Add(textbox); } panel.Dock = DockStyle.Fill; panel.Location = new Point(3, 28); panel.Name = Guid.NewGuid().ToString(); panel.Padding = new Padding(0, 3, 0, 0); panel.Size = new Size(666, 461); // buttonback ToolStripButton buttonback = null; if (tabc.MyType == TabType.Forum || tabc.MyType == TabType.Log || tabc.MyType == TabType.Other) { buttonback = new ToolStripButton { Image = Resources._16x16_back, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(58, 22), Text = "Назад", ToolTipText = "Возврат на предыдущую страницу", Tag = browser }; buttonback.Click += buttonForumBack_Click; } // buttonrefresh ToolStripButton buttonrefresh = null; if ((tabc.MyType != TabType.Notepad) && (tabc.MyType != TabType.TodayChat)) { buttonrefresh = new ToolStripButton { Image = Resources._16x16_refresh, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(77, 22), Text = "Обновить", ToolTipText = "Обновление текущей страницы", Tag = browser }; buttonrefresh.Click += buttonForumRefresh_Click; } // buttonreload ToolStripButton buttonreload = null; if (tabc.MyType == TabType.TodayChat) { buttonreload = new ToolStripButton { Image = Resources._16x16_refresh, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(77, 22), Text = "Перечитать", ToolTipText = "Обновление сегодняшнего чата", Tag = browser }; buttonreload.Click += buttonReload_Click; } // buttonclose var buttonclose = new ToolStripButton { Image = Resources._16x16_close, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(71, 22), Text = "Закрыть", ToolTipText = "Закрытие этой закладки", Tag = tabpage }; buttonclose.Click += buttonForumClose_Click; // toolstripseparator1 ToolStripSeparator toolstripseparator1 = null; if (tabc.MyType != TabType.Notepad) { toolstripseparator1 = new ToolStripSeparator { Name = Guid.NewGuid().ToString(), Size = new Size(6, 25) }; } // buttoncompas ToolStripButton buttoncompas = null; if (tabc.MyType == TabType.PInfo || tabc.MyType == TabType.PName) { if (!string.IsNullOrEmpty(tourl)) { var nick = tabc.MyType == TabType.PInfo ? HelperConverters.NickDecode(tourl.Substring(Resources.AddressPInfo.Length)) : HelperConverters.NickDecode(tourl.Substring(Resources.AddressPName.Length)); buttoncompas = new ToolStripButton { Image = Resources._16x16_compas, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(64, 22), Text = "Компас", ToolTipText = "Поиск точного положения на природе", Tag = nick, Enabled = true }; buttoncompas.Click += buttonCompas_Click; } } // buttonprivate ToolStripButton buttonprivate = null; if (tabc.MyType == TabType.PInfo || tabc.MyType == TabType.PName) { if (!string.IsNullOrEmpty(tourl)) { var nick = tabc.MyType == TabType.PInfo ? HelperConverters.NickDecode(tourl.Substring(Resources.AddressPInfo.Length)) : HelperConverters.NickDecode(tourl.Substring(Resources.AddressPName.Length)); buttonprivate = new ToolStripButton { Image = Resources._16x16_private, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(64, 22), Text = "Приват", ToolTipText = "Обратиться в приват", Tag = nick }; buttonprivate.Click += buttonPrivate_Click; } } // buttoncontact ToolStripButton buttoncontact = null; if (tabc.MyType == TabType.PInfo || tabc.MyType == TabType.PName) { if (!string.IsNullOrEmpty(tourl)) { var nick = tabc.MyType == TabType.PInfo ? HelperConverters.NickDecode(tourl.Substring(Resources.AddressPInfo.Length)) : HelperConverters.NickDecode(tourl.Substring(Resources.AddressPName.Length)); buttoncontact = new ToolStripButton { Image = Resources._16x16_person, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(64, 22), Text = "В контакты", ToolTipText = "Добавить в контакты", Tag = nick }; buttoncontact.Click += buttonContact_Click; } } // buttonaddclan ToolStripButton buttonAddClan = null; if (tabc.MyType == TabType.PInfo || tabc.MyType == TabType.PName) { if (!string.IsNullOrEmpty(tourl)) { var nick = tabc.MyType == TabType.PInfo ? HelperConverters.NickDecode(tourl.Substring(Resources.AddressPInfo.Length)) : HelperConverters.NickDecode(tourl.Substring(Resources.AddressPName.Length)); buttonAddClan = new ToolStripButton { Image = Resources._16x16_person, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(64, 22), Text = @"Весь клан", ToolTipText = @"Добавление всего клана в контакты", Tag = nick, Enabled = true }; buttonAddClan.Click += buttonAddClan_Click; } } // buttonscreen ToolStripButton buttonscreen = null; if ((tabc.MyType != TabType.Notepad) && (tabc.MyType != TabType.TodayChat)) { buttonscreen = new ToolStripButton { Image = Resources._16x16_camera, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(64, 22), Text = "Снимок", ToolTipText = "Снимок текущей закладки", Tag = browser }; buttonscreen.Click += buttonForumScreen_Click; } // separator ToolStripSeparator toolstripseparator2 = null; if ((tabc.MyType != TabType.Notepad) && (tabc.MyType != TabType.TodayChat)) { toolstripseparator2 = new ToolStripSeparator { Name = Guid.NewGuid().ToString(), Size = new Size(6, 25) }; } // buttonaddress ToolStripButton buttonaddress = null; if ((tabc.MyType != TabType.Notepad) && (tabc.MyType != TabType.TodayChat)) { buttonaddress = new ToolStripButton { DisplayStyle = ToolStripItemDisplayStyle.Image, Image = Resources._16x16_copyurl, ImageTransparentColor = Color.Magenta, Name = Guid.NewGuid().ToString(), Size = new Size(23, 22), ToolTipText = "Копировать адрес в клипборд" }; buttonaddress.Click += buttonForumCopyAddress_Click; } // labeladdress ToolStripStatusLabel labeladdress = null; if ((tabc.MyType != TabType.Notepad) && (tabc.MyType != TabType.TodayChat)) { labeladdress = new ToolStripStatusLabel { Enabled = false, Name = Guid.NewGuid().ToString(), Size = new Size(65, 22), Text = tabc.AddressInit, TextAlign = ContentAlignment.MiddleLeft, DisplayStyle = ToolStripItemDisplayStyle.Text }; } if (browser != null) { browser.Tag = labeladdress; browser.DocumentCompleted += wbTab_DocumentCompleted; } // // toolstrip // var toolstrip = new ToolStrip(); switch (tabc.MyType) { case TabType.Other: case TabType.Log: case TabType.Forum: toolstrip.Items.AddRange(new ToolStripItem[] { buttonback, buttonrefresh, buttonclose, toolstripseparator1, buttonscreen, toolstripseparator2, buttonaddress, labeladdress }); break; case TabType.PBots: case TabType.Room: toolstrip.Items.AddRange(new ToolStripItem[] { buttonrefresh, buttonclose, toolstripseparator1, buttonscreen, toolstripseparator2, buttonaddress, labeladdress }); break; case TabType.PInfo: case TabType.PName: toolstrip.Items.AddRange(new ToolStripItem[] { buttonrefresh, buttonclose, toolstripseparator1, buttoncompas, buttonprivate, buttoncontact, buttonAddClan, buttonscreen, toolstripseparator2, buttonaddress, labeladdress }); break; case TabType.Notepad: toolstrip.Items.AddRange(new ToolStripItem[] { buttonclose }); break; case TabType.TodayChat: toolstrip.Items.AddRange(new ToolStripItem[] { buttonreload, buttonclose }); break; } toolstrip.Location = new Point(3, 3); toolstrip.Name = Guid.NewGuid().ToString(); toolstrip.Size = new Size(666, 25); tabpage.Controls.Add(panel); tabpage.Controls.Add(toolstrip); tabpage.Name = Guid.NewGuid().ToString(); tabpage.Location = new Point(4, 23); tabpage.Size = new Size(672, 492); tabpage.Padding = new Padding(3); tabpage.UseVisualStyleBackColor = true; switch (tt) { case TabType.Forum: tabpage.Text = "Форум"; break; case TabType.PInfo: if (tourl != null) { tabpage.Text = HelperConverters.NickDecode(tourl.Substring(Resources.AddressPInfo.Length)); tourl = HelperConverters.AddressEncode(Resources.AddressPInfo + tabpage.Text); } tabpage.ImageIndex = 0; break; case TabType.PName: if (tourl != null) { tabpage.Text = HelperConverters.NickDecode(tourl.Substring(Resources.AddressPName.Length)); tourl = HelperConverters.AddressEncode(Resources.AddressPName + tabpage.Text); } tabpage.ImageIndex = 0; break; case TabType.PBots: if (tourl != null) { tabpage.Text = "Бот " + tourl.Substring(Resources.AddressPBots.Length); } tabpage.ImageIndex = 0; break; case TabType.Log: if (tourl != null) { var slog = tourl.Substring(Resources.AddressFightLog.Length); var pos = slog.IndexOf('&'); if (pos != -1) { slog = slog.Substring(0, pos); } tabpage.Text = "Бой " + slog; } break; case TabType.Room: if (tourl != null) { tabpage.Text = "Комната " + tourl.Substring("http://www.neverlands.ru/ch.php?lo=1&r=".Length); } break; case TabType.Notepad: tabpage.Text = "Блокнот"; tabpage.ImageIndex = 1; break; case TabType.TodayChat: tabpage.Text = "Сегодняшний чат"; break; case TabType.Other: if (tourl != null) { tabpage.Text = new Uri(tourl).DnsSafeHost; } break; } if ((tt != TabType.Game) && (tt != TabType.Notepad) && (tt != TabType.TodayChat)) { if (!delayed) { tabc.WB.Navigate(tourl); } } if (tt == TabType.TodayChat) { if (!delayed) { TabReload(buttonreload); } } tabc.Address = tourl; tabpage.Tag = tabc; if ((tt == TabType.PInfo) && (tabpage.Text.Equals(AppVars.Profile.UserNick, StringComparison.OrdinalIgnoreCase))) { tabControlLeft.TabPages.Insert(1, tabpage); } else { tabControlLeft.TabPages.Add(tabpage); } if (delayed) { return; } SaveTabs(); tabControlLeft.SelectedTab = tabpage; }
private void InitGameTab() { try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateTexLogDelegate(AppVars.MainForm.UpdateTexLog), new object[] { "InitGameTab()" }); } } catch (InvalidOperationException) { } if (tabControlLeft == null) { return; } if (tabControlLeft.TabPages.Count == 0) { return; } var tabPage = tabControlLeft.TabPages[0]; tabPage.Text = AppVars.Profile.UserNick; TabClass tabClass; if (tabPage.Tag == null) { tabClass = new TabClass { MyType = TabType.Game, WB = browserGame }; tabPage.Tag = tabClass; } browserGame.BeforeNewWindow -= wbTab_BeforeNewWindow; browserGame.BeforeNavigate -= browserGame_BeforeNavigate; browserGame.DocumentCompleted -= browserGame_DocumentCompleted; panelGame.Controls.Remove(browserGame); browserGame.Dispose(); browserGame = null; CookiesManager.ClearGame(); browserGame = new ExtendedWebBrowser { Dock = DockStyle.Fill, Name = "browserGame", ScriptErrorsSuppressed = true, TabIndex = 0, ObjectForScripting = new ScriptManager() }; browserGame.BeforeNewWindow += wbTab_BeforeNewWindow; browserGame.BeforeNavigate += browserGame_BeforeNavigate; browserGame.DocumentCompleted += browserGame_DocumentCompleted; panelGame.Controls.Add(browserGame); tabClass = (TabClass)tabPage.Tag; tabClass.WB = browserGame; tabPage.Tag = tabClass; buttonGameScreen.Tag = browserGame; /* * var encnick = HelperConverters.NickEncode("Мастер Создатель"); * var url = $"http://www.neverlands.ru/pinfo.cgi?{encnick}"; * browserGame.Navigate(url); * while (browserGame != null && !browserGame.IsDisposed && browserGame.ReadyState != WebBrowserReadyState.Complete) * Application.DoEvents(); * */ if (browserGame != null && !browserGame.IsDisposed) { browserGame.Navigate(Resources.AddressNeverlands); try { if (AppVars.MainForm != null) { AppVars.MainForm.BeginInvoke( new UpdateTexLogDelegate(AppVars.MainForm.UpdateTexLog), new object[] { $"browserGame.Navigate({Resources.AddressNeverlands})" }); } } catch (InvalidOperationException) { } while (browserGame != null && !browserGame.IsDisposed && browserGame.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } /* * if (browserGame != null && !browserGame.IsDisposed) * browserGame.Navigate(Resources.AddressNeverlands); */ } }
private void InitGameTab() { if (tabControlLeft == null) { return; } if (tabControlLeft.TabPages.Count == 0) { return; } var tabPage = tabControlLeft.TabPages[0]; tabPage.Text = AppVars.Profile.UserNick; TabClass tabClass; if (tabPage.Tag == null) { tabClass = new TabClass { MyType = TabType.Game, WB = browserGame }; tabPage.Tag = tabClass; } browserGame.BeforeNewWindow -= wbTab_BeforeNewWindow; browserGame.BeforeNavigate -= browserGame_BeforeNavigate; browserGame.DocumentCompleted -= browserGame_DocumentCompleted; panelGame.Controls.Remove(browserGame); browserGame.Dispose(); browserGame = null; CookiesManager.ClearGame(); browserGame = new ExtendedWebBrowser { Dock = DockStyle.Fill, Name = "browserGame", ScriptErrorsSuppressed = true, TabIndex = 0, ObjectForScripting = new ScriptManager() }; browserGame.BeforeNewWindow += wbTab_BeforeNewWindow; browserGame.BeforeNavigate += browserGame_BeforeNavigate; browserGame.DocumentCompleted += browserGame_DocumentCompleted; panelGame.Controls.Add(browserGame); tabClass = (TabClass)tabPage.Tag; tabClass.WB = browserGame; tabPage.Tag = tabClass; buttonGameScreen.Tag = browserGame; var url = HelperConverters.AddressEncode(string.Concat("http://www.neverlands.ru/pinfo.cgi?", "Мастер Создатель")); browserGame.Navigate(url); while (browserGame != null && !browserGame.IsDisposed && browserGame.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } if (browserGame != null && !browserGame.IsDisposed) { browserGame.Navigate(Resources.AddressNeverlands); while (browserGame != null && !browserGame.IsDisposed && browserGame.ReadyState != WebBrowserReadyState.Complete) { Application.DoEvents(); } if (browserGame != null && !browserGame.IsDisposed) { browserGame.Navigate(Resources.AddressNeverlands); } } }
void SourceBrowser_NewWindow2(object sender, NewWindow2EventArgs e) { TabPage NewTabPage = new TabPage(); /* if (((ExtendedWebBrowser)sender).Url.ToString().IndexOf("cyworld") != -1 || ((ExtendedWebBrowser)sender).Url.ToString().IndexOf("nate") != -1) { return; } */ ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser() { Parent = NewTabPage, Dock = DockStyle.Fill, Tag = NewTabPage }; e.PPDisp = NewTabBrowser.Application; InitializeBrowserEvents(NewTabBrowser); tabControl.TabPages.Add(NewTabPage); tabControl.SelectedTab = NewTabPage; }
private void nightMealBtn_Click(object sender, EventArgs e) { TabPage NewTabPage = new TabPage(); ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser() { Parent = NewTabPage, Dock = DockStyle.Fill, Tag = NewTabPage }; NewTabBrowser.Navigate("https://docs.google.com/spreadsheet/ccc?key=0AiTS2HBKYvZxdEpRVHJ1cXliQVRNUTI1OVQwTzlyTFE&usp=sharing#gid=0"); InitializeBrowserEvents(NewTabBrowser); tabControl.TabPages.Add(NewTabPage); tabControl.SelectedTab = NewTabPage; // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]); // ex.Navigate("http://club.cyworld.com/ClubV1/Home.cy/53814181"); }
private void nateClubBtn_Click(object sender, EventArgs e) { TabPage NewTabPage = new TabPage(); ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser() { Parent = NewTabPage, Dock = DockStyle.Fill, Tag = NewTabPage }; NewTabBrowser.Navigate("http://club.cyworld.com/ClubV1/Home.cy/53814181"); // NewTabBrowser.Navigate("http://xo.nate.com/Notfound.sk?redirect=http://club.cyworld.com/uniallstar&cpurl=www_ndr.nate.com%2flogin&viewnid=null&viewcid=null&flag=Y&e_url=http://www.nate.com/&mode="); InitializeBrowserEvents(NewTabBrowser); tabControl.TabPages.Add(NewTabPage); tabControl.SelectedTab = NewTabPage; // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]); // ex.Navigate("http://club.cyworld.com/ClubV1/Home.cy/53814181"); }
public static void SingIn(ExtendedWebBrowser exWeb, string userId, string password) { }
public static void ChangeTarget(ExtendedWebBrowser exWeb) { }
/// <summary> /// popup new window in custom tab /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void webBrowser_StartNewWindow(object sender, Utils.BrowserExtendedNavigatingEventArgs e) { // Here we do the pop-up blocker work // Note that in Windows 2000 or lower this event will fire, but the // event arguments will not contain any useful information // for blocking pop-ups. // There are 4 filter levels. // None: Allow all pop-ups // Low: Allow pop-ups from secure sites // Medium: Block most pop-ups // High: Block all pop-ups (Use Ctrl to override) // We need the instance of the main form, because this holds the instance // to the WindowManager. if (!Utils.BrowserController.Contains(this)) { return; } // Allow a popup when there is no information available or when the Ctrl key is pressed bool allowPopup = (e.NavigationContext == UrlContext.None) || ((e.NavigationContext & UrlContext.OverrideKey) == UrlContext.OverrideKey); if (!allowPopup) { // Give None, Low & Medium still a chance. switch (SettingsHelper.Current.FilterLevel) { case PopupBlockerFilterLevel.None: allowPopup = true; break; case PopupBlockerFilterLevel.Low: // See if this is a secure site if (this.webBrowser.EncryptionLevel != WebBrowserEncryptionLevel.Insecure) { allowPopup = true; } else { // Not a secure site, handle this like the medium filter goto case PopupBlockerFilterLevel.Medium; } break; case PopupBlockerFilterLevel.Medium: // This is the most dificult one. // Only when the user first inited and the new window is user inited if ((e.NavigationContext & UrlContext.UserFirstInited) == UrlContext.UserFirstInited && (e.NavigationContext & UrlContext.UserInited) == UrlContext.UserInited) { allowPopup = true; } break; } } if (allowPopup) { // Check wheter it's a HTML dialog box. If so, allow the popup but do not open a new tab if (!((e.NavigationContext & UrlContext.HtmlDialog) == UrlContext.HtmlDialog)) { ExtendedWebBrowser ewb = BrowserController.AddNewWebView().webBrowser; // The (in)famous application object e.AutomationObject = ewb.Application; } } else { // Here you could notify the user that the pop-up was blocked e.Cancel = true; } }
public WebBrowserExtendedEvents(ExtendedWebBrowser browser) { _Browser = browser; }
private void calendarBtn_Click(object sender, EventArgs e) { TabPage NewTabPage = new TabPage(); ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser() { Parent = NewTabPage, Dock = DockStyle.Fill, Tag = NewTabPage }; NewTabBrowser.Navigate("https://www.google.com/calendar/embed?src=anr9a4cbgv3os8ac5i8fg6fqic%40group.calendar.google.com&ctz=Asia/Seoul"); InitializeBrowserEvents(NewTabBrowser); tabControl.TabPages.Add(NewTabPage); tabControl.SelectedTab = NewTabPage; // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]); // ex.Navigate("http://club.cyworld.com/ClubV1/Home.cy/53814181"); }
public static void FilterContent(ExtendedWebBrowser exWeb) { }
private void epBtn_Click(object sender, EventArgs e) { TabPage NewTabPage = new TabPage(); ExtendedWebBrowser NewTabBrowser = new ExtendedWebBrowser() { Parent = NewTabPage, Dock = DockStyle.Fill, Tag = NewTabPage }; NewTabBrowser.Navigate("http://portal.unist.ac.kr/EP/tmaxsso/runSAPEP.jsp"); InitializeBrowserEvents(NewTabBrowser); tabControl.TabPages.Add(NewTabPage); tabControl.SelectedTab = NewTabPage; // ExtendedWebBrowser ex = (ExtendedWebBrowser)(tabControl.SelectedTab.Controls[0]); // ex.Navigate("http://portal.unist.ac.kr/EP/web/portal/jsp/EP_Default1.jsp"); }
private void InitializeBrowserEvents(ExtendedWebBrowser SourceBrowser) { SourceBrowser.ScriptErrorsSuppressed = true; SourceBrowser.NewWindow += new CancelEventHandler(cancel_newWindow); SourceBrowser.NewWindow2 += new EventHandler<NewWindow2EventArgs>(SourceBrowser_NewWindow2); SourceBrowser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(browser_DocumentCompleted); // SourceBrowser.Navigating += new System.Windows.Forms.WebBrowserNavigatingEventHandler(browser_Navigating); }
public HtmlHelper(ExtendedWebBrowser extendedWeb, string userName, string password) { this.userName = userName; this.password = password; this.extendedWeb = extendedWeb; }