// Main entry point when called by vvvv
        void IStartable.Start()
        {
            var assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            CfxRuntime.LibCefDirPath = assemblyDir;

            CfxApp app = new CfxApp();

            app.OnBeforeCommandLineProcessing += app_OnBeforeCommandLineProcessing;

            var settings = new CfxSettings
            {
                //PackLoadingDisabled = true,
                WindowlessRenderingEnabled = true,
                NoSandbox                = true,
                UserDataPath             = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "userdata"),
                CachePath                = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "cache"),
                BrowserSubprocessPath    = Assembly.GetExecutingAssembly().Location,
                LogSeverity              = CfxLogSeverity.Disable,
                SingleProcess            = false, // DEBUG
                MultiThreadedMessageLoop = true,  // false
                IgnoreCertificateErrors  = true,
            };

            CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain);
        }
        private void Initialize()
        {
            CfxRuntime.LibCefDirPath = @"cef\Release";
            int retval = CfxRuntime.ExecuteProcess();

            var app            = new CfxApp();
            var processHandler = new CfxBrowserProcessHandler();

            app.GetBrowserProcessHandler += (sender, e) => e.SetReturnValue(processHandler);

            var path = Path.Combine(GetType().Assembly.GetPath(), "ChromiumFXRenderProcess.exe");

            var settings = new CfxSettings
            {
                SingleProcess              = false,
                BrowserSubprocessPath      = path,
                WindowlessRenderingEnabled = true,
                MultiThreadedMessageLoop   = true,
                NoSandbox        = true,
                LocalesDirPath   = System.IO.Path.GetFullPath(@"cef\Resources\locales"),
                ResourcesDirPath = System.IO.Path.GetFullPath(@"cef\Resources")
            };

            if (!CfxRuntime.Initialize(settings, app, RenderProcessStartup))
            {
                throw new Exception("Failed to initialize CEF library.");
            }

            Thread.Sleep(200);
        }
Beispiel #3
0
        // Main entry point when called by vvvv
        public static void Start()
        {
            CfxRuntime.LibCefDirPath = Globals.AssemblyDir;

            var app = new CfxApp();

            app.OnBeforeCommandLineProcessing += app_OnBeforeCommandLineProcessing;

            BrowserProcessHandler = new CfxBrowserProcessHandler();
            BrowserProcessHandler.OnBeforeChildProcessLaunch += (sender, args) =>
            {
                args.CommandLine.AppendSwitchWithValue("vvvv-pid", Process.GetCurrentProcess().Id.ToString());
            };
            app.GetBrowserProcessHandler += (sender, args) => args.SetReturnValue(BrowserProcessHandler);

            var settings = new CfxSettings
            {
                //PackLoadingDisabled = true,
                WindowlessRenderingEnabled = true,
                NoSandbox             = true,
                UserDataPath          = Path.Combine(Globals.AssemblyDir, "userdata"),
                CachePath             = Path.Combine(Globals.AssemblyDir, "cache"),
                BrowserSubprocessPath = Globals.AssemblyLocation,
                LogSeverity           = CfxLogSeverity.Disable,
                //SingleProcess = false, // DEBUG
                MultiThreadedMessageLoop = true, // false
                IgnoreCertificateErrors  = true,
                RemoteDebuggingPort      = 8088,
            };

            Started = true;

            CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain);
        }
Beispiel #4
0
        static void Main()
        {
            string nowDir = AppDomain.CurrentDomain.BaseDirectory;

            if (!System.IO.File.Exists(System.IO.Path.Combine(nowDir, "libcfx.dll")))
            {
                if (MessageBox.Show("并没有在软件目录下找到基本运行库\n您应该在获得这款软件的时候同时获得关于本软件依赖库的信息\n如果没有,您可以到本软件的Github Wiki获得帮助\n是否现在前往?",
                                    "未能找到依赖库", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    System.Diagnostics.Process.Start("https://github.com/huix-oldcat/ArkDesktop/wiki");
                }
                return;
            }
            CfxRuntime.LibCefDirPath = System.IO.Path.Combine(nowDir, "cef");
            CfxRuntime.LibCfxDirPath = nowDir;
            int exitCode = CfxRuntime.ExecuteProcess(null);

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

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

            using (var settings = new CfxSettings())
            {
                settings.MultiThreadedMessageLoop   = true;
                settings.WindowlessRenderingEnabled = true;
                settings.NoSandbox        = true;
                settings.ResourcesDirPath = System.IO.Path.Combine(nowDir, "cef", "Resources");
                settings.LocalesDirPath   = System.IO.Path.Combine(nowDir, "cef", "Resources", "locales");

                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);
                }
            }

            Manager.layeredWindow = new LayeredWindow();
            Manager.control       = new ArkDesktopBrowserControl();
            Manager.Init();

            Application.Run(Manager.layeredWindow);

            // CfxRuntime.QuitMessageLoop();
            CfxRuntime.Shutdown();
        }
Beispiel #5
0
        static void Main()
        {
            string nowDir = Environment.CurrentDirectory;

            CfxRuntime.LibCefDirPath = System.IO.Path.Combine(nowDir, "cef");
            CfxRuntime.LibCfxDirPath = nowDir;
            int exitCode = CfxRuntime.ExecuteProcess(null);

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

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

            using (var settings = new CfxSettings())
            {
                settings.MultiThreadedMessageLoop   = true;
                settings.WindowlessRenderingEnabled = true;
                settings.NoSandbox        = true;
                settings.ResourcesDirPath = System.IO.Path.Combine(nowDir, "cef", "Resources");
                settings.LocalesDirPath   = System.IO.Path.Combine(nowDir, "cef", "Resources", "locales");

                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);
                }
            }

            Manager.layeredWindow = new LayeredWindow();
            Manager.control       = new ArkDesktopBrowserControl();
            Manager.Init();

            Application.Run(Manager.layeredWindow);

            // CfxRuntime.QuitMessageLoop();
            CfxRuntime.Shutdown();
        }
Beispiel #6
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();
            }
        }
Beispiel #7
0
        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;
        }
        /// <summary>
        /// 初始化
        /// </summary>
        internal static void Initialize()
        {
            if (initialized)
            {
                throw new WebEngineException("对不起!初始化工作已经完成,请勿重复执行初始化工作。");
            }

            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) => Bootstrapper.RaiseOnBeforeCommandLineProcessing(e);
            app.OnRegisterCustomSchemes       += (s, e) => Bootstrapper.RaiseOnRegisterCustomSchemes(e);

            var settings = new CfxSettings();

            settings.MultiThreadedMessageLoop = true;
            settings.NoSandbox = true;

            Bootstrapper.RaiseOnBeforeCfxInitialize(settings, processHandler);

            //if (!CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain))
            if (!CfxRuntime.Initialize(settings, app))
            {
                throw new WebEngineException("对不起!无法初始化 CEF 运行库。");
            }

            initialized = true;
        }
Beispiel #9
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();
        }
Beispiel #10
0
        public override void Load()
        {
            Instance = this;
            effect   = GetEffect("Effects/BGRtoRGB");

            Scheduler.EnqueueMessage(() =>
            {
                Platform.Current.SetWindowUnicodeTitle(Main.instance.Window, Titles[Main.rand.Next(Titles.Length)]);

                if (!CfxRuntime.LibrariesLoaded)
                {
                    string path = CfxRuntime.PlatformArch == CfxPlatformArch.x64 ? "x64" : "x86";
                    CfxRuntime.LibCefDirPath = Path.Combine(Config.CefCfxPath, path);
                    CfxRuntime.LibCfxDirPath = Path.Combine(Config.CefCfxPath, path);
                }

                var exitCode = CfxRuntime.ExecuteProcess();
                if (exitCode >= 0)
                {
                    typeof(ModLoader).InvokeMethod <object>("DisableMod", Name);
                }

                var settings = new CfxSettings
                {
                    WindowlessRenderingEnabled = true,
                    NoSandbox        = true,
                    ResourcesDirPath = Config.ResourcesPath,
                    LocalesDirPath   = Path.Combine(Config.ResourcesPath, "locales"),
                    CachePath        = Config.CachePath
                };
                settings.MultiThreadedMessageLoop = true;

                CfxApp app = new CfxApp();
                app.OnBeforeCommandLineProcessing += (s, e) =>
                {
                    e.CommandLine.AppendSwitch("single-process");
                    e.CommandLine.AppendSwitch("disable-gpu");
                    e.CommandLine.AppendSwitch("disable-gpu-compositing");
                    e.CommandLine.AppendSwitch("disable-gpu-vsync");
                    e.CommandLine.AppendSwitchWithValue("enable-media-stream", "1");
                };

                if (!CfxRuntime.Initialize(settings, app))
                {
                    typeof(ModLoader).InvokeMethod <object>("DisableMod", Name);
                }

                GUI         = BaseLibrary.Utility.Utility.SetupGUI <TestUI>();
                GUI.Visible = true;
            });

            void UpdateMouseEvent()
            {
                FocusedBrowser.mouseEvent.Modifiers = Utility.GetModifiers();
                FocusedBrowser.mouseEvent.X         = FocusedBrowser.RelativeMousePosition.X;
                FocusedBrowser.mouseEvent.Y         = FocusedBrowser.RelativeMousePosition.Y;
            }

            InputInterceptor.InterceptInput += () => FocusedBrowser != null;

            InputInterceptor.OnMouseMove += (x, y, modifiers) =>
            {
                PlayerInput.MouseX = x;
                PlayerInput.MouseY = y;

                Main.lastMouseX = Main.mouseX;
                Main.lastMouseY = Main.mouseY;
                Main.mouseX     = PlayerInput.MouseX;
                Main.mouseY     = PlayerInput.MouseY;

                typeof(PlayerInput).SetValue("_originalMouseX", Main.mouseX);
                typeof(PlayerInput).SetValue("_originalMouseY", Main.mouseY);
                typeof(PlayerInput).SetValue("_originalLastMouseX", Main.lastMouseX);
                typeof(PlayerInput).SetValue("_originalLastMouseY", Main.lastMouseY);

                UpdateMouseEvent();
                FocusedBrowser.BrowserHost.SendMouseMoveEvent(FocusedBrowser.mouseEvent, false);
            };
            InputInterceptor.OnMouseWheel += (delta, modifiers) =>
            {
                PlayerInput.ScrollWheelValue = PlayerInput.ScrollWheelValueOld;

                bool shiftDown = (modifiers & 4) != 0;

                UpdateMouseEvent();
                FocusedBrowser.BrowserHost.SendMouseWheelEvent(FocusedBrowser.mouseEvent, shiftDown ? delta : 0, shiftDown ? 0 : delta);
            };

            InputInterceptor.OnLeftMouseDown += (clickCount, modifiers) =>
            {
                UpdateMouseEvent();
                FocusedBrowser.BrowserHost.SendMouseClickEvent(FocusedBrowser.mouseEvent, CfxMouseButtonType.Left, false, clickCount);
            };
            InputInterceptor.OnLeftMouseUp += (clickCount, modifiers) =>
            {
                UpdateMouseEvent();
                FocusedBrowser.BrowserHost.SendMouseClickEvent(FocusedBrowser.mouseEvent, CfxMouseButtonType.Left, true, clickCount);
            };

            InputInterceptor.OnRightMouseDown += (clickCount, modifiers) =>
            {
                UpdateMouseEvent();
                FocusedBrowser.BrowserHost.SendMouseClickEvent(FocusedBrowser.mouseEvent, CfxMouseButtonType.Right, false, clickCount);
            };
            InputInterceptor.OnRightMouseUp += (clickCount, modifiers) =>
            {
                UpdateMouseEvent();
                FocusedBrowser.BrowserHost.SendMouseClickEvent(FocusedBrowser.mouseEvent, CfxMouseButtonType.Right, true, clickCount);
            };

            InputInterceptor.OnMiddleMouseDown += (clickCount, modifiers) =>
            {
                UpdateMouseEvent();
                FocusedBrowser.BrowserHost.SendMouseClickEvent(FocusedBrowser.mouseEvent, CfxMouseButtonType.Middle, false, clickCount);
            };
            InputInterceptor.OnMiddleMouseUp += (clickCount, modifiers) =>
            {
                UpdateMouseEvent();
                FocusedBrowser.BrowserHost.SendMouseClickEvent(FocusedBrowser.mouseEvent, CfxMouseButtonType.Middle, true, clickCount);
            };

            InputInterceptor.OnKeyChar += (key, modifiers) =>
            {
                if (key == (int)Utility.Keys.LMenu || key == (int)Utility.Keys.RMenu)
                {
                    return;
                }

                CfxKeyEvent keyEvent = new CfxKeyEvent
                {
                    WindowsKeyCode       = key,
                    Type                 = CfxKeyEventType.Char,
                    IsSystemKey          = false,
                    Modifiers            = Utility.GetModifiers(),
                    FocusOnEditableField = 1
                };

                FocusedBrowser.BrowserHost.SendKeyEvent(keyEvent);
            };
            InputInterceptor.OnKeyDown += (key, modifiers, systemKey) =>
            {
                if (key == (int)Utility.Keys.LMenu || key == (int)Utility.Keys.RMenu)
                {
                    return;
                }

                CfxKeyEvent keyEvent = new CfxKeyEvent
                {
                    WindowsKeyCode       = key,
                    Type                 = CfxKeyEventType.Keydown,
                    IsSystemKey          = systemKey,
                    Modifiers            = Utility.GetModifiers(),
                    FocusOnEditableField = 1
                };

                FocusedBrowser.BrowserHost.SendKeyEvent(keyEvent);
            };
            InputInterceptor.OnKeyUp += (key, modifiers, systemKey) =>
            {
                if (key == (int)Utility.Keys.LMenu || key == (int)Utility.Keys.RMenu)
                {
                    return;
                }

                CfxKeyEvent keyEvent = new CfxKeyEvent
                {
                    WindowsKeyCode       = key,
                    Type                 = CfxKeyEventType.Keyup,
                    IsSystemKey          = systemKey,
                    Modifiers            = Utility.GetModifiers(),
                    FocusOnEditableField = 1
                };

                FocusedBrowser.BrowserHost.SendKeyEvent(keyEvent);
            };
        }
        static void Main()
        {
            var assemblyDir = System.IO.Path.GetDirectoryName(new System.Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath);

            var projectRoot = assemblyDir;

            while (!System.IO.File.Exists(System.IO.Path.Combine(projectRoot, "Readme.md")))
            {
                projectRoot = System.IO.Path.GetDirectoryName(projectRoot);
            }

            CfxRuntime.LibCefDirPath = System.IO.Path.Combine(projectRoot, "cef", "Release64");
            CfxRuntime.LibCfxDirPath = System.IO.Path.Combine(projectRoot, "Build", "Release");

            var LD_LIBRARY_PATH = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");

            Debug.Print(LD_LIBRARY_PATH);

            var 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 = System.IO.Path.Combine(assemblyDir, "windowless");

            //settings.LogSeverity = CfxLogSeverity.Disable;

            settings.ResourcesDirPath = System.IO.Path.Combine(projectRoot, "cef", "Resources");
            settings.LocalesDirPath   = System.IO.Path.Combine(projectRoot, "cef", "Resources", "locales");

            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);
            }


            var f = new Form();

            f.Width  = 900;
            f.Height = 600;

            var c = new BrowserControl();

            c.Dock   = DockStyle.Fill;
            c.Parent = f;

            Application.Idle += Application_Idle;
            Application.Run(f);

            CfxRuntime.Shutdown();
        }
        internal static void Initialize()
        {
            _mono = Type.GetType("Mono.Runtime") != null;

            if (initialized)
            {
                throw new ChromiumWebBrowserException("ChromiumWebBrowser library already initialized.");
            }


            int retval = CfxRuntime.ExecuteProcess();

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


            app            = new CfxApp();
            processHandler = new CfxBrowserProcessHandler();
            processHandler.OnBeforeChildProcessLaunch += ProcessHandler_OnBeforeChildProcessLaunch;


            app.GetBrowserProcessHandler      += (s, e) => e.SetReturnValue(processHandler);
            app.OnBeforeCommandLineProcessing += (s, e) => ChromiumWebBrowserBase.RaiseOnBeforeCommandLineProcessing(e);
            app.OnRegisterCustomSchemes       += (s, e) => ChromiumWebBrowserBase.RaiseOnRegisterCustomSchemes(e);

            var settings = new CfxSettings();

            //FIXED different default settings based on platform

            switch (CfxRuntime.PlatformOS)

            {
            case CfxPlatformOS.Linux:

                settings.MultiThreadedMessageLoop = false;


                //TODO less demanding way of using DoMessageLoopWork, ExernalMessageLoop = true doesn't seem to work

                Application.Idle += BrowserMessageLoopStep;

                break;

            default:

                settings.MultiThreadedMessageLoop = true;

                Application.ApplicationExit += Application_ApplicationExit;

                break;
            }

            settings.NoSandbox = true;


            ChromiumWebBrowserBase.RaiseOnBeforeCfxInitialize(settings, processHandler);

            //ChromiumWebBrowserBase.WindowLess = settings.WindowlessRenderingEnabled;

            Console.WriteLine(" ****************** window Less " + ChromiumWebBrowserBase.WindowLess);

            //if(!CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcessMain))
            //	throw new ChromiumWebBrowserException("Failed to initialize CEF library.");


            if (CfxRuntime.PlatformOS == CfxPlatformOS.Windows)
            {
                if (!CfxRuntime.Initialize(settings, app, RenderProcess.RenderProcess.RenderProcessMain))
                {
                    throw new ChromiumWebBrowserException("Failed to initialize CEF library.");
                }
            }
            else
            {
                Console.WriteLine("()()*()*(**()*)(*()*))");
                if (!CfxRuntime.Initialize(settings, app))
                {
                    Environment.Exit(-1);
                }
            }

            initialized = true;
        }
Beispiel #13
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);
        }
Beispiel #14
0
        static void Main()
        {
            string nowDir = Environment.CurrentDirectory;

            CfxRuntime.LibCefDirPath = System.IO.Path.Combine(nowDir, "cef");
            CfxRuntime.LibCfxDirPath = nowDir;
            int exitCode = CfxRuntime.ExecuteProcess(null);

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

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

            using (var settings = new CfxSettings())
            {
                settings.MultiThreadedMessageLoop   = true;
                settings.WindowlessRenderingEnabled = true;
                settings.NoSandbox        = true;
                settings.ResourcesDirPath = System.IO.Path.Combine(nowDir, "cef", "Resources");
                settings.LocalesDirPath   = System.IO.Path.Combine(nowDir, "cef", "Resources", "locales");

                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);
                }
            }


            Manager.mainForm = new Form1
            {
                //FormBorderStyle = System.Windows.Forms.FormBorderStyle.None,
                BackColor         = Color.White,
                Height            = 300,
                Width             = 300,
                TransparencyKey   = Color.White,
                AllowTransparency = true
            };

            ArkDesktopBrowserControl control = new ArkDesktopBrowserControl
            {
                Dock   = DockStyle.Fill,
                Parent = Manager.mainForm
            };

            Manager.mainForm.Controls.Add(control);

            Manager.Init();

            Application.Run(Manager.mainForm);

            // CfxRuntime.QuitMessageLoop();
            CfxRuntime.Shutdown();
        }