基线 SVN r240
SVN-Revision: r240
This commit is contained in:
@@ -0,0 +1,153 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using DevExpress.XtraSplashScreen;
|
||||
using System.Threading;
|
||||
using System.Globalization;
|
||||
using DevExpress.UserSkins;
|
||||
using DevExpress.Skins;
|
||||
using DevExpress.LookAndFeel;
|
||||
using Lskj.Control;
|
||||
using Lskj.Control.Model;
|
||||
using Lskj.Main2.Model;
|
||||
using Lskj.Util;
|
||||
using Xilium.CefGlue;
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
|
||||
namespace Lskj.Main2
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main(string[] args)
|
||||
{
|
||||
|
||||
CefRuntime.Load();//cef浏览器模块设置加载
|
||||
var mainArgs = new CefMainArgs(args);
|
||||
var app = new DemoCefApp();
|
||||
var settings = new CefSettings
|
||||
{
|
||||
MultiThreadedMessageLoop = true,
|
||||
LogSeverity = CefLogSeverity.Disable,
|
||||
LogFile = "CefGlue.log",
|
||||
Locale = "zh-CN"
|
||||
};
|
||||
try
|
||||
{
|
||||
var Code = CefRuntime.ExecuteProcess(mainArgs, app, IntPtr.Zero);
|
||||
Console.WriteLine("CefRuntime.ExecuteProcess() returns {0}", Code);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
CefRuntime.Initialize(mainArgs, settings, app, IntPtr.Zero);
|
||||
try
|
||||
{
|
||||
// 汉化DevExpress界面
|
||||
Thread.CurrentThread.CurrentUICulture = new CultureInfo("zh-Hans");
|
||||
// 设置皮肤
|
||||
BonusSkins.Register();
|
||||
SkinManager.EnableFormSkins();
|
||||
|
||||
//处理未捕获的异常
|
||||
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
|
||||
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
|
||||
if (!settings.MultiThreadedMessageLoop)//消息循环
|
||||
{
|
||||
Application.Idle += (sender, e) => { CefRuntime.DoMessageLoopWork(); };
|
||||
}
|
||||
AboutDevCompanion DC = new AboutDevCompanion(1, false);
|
||||
DC.Run();
|
||||
// 启动程序
|
||||
Manager.StartForm();
|
||||
CefRuntime.Shutdown();
|
||||
DC.Stop();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageUtil.Show(ex);
|
||||
}
|
||||
|
||||
}
|
||||
#region 浏览器处理类
|
||||
/// <summary>
|
||||
/// <para>说明:浏览器处理类</para>
|
||||
/// <para>创建人:唐德馨</para>
|
||||
/// <para>创建日期:2022-1-26 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
internal sealed class DemoCefApp : CefApp
|
||||
{
|
||||
protected override void OnBeforeCommandLineProcessing(string processType, CefCommandLine commandLine)
|
||||
{
|
||||
//Console.WriteLine("OnBeforeCommandLineProcessing: {0} {1}", processType, commandLine);
|
||||
// TODO: currently on linux platform location of locales and pack files are determined
|
||||
// incorrectly (relative to main module instead of libcef.so module).
|
||||
// Once issue http://code.google.com/p/chromiumembedded/issues/detail?id=668 will be resolved
|
||||
// this code can be removed.
|
||||
Version currentVersion = Environment.OSVersion.Version;
|
||||
Version compareToVersion = new Version("6.2");
|
||||
//if (CefRuntime.Platform == CefRuntimePlatform.Windows && currentVersion.CompareTo(compareToVersion) > 0)
|
||||
//{
|
||||
//win8及其以下版本的系统
|
||||
var path = new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath;
|
||||
path = Path.GetDirectoryName(path);
|
||||
commandLine.AppendSwitch("resources-dir-path", path);
|
||||
commandLine.AppendSwitch("locales-dir-path", Path.Combine(path, "locales"));
|
||||
commandLine.AppendSwitch("single-process", "1");
|
||||
//commandLine.AppendSwitch("ppapi-flash-version", "19.0.0.185");
|
||||
//commandLine.AppendSwitch("ppapi-flash-path", @"PepperFlash\pepflashplayer.dll");
|
||||
//}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// <para>说明:处理异常</para>
|
||||
/// <para>创建人:龚宇超</para>
|
||||
/// <para>创建日期:2017-11-22 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="ThreadExceptionEventArgs"/> instance containing the event data.</param>
|
||||
static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
|
||||
{
|
||||
MessageUtil.Show(e.Exception);
|
||||
LogHelper.Instance.WriteError(e.Exception);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <para>说明:处理异常</para>
|
||||
/// <para>创建人:王一帆</para>
|
||||
/// <para>创建日期:2021-07-08 </para>
|
||||
/// <para>修改人:</para>
|
||||
/// <para>修改日期:</para>
|
||||
/// <para>修改备注:</para>
|
||||
/// <para>版本:1.0</para>
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="ThreadExceptionEventArgs"/> instance containing the event data.</param>
|
||||
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
|
||||
{
|
||||
Console.WriteLine(e.ExceptionObject.ToString());
|
||||
MessageUtil.Show(e.ExceptionObject.ToString());
|
||||
}
|
||||
//public static Form GetForm()
|
||||
//{
|
||||
// Form X = new CEFdemo.Form1();
|
||||
// return X;
|
||||
//}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user