protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); _initScripts.Add(WebAppTemplates.GetPolyfill()); _initScripts.Add(string.Format(WebContext.LoadStringResource(Assembly.GetExecutingAssembly(), "LogicReinc.WebApp.Android.Scripts.IPCSetup.Android.js"))); _view = new WebView(this); _view.Settings.JavaScriptEnabled = true; _view.AddJavascriptInterface(new JSInterface(this), "_host"); _view.SetWebViewClient(new WebviewCallbacks(this)); this.SetContentView(_view); try { Controller = (WebWindow)Activator.CreateInstance(typeof(T), new object[] { this }); } catch (TargetInvocationException ex) { throw ex.InnerException; } }
public ChromiumWindow() { RegisterInitScript(WebAppTemplates.GetPolyfill()); RegisterInitScript(string.Format(WebContext.LoadStringResource(Assembly.GetExecutingAssembly(), "LogicReinc.WebApp.Mixed.IPCSetup.Chromium.js"))); }
public WebViewWindow() { DoubleBuffered = true; _browser = new WebView(); _browser.IsJavaScriptEnabled = true; _browser.IsScriptNotifyAllowed = true; _browser.AddInitializeScript(WebAppTemplates.GetPolyfill()); _browser.ScriptNotify += async(sender, wsn) => { if (OnIPC != null) { OnIPC(wsn.Value); } /* * string notify = wsn.Value; * string id = notify.Substring(0, notify.IndexOf(":")); * notify = notify.Substring(notify.IndexOf(":") + 1); * * * Task<object> resultT = null; * if (OnIPC != null) * resultT = OnIPC(notify); * * if (resultT == null) * return; * * //resultT.Wait(); * object result = await resultT;//.Result; * * * if (result != null && result.GetType() == typeof(NoIPCResponse)) * return; * * if(!string.IsNullOrEmpty(id)) * Execute(WebAppTemplates.FormatIf( * $"_IPCResolves[{id}]", * $"_IPCResolves[{id}]({JsonConvert.SerializeObject(result)});")); */ }; this.FormClosing += (a, b) => { Invoke(() => { this.Controls.Remove(_browser); if (_needCleanup) { _browser.Process.Terminate(); _needCleanup = false; } _browser.Dispose(); }); }; AppDomain.CurrentDomain.ProcessExit += (a, b) => { if (_needCleanup) { _browser.Process.Terminate(); } }; _browser.Dock = DockStyle.Fill; Controls.Add(_browser); RegisterInitScript(string.Format(WebContext.LoadStringResource(Assembly.GetExecutingAssembly(), "LogicReinc.WebApp.Mixed.IPCSetup.WebView.js"))); _isReady = true; }