Commit cb4f5dc8 authored by tr's avatar tr

1、CEF示例:界面微调

parent c9bb097e
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<appSettings>
<add key="UpdateTime" value="2021-08-11 17:21:10.523"/>
<add key="UpdateTime" value="2021-08-19 17:29:13.623"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
......
......@@ -5,6 +5,9 @@ using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
//
using CefSharp;
using CefSharp.WinForms;
namespace Tools
{
......@@ -16,6 +19,10 @@ namespace Tools
[STAThread]
static void Main()
{
CefSettings cefSettings = new CefSettings();
cefSettings.DisableGpuAcceleration();
Cef.Initialize(cefSettings);
//
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new wMain());
......
......@@ -33,13 +33,17 @@ namespace Tools.UI
//browser = new ChromiumWebBrowser("jhdsoft.gicp.net:21802/#/login?redirect=%2Fhome");
browser = new ChromiumWebBrowser("jhdsoft.gicp.net:9201/lining_Dev/#/Home");
toolStripContainer1.ContentPanel.Controls.Add(browser);
browser.Show();
//浏览器事件绑定
browser.IsBrowserInitializedChanged += OnIsBrowserInitializedChanged;
browser.LoadingStateChanged += OnLoadingStateChanged;
browser.TitleChanged += OnBrowserTitleChanged;
browser.AddressChanged += OnBrowserAddressChanged;
//窗体事件
this.FormClosing += WCefDemo_FormClosing;
//菜单栏事件
this.menuStrip1.Visible = false;
this.tsmiShowDevTools.Click += TsmiShowDevTools_Click;
this.tsmiExit.Click += TsmiExit_Click;
//工具栏事件
......@@ -51,6 +55,12 @@ namespace Tools.UI
}
}
//窗体:关闭前
private void WCefDemo_FormClosing(object sender, FormClosingEventArgs e)
{
this.CloseBrowser();
}
#region 浏览器相关事件
//浏览器上的初始化是否已更改
......@@ -94,8 +104,7 @@ namespace Tools.UI
//退出
private void TsmiExit_Click(object sender, EventArgs e)
{
browser.Dispose();
Cef.Shutdown();
this.CloseBrowser();
this.Close();
}
......@@ -135,6 +144,26 @@ namespace Tools.UI
#region 自定义方法
/// <summary>
/// 加载网页
/// </summary>
/// <param name="url"></param>
private void LoadUrl(string url)
{
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
{
browser.Load(url);
}
}
/// <summary>
/// 关闭浏览器
/// </summary>
private void CloseBrowser()
{
browser.Dispose();
Cef.Shutdown();
}
/// <summary>
/// 重置地址栏长度(依赖:ToolStripItem.AutoSize=false)
/// </summary>
......@@ -150,17 +179,6 @@ namespace Tools.UI
}
this.UrlTextBox.Width = Math.Max(0, width - UrlTextBox.Margin.Horizontal - 18);
}
/// <summary>
/// 加载网页
/// </summary>
/// <param name="url"></param>
private void LoadUrl(string url)
{
if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
{
browser.Load(url);
}
}
#endregion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment