示例#1
0
        protected override void OnCreate(ref CreateWindowPacket packet)
        {
            //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, "locales");

            m_settings = new CefSharpGlobal.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.
            CefSharpGlobal.Cef.Initialize(m_settings, performDependencyCheck: HostConfig.PerformDependencyCheck, browserProcessHandler: null);

            m_browser = new ChromiumWebBrowser(Handle, HostConfig.StartUrl);
            m_browser.IsBrowserInitializedChanged += IsBrowserInitializedChanged;
            m_browser.MenuHandler = new CefSharpContextMenuHandler();

            m_browser.RequestHandler = new CefSharpRequestHandler();
            RegisterJsHandlers();

            base.OnCreate(ref packet);

            Log.Info("Cef browser successfully created.");
        }
示例#2
0
 protected override void OnCreate(ref CreateWindowPacket packet)
 {
     this.DwmHelper.Initialize(this.DrawCaptionIcon, this.DrawCaptionTitle, this.AllowSystemMenu);
     base.OnCreate(ref packet);
 }
示例#3
0
        /// <summary>
        /// The on create.
        /// </summary>
        /// <param name="packet">
        /// The packet.
        /// </param>
        /// <exception cref="Exception">
        /// Rethrown exception on Cef load failure.
        /// </exception>
        protected override void OnCreate(ref CreateWindowPacket packet)
        {
            CefRuntime.EnableHighDpiSupport();

            // Will throw exception if Cef load fails.
            CefRuntime.Load();

            var mainArgs = new CefMainArgs(this.HostConfig.AppArgs);
            var app      = new CefGlueApp(this.HostConfig);

            var exitCode = CefRuntime.ExecuteProcess(mainArgs, app, IntPtr.Zero);

            if (exitCode != -1)
            {
                return;
            }

            var codeBase       = Assembly.GetExecutingAssembly().CodeBase;
            var localFolder    = Path.GetDirectoryName(new Uri(codeBase).LocalPath);
            var localesDirPath = Path.Combine(localFolder, "locales");

            var settings = new CefSettings
            {
                LocalesDirPath           = localesDirPath,
                Locale                   = this.HostConfig.Locale,
                SingleProcess            = false,
                MultiThreadedMessageLoop = true,
                LogSeverity              = (CefLogSeverity)this.HostConfig.LogSeverity,
                LogFile                  = this.HostConfig.LogFile,
                ResourcesDirPath         = Path.GetDirectoryName(new Uri(Assembly.GetEntryAssembly().CodeBase).LocalPath),
                NoSandbox                = true
            };

            // Update configuration settings
            settings.Update(this.HostConfig.CustomSettings);

            CefRuntime.Initialize(mainArgs, settings, app, IntPtr.Zero);

            this.RegisterSchemeHandlers();
            this.RegisterMessageRouters();

            var clientSize = this.GetClientSize();

            var browserConfig = new CefBrowserConfig
            {
                StartUrl         = this.HostConfig.StartUrl,
                ParentHandle     = this.Handle,
                AppArgs          = this.HostConfig.AppArgs,
                StartWebSocket   = this.HostConfig.StartWebSocket,
                WebsocketAddress = this.HostConfig.WebsocketAddress,
                WebsocketPort    = this.HostConfig.WebsocketPort,
                CefRectangle     =
                    new CefRectangle
                {
                    X      = 0,
                    Y      = 0,
                    Width  = clientSize.Width,
                    Height = clientSize.Height
                }
            };

            this.mBrowser = new CefGlueBrowser(browserConfig);
            this.mBrowser.BrowserCreated += OnBrowserCreated;

            base.OnCreate(ref packet);

            Log.Info("Cef browser successfully created.");
        }
示例#4
0
 protected override void OnCreate(ref CreateWindowPacket packet)
 {
     this.m_dx.Initialize(this.Handle, this.GetClientSize());
     base.OnCreate(ref packet);
 }