aboutsummaryrefslogtreecommitdiff
path: root/ShiftOS_TheReturn/TerminalBackend.cs
diff options
context:
space:
mode:
authorMichael <[email protected]>2017-06-16 21:10:13 -0400
committerMichael <[email protected]>2017-06-16 21:10:13 -0400
commit764cdc940f9362485e177ec3a011faff77745bc0 (patch)
treea1b1a1a1f27521772da171ff455d5b3828ecf866 /ShiftOS_TheReturn/TerminalBackend.cs
parent79fe2101aef62b744b150203dee6953b0d17f5aa (diff)
downloadshiftos_thereturn-764cdc940f9362485e177ec3a011faff77745bc0.tar.gz
shiftos_thereturn-764cdc940f9362485e177ec3a011faff77745bc0.tar.bz2
shiftos_thereturn-764cdc940f9362485e177ec3a011faff77745bc0.zip
programs are treated as commands
Diffstat (limited to 'ShiftOS_TheReturn/TerminalBackend.cs')
-rw-r--r--ShiftOS_TheReturn/TerminalBackend.cs36
1 files changed, 35 insertions, 1 deletions
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<string, object> args)
+ public virtual void Invoke(Dictionary<string, object> args)
{
List<string> errors = new List<string>();
bool requiresAuth = false;
@@ -237,6 +237,19 @@ namespace ShiftOS.Engine
}
}
+ public class WinOpenCommand : TerminalCommand
+ {
+ public Type ShiftOSWindow { get; set; }
+
+
+ public override void Invoke(Dictionary<string, object> 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<TerminalCommand>();
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<string>();
+ 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);