static void Main(string[] argArray) { try { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); HtmlUILauncher.EnableFlashSupport = false; if (HtmlUILauncher.InitializeChromium((args => { args.Settings.LogSeverity = Chromium.CfxLogSeverity.Default; }))) { //初始化成功,加载程序集内嵌的资源到运行时中 HtmlUILauncher.RegisterEmbeddedScheme(System.Reflection.Assembly.GetExecutingAssembly()); if (argArray.Length > 0) { Application.Run(new MainForm(argArray[3], int.Parse(argArray[7]), argArray[5], argArray[9], argArray[11])); } else { Application.Run(new MainForm("", 1, "admin", "", "D:\\Projects\\Visual Studio 2017\\Sources\\Workspaces\\DiagnosisWorkstation\\DiagnosisWorkstation\\bin\\Debug")); } } } catch (FileNotFoundException ex) { MessageBox.Show("相关文件不存在:\r" + ex.Message, "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); HtmlUILauncher.EnableFlashSupport = false; // 需要引用PepperFlash文件夹 if (HtmlUILauncher.InitializeChromium((args => { args.Settings.LogSeverity = Chromium.CfxLogSeverity.Disable; }), cmd => { cmd.CommandLine.AppendSwitch("disable-web-security"); // 取消掉安全设置,可以跨域请求数据 //cmd.CommandLine.AppendArgument("--single-process"); // 没有效果 cmd.CommandLine.AppendSwitch("disable-direct-write"); cmd.CommandLine.AppendSwitch("--disable-directwrite-for-ui"); cmd.CommandLine.AppendSwitch("--single-process"); })) { //初始化成功,加载程序集内嵌的资源到运行时中 HtmlUILauncher.RegisterEmbeddedScheme(System.Reflection.Assembly.GetExecutingAssembly()); var l = System.Reflection.Assembly.GetExecutingAssembly(); //启动主窗体 Application.Run(new SubForm()); } }
void RenderProcessHandler_OnUncaughtException(object sender, CfrOnUncaughtExceptionEventArgs e) { var wb = HtmlUILauncher.GetBrowser(e.Browser.Identifier); if (wb != null) { } }
private void LocalSchemeHandlerFactory_Create(object sender, Chromium.Event.CfxSchemeHandlerFactoryCreateEventArgs e) { if (e.SchemeName.Equals("local") && e.Browser != null) { var browser = HtmlUILauncher.GetBrowser(e.Browser.Identifier); var handler = new LocalResourceHandler(browser); e.SetReturnValue(handler); } }
private void EmbeddedSchemeHandlerFactory_Create(object sender, Chromium.Event.CfxSchemeHandlerFactoryCreateEventArgs e) { if (e.SchemeName == SchemeName && e.Browser != null) { var browser = HtmlUILauncher.GetBrowser(e.Browser.Identifier); var handler = new EmbeddedResourceHandler(resourceAssembly, browser); e.SetReturnValue(handler); } }
internal static int RenderProcessMain() { try { var rp = new RenderProcess(); HtmlUILauncher.RaiseRemoteProcessCreated(rp.processHandler); return(rp.RemoteMain()); } catch (CfxRemotingException) { return(-1); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (HtmlUILauncher.InitializeChromium()) { HtmlUILauncher.RegisterEmbeddedScheme(System.Reflection.Assembly.GetExecutingAssembly(), "res"); Application.Run(new frmMain()); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (HtmlUILauncher.InitializeChromium()) { //初始化成功,加载程序集内嵌的资源到运行时中 HtmlUILauncher.RegisterEmbeddedScheme(Resources.SchemeHelper.GetSchemeAssembley()); //启动主窗体 Application.Run(new EditorForm()); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); HtmlUILauncher.EnableFlashSupport = true; if (HtmlUILauncher.InitializeChromium()) { //初始化成功,加载程序集内嵌的资源到运行时中 HtmlUILauncher.RegisterEmbeddedScheme(System.Reflection.Assembly.GetExecutingAssembly()); //启动主窗体 Application.Run(new frmWelcome()); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); if (HtmlUILauncher.InitializeChromium((args) => { args.Settings.LogSeverity = Chromium.CfxLogSeverity.Verbose; }, settings => { })) { HtmlUILauncher.RegisterEmbeddedScheme(System.Reflection.Assembly.GetExecutingAssembly()); Application.Run(new Form1()); } }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); HtmlUILauncher.EnableFlashSupport = true; if (HtmlUILauncher.InitializeChromium((args => { args.Settings.LogSeverity = Chromium.CfxLogSeverity.Default; }))) { //初始化成功,加载程序集内嵌的资源到运行时中 HtmlUILauncher.RegisterEmbeddedScheme(System.Reflection.Assembly.GetExecutingAssembly(), domainName: "res.welcome.local"); //启动主窗体 Application.Run(new frmWelcome()); } }
void RenderProcessHandler_OnContextCreated(object sender, CfrOnContextCreatedEventArgs e) { var wb = HtmlUILauncher.GetBrowser(e.Browser.Identifier); if (wb != null) { if (e.Frame.IsMain) { SetProperties(e.Context, wb.GlobalObject); } else { JSObject obj; if (wb.FrameGlobalObjects.TryGetValue(e.Frame.Name, out obj)) { SetProperties(e.Context, obj); } } wb.RaiseOnV8ContextCreated(e); } }
internal static void Initialize() { if (initialized) { throw new HtmlUIException("ChromiumWebBrowser library already initialized."); } int retval = CfxRuntime.ExecuteProcess(); if (retval >= 0) { Environment.Exit(retval); } app = new CfxApp(); processHandler = new CfxBrowserProcessHandler(); app.GetBrowserProcessHandler += (s, e) => e.SetReturnValue(processHandler); app.OnBeforeCommandLineProcessing += (s, e) => HtmlUILauncher.RaiseOnBeforeCommandLineProcessing(e); app.OnRegisterCustomSchemes += (s, e) => HtmlUILauncher.RaiseOnRegisterCustomSchemes(e); var settings = new CfxSettings(); settings.MultiThreadedMessageLoop = true; settings.NoSandbox = true; HtmlUILauncher.RaiseOnBeforeCfxInitialize(settings, processHandler); if (!CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain)) { throw new HtmlUIException("Failed to initialize CEF library."); } initialized = true; }
void RenderProcessHandler_OnContextCreated(object sender, CfrOnContextCreatedEventArgs e) { var wb = HtmlUILauncher.GetBrowser(e.Browser.Identifier); if (wb != null) { if (e.Frame.IsMain) { SetProperties(e.Context, wb.GlobalObject); //TODO:添加内置的-nanui-[cmd]支持 e.Frame.ExecuteJavaScript(Properties.Resources.InitialScripts, e.Frame.Url, 0); } else { JSObject obj; if (wb.FrameGlobalObjects.TryGetValue(e.Frame.Name, out obj)) { SetProperties(e.Context, obj); } } wb.RaiseOnV8ContextCreated(e); } }
void RenderProcessHandler_OnBrowserCreated(object sender, CfrOnBrowserCreatedEventArgs e) { var id = e.Browser.Identifier; var wb = HtmlUILauncher.GetBrowser(id); if (wb != null) { var rp = wb.RemoteProcess; if (rp != null && rp != this.remoteProcess) { // A new process has been created for the browser. // The old process is still alive, but probably it gets // killed soon after this callback returns. // So we suspend all callbacks from the old process. // If there are currently executing callbacks, // this call will block until they are finished. // When this call returns, it should be safe to // continue execution and let the old process die. CfxRemoteCallbackManager.SuspendCallbacks(rp.RemoteProcessId); } wb.SetRemoteBrowser(e.Browser, remoteProcess); } }