private void btn_open_Click(object sender, EventArgs ea) { if (txt_url.Text.Length == 0) { return; } this.txt_url.SelectionStart = 0; if (!txt_url.Text.StartsWith("http")) { txt_url.Text = "http://" + txt_url.Text; } var tabPage = new BrowserTabPage { Name = "tabPage_share" + new Random().Next().ToString(), Text = "打开链接", Url = txt_url.Text }; this.tabControl1.TabPages.Add(tabPage); var browser = tabPage.Browser; browser.TitleChanged += (s, e) => { this.Invoke(() => { tabPage.Text = e.Title.Length < 10 ? e.Title : e.Title.Substring(0, 10); }); }; browser.FrameLoadEnd += (s, e) => { SetPageScript(browser); }; browser.AddressChanged += (s, e) => { this.Invoke(() => { if (this.tabControl1.SelectedTab == tabPage) { this.txt_url.Text = e.Address; this.txt_url.SelectionStart = 0; } }); }; tabPage.Load(); this.tabControl1.SelectedTab = tabPage; }
private void timer1_Tick(object sender, EventArgs ea) { timer1.Enabled = false; notify = new Notify(this); if (config.Get("notify") == "false") { notify.Enabled = false; } notify.AddMenuItem("打开下载目录", () => { Process.Start("explorer.exe", this.aria2.Config.__dir); }); notify.AddMenuItem(notify.Enabled ? "关闭通知" : "开启通知", (s) => { notify.Enabled = !notify.Enabled; s.Text = notify.Enabled ? "关闭通知" : "开启通知"; }); notify.AddMenuItem(aria2.Enabled ? "关闭Aria2" : "开启Aria2", (s) => { aria2.Enabled = !aria2.Enabled; s.Text = aria2.Enabled ? "关闭Aria2" : "开启Aria2"; if (aria2.Enabled) { aria2.Start(); } else { aria2.Stop(); } }); notify.AddMenuItem("设置下载目录", () => { FolderBrowserDialog dialog = new FolderBrowserDialog(); dialog.ShowDialog(); this.aria2.Config.__dir = dialog.SelectedPath; aria2.Stop(); aria2.Start(); }); notify.AddMenuItem("显示日志", () => { if (log == null) { log = new LogForm(); } aria2.DataReceived += log.Log; log.Show(); }); notify.AddMenuItem("退出", () => { closing = true; Application.Exit(); }); var tabPage_home = new BrowserTabPage { Name = "tabPage_home", Text = "主页", Url = "http://pan.baidu.com", MainPage = true }; this.tabControl1.TabPages.Add(tabPage_home); this.webBrowser1 = tabPage_home.Browser; webBrowser1.FrameLoadEnd += (s, e) => { SetPageScript(webBrowser1); }; tabPage_home.Load(); var tabPage_aria = new BrowserTabPage { Name = "tabPage_aria", Text = "下载", Url = localurl + "/resource/" + webui + "/index.html", MainPage = true }; this.tabControl1.TabPages.Add(tabPage_aria); tabPage_aria.Browser.TitleChanged += (a, e) => { this.Invoke(() => { this.Text = e.Title; }); }; tabPage_aria.Load(); }