Пример #1
0
        protected override void OnRealized()
        {
            base.OnRealized();

            ChildVisible = true;

            var windowInfo = CefWindowInfo.Create();

            switch (CefRuntime.Platform)
            {
            case CefRuntimePlatform.Windows:
                var parentHandle = gdk_win32_drawable_get_handle(GdkWindow.Handle);
                windowInfo.SetAsChild(parentHandle, new CefRectangle(0, 0, 0, 0));     // TODO: set correct  x, y, width, height  to do not waiting OnSizeAllocated event
                break;

            case CefRuntimePlatform.Linux:
                Console.WriteLine("REALIZED - RAW = {0}, HANDLE = {1}", Raw, Handle);
                windowInfo.SetAsChild(Handle, new CefRectangle(0, 0, 0, 0));
                break;

            case CefRuntimePlatform.MacOSX:
            default:
                throw new NotSupportedException();
            }

            _core.Create(windowInfo);
        }
Пример #2
0
        protected override void OnRealized()
        {
            base.OnRealized();

            ChildVisible = true;

            var windowInfo = CefWindowInfo.Create();

            switch (CefRuntime.Platform)
            {
            case CefRuntimePlatform.Windows:
                windowInfo.ParentHandle = gdk_win32_drawable_get_handle(GdkWindow.Handle);
                // set windowInfo - x, y, width, height ?
                break;

            case CefRuntimePlatform.Linux:
                Console.WriteLine("REALIZED - RAW = {0}, HANDLE = {1}", Raw, Handle);
                windowInfo.ParentHandle = Handle;
                break;

            case CefRuntimePlatform.MacOSX:
            default:
                throw new NotSupportedException();
            }

            _core.Create(windowInfo);
        }
Пример #3
0
        private void Load(string[] args)
        {
            try
            {
                CefRuntime.Load();
            }
            catch (DllNotFoundException ex)
            {
                Debug.LogException(ex);
                return;
            }
            catch (CefRuntimeException ex)
            {
                Debug.LogException(ex);
                return;
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
                return;
            }

            var mainArgs = new CefMainArgs(args);
            var app      = new DemoApp();

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

            if (exitCode != -1)
            {
                Debug.LogErrorFormat("ExitCode={0}", exitCode);
                return;
            }

            string codeBase = Assembly.GetExecutingAssembly().CodeBase;

            Debug.LogFormat("codeBase: {0}", codeBase);

            string localFolder = Path.GetDirectoryName(new Uri(codeBase).LocalPath);

            Debug.LogFormat("localFolder: {0}", localFolder);

            string browserProcessPath = CombinePaths(localFolder, "..", "..", "..",
                                                     "CefGlue.Demo.WinForms", "bin", "Release", "Xilium.CefGlue.Demo.WinForms.exe");

            Debug.LogFormat("browserProcessPath: {0}", browserProcessPath);

            CefSettings settings = new CefSettings
            {
                BrowserSubprocessPath    = browserProcessPath,
                SingleProcess            = false,
                MultiThreadedMessageLoop = true,
                LogSeverity = CefLogSeverity.Disable,
                LogFile     = "CefGlue.log",
            };

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

            if (!settings.MultiThreadedMessageLoop)
            {
                _mDoUpdates = true;
            }

            string url = "https://www.youtube.com/watch?v=qjb1oZk3mNM";

            _mCore          = new WebBrowser(this, new CefBrowserSettings(), url);
            _mCore.Created += new EventHandler(BrowserCreated);
            _mCore.StartUrl = url;

            var windowInfo = CefWindowInfo.Create();

            windowInfo.Name = url;
            _mCore.Create(windowInfo);

            Debug.Log("Load: Done");
        }