123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674 |
- 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<int, DownloadItem> downloads;
- public Dictionary<int, string> downloadNames;
- public List<int> 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<int> CancelRequests => downloadCancelRequests;
- public Dictionary<int, DownloadItem> 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);
- }
- }
- /// <summary>
- /// 主窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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;
- }
- /// <summary>
- /// 加载热键列表
- /// </summary>
- 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<XElement> enumerable = settingEle.Elements();
- foreach (XElement item in enumerable)
- {
- if (item.Attribute("key").Value == attr)
- {
- xmlValue = item.Attribute("value").Value;
- }
- }
- return xmlValue;
- }
- /// <summary>
- /// 载入浏览器
- /// </summary>
- 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();
- });
- }
- /// <summary>
- /// 新增浏览器标签
- /// </summary>
- /// <param name="url">标签地址</param>
- /// <param name="focusNewTab"></param>
- /// <param name="refererUrl"></param>
- /// <returns></returns>
- public ChromiumWebBrowser AddNewBrowserTab(string url, bool focusNewTab = true, string refererUrl = null)
- {
- return (ChromiumWebBrowser)Invoke((Func<ChromiumWebBrowser>)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;
- });
- }
- /// <summary>
- /// 新增浏览器窗体
- /// </summary>
- /// <param name="tabStrip"></param>
- /// <param name="url"></param>
- /// <returns></returns>
- 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);
- }
- /// <summary>
- /// 关闭标签页
- /// </summary>
- 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--;
- }
- }
- /// <summary>
- /// 浏览器地址变更
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- 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<FATabStripItem> listToClose = new List<FATabStripItem>();
- 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<int, DownloadItem>();
- downloadNames = new Dictionary<int, string>();
- downloadCancelRequests = new List<int>();
- }
- 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);
- }
- }
- }
|