Beispiel #1
0
        public static bool Open(Dictionary <string, object> args)
        {
            try
            {
                if (args.ContainsKey("app"))
                {
                    var app = args["app"] as string;
                    //ANNND now we start reflecting...
                    foreach (var asmExec in System.IO.Directory.GetFiles(Environment.CurrentDirectory))
                    {
                        if (asmExec.EndsWith(".exe") || asmExec.EndsWith(".dll"))
                        {
                            var asm = Assembly.LoadFile(asmExec);

                            foreach (var type in asm.GetTypes())
                            {
                                if (type.BaseType == typeof(UserControl))
                                {
                                    foreach (var attr in type.GetCustomAttributes(false))
                                    {
                                        if (attr is WinOpenAttribute)
                                        {
                                            if (app == (attr as WinOpenAttribute).ID)
                                            {
                                                if (SaveSystem.CurrentSave.Upgrades.ContainsKey(app))
                                                {
                                                    if (Shiftorium.UpgradeInstalled(app))
                                                    {
                                                        IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow;
                                                        AppearanceManager.SetupWindow(frm);
                                                        return(true);
                                                    }
                                                    else
                                                    {
                                                        throw new Exception($"{app} was not found on your system! Try looking in the shiftorium...");
                                                    }
                                                }
                                                else
                                                {
                                                    IShiftOSWindow frm = Activator.CreateInstance(type) as IShiftOSWindow;
                                                    AppearanceManager.SetupWindow(frm);
                                                    return(true);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Please specify a valid 'app' param.");
                    return(true);
                }
                Console.WriteLine("Couldn't find the specified app on your system.");
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error running script:" + ex);
                return(false);
            }
        }
Beispiel #2
0
 public override void Invoke(Dictionary <string, object> args)
 {
     AppearanceManager.SetupWindow((IShiftOSWindow)Activator.CreateInstance(ShiftOSWindow, null));
 }