using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using CefSharp;
|
using CefSharp.WinForms;
|
using System.IO;
|
|
namespace TProduct.WebPage
|
{
|
/// <summary>
|
/// 客户端加载网页设置
|
/// </summary>
|
public class WebBrowserManager
|
{
|
/// <summary>
|
/// CefSharp初始化设置
|
/// </summary>
|
public static void Initialize()
|
{
|
var direct = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CefSharp");
|
CefSharp.CefSettings settings = new CefSharp.CefSettings();
|
settings.LocalesDirPath = Path.Combine(direct, @"locales");
|
settings.Locale = "zh-CN";
|
settings.BrowserSubprocessPath = Path.Combine(direct, @"CefSharp.BrowserSubprocess.exe");
|
CefSharp.Cef.Initialize(settings);
|
|
//设置允许客户端与js进行交互(默认为false)
|
CefSharp.CefSharpSettings.LegacyJavascriptBindingEnabled=true;
|
|
//当程序退出时,关闭并释放CefSharp占用的资源
|
CefSharp.CefSharpSettings.ShutdownOnExit=true;
|
|
//父线程退出后,子线程也退出
|
CefSharp.CefSharpSettings.SubprocessExitIfParentProcessClosed=true;
|
}
|
|
/// <summary>
|
/// 支持高DPI设备显示
|
/// </summary>
|
public static void EnableHighDPISupport()
|
{
|
//支持高DPI设备显示
|
CefSharp.Cef.EnableHighDPISupport();
|
}
|
|
}
|
}
|