public static IntPtr RequestWindowFactory(ScriptScopeContext scope) { if (scope.TryGetValue(ScriptConstants.Request, out var oRequest) && oRequest is IRequest req) { var info = req.GetHeader("X-Desktop-Info"); if (info != null) { NativeWin.SetDesktopInfo(info.FromJsv <Dictionary <string, string> >()); } var handle = req.GetHeader("X-Window-Handle"); if (handle != null && long.TryParse(handle, out var lHandle)) { return((IntPtr)lHandle); } } return(IntPtr.Zero); }
public void BeforePluginsLoaded(IAppHost appHost) { appHost.Config.EmbeddedResourceBaseTypes.Add(typeof(DesktopAssets)); appHost.ScriptContext.ScriptMethods.Add(new DesktopScripts( scope => { if (scope.TryGetValue(ScriptConstants.Request, out var oRequest) && oRequest is IRequest req) { var info = req.GetHeader("X-Desktop-Info"); if (info != null) { NativeWin.SetDesktopInfo(info.FromJsv <Dictionary <string, string> >()); } var handle = req.GetHeader("X-Window-Handle"); if (handle != null && long.TryParse(handle, out var lHandle)) { return((IntPtr)lHandle); } } return(IntPtr.Zero); })); }
public string expandEnvVars(ScriptScopeContext scope, string path) => scope.DoWindow(w => NativeWin.ExpandEnvVars(path));
public int messageBox(ScriptScopeContext scope, string text, string caption, uint type) => scope.DoWindow(w => NativeWin.MessageBox(0, text, caption, type));
public bool setClipboard(ScriptScopeContext scope, string data) => scope.DoWindow(w => NativeWin.SetStringInClipboard(data));
public string clipboard(ScriptScopeContext scope) => scope.DoWindow(w => NativeWin.GetClipboardAsString());
public long findWindowByName(ScriptScopeContext scope, string name) => scope.DoWindow(w => (long)NativeWin.FindWindowByName(name));
public Dictionary <string, object> deviceScreenResolution(ScriptScopeContext scope) => scope.DoWindow(w => NativeWin.ToObject(NativeWin.GetScreenResolution()));
public Dictionary <string, string> desktopInfo(ScriptScopeContext scope) => scope.DoWindow(w => NativeWin.GetDesktopInfo());
public bool start(ScriptScopeContext scope, string cmd) => scope.DoWindow(w => NativeWin.Open(cmd));
public bool openUrl(ScriptScopeContext scope, string url) => scope.DoWindow(w => NativeWin.Open(new Uri(resolveUrl(scope, url)).ToString()));