using System; using System.Collections.Generic; using System.ComponentModel; using System.Configuration; using System.Diagnostics; using System.Drawing; using System.IO; using System.Net; using System.Reflection; using System.Threading; using System.Web; using System.Windows.Forms; using CefSharp; using CefSharp.Event; using CefSharp.WinForms; using FarsiLibrary.Win; using prBrowser.Properties; using prBrowser.Weblogic; using System.Xml.Linq; using prBrowserUpdate; namespace prBrowser { internal class MainForm : Form { private string appPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\"; public static MainForm Instance; public static string Branding = "prBrowser"; public static string UserAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.1.360.0 Safari/537.36"; //public static string AcceptLanguage = "en-US,en;q=0.9"; public static string AcceptLanguage = "zh-CN,zh;q=0.9,en;q=0.8"; public string HomepageURL = ConfigurationManager.AppSettings["DefaultUrl"]; public string NewTabURL = ConfigurationManager.AppSettings["DefaultUrl"]; public static string InternalURL = "prBrowser"; public static string DownloadsURL = "prBrowser://storage/downloads.html"; public static string FileNotFoundURL = "prBrowser://storage/errors/notFound.html"; public static string CannotConnectURL = "prBrowser://storage/errors/cannotConnect.html"; public static string SearchURL = "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&rsv_idx=1&tn=baidu&wd="; public bool WebSecurity = true; public bool CrossDomainSecurity = true; public bool WebGL = true; public bool ApplicationCache = true; public static Assembly assembly = null; private FATabStripItem newStrip; private FATabStripItem downloadsStrip; private string currentFullURL; private string currentCleanURL; private string currentTitle; private int currentZoom; public HostHandler host; private DownloadHandler dHandler; private ContextMenuHandler mHandler; private LifeSpanHandler lHandler; private KeyboardHandler kHandler; private RequestHandler rHandler; public Dictionary downloads; public Dictionary downloadNames; public List downloadCancelRequests; private bool searchOpen = false; private string lastSearch = ""; private IContainer components = null; private FATabStrip TabPages; private FATabStripItem tabStrip1; private FATabStripItem tabStripAdd; private System.Windows.Forms.Timer timer1; private ContextMenuStrip menuStripTab; private ToolStripMenuItem menuCloseTab; private ToolStripMenuItem menuCloseOtherTabs; private Button BtnForward; private Button BtnBack; private Button BtnStop; private Button BtnRefresh; private Button BtnDownloads; private TextBox TxtURL; private Panel PanelToolbar; private Panel PanelStatus; private Panel PanelSearch; private TextBox TxtSearch; private Button BtnCloseSearch; private Button BtnPrevSearch; private Button BtnNextSearch; private Button BtnSettings; private ContextMenuStrip settingMenuStrip; private ToolStripMenuItem toolStripMenuItemDevTool; private ToolStripMenuItem toolStripMenuItemViewSource; private ToolStripMenuItem toolStripMenuItemDelCache; private ToolStripSeparator toolStripSeparator3; private ToolStripMenuItem toolStripMenuItemMinus; private ToolStripTextBox toolStripTextBoxZoom; private ToolStripMenuItem toolStripMenuItemAdd; private ToolStripMenuItem toolStripMenuItemResume; private ToolStripMenuItem toolStripMenuItemFullScreen; private ToolStripSeparator toolStripSeparator4; private ToolStripMenuItem toolStripMenuItemExit; private ToolStripMenuItem toolStripMenuItemServer; private ToolStripMenuItem toolStripMenuItemUpdate; //QY 此处定义更新窗体,可直接访问更新程序及其方法 prBrowserUpdate.MainForm updateMain = new prBrowserUpdate.MainForm(); private int CurIndex { get { return TabPages.Items.IndexOf(TabPages.SelectedItem); } set { TabPages.SelectedItem = TabPages.Items[value]; } } private int LastIndex => TabPages.Items.Count - 2; public ChromiumWebBrowser CurBrowser { get { if (TabPages.SelectedItem != null && TabPages.SelectedItem.Tag != null) { return ((SharpTab)TabPages.SelectedItem.Tag).Browser; } return null; } } public SharpTab CurTab { get { if (TabPages.SelectedItem != null && TabPages.SelectedItem.Tag != null) { return (SharpTab)TabPages.SelectedItem.Tag; } return null; } } public int CurTabLoadingDur { get { if (TabPages.SelectedItem != null && TabPages.SelectedItem.Tag != null) { return (int)(DateTime.Now - CurTab.DateCreated).TotalMilliseconds; } return 0; } } public List CancelRequests => downloadCancelRequests; public Dictionary Downloads => downloads; public MainForm() { try { checkServerUrl(); InitCache(); Instance = this; InitializeComponent(); //QY //doUpdate(); InitBrowser(); SetFormTitle(null); //string AutoUpdate = ConfigurationManager.AppSettings["AutoUpdate"]; //if (AutoUpdate == "Y") //{ //doUpdate(); //} } catch (Exception ex) { MessageBox.Show(ex.Message); Application.Exit(); //QY 完全退出程序,Application.Exit()无效 //System.Environment.Exit(0); } } /// /// 主窗体加载事件 /// /// /// private void MainForm_Load(object sender, EventArgs e) { InitTooltips(base.Controls); InitHotkeys(); } private void InitAppIcon() { assembly = Assembly.GetAssembly(typeof(MainForm)); base.Icon = new Icon(GetResourceStream("prBrowser.ico"), new Size(64, 64)); } public Stream GetResourceStream(string filename, bool withNamespace = true) { try { return assembly.GetManifestResourceStream("prBrowser.Resources." + filename); } catch { } return null; } /// /// 加载热键列表 /// private void InitHotkeys() { KeyboardHandler.AddHotKey(this, CloseActiveTab, Keys.W, ctrl: true); KeyboardHandler.AddHotKey(this, CloseActiveTab, Keys.Escape, ctrl: true); KeyboardHandler.AddHotKey(this, AddBlankWindow, Keys.N, ctrl: true); KeyboardHandler.AddHotKey(this, AddBlankTab, Keys.T, ctrl: true); KeyboardHandler.AddHotKey(this, RefreshActiveTab, Keys.F5); KeyboardHandler.AddHotKey(this, OpenDeveloperTools, Keys.F12); KeyboardHandler.AddHotKey(this, NextTab, Keys.Tab, ctrl: true); KeyboardHandler.AddHotKey(this, PrevTab, Keys.Tab, ctrl: true, shift: true); KeyboardHandler.AddHotKey(this, MinusZoom, Keys.OemMinus, ctrl: true); KeyboardHandler.AddHotKey(this, PlusZoom, Keys.Oemplus, ctrl: true); KeyboardHandler.AddHotKey(this, FullScreen, Keys.F11); KeyboardHandler.AddHotKey(this, OpenSearch, Keys.F, ctrl: true); KeyboardHandler.AddHotKey(this, CloseSearch, Keys.Escape); KeyboardHandler.AddHotKey(this, StopActiveTab, Keys.Escape); } public void InitTooltips(Control.ControlCollection parent) { foreach (Control ui in parent) { Button btn = ui as Button; if (btn != null && btn.Tag != null) { ToolTip tip = new ToolTip(); int num3 = (tip.ReshowDelay = (tip.InitialDelay = 200)); tip.ShowAlways = true; tip.SetToolTip(btn, btn.Tag.ToString()); } Panel panel = ui as Panel; if (panel != null) { InitTooltips(panel.Controls); } } } private string getXMLValue(string path, string attr) { string xmlValue = ""; XDocument document = XDocument.Load(path); XElement root = document.Root; XElement settingEle = root.Element("appSettings"); IEnumerable enumerable = settingEle.Elements(); foreach (XElement item in enumerable) { if (item.Attribute("key").Value == attr) { xmlValue = item.Attribute("value").Value; } } return xmlValue; } /// /// 载入浏览器 /// private void InitBrowser() { HomepageURL = ConfigurationManager.AppSettings["DefaultUrl"]; NewTabURL = ConfigurationManager.AppSettings["DefaultUrl"]; currentZoom = 100; try { currentZoom = Convert.ToInt32(getXMLValue("prBrowser.exe.config", "DefaultZoom")); } catch (Exception ex) { currentZoom = 100; //设置页面分辨率为100 } if (currentZoom == 0) currentZoom = 100; //设置页面分辨率为100 CefSharpSettings.LegacyJavascriptBindingEnabled = true; CefSharpSettings.WcfEnabled = false; CefSettings settings = new CefSettings(); //QY 运行时此处存在则异常 settings.RegisterScheme(new CefCustomScheme { SchemeName = InternalURL, SchemeHandlerFactory = new SchemeHandlerFactory() }); Cef.EnableHighDPISupport(); string insecureUrl = ConfigurationManager.AppSettings["InsecureUrl"]; settings.Locale = "zh-CN"; settings.CefCommandLineArgs.Add("--enable-npapi", "1"); settings.CefCommandLineArgs.Add("--disable-web-security", "1"); settings.CefCommandLineArgs.Remove("enable-system-flash"); settings.CefCommandLineArgs.Add("enable-system-flash", "1"); settings.CefCommandLineArgs.Add("enable-media-stream", "1"); settings.CefCommandLineArgs.Add("enable-speech-input", "1"); settings.CefCommandLineArgs.Add("no-proxy-server", "1"); settings.CefCommandLineArgs.Add("--unsafely-treat-insecure-origin-as-secure", insecureUrl); settings.CefCommandLineArgs.Add("--use-system-default-printer", "1"); settings.CefCommandLineArgs.Add("-enable-print-preview", "1"); settings.CefCommandLineArgs.Add("ppapi-flash-version", "32.0.0.321"); settings.CefCommandLineArgs.Add("ppapi-flash-path", AppDomain.CurrentDomain.BaseDirectory + "pepflashplayer.dll"); settings.UserAgent = UserAgent; settings.AcceptLanguageList = AcceptLanguage; settings.IgnoreCertificateErrors = true; settings.CachePath = GetAppDir("Cache"); settings.EnablePrintPreview(); Cef.Initialize(settings); dHandler = new DownloadHandler(this); lHandler = new LifeSpanHandler(this); mHandler = new ContextMenuHandler(this); kHandler = new KeyboardHandler(this); rHandler = new RequestHandler(this); InitDownloads(); host = new HostHandler(this); AddNewBrowser(tabStrip1, HomepageURL); initBrowserZoom(); } private void ConfigureBrowser(ChromiumWebBrowser browser) { BrowserSettings config = new BrowserSettings(); config.FileAccessFromFileUrls = (!CrossDomainSecurity).ToCefState(); config.UniversalAccessFromFileUrls = (!CrossDomainSecurity).ToCefState(); config.WebSecurity = WebSecurity.ToCefState(); config.WebGl = WebGL.ToCefState(); config.ApplicationCache = ApplicationCache.ToCefState(); browser.BrowserSettings = config; } private static string GetAppDir(string name) { string appPath = Path.GetDirectoryName(Application.ExecutablePath) + "\\"; return appPath + name + "\\"; } private void LoadURL(string url) { string newUrl = url; string urlLower = url.Trim().ToLower(); SetTabTitle(CurBrowser, "加载中..."); if (urlLower == "localhost") { newUrl = "http://localhost/"; } else if (url.CheckIfFilePath() || url.CheckIfFilePath2()) { newUrl = url.PathToURL(); } else { Uri.TryCreate(url, UriKind.Absolute, out var outUri); if (!urlLower.StartsWith("http") && !urlLower.StartsWith(InternalURL) && (outUri == null || outUri.Scheme != Uri.UriSchemeFile)) { newUrl = "http://" + url; } if (!urlLower.StartsWith(InternalURL + ":") && (!Uri.TryCreate(newUrl, UriKind.Absolute, out outUri) || (((!(outUri.Scheme == Uri.UriSchemeHttp) && !(outUri.Scheme == Uri.UriSchemeHttps)) || !newUrl.Contains(".")) && !(outUri.Scheme == Uri.UriSchemeFile)))) { newUrl = SearchURL + HttpUtility.UrlEncode(url); } } CurBrowser.Load(newUrl); SetFormURL(newUrl); EnableBackButton(canGoBack: true); EnableForwardButton(canGoForward: false); } private void SetFormTitle(string tabName) { if (tabName.CheckIfValid()) { Text = tabName + " - " + Branding; currentTitle = tabName; } else { Text = Branding; currentTitle = "新标签"; } } private void SetFormURL(string URL) { currentFullURL = URL; currentCleanURL = URL; TxtURL.Text = currentCleanURL; CurTab.CurURL = currentFullURL; CloseSearch(); } private string CleanURL(string url) { if (url.BeginsWith("about:")) { return ""; } url = url.RemovePrefix("http://"); url = url.RemovePrefix("https://"); url = url.RemovePrefix("file://"); url = url.RemovePrefix("/"); return url.DecodeURL(); } private bool IsBlank(string url) { return url == "" || url == "about:blank"; } private bool IsBlankOrSystem(string url) { return url == "" || url.BeginsWith("about:") || url.BeginsWith("chrome:") || url.BeginsWith(InternalURL + ":"); } public void AddBlankWindow() { ProcessStartInfo info = new ProcessStartInfo(Application.ExecutablePath, ""); info.LoadUserProfile = true; info.UseShellExecute = false; info.RedirectStandardError = true; info.RedirectStandardOutput = true; info.RedirectStandardInput = true; Process.Start(info); } public void AddBlankTab() { AddNewBrowserTab(""); this.InvokeOnParent(delegate { TxtURL.Focus(); }); } /// /// 新增浏览器标签 /// /// 标签地址 /// /// /// public ChromiumWebBrowser AddNewBrowserTab(string url, bool focusNewTab = true, string refererUrl = null) { return (ChromiumWebBrowser)Invoke((Func)delegate { foreach (FATabStripItem fATabStripItem in TabPages.Items) { SharpTab sharpTab = (SharpTab)fATabStripItem.Tag; if (sharpTab != null && sharpTab.CurURL == url) { TabPages.SelectedItem = fATabStripItem; return sharpTab.Browser; } } FATabStripItem item = new FATabStripItem { Title = "新标签" }; TabPages.Items.Insert(TabPages.Items.Count - 1, item); newStrip = item; SharpTab sharpTab2 = AddNewBrowser(newStrip, url); sharpTab2.RefererURL = refererUrl; if (focusNewTab) { timer1.Enabled = true; } return sharpTab2.Browser; }); } /// /// 新增浏览器窗体 /// /// /// /// private SharpTab AddNewBrowser(FATabStripItem tabStrip, string url) { if (url == "") { url = NewTabURL; } ChromiumWebBrowser browser = new ChromiumWebBrowser(url); ConfigureBrowser(browser); browser.Dock = DockStyle.Fill; tabStrip.Controls.Add(browser); browser.BringToFront(); browser.StatusMessage += Browser_StatusMessage; browser.LoadingStateChanged += Browser_LoadingStateChanged; browser.TitleChanged += Browser_TitleChanged; browser.LoadError += Browser_LoadError; browser.AddressChanged += Browser_URLChanged; browser.DownloadHandler = dHandler; browser.MenuHandler = mHandler; browser.LifeSpanHandler = lHandler; browser.KeyboardHandler = kHandler; browser.RequestHandler = rHandler; SharpTab tab = (SharpTab)(tabStrip.Tag = new SharpTab { IsOpen = true, Browser = browser, Tab = tabStrip, OrigURL = url, CurURL = url, Title = "新标签", DateCreated = DateTime.Now }); if (url.StartsWith(InternalURL + ":")) { browser.JavascriptObjectRepository.Register("host", host, isAsync: true, BindingOptions.DefaultBinder); } else { browser.JavascriptObjectRepository.ResolveObject += delegate (object s, JavascriptBindingEventArgs eve) { IJavascriptObjectRepository objectRepository = eve.ObjectRepository; if (eve.ObjectName == "xysCefToJavaScripts") { objectRepository.Register("xysCefToJavaScripts", new BrowserToJavaScript(browser, this), isAsync: true, BindingOptions.DefaultBinder); } }; } return tab; } public SharpTab GetTabByBrowser(IWebBrowser browser) { foreach (FATabStripItem tab2 in TabPages.Items) { SharpTab tab = (SharpTab)tab2.Tag; if (tab != null && tab.Browser == browser) { return tab; } } return null; } public void RefreshActiveTab() { CurBrowser.Load(CurBrowser.Address); firstCalculateZoom(currentZoom); } /// /// 关闭标签页 /// public void CloseActiveTab() { if (CurTab != null && TabPages.Items.Count > 2) { int index = TabPages.Items.IndexOf(TabPages.SelectedItem); TabPages.RemoveTab(TabPages.SelectedItem); if (TabPages.Items.Count - 1 > index) { TabPages.SelectedItem = TabPages.Items[index]; } return; } if (DownloadsInProgress() && MessageBox.Show("有下载任务是否关闭?", "确认关闭", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { foreach (TabPage tab2 in TabPages.Items) { ChromiumWebBrowser browser2 = (ChromiumWebBrowser)tab2.Controls[0]; browser2.Dispose(); Application.Exit(); } return; } try { foreach (TabPage tab in TabPages.Items) { ChromiumWebBrowser browser = (ChromiumWebBrowser)tab.Controls[0]; browser.Dispose(); Application.Exit(); } } catch { Application.Exit(); } } private void OnTabClosed(object sender, EventArgs e) { } private void OnTabClosing(TabStripItemClosingEventArgs e) { if (CurTab == null) { e.Cancel = true; } else if (TabPages.Items.Count <= 2) { AddBlankTab(); } } private void StopActiveTab() { CurBrowser.Stop(); } private bool IsOnFirstTab() { return TabPages.SelectedItem == TabPages.Items[0]; } private bool IsOnLastTab() { return TabPages.SelectedItem == TabPages.Items[TabPages.Items.Count - 2]; } private void NextTab() { if (IsOnLastTab()) { CurIndex = 0; } else { CurIndex++; } } private void PrevTab() { if (IsOnFirstTab()) { CurIndex = LastIndex; } else { CurIndex--; } } /// /// 浏览器地址变更 /// /// /// private void Browser_URLChanged(object sender, AddressChangedEventArgs e) { InvokeIfNeeded(delegate { if (sender == CurBrowser) { if (!Utils.IsFocussed(TxtURL)) { SetFormURL(e.Address); } EnableBackButton(CurBrowser.CanGoBack); EnableForwardButton(CurBrowser.CanGoForward); SetTabTitle((ChromiumWebBrowser)sender, "加载中..."); BtnRefresh.Visible = false; BtnStop.Visible = true; CurTab.DateCreated = DateTime.Now; float divisor = currentZoom; float beDivisor = 100; float curZoomPecent = (divisor - beDivisor) / 25; CurBrowser.SetZoomLevel(curZoomPecent); } }); } private void Browser_LoadError(object sender, LoadErrorEventArgs e) { } private void Browser_TitleChanged(object sender, TitleChangedEventArgs e) { InvokeIfNeeded(delegate { ChromiumWebBrowser browser = (ChromiumWebBrowser)sender; SetTabTitle(browser, e.Title); }); } private void SetTabTitle(ChromiumWebBrowser browser, string text) { text = text.Trim(); if (IsBlank(text)) { text = "新标签"; } browser.Tag = text; FATabStripItem tabStrip = (FATabStripItem)browser.Parent; if (tabStrip != null) { tabStrip.Title = text; } if (browser == CurBrowser) { SetFormTitle(text); } } private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e) { if (sender != CurBrowser) { return; } EnableBackButton(e.CanGoBack); EnableForwardButton(e.CanGoForward); if (!e.IsLoading) { InvokeIfNeeded(delegate { BtnRefresh.Visible = true; BtnStop.Visible = false; }); } } public void InvokeIfNeeded(Action action) { if (base.InvokeRequired) { BeginInvoke(action); } else { action(); } } private void Browser_StatusMessage(object sender, StatusMessageEventArgs e) { } public void WaitForBrowserToInitialize(ChromiumWebBrowser browser) { while (!browser.IsBrowserInitialized) { Thread.Sleep(100); } } private void EnableBackButton(bool canGoBack) { InvokeIfNeeded(delegate { BtnBack.Enabled = canGoBack; }); } private void EnableForwardButton(bool canGoForward) { InvokeIfNeeded(delegate { BtnForward.Enabled = canGoForward; }); } private void OnTabsChanged(TabStripItemChangedEventArgs e) { ChromiumWebBrowser browser = null; try { browser = (ChromiumWebBrowser)e.Item.Controls[0]; } catch { } if (e.ChangeType == FATabStripItemChangeTypes.SelectionChanged) { if (TabPages.SelectedItem == tabStripAdd) { AddBlankTab(); } else { browser = CurBrowser; SetFormURL(browser.Address); SetFormTitle(browser.Tag.ConvertToString() ?? "新标签"); EnableBackButton(browser.CanGoBack); EnableForwardButton(browser.CanGoForward); } } if (e.ChangeType == FATabStripItemChangeTypes.Removed) { if (e.Item == downloadsStrip) { downloadsStrip = null; } browser?.Dispose(); } if (e.ChangeType == FATabStripItemChangeTypes.Changed && browser != null && currentFullURL != "about:blank") { browser.Focus(); } } private void timer1_Tick(object sender, EventArgs e) { TabPages.SelectedItem = newStrip; timer1.Enabled = false; } private void menuCloseTab_Click(object sender, EventArgs e) { CloseActiveTab(); } private void menuCloseOtherTabs_Click(object sender, EventArgs e) { List listToClose = new List(); foreach (FATabStripItem tab2 in TabPages.Items) { if (tab2 != tabStripAdd && tab2 != TabPages.SelectedItem) { listToClose.Add(tab2); } } foreach (FATabStripItem tab in listToClose) { TabPages.RemoveTab(tab); } } private void bBack_Click(object sender, EventArgs e) { CurBrowser.Back(); } private void bForward_Click(object sender, EventArgs e) { CurBrowser.Forward(); } private void txtUrl_TextChanged(object sender, EventArgs e) { } private void bDownloads_Click(object sender, EventArgs e) { AddNewBrowserTab(DownloadsURL); } private void bRefresh_Click(object sender, EventArgs e) { RefreshActiveTab(); } private void bStop_Click(object sender, EventArgs e) { StopActiveTab(); } private void TxtURL_KeyDown(object sender, KeyEventArgs e) { if (e.IsHotkey(Keys.Return) || e.IsHotkey(Keys.Return, ctrl: true)) { LoadURL(TxtURL.Text); e.Handled = true; e.SuppressKeyPress = true; Focus(); } if (e.IsHotkey(Keys.C, ctrl: true) && Utils.IsFullySelected(TxtURL)) { Clipboard.SetText(CurBrowser.Address, TextDataFormat.UnicodeText); e.Handled = true; e.SuppressKeyPress = true; } } private void txtUrl_Click(object sender, EventArgs e) { if (!Utils.HasSelection(TxtURL)) { TxtURL.SelectAll(); } } private void OpenDeveloperTools() { CurBrowser.ShowDevTools(); } private void tabPages_MouseClick(object sender, MouseEventArgs e) { } private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (DownloadsInProgress() && MessageBox.Show("有下载任务是否关闭?", "确认关闭", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes) { e.Cancel = true; foreach (TabPage tab2 in TabPages.Items) { ChromiumWebBrowser browser2 = (ChromiumWebBrowser)tab2.Controls[0]; browser2.Dispose(); } return; } try { foreach (TabPage tab in TabPages.Items) { ChromiumWebBrowser browser = (ChromiumWebBrowser)tab.Controls[0]; browser.Dispose(); } } catch { } } private void InitDownloads() { downloads = new Dictionary(); downloadNames = new Dictionary(); downloadCancelRequests = new List(); } public void UpdateDownloadItem(DownloadItem item) { lock (downloads) { if (item.SuggestedFileName != "") { downloadNames[item.Id] = item.SuggestedFileName; } if (item.SuggestedFileName == "" && downloadNames.ContainsKey(item.Id)) { item.SuggestedFileName = downloadNames[item.Id]; } downloads[item.Id] = item; } } public string CalcDownloadPath(DownloadItem item) { return item.SuggestedFileName; } public bool DownloadsInProgress() { foreach (DownloadItem item in downloads.Values) { if (item.IsInProgress) { return true; } } return false; } private void btnDownloads_Click(object sender, EventArgs e) { OpenDownloadsTab(); } public void OpenDownloadsTab() { if (downloadsStrip != null && ((ChromiumWebBrowser)downloadsStrip.Controls[0]).Address == DownloadsURL) { TabPages.SelectedItem = downloadsStrip; return; } ChromiumWebBrowser brw = AddNewBrowserTab(DownloadsURL); downloadsStrip = (FATabStripItem)brw.Parent; } private void OpenSearch() { if (!searchOpen) { searchOpen = true; InvokeIfNeeded(delegate { PanelSearch.Visible = true; TxtSearch.Text = lastSearch; TxtSearch.Focus(); TxtSearch.SelectAll(); }); } else { InvokeIfNeeded(delegate { TxtSearch.Focus(); TxtSearch.SelectAll(); }); } } private void CloseSearch() { if (searchOpen) { searchOpen = false; InvokeIfNeeded(delegate { PanelSearch.Visible = false; CurBrowser.GetBrowser().StopFinding(clearSelection: true); }); } } private void BtnClearSearch_Click(object sender, EventArgs e) { CloseSearch(); } private void BtnPrevSearch_Click(object sender, EventArgs e) { FindTextOnPage(next: false); } private void BtnNextSearch_Click(object sender, EventArgs e) { FindTextOnPage(); } private void FindTextOnPage(bool next = true) { bool first = lastSearch != TxtSearch.Text; lastSearch = TxtSearch.Text; if (lastSearch.CheckIfValid()) { CurBrowser.GetBrowser().Find(0, lastSearch, forward: true, matchCase: false, !first); } else { CurBrowser.GetBrowser().StopFinding(clearSelection: true); } TxtSearch.Focus(); } private void TxtSearch_TextChanged(object sender, EventArgs e) { FindTextOnPage(); } private void TxtSearch_KeyDown(object sender, KeyEventArgs e) { if (e.IsHotkey(Keys.Return)) { FindTextOnPage(); } if (e.IsHotkey(Keys.Return, ctrl: true) || e.IsHotkey(Keys.Return, ctrl: false, shift: true)) { FindTextOnPage(next: false); } } public void InitCache() { string cachePath = GetAppDir("Cache"); if (Directory.Exists(cachePath)) { Directory.Delete(cachePath, recursive: true); } } private void toolStripMenuItemDevTool_Click(object sender, EventArgs e) { OpenDeveloperTools(); } private void toolStripMenuItemViewSource_Click(object sender, EventArgs e) { CurBrowser.ViewSource(); } private void toolStripMenuItemDelCache_Click(object sender, EventArgs e) { Application.Exit(); } private void initBrowserZoom() { toolStripTextBoxZoom.Text = currentZoom.ToString(); //firstCalculateZoom(currentZoom); } private void toolStripMenuItemMinus_Click(object sender, EventArgs e) { MinusZoom(); } private void toolStripMenuItemAdd_Click(object sender, EventArgs e) { PlusZoom(); } private void toolStripMenuItemResume_Click(object sender, EventArgs e) { ResumeZoom(); } public void MinusZoom() { calculateZoom("MINUS", 0); } public void PlusZoom() { calculateZoom("PLUS", 500); } public void ResumeZoom() { calculateZoom("RESUME", 100); } public void FullScreen() { string borderStyle = Instance.FormBorderStyle.ToString(); if (borderStyle == "Sizable") { Instance.FormBorderStyle = FormBorderStyle.None; } else { Instance.FormBorderStyle = FormBorderStyle.Sizable; } } public void firstCalculateZoom(int defaultZoom) { toolStripTextBoxZoom.Text = defaultZoom.ToString(); float divisor = defaultZoom; float beDivisor = 100f; float curZoomPecent = (divisor - beDivisor) / 25f; CurBrowser.SetZoomLevel(curZoomPecent); currentZoom = defaultZoom; } public void calculateZoom(string type, int limitNum) { if (!(type != "RESUME") || currentZoom != limitNum) { if (type == "MINUS") { currentZoom -= 5; } if (type == "PLUS") { currentZoom += 5; } if (type == "RESUME") { currentZoom = 100; } toolStripTextBoxZoom.Text = currentZoom.ToString(); float divisor = currentZoom; float beDivisor = 100f; float curZoomPecent = (divisor - beDivisor) / 25f; CurBrowser.SetZoomLevel(curZoomPecent); if (type != "RESUME") { settingMenuStrip.Show(); } } } private void toolStripMenuItemExit_Click(object sender, EventArgs e) { Application.Exit(); } private void toolStripMenuItemFullScreen_Click(object sender, EventArgs e) { FullScreen(); } private void BtnSettings_Click(object sender, EventArgs e) { settingMenuStrip.Show(sender as Button, (sender as Button).PointToClient(Cursor.Position), ToolStripDropDownDirection.BelowLeft); } private void settingMenuStrip_MouseLeave(object sender, EventArgs e) { settingMenuStrip.Hide(); } private void toolStripMenuItemServer_Click(object sender, EventArgs e) { panelServerSetting serverSetting = new panelServerSetting(); serverSetting.ShowDialog(); } private void checkServerUrl() { string DefaultUrl = ConfigurationManager.AppSettings["DefaultUrl"]; string InsecureUrl = ConfigurationManager.AppSettings["InsecureUrl"]; panelServerSetting serverSetting = new panelServerSetting(); if (!UrlIsExist(DefaultUrl)) { serverSetting.ShowDialog(); HomepageURL = ConfigurationManager.AppSettings["DefaultUrl"]; NewTabURL = ConfigurationManager.AppSettings["DefaultUrl"]; } } private bool UrlIsExist(string url) { Uri u = null; try { u = new Uri(url); } catch { return false; } bool isExist = false; HttpWebRequest request = WebRequest.Create(u) as HttpWebRequest; request.Method = "HEAD"; try { HttpWebResponse response = request.GetResponse() as HttpWebResponse; if (response.StatusCode == HttpStatusCode.OK) { isExist = true; } } catch (WebException ex) { try { isExist = (ex.Response as HttpWebResponse).StatusCode != HttpStatusCode.NotFound; } catch { isExist = ex.Status == WebExceptionStatus.Success; } } return isExist; } private void toolStripMenuItemUpdate_Click(object sender, EventArgs e) { doUpdate(); } private void doUpdate() { FTPHelper ftpObj = new FTPHelper(); int checkFlag = ftpObj.CheckUpdate(); if (checkFlag == 1) { if (MessageBox.Show("发现更新,是否更新?", "更新消息", MessageBoxButtons.OKCancel) == DialogResult.OK) { //ftpObj.ExecuteAsAdmin("prBrowserUpdate.exe"); //Environment.Exit(0); //QY 调用更新程序 updateMain.Show(); } } else { MessageBox.Show("已是最新版,无需更新!"); } } protected override void Dispose(bool disposing) { if (disposing && components != null) { components.Dispose(); } base.Dispose(disposing); } private void InitializeComponent() { components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(prBrowser.MainForm)); menuStripTab = new System.Windows.Forms.ContextMenuStrip(components); menuCloseTab = new System.Windows.Forms.ToolStripMenuItem(); menuCloseOtherTabs = new System.Windows.Forms.ToolStripMenuItem(); timer1 = new System.Windows.Forms.Timer(components); TxtURL = new System.Windows.Forms.TextBox(); PanelToolbar = new System.Windows.Forms.Panel(); BtnSettings = new System.Windows.Forms.Button(); BtnRefresh = new System.Windows.Forms.Button(); BtnDownloads = new System.Windows.Forms.Button(); BtnStop = new System.Windows.Forms.Button(); BtnForward = new System.Windows.Forms.Button(); BtnBack = new System.Windows.Forms.Button(); settingMenuStrip = new System.Windows.Forms.ContextMenuStrip(components); toolStripMenuItemDevTool = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItemViewSource = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItemDelCache = new System.Windows.Forms.ToolStripMenuItem(); toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator(); toolStripMenuItemMinus = new System.Windows.Forms.ToolStripMenuItem(); toolStripTextBoxZoom = new System.Windows.Forms.ToolStripTextBox(); toolStripMenuItemAdd = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItemResume = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItemFullScreen = new System.Windows.Forms.ToolStripMenuItem(); toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator(); toolStripMenuItemServer = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItemUpdate = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItemExit = new System.Windows.Forms.ToolStripMenuItem(); TabPages = new FarsiLibrary.Win.FATabStrip(); tabStrip1 = new FarsiLibrary.Win.FATabStripItem(); tabStripAdd = new FarsiLibrary.Win.FATabStripItem(); PanelStatus = new System.Windows.Forms.Panel(); PanelSearch = new System.Windows.Forms.Panel(); BtnNextSearch = new System.Windows.Forms.Button(); BtnPrevSearch = new System.Windows.Forms.Button(); BtnCloseSearch = new System.Windows.Forms.Button(); TxtSearch = new System.Windows.Forms.TextBox(); menuStripTab.SuspendLayout(); PanelToolbar.SuspendLayout(); settingMenuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)TabPages).BeginInit(); TabPages.SuspendLayout(); PanelSearch.SuspendLayout(); SuspendLayout(); menuStripTab.Items.AddRange(new System.Windows.Forms.ToolStripItem[2] { menuCloseTab, menuCloseOtherTabs }); menuStripTab.Name = "menuStripTab"; menuStripTab.Size = new System.Drawing.Size(187, 48); menuCloseTab.Name = "menuCloseTab"; menuCloseTab.ShortcutKeys = System.Windows.Forms.Keys.F4 | System.Windows.Forms.Keys.Control; menuCloseTab.Size = new System.Drawing.Size(186, 22); menuCloseTab.Text = "关闭标签页"; menuCloseTab.Click += new System.EventHandler(menuCloseTab_Click); menuCloseOtherTabs.Name = "menuCloseOtherTabs"; menuCloseOtherTabs.Size = new System.Drawing.Size(186, 22); menuCloseOtherTabs.Text = "关闭其他标签页"; menuCloseOtherTabs.Click += new System.EventHandler(menuCloseOtherTabs_Click); timer1.Interval = 50; timer1.Tick += new System.EventHandler(timer1_Tick); TxtURL.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; TxtURL.BorderStyle = System.Windows.Forms.BorderStyle.None; TxtURL.Font = new System.Drawing.Font("Segoe UI", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); TxtURL.Location = new System.Drawing.Point(60, 5); TxtURL.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); TxtURL.Name = "TxtURL"; TxtURL.Size = new System.Drawing.Size(757, 22); TxtURL.TabIndex = 5; TxtURL.Click += new System.EventHandler(txtUrl_Click); TxtURL.TextChanged += new System.EventHandler(txtUrl_TextChanged); TxtURL.KeyDown += new System.Windows.Forms.KeyEventHandler(TxtURL_KeyDown); PanelToolbar.BackColor = System.Drawing.Color.White; PanelToolbar.Controls.Add(BtnSettings); PanelToolbar.Controls.Add(BtnRefresh); PanelToolbar.Controls.Add(BtnDownloads); PanelToolbar.Controls.Add(BtnStop); PanelToolbar.Controls.Add(TxtURL); PanelToolbar.Controls.Add(BtnForward); PanelToolbar.Controls.Add(BtnBack); PanelToolbar.Dock = System.Windows.Forms.DockStyle.Top; PanelToolbar.Location = new System.Drawing.Point(0, 0); PanelToolbar.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); PanelToolbar.Name = "PanelToolbar"; PanelToolbar.Size = new System.Drawing.Size(934, 30); PanelToolbar.TabIndex = 6; BtnSettings.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; BtnSettings.FlatStyle = System.Windows.Forms.FlatStyle.Flat; BtnSettings.ForeColor = System.Drawing.Color.White; BtnSettings.Image = prBrowser.Properties.Resources.antd_setting_20; BtnSettings.Location = new System.Drawing.Point(899, 0); BtnSettings.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); BtnSettings.Name = "BtnSettings"; BtnSettings.Size = new System.Drawing.Size(32, 31); BtnSettings.TabIndex = 6; BtnSettings.Tag = ""; BtnSettings.UseVisualStyleBackColor = true; BtnSettings.Click += new System.EventHandler(BtnSettings_Click); BtnRefresh.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; BtnRefresh.FlatStyle = System.Windows.Forms.FlatStyle.Flat; BtnRefresh.ForeColor = System.Drawing.Color.White; BtnRefresh.Image = prBrowser.Properties.Resources.antd_reload_20; BtnRefresh.Location = new System.Drawing.Point(823, -1); BtnRefresh.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); BtnRefresh.Name = "BtnRefresh"; BtnRefresh.Size = new System.Drawing.Size(35, 32); BtnRefresh.TabIndex = 3; BtnRefresh.Tag = "刷新"; BtnRefresh.UseVisualStyleBackColor = true; BtnRefresh.Click += new System.EventHandler(bRefresh_Click); BtnDownloads.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; BtnDownloads.FlatStyle = System.Windows.Forms.FlatStyle.Flat; BtnDownloads.ForeColor = System.Drawing.Color.White; BtnDownloads.Image = prBrowser.Properties.Resources.antd_download_20; BtnDownloads.Location = new System.Drawing.Point(860, 0); BtnDownloads.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); BtnDownloads.Name = "BtnDownloads"; BtnDownloads.Size = new System.Drawing.Size(37, 30); BtnDownloads.TabIndex = 4; BtnDownloads.Tag = "下载"; BtnDownloads.UseVisualStyleBackColor = true; BtnDownloads.Click += new System.EventHandler(bDownloads_Click); BtnStop.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; BtnStop.FlatStyle = System.Windows.Forms.FlatStyle.Flat; BtnStop.ForeColor = System.Drawing.Color.White; BtnStop.Image = prBrowser.Properties.Resources.antd_stop_20; BtnStop.Location = new System.Drawing.Point(823, 0); BtnStop.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); BtnStop.Name = "BtnStop"; BtnStop.Size = new System.Drawing.Size(34, 30); BtnStop.TabIndex = 2; BtnStop.Tag = "停止"; BtnStop.UseVisualStyleBackColor = true; BtnStop.Click += new System.EventHandler(bStop_Click); BtnForward.FlatStyle = System.Windows.Forms.FlatStyle.Flat; BtnForward.ForeColor = System.Drawing.Color.White; BtnForward.Image = prBrowser.Properties.Resources.antd_right_20; BtnForward.Location = new System.Drawing.Point(29, 0); BtnForward.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); BtnForward.Name = "BtnForward"; BtnForward.Size = new System.Drawing.Size(25, 30); BtnForward.TabIndex = 1; BtnForward.Tag = "前进"; BtnForward.UseVisualStyleBackColor = true; BtnForward.Click += new System.EventHandler(bForward_Click); BtnBack.FlatStyle = System.Windows.Forms.FlatStyle.Flat; BtnBack.ForeColor = System.Drawing.Color.White; BtnBack.Image = prBrowser.Properties.Resources.antd_left_20; BtnBack.Location = new System.Drawing.Point(2, 0); BtnBack.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); BtnBack.Name = "BtnBack"; BtnBack.Size = new System.Drawing.Size(25, 30); BtnBack.TabIndex = 0; BtnBack.Tag = "后退"; BtnBack.UseVisualStyleBackColor = true; BtnBack.Click += new System.EventHandler(bBack_Click); settingMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[12] { toolStripMenuItemDevTool, toolStripMenuItemViewSource, toolStripMenuItemDelCache, toolStripSeparator3, toolStripMenuItemMinus, toolStripTextBoxZoom, toolStripMenuItemAdd, toolStripMenuItemResume, toolStripMenuItemFullScreen, toolStripSeparator4, toolStripMenuItemServer, toolStripMenuItemExit }); settingMenuStrip.Name = "settingMenuStrip"; settingMenuStrip.Size = new System.Drawing.Size(201, 261); settingMenuStrip.MouseLeave += new System.EventHandler(settingMenuStrip_MouseLeave); toolStripMenuItemDevTool.Name = "toolStripMenuItemDevTool"; toolStripMenuItemDevTool.ShortcutKeys = System.Windows.Forms.Keys.F12; toolStripMenuItemDevTool.Size = new System.Drawing.Size(200, 22); toolStripMenuItemDevTool.Text = "开发者工具"; toolStripMenuItemDevTool.Click += new System.EventHandler(toolStripMenuItemDevTool_Click); toolStripMenuItemViewSource.Name = "toolStripMenuItemViewSource"; toolStripMenuItemViewSource.Size = new System.Drawing.Size(200, 22); toolStripMenuItemViewSource.Text = "查看源代码"; toolStripMenuItemViewSource.Click += new System.EventHandler(toolStripMenuItemViewSource_Click); toolStripMenuItemDelCache.Name = "toolStripMenuItemDelCache"; toolStripMenuItemDelCache.Size = new System.Drawing.Size(200, 22); toolStripMenuItemDelCache.Text = "强力清除缓存"; toolStripMenuItemDelCache.Click += new System.EventHandler(toolStripMenuItemDelCache_Click); toolStripSeparator3.Name = "toolStripSeparator3"; toolStripSeparator3.Size = new System.Drawing.Size(197, 6); toolStripMenuItemMinus.Name = "toolStripMenuItemMinus"; toolStripMenuItemMinus.ShortcutKeys = System.Windows.Forms.Keys.OemMinus | System.Windows.Forms.Keys.Control; toolStripMenuItemMinus.Size = new System.Drawing.Size(200, 22); toolStripMenuItemMinus.Text = "缩小"; toolStripMenuItemMinus.Click += new System.EventHandler(toolStripMenuItemMinus_Click); toolStripTextBoxZoom.Font = new System.Drawing.Font("Microsoft YaHei UI", 9f); toolStripTextBoxZoom.Name = "toolStripTextBoxZoom"; toolStripTextBoxZoom.ReadOnly = true; toolStripTextBoxZoom.Size = new System.Drawing.Size(30, 23); toolStripTextBoxZoom.Text = "100"; toolStripMenuItemAdd.Name = "toolStripMenuItemAdd"; toolStripMenuItemAdd.ShortcutKeys = System.Windows.Forms.Keys.Oemplus | System.Windows.Forms.Keys.Control; toolStripMenuItemAdd.Size = new System.Drawing.Size(200, 22); toolStripMenuItemAdd.Text = "放大"; toolStripMenuItemAdd.Click += new System.EventHandler(toolStripMenuItemAdd_Click); toolStripMenuItemResume.Name = "toolStripMenuItemResume"; toolStripMenuItemResume.Size = new System.Drawing.Size(200, 22); toolStripMenuItemResume.Text = "重置"; toolStripMenuItemResume.Click += new System.EventHandler(toolStripMenuItemResume_Click); toolStripMenuItemFullScreen.Name = "toolStripMenuItemFullScreen"; toolStripMenuItemFullScreen.ShortcutKeys = System.Windows.Forms.Keys.F11; toolStripMenuItemFullScreen.Size = new System.Drawing.Size(200, 22); toolStripMenuItemFullScreen.Text = "全屏"; toolStripMenuItemFullScreen.Click += new System.EventHandler(toolStripMenuItemFullScreen_Click); toolStripSeparator4.Name = "toolStripSeparator4"; toolStripSeparator4.Size = new System.Drawing.Size(197, 6); toolStripMenuItemServer.Name = "toolStripMenuItemServer"; toolStripMenuItemServer.Size = new System.Drawing.Size(200, 22); toolStripMenuItemServer.Text = "服务器设置"; toolStripMenuItemServer.Click += new System.EventHandler(toolStripMenuItemServer_Click); //toolStripMenuItemUpdate.Name = "toolStripMenuItemUpdate"; //toolStripMenuItemUpdate.Size = new System.Drawing.Size(200, 22); //toolStripMenuItemUpdate.Text = "检查更新"; //toolStripMenuItemUpdate.Click += new System.EventHandler(toolStripMenuItemUpdate_Click); toolStripMenuItemExit.Name = "toolStripMenuItemExit"; toolStripMenuItemExit.Size = new System.Drawing.Size(200, 22); toolStripMenuItemExit.Text = "完美退出"; toolStripMenuItemExit.Click += new System.EventHandler(toolStripMenuItemExit_Click); TabPages.ContextMenuStrip = menuStripTab; TabPages.Dock = System.Windows.Forms.DockStyle.Fill; TabPages.Font = new System.Drawing.Font("Segoe UI", 10.8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); TabPages.Items.AddRange(new FarsiLibrary.Win.FATabStripItem[2] { tabStrip1, tabStripAdd }); TabPages.Location = new System.Drawing.Point(0, 30); TabPages.Name = "TabPages"; TabPages.SelectedItem = tabStrip1; TabPages.Size = new System.Drawing.Size(934, 621); TabPages.TabIndex = 4; TabPages.Text = "faTabStrip1"; TabPages.TabStripItemSelectionChanged += new FarsiLibrary.Win.TabStripItemChangedHandler(OnTabsChanged); TabPages.TabStripItemClosed += new System.EventHandler(OnTabClosed); TabPages.MouseClick += new System.Windows.Forms.MouseEventHandler(tabPages_MouseClick); tabStrip1.IsDrawn = true; tabStrip1.Name = "tabStrip1"; tabStrip1.Selected = true; tabStrip1.Size = new System.Drawing.Size(932, 591); tabStrip1.TabIndex = 0; tabStrip1.Title = "加载中..."; tabStripAdd.CanClose = false; tabStripAdd.IsDrawn = true; tabStripAdd.Name = "tabStripAdd"; tabStripAdd.Size = new System.Drawing.Size(931, 601); tabStripAdd.TabIndex = 1; tabStripAdd.Title = "+"; PanelStatus.Dock = System.Windows.Forms.DockStyle.Bottom; PanelStatus.Location = new System.Drawing.Point(0, 651); PanelStatus.Name = "PanelStatus"; PanelStatus.Size = new System.Drawing.Size(934, 20); PanelStatus.TabIndex = 8; PanelSearch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; PanelSearch.BackColor = System.Drawing.Color.White; PanelSearch.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; PanelSearch.Controls.Add(BtnNextSearch); PanelSearch.Controls.Add(BtnPrevSearch); PanelSearch.Controls.Add(BtnCloseSearch); PanelSearch.Controls.Add(TxtSearch); PanelSearch.Location = new System.Drawing.Point(625, 41); PanelSearch.Name = "PanelSearch"; PanelSearch.Size = new System.Drawing.Size(307, 40); PanelSearch.TabIndex = 9; PanelSearch.Visible = false; BtnNextSearch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; BtnNextSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat; BtnNextSearch.ForeColor = System.Drawing.Color.White; BtnNextSearch.Image = prBrowser.Properties.Resources.antd_down_20; BtnNextSearch.Location = new System.Drawing.Point(239, 4); BtnNextSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); BtnNextSearch.Name = "BtnNextSearch"; BtnNextSearch.Size = new System.Drawing.Size(25, 30); BtnNextSearch.TabIndex = 9; BtnNextSearch.Tag = "查找下一条(Enter)"; BtnNextSearch.UseVisualStyleBackColor = true; BtnNextSearch.Click += new System.EventHandler(BtnNextSearch_Click); BtnPrevSearch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; BtnPrevSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat; BtnPrevSearch.ForeColor = System.Drawing.Color.White; BtnPrevSearch.Image = prBrowser.Properties.Resources.antd_up_20; BtnPrevSearch.Location = new System.Drawing.Point(206, 4); BtnPrevSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); BtnPrevSearch.Name = "BtnPrevSearch"; BtnPrevSearch.Size = new System.Drawing.Size(25, 30); BtnPrevSearch.TabIndex = 8; BtnPrevSearch.Tag = "查找上一条(Shift+Enter)"; BtnPrevSearch.UseVisualStyleBackColor = true; BtnPrevSearch.Click += new System.EventHandler(BtnPrevSearch_Click); BtnCloseSearch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right; BtnCloseSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat; BtnCloseSearch.ForeColor = System.Drawing.Color.White; BtnCloseSearch.Image = prBrowser.Properties.Resources.antd_close_20; BtnCloseSearch.Location = new System.Drawing.Point(272, 4); BtnCloseSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); BtnCloseSearch.Name = "BtnCloseSearch"; BtnCloseSearch.Size = new System.Drawing.Size(25, 30); BtnCloseSearch.TabIndex = 7; BtnCloseSearch.Tag = "关闭 (Esc)"; BtnCloseSearch.UseVisualStyleBackColor = true; BtnCloseSearch.Click += new System.EventHandler(BtnClearSearch_Click); TxtSearch.Anchor = System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right; TxtSearch.BorderStyle = System.Windows.Forms.BorderStyle.None; TxtSearch.Font = new System.Drawing.Font("Segoe UI", 13.8f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); TxtSearch.Location = new System.Drawing.Point(10, 6); TxtSearch.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); TxtSearch.Name = "TxtSearch"; TxtSearch.Size = new System.Drawing.Size(181, 25); TxtSearch.TabIndex = 6; TxtSearch.TextChanged += new System.EventHandler(TxtSearch_TextChanged); TxtSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(TxtSearch_KeyDown); base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; base.ClientSize = new System.Drawing.Size(934, 671); base.Controls.Add(PanelSearch); base.Controls.Add(TabPages); base.Controls.Add(PanelStatus); base.Controls.Add(PanelToolbar); Font = new System.Drawing.Font("Segoe UI", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 0); base.Icon = (System.Drawing.Icon)resources.GetObject("$this.Icon"); base.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5); base.Name = "MainForm"; base.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; Text = "云HIS浏览器"; base.WindowState = System.Windows.Forms.FormWindowState.Maximized; base.FormClosing += new System.Windows.Forms.FormClosingEventHandler(MainForm_FormClosing); base.Load += new System.EventHandler(MainForm_Load); menuStripTab.ResumeLayout(false); PanelToolbar.ResumeLayout(false); PanelToolbar.PerformLayout(); settingMenuStrip.ResumeLayout(false); settingMenuStrip.PerformLayout(); ((System.ComponentModel.ISupportInitialize)TabPages).EndInit(); TabPages.ResumeLayout(false); PanelSearch.ResumeLayout(false); PanelSearch.PerformLayout(); ResumeLayout(false); } } }