From 764cdc940f9362485e177ec3a011faff77745bc0 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 16 Jun 2017 21:10:13 -0400 Subject: programs are treated as commands --- ShiftOS_TheReturn/TerminalBackend.cs | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'ShiftOS_TheReturn/TerminalBackend.cs') diff --git a/ShiftOS_TheReturn/TerminalBackend.cs b/ShiftOS_TheReturn/TerminalBackend.cs index 4594eb3..1ca31e0 100644 --- a/ShiftOS_TheReturn/TerminalBackend.cs +++ b/ShiftOS_TheReturn/TerminalBackend.cs @@ -180,7 +180,7 @@ namespace ShiftOS.Engine public bool RequiresElevation { get; set; } - public void Invoke(Dictionary args) + public virtual void Invoke(Dictionary args) { List errors = new List(); bool requiresAuth = false; @@ -237,6 +237,19 @@ namespace ShiftOS.Engine } } + public class WinOpenCommand : TerminalCommand + { + public Type ShiftOSWindow { get; set; } + + + public override void Invoke(Dictionary args) + { + AppearanceManager.SetupWindow((IShiftOSWindow)Activator.CreateInstance(ShiftOSWindow, null)); + } + + + } + public class MemoryTextWriter : System.IO.TextWriter { public override Encoding Encoding @@ -294,6 +307,27 @@ namespace ShiftOS.Engine Commands = new List(); foreach (var type in ReflectMan.Types) { + if (type.GetInterfaces().Contains(typeof(IShiftOSWindow))) + { + var winopenattrib = type.GetCustomAttributes(false).FirstOrDefault(x => x is WinOpenAttribute) as WinOpenAttribute; + if(winopenattrib != null) + { + var winc = new WinOpenCommand(); + winc.CommandType = type; + var rupg = type.GetCustomAttributes().FirstOrDefault(x => x is RequiresUpgradeAttribute) as RequiresUpgradeAttribute; + if (rupg != null) + winc.Dependencies = rupg.Upgrade; + winc.CommandInfo = new Engine.Command(winopenattrib.ID, "", "Opens the \"" + winopenattrib.ID + " program."); + winc.RequiredArguments = new List(); + winc.RequiresElevation = false; + winc.ShiftOSWindow = type; + + var ambiguity = Commands.FirstOrDefault(x => x.CommandInfo.name == winc.CommandInfo.name); + if (ambiguity != null) + throw new Exception("Ambiguity error. The program " + winc.CommandInfo.name + " collides with another program or terminal command with the same name. Please either change the already-existing program/command, or change this one's WinOpenAttribute value to compensate."); + Commands.Add(winc); + } + } foreach (var mth in type.GetMethods(BindingFlags.Public | BindingFlags.Static)) { var cmd = mth.GetCustomAttributes(false).FirstOrDefault(x => x is Command); -- cgit v1.2.3