示例#1
0
        public void MainThread(object coreInst)
        {
            core           = (Core)coreInst;
            additionalPath = Path.Combine(core.RootPath, "./Resources/ArkDesktop.Cfx/");
            if (CheckLibs() == false)
            {
                return;
            }
            int exitCode = CfxRuntime.ExecuteProcess(null);

            using (var settings = new CfxSettings())
            {
                settings.MultiThreadedMessageLoop   = true;
                settings.WindowlessRenderingEnabled = true;
                settings.NoSandbox             = true;
                settings.ResourcesDirPath      = Path.Combine(additionalPath, "cef", "Resources");
                settings.LocalesDirPath        = Path.Combine(additionalPath, "cef", "Resources", "locales");
                settings.BrowserSubprocessPath = Path.Combine(additionalPath, "ArkDesktopCfxSubProcess.exe");
                settings.LogFile = "C:/Users/z1223/Desktop/log.txt";

                var app = new CfxApp();
                app.OnBeforeCommandLineProcessing += (s, e) =>
                {
                    // optimizations following recommendations from issue #84
                    e.CommandLine.AppendSwitch("disable-gpu");
                    e.CommandLine.AppendSwitch("disable-gpu-compositing");
                    e.CommandLine.AppendSwitch("disable-gpu-vsync");
                };
                app.OnRegisterCustomSchemes += App_OnRegisterCustomSchemes;
                if (!CfxRuntime.Initialize(settings, app))
                {
                    return;
                }
                CfxRuntime.RegisterSchemeHandlerFactory("akd", "test", new ResourceManager.SchemeHandlerFactory(Path.Combine(core.RootPath, "Resources\\")));
            }
            CreateThreads();
            manager = new ArkDesktopBrowserControl(window);
            while (!disposed)
            {
                CfxRuntime.DoMessageLoopWork();
            }
        }
示例#2
0
        static void Main()
        {
            Config = JsonConvert.DeserializeObject <Config>(File.ReadAllText("Config.json"));

            if (CfxRuntime.PlatformArch == CfxPlatformArch.x64)
            {
                CfxRuntime.LibCefDirPath = Path.GetFullPath(@"..\..\..\libcef\x64");
            }
            else
            {
                CfxRuntime.LibCefDirPath = System.IO.Path.GetFullPath(@"..\..\..\libcef\x86");
            }

            CfxRuntime.LibCfxDirPath = CfxRuntime.LibCefDirPath;

            string assemblyDir = System.IO.Path.GetDirectoryName(
                new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath
                );

            //CfxRuntime.EnableHighDpiSupport();

            int exitCode = CfxRuntime.ExecuteProcess(null);

            if (exitCode >= 0)
            {
                Environment.Exit(exitCode);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var settings = new CfxSettings();

            settings.WindowlessRenderingEnabled = true;
            settings.NoSandbox = true;

            //settings.SingleProcess = true;
            settings.BrowserSubprocessPath = Path.Combine(assemblyDir, "xRemote");

            //settings.LogSeverity = CfxLogSeverity.Disable;

            settings.ResourcesDirPath = Path.GetFullPath(@"..\..\..\libcef\Resources");
            settings.LocalesDirPath   = Path.GetFullPath(@"..\..\..\libcef\Resources\locales");

            var app = new CfxApp();

            app.OnBeforeCommandLineProcessing += (s, e) =>
            {
                e.CommandLine.AppendSwitch("disable-web-security");
                e.CommandLine.AppendSwitch("enable-system-flash");

                // optimizations following recommendations from issue #84
                //e.CommandLine.AppendSwitch("disable-gpu");
                //e.CommandLine.AppendSwitch("disable-gpu-compositing");
                //e.CommandLine.AppendSwitch("disable-gpu-vsync");
            };

            if (!CfxRuntime.Initialize(settings, app))
            {
                Environment.Exit(-1);
            }

            Common.GlobalObjectPool.InitializePool();

            // 监听连接请求
            ProxyListener.Initialize();

            var f = new MainForm();

            f.Show();
            Application.Idle += (s, e) => CfxRuntime.DoMessageLoopWork();
            Application.Run(f);

            Common.GlobalObjectPool.DestroyPool();

            CfxRuntime.Shutdown();
        }
 static void Application_Idle(object sender, EventArgs e)
 {
     CfxRuntime.DoMessageLoopWork();
 }
 private static void BrowserMessageLoopStep(object sender, EventArgs e)
 {
     CfxRuntime.DoMessageLoopWork();
     Thread.Yield();
 }
示例#5
0
        public static bool InitializeChromium()
        {
            if (ChromiumStartupSettings.PrepareRuntime())
            {
                var exitCode = CfxRuntime.ExecuteProcess(null);
                if (exitCode >= 0)
                {
                    Environment.Exit(exitCode);
                }

                var settings = new CfxSettings();
                settings.WindowlessRenderingEnabled = true;
                settings.NoSandbox = true;

                var cachePath = System.IO.Path.Combine(ChromiumStartupSettings.ApplicationDataDir, Application.ProductName, "Cache");
                if (!System.IO.Directory.Exists(cachePath))
                {
                    System.IO.Directory.CreateDirectory(cachePath);
                }

                settings.LocalesDirPath   = ChromiumStartupSettings.LocalesDir;
                settings.ResourcesDirPath = ChromiumStartupSettings.ResourcesDir;
                settings.Locale           = "zh-CN";
                settings.CachePath        = cachePath;
                settings.LogSeverity      = CfxLogSeverity.Disable;



                OnRegisterCustomSchemes += args =>
                {
                    args.Registrar.AddCustomScheme("embedded", false, false, false);
                };



                try
                {
                    var app = new CfxApp();
                    app.OnBeforeCommandLineProcessing += (s, e) =>
                    {
                        // optimizations following recommendations from issue #84
                        e.CommandLine.AppendSwitch("disable-gpu");
                        e.CommandLine.AppendSwitch("disable-gpu-compositing");
                        e.CommandLine.AppendSwitch("disable-gpu-vsync");
                    };

                    if (!CfxRuntime.Initialize(settings, app))
                    {
                        //Environment.Exit(-1);
                        return(false);
                    }

                    Application.Idle += (sender, e) =>
                    {
                        CfxRuntime.DoMessageLoopWork();
                    };



                    return(true);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);

                    Console.WriteLine(ex.InnerException);
                    MessageBox.Show(string.Format("初始化系统失败。\r\n{0}", ex.Message), "错误", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            return(false);
        }