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);
 }
Ejemplo n.º 2
0
        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);
            }));
        }
Ejemplo n.º 3
0
 public string expandEnvVars(ScriptScopeContext scope, string path) =>
 scope.DoWindow(w => NativeWin.ExpandEnvVars(path));
Ejemplo n.º 4
0
 public int messageBox(ScriptScopeContext scope, string text, string caption, uint type) =>
 scope.DoWindow(w => NativeWin.MessageBox(0, text, caption, type));
Ejemplo n.º 5
0
 public bool setClipboard(ScriptScopeContext scope, string data) =>
 scope.DoWindow(w => NativeWin.SetStringInClipboard(data));
Ejemplo n.º 6
0
 public string clipboard(ScriptScopeContext scope) =>
 scope.DoWindow(w => NativeWin.GetClipboardAsString());
Ejemplo n.º 7
0
 public long findWindowByName(ScriptScopeContext scope, string name) =>
 scope.DoWindow(w => (long)NativeWin.FindWindowByName(name));
Ejemplo n.º 8
0
 public Dictionary <string, object> deviceScreenResolution(ScriptScopeContext scope) =>
 scope.DoWindow(w => NativeWin.ToObject(NativeWin.GetScreenResolution()));
Ejemplo n.º 9
0
 public Dictionary <string, string> desktopInfo(ScriptScopeContext scope) =>
 scope.DoWindow(w => NativeWin.GetDesktopInfo());
Ejemplo n.º 10
0
 public bool start(ScriptScopeContext scope, string cmd) =>
 scope.DoWindow(w => NativeWin.Open(cmd));
Ejemplo n.º 11
0
 public bool openUrl(ScriptScopeContext scope, string url) =>
 scope.DoWindow(w => NativeWin.Open(new Uri(resolveUrl(scope, url)).ToString()));