static async void MainAsync() { //init WindowMgr windowmgr = new WindowMgr(); await windowmgr.Init(); //当GUI全关闭时,让这个进程也退出 windowmgr.onAllWindowClose += () => bexit = true; //create window WindowCreateOption op = new WindowCreateOption(); op.title = "hello world"; var window = await WindowRemote.Create(windowmgr, op); //eval var time = DateTime.Now.ToString(); await window.Remote_Eval("document.body.innerHTML='hello world<hr/>" + time + "'"); }
static async void MainAsync() { //init WindowMgr windowmgr = new WindowMgr(); await windowmgr.Init(); //当GUI全关闭时,让这个进程也退出 windowmgr.onAllWindowClose += () => bexit = true; //create window WindowCreateOption op = new WindowCreateOption(); op.title = "workwithhtml"; var window = await WindowRemote.Create(windowmgr, op); var file = System.IO.Path.GetFullPath("html/mypage.html"); file = file.Replace("\\", "/"); //eval sethtmlbody //file = ""; var html = @"<iframe src = '" + file + "' style='width: 100%; height: 100%; border: 0px'></iframe>"; var evalstr = "document.body.innerHTML=\"" + html + "\";"; var v = await window.Remote_Eval(evalstr); ////eval bindevent //var bindjs = @" var btn = document.getElementById('btn'); // btn.onclick = function () { // var txt = document.getElementById('textbox'); // __api.sendback(['click', txt.value]); // };"; ////use __api.sendback([]) to send a json array to dotnet core. //await window.Remote_Eval(bindjs); //watch event window.OnSendBack += (args) => { Console.WriteLine("recv:" + args.ToString()); }; }
static async void MainAsync() { //init WindowMgr windowmgr = new WindowMgr(); await windowmgr.Init(); //当GUI全关闭时,让这个进程也退出 windowmgr.onAllWindowClose += () => bexit = true; //create window WindowCreateOption op = new WindowCreateOption(); op.title = "sendback"; var window = await WindowRemote.Create(windowmgr, op); //eval sethtmlbody var html = @" <span>input text here</span> <input id = 'textbox' type = 'text'></input> <button id = 'btn'> click me </button>"; await window.Remote_Eval("document.body.innerHTML=\"" + html + "\""); //eval bindevent var bindjs = @" var btn = document.getElementById('btn'); btn.onclick = function () { var txt = document.getElementById('textbox'); __api.sendback(['click', txt.value]); };"; //use __api.sendback([]) to send a json array to dotnet core. await window.Remote_Eval(bindjs); //watch event window.OnSendBack += (args) => { Console.WriteLine("recv:" + args.ToString()); }; }
static async void MainAsync() { //init WindowMgr windowmgr = new WindowMgr(); await windowmgr.Init(); //当GUI全关闭时,让这个进程也退出 windowmgr.onAllWindowClose += () => bexit = true; //create window WindowCreateOption op = new WindowCreateOption(); op.title = "workwithfiles"; var window = await WindowRemote.Create(windowmgr, op); var file = System.IO.Path.GetFullPath("files/tmx.png"); file = file.Replace("\\", "/"); //eval sethtmlbody //file = ""; var html = @"<span>image here</span><image src = '" + file + "'></image>"; var evalstr = "document.body.innerHTML=\"" + html + "\";"; var v = await window.Remote_Eval(evalstr); }