/// <summary> /// The run internal. /// </summary> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> private int RunInternal(string[] args) { // For Windows 7 and above, best to include relevant app.manifest entries as well Cef.EnableHighDPISupport(); var codeBase = Assembly.GetExecutingAssembly().CodeBase; var localFolder = Path.GetDirectoryName(new Uri(codeBase).LocalPath); var localesDirPath = Path.Combine(localFolder ?? throw new InvalidOperationException(), "locales"); _settings = new CefSettings { LocalesDirPath = localesDirPath, Locale = HostConfig.Locale, // MultiThreadedMessageLoop = true, // MultiThreadedMessageLoop is not allowed to be used as it will break frameless mode MultiThreadedMessageLoop = !(HostConfig.HostPlacement.Frameless || HostConfig.HostPlacement.KioskMode), CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"), LogSeverity = (CefSharpGlobal.LogSeverity)HostConfig.LogSeverity, LogFile = HostConfig.LogFile }; // Update configuration settings _settings.Update(HostConfig.CustomSettings); _settings.UpdateCommandLineArgs(HostConfig.CommandLineArgs); RegisterSchemeHandlers(); // Perform dependency check to make sure all relevant resources are in our output directory. Cef.Initialize(_settings, true, browserProcessHandler: null); Initialize(); _mainView = CreateMainView(_settings); bool centerScreen = HostConfig.HostPlacement.CenterScreen; if (centerScreen) { _mainView.CenterToScreen(); } _windowCreated = true; IoC.RegisterInstance(typeof(IChromelyWindow), typeof(IChromelyWindow).FullName, this); RunMessageLoop(); _mainView.Dispose(); _mainView = null; Cef.Shutdown(); Shutdown(); return(0); }
/// <summary> /// The run internal. /// </summary> /// <param name="args"> /// The args. /// </param> /// <returns> /// The <see cref="int"/>. /// </returns> private int RunInternal(string[] args) { // For Windows 7 and above, best to include relevant app.manifest entries as well CefSharpGlobal.Cef.EnableHighDPISupport(); var codeBase = Assembly.GetExecutingAssembly().CodeBase; var localFolder = Path.GetDirectoryName(new Uri(codeBase).LocalPath); var localesDirPath = Path.Combine(localFolder ?? throw new InvalidOperationException(), "locales"); mSettings = new CefSettings { LocalesDirPath = localesDirPath, Locale = HostConfig.Locale, MultiThreadedMessageLoop = true, CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"), LogSeverity = (CefSharpGlobal.LogSeverity)HostConfig.LogSeverity, LogFile = HostConfig.LogFile }; // Update configuration settings mSettings.Update(HostConfig.CustomSettings); mSettings.UpdateCommandLineArgs(HostConfig.CommandLineArgs); RegisterSchemeHandlers(); // Perform dependency check to make sure all relevant resources are in our output directory. CefSharpGlobal.Cef.Initialize(mSettings, performDependencyCheck: true, browserProcessHandler: null); Initialize(); mMainView = CreateMainView(mSettings); if (HostConfig.HostCenterScreen) { mMainView.CenterToScreen(); } mWindowCreated = true; RunMessageLoop(); mMainView.Dispose(); mMainView = null; CefSharpGlobal.Cef.Shutdown(); Shutdown(); return(0); }
protected override void OnCreate(ref CreateWindowPacket packet) { //For Windows 7 and above, best to include relevant app.manifest entries as well Cef.EnableHighDPISupport(); var codeBase = Assembly.GetExecutingAssembly().CodeBase; var localFolder = Path.GetDirectoryName(new Uri(codeBase).LocalPath); var localesDirPath = Path.Combine(localFolder, "locales"); m_settings = new CefSettings { LocalesDirPath = localesDirPath, Locale = HostConfig.Locale, MultiThreadedMessageLoop = true, CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"), LogSeverity = (CefSharpGlobal.LogSeverity)HostConfig.LogSeverity, LogFile = HostConfig.LogFile }; // Update configuration settings m_settings.Update(HostConfig.CustomSettings); m_settings.UpdateCommandLineArgs(HostConfig.CommandLineArgs); RegisterSchemeHandlers(); //Perform dependency check to make sure all relevant resources are in our output directory. Cef.Initialize(m_settings, performDependencyCheck: HostConfig.PerformDependencyCheck, browserProcessHandler: null); m_browser = new ChromiumWebBrowser(Handle, HostConfig.StartUrl); m_browser.IsBrowserInitializedChanged += IsBrowserInitializedChanged; // Set handlers m_browser.SetHandlers(); RegisterJsHandlers(); base.OnCreate(ref packet); Log.Info("Cef browser successfully created."); }
protected int RunInternal(string[] args) { // For Windows 7 and above, best to include relevant app.manifest entries as well Cef.EnableHighDPISupport(); var localFolder = _config.AppExeLocation; if (string.IsNullOrWhiteSpace(localFolder)) { var codeBase = Assembly.GetExecutingAssembly().CodeBase; localFolder = Path.GetDirectoryName(new Uri(codeBase).LocalPath); } var localesDirPath = Path.Combine(localFolder ?? throw new InvalidOperationException(), "locales"); _settings = new CefSettings { LocalesDirPath = localesDirPath, Locale = "en-US", RemoteDebuggingPort = 20480, MultiThreadedMessageLoop = !_config.WindowOptions.UseOnlyCefMessageLoop, CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache"), LogSeverity = LogSeverity.Default, LogFile = "logs\\chromely.cef_" + DateTime.Now.ToString("yyyyMMdd") + ".log", }; // Update configuration settings _settings.Update(_config.CustomSettings); _settings.UpdateCommandOptions(_config.CommandLineOptions); _settings.UpdateCommandLineArgs(_config.CommandLineArgs); // If MultiThreadedMessageLoop is overriden in Setting using CustomSettings, then // It is assumed that the developer way not be aware of IWindowOptions - UseOnlyCefMessageLoop _config.WindowOptions.UseOnlyCefMessageLoop = !_settings.MultiThreadedMessageLoop; // Set DevTools url string devtoolsUrl = _config.DevToolsUrl; if (string.IsNullOrWhiteSpace(devtoolsUrl)) { _config.DevToolsUrl = $"http://127.0.0.1:{_settings.RemoteDebuggingPort}"; } else { Uri uri = new Uri(devtoolsUrl); if (uri.Port <= 80) { _config.DevToolsUrl = $"{devtoolsUrl}:{_settings.RemoteDebuggingPort}"; } } RegisterDefaultSchemeHandlers(); RegisterCustomSchemeHandlers(); // Perform dependency check to make sure all relevant resources are in our output directory. Cef.Initialize(_settings, true, browserProcessHandler: null); _window.RegisterHandlers(); _window.Init(_settings); NativeHost_CreateAndShowWindow(); NativeHost_Run(); Cef.Shutdown(); NativeHost_Quit(); return(0); }