Example #1
0
        public static CefViewHelper Create(AsyncJsObject asyncJsObject, string uri, Action <UrlProcessed> action)
        {
            var cefViewHelper = new CefViewHelper();

            cefViewHelper.InitCefBrowser(asyncJsObject, uri, action);
            return(cefViewHelper);
        }
Example #2
0
        public ChromiumWebBrowser CreateChromiumWebBrowser(bool autoInit, AsyncJsObject asyncJsObject)
        {
            if (!Initialized)
            {
                if (!autoInit)
                {
                    throw new InvalidOperationException("Cef is not be initialized!");
                }

                var defaultCefSettings = CreateDefaultCefSettings();
                Init(defaultCefSettings);
            }
            var chromiumWebBrowser = new ChromiumWebBrowser();

            //add F12 dev tool
            chromiumWebBrowser.KeyboardHandler = new CefKeyBoardHandler();

            if (asyncJsObject != null)
            {
                var option = (BindingOptions)asyncJsObject.BindingOptions;
                if (option == null)
                {
                    option = BindingOptions.DefaultBinder;
                }

                //chromiumWebBrowser.RegisterAsyncJsObject(asyncJsObject.Name, asyncJsObject.BindObject, option);
                //The javascript object repository, one repository per ChromiumWebBrowser instance.
                chromiumWebBrowser.JavascriptObjectRepository.Register(asyncJsObject.Name, asyncJsObject.BindObject, true, option);
            }
            return(chromiumWebBrowser);
        }
Example #3
0
        public void InitCefBrowser(AsyncJsObject asyncJsObject, string uri, Action <UrlProcessed> action)
        {
            UrlProcessedAction = action;
            var cefConfig = CefConfig.Default;

            Browser = cefConfig.CreateChromiumWebBrowser(true, asyncJsObject);
            Browser.FrameLoadEnd += Browser_FrameLoadEnd;
            Browser.Address       = uri;
        }