protected void RegisterActivatedStateChangedHandler()
        {
            parentForm.Activated += (s, e) =>
            {
                var js = "raiseCustomEvent('hostactivestate', {state:1, stateName:'activated'})";


                if (browserCore == null || !browserCore.IsMainFrameLoaded || !browserCore.ExecuteJavascript(js))
                {
                    delayedScripts["hostactivestate"] = js;
                }
            };

            parentForm.Deactivate += (s, e) =>
            {
                var js = "raiseCustomEvent('hostactivestate', {state:0, stateName:'deactivated'})";
                if (browserCore == null || !browserCore.IsMainFrameLoaded || !browserCore.ExecuteJavascript(js))
                {
                    delayedScripts["hostactivestate"] = js;
                }
            };
        }
        public WebBrowserFormImplement(Form form, BrowserCore browser)
        {
            parentForm  = form;
            browserCore = browser;


            browser.RemoteBrowserCreated += (_, e) => {
                formV8Handler = new FormV8Handler(parentForm);
#if XP
                CfrRuntime.RegisterExtension("nanui/form", Xzy.UI.Core.XP.Properties.Resources.nanui_formExtension, formV8Handler);
#else
                CfrRuntime.RegisterExtension("nanui/form", Xzy.UI.Core.Properties.Resources.nanui_formExtension, formV8Handler);
#endif
            };
            browser.LoadHandler.OnLoadEnd += (_, e) => {
                if (e.Frame.IsMain)
                {
                    foreach (var script in delayedScripts)
                    {
                        browserCore.ExecuteJavascript(script.Value);
                    }
                }
            };


            form.Move += (_, e) =>
            {
                if (browserCore != null && browserCore.BrowserHost != null)
                {
                    browserCore.BrowserHost.NotifyMoveOrResizeStarted();
                }
            };



            RegisterActivatedStateChangedHandler();
            RegisterSizeChangedEventHandler();
        }
Esempio n. 3
0
 public bool ExecuteJavascript(string code) => browserCore.ExecuteJavascript(code);