public NKE_BrowserWindow(Dictionary <string, object> options)
        {
            _thread_id  = (int)startupOptions["NKS.MainThreadId"];
            syncContext = new TaskFactory((TaskScheduler)startupOptions["NKS.MainThreadScheduler"]);

            _id = NKScriptContextFactory.sequenceNumber++;

            if (options == null)
            {
                options = new Dictionary <string, object>();
            }

            windowArray[_id] = this;
            try
            {
                _webContents = new NKE_WebContents(this);
                var _ = ensureOnUIThread(createBrowserWindow, options);
            }
            catch (Exception ex)
            {
                NKLogging.log("!Error Creating Window" + ex.Message);
                NKLogging.log(ex.StackTrace);
            }
            events.on <int>("NKE.DidFinishLoad", (e, id) =>
            {
                this.getNKScriptValue().invokeMethod("emit", new[] { "did-finish-load" });
            });
        }
Example #2
0
        public async static Task addElectro(NKScriptContext context, Dictionary <string, object> options)
        {
            var appjs = await NKStorage.getResourceAsync(typeof(Main), "_nke_main.js", "lib_electro");

            var script       = "function loadbootstrap(){\n" + appjs + "\n}\n" + "loadbootstrap();" + "\n";
            var scriptsource = new NKScriptSource(script, "io.nodekit.electro/lib-electro/_nke_main.js", "io.nodekit.electro.main");
            await context.NKinjectScript(scriptsource);

            bool multiProcess = NKOptions.itemOrDefault <bool>(options, "NKS.RemoteProcess", false);

            var optionsDefault = new Dictionary <string, object>
            {
                ["NKS.PluginBridge"] = NKScriptExportType.NKScriptExport
            };

            var optionsMulti = new Dictionary <string, object>
            {
                ["NKS.PluginBridge"]  = NKScriptExportType.NKScriptExport,
                ["NKS.RemoteProcess"] = true
            };

            var optionsMain = new Dictionary <string, object>
            {
                ["NKS.PluginBridge"]        = NKScriptExportType.NKScriptExport,
                ["NKS.MainThread"]          = true,
                ["NKS.MainThreadId"]        = (int)options["NKS.MainThreadId"],
                ["NKS.MainThreadScheduler"] = (TaskScheduler)options["NKS.MainThreadScheduler"]
            };

            await context.NKloadPlugin(typeof(NKE_App), null, optionsDefault);

            if (!multiProcess)
            {
                await NKE_BrowserWindow.attachToContext(context, optionsMain);
            }
            else
            {
                await NKE_BrowserWindow.attachToContext(context, optionsMulti);
            }

            if (!multiProcess)
            {
                await NKE_WebContents.attachToContext(context, optionsMain);
            }
            else
            {
                await NKE_WebContents.attachToContext(context, optionsMulti);
            }

            await NKE_Dialog.attachToContext(context, optionsMain);

            await NKE_IpcMain.attachToContext(context, optionsDefault);

            // NKE_Menu.attachTo(context);
            // NKE_Protocol.attachTo(context);
        }
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (_webContents != null)
                    {
                        _webContents.Dispose();
                        _webContents = null;
                    }
                }

                this.getNKScriptValue().Dispose();

                disposedValue = true;
            }
        }
Example #4
0
        public async static Task addElectroRemoteProxy(NKScriptContext context, Dictionary <string, object> options)
        {
            var optionsDefault = new Dictionary <string, object>
            {
                ["NKS.PluginBridge"]        = NKScriptExportType.NKScriptExport,
                ["NKS.MainThread"]          = true,
                ["NKS.MainThreadId"]        = (int)options["NKS.MainThreadId"],
                ["NKS.MainThreadScheduler"] = (TaskScheduler)options["NKS.MainThreadScheduler"]
            };

            await NKE_BrowserWindow.attachToContext(context, optionsDefault);

            await NKE_WebContents.attachToContext(context, optionsDefault);

            // await context.NKloadPlugin(typeof(NKEDialog), "io.nodekit.electro.dialog", options);

            // NKE_BrowserWindow.attachTo(context);
            // NKE_WebContentsBase.attachTo(context);
            // NKE_Dialog.attachTo(context);
            // NKE_IpcMain.attachTo(context);
            // NKE_Menu.attachTo(context);
            // NKE_Protocol.attachTo(context);
        }
        public NKE_BrowserWindow(Dictionary<string, object> options)
        {
            _thread_id = (int)startupOptions["NKS.MainThreadId"];
            syncContext = new TaskFactory((TaskScheduler)startupOptions["NKS.MainThreadScheduler"]);

            _id = NKScriptContextFactory.sequenceNumber++;

            if (options == null)
                options = new Dictionary<string, object>();

            windowArray[_id] = this;
            try
            {
                _webContents = new NKE_WebContents(this);
                var _ = ensureOnUIThread(createBrowserWindow, options);
             }
            catch (Exception ex)
            {
                NKLogging.log("!Error Creating Window" + ex.Message);
                NKLogging.log(ex.StackTrace);
            }
            events.on<int>("NKE.DidFinishLoad", (e, id) =>
            {
                this.getNKScriptValue().invokeMethod("emit", new[] { "did-finish-load" });
            });
   
        }
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    if (_webContents != null)
                    {
                        _webContents.Dispose();
                        _webContents = null;
                    }
                }

                this.getNKScriptValue().Dispose();

                disposedValue = true;
            }
        }