WpfMdict / csharp /mdict /App.xaml.cs
fasdfsa's picture
fix mdx 页面内词条跳转
121e5f3
using System.Configuration;
using System.Data;
using System.IO;
using System.Reflection;
using System.Windows;
using CefSharp;
using CefSharp.Wpf;
using mdict.Services;
namespace mdict
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
InitializeCef();
}
private void InitializeCef()
{
var settings = new CefSettings();
// Register mdx scheme
settings.RegisterScheme(new CefCustomScheme
{
SchemeName = "mdx",
SchemeHandlerFactory = new MdxSchemeHandlerFactory(),
IsStandard = true,
IsSecure = true,
IsCorsEnabled = false
});
// Set cache path to a writable directory
string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? string.Empty;
string cachePath = Path.Combine(exePath, "Cache");
Directory.CreateDirectory(cachePath);
settings.CachePath = cachePath;
settings.Locale = "zh-CN";
// Performance settings
settings.CefCommandLineArgs.Add("enable-gpu", "1");
settings.CefCommandLineArgs.Add("enable-gpu-compositing", "1");
Cef.Initialize(settings);
}
}
}