Beispiel #1
0
        void LoadApplications()
        {
            wtc.WriteWhiteLine("[Apps] Scanning for Applications");
            logger.Debug("Scanning for Applications in " + appDir);

            ICollection<string> directories = Directory.GetDirectories(appDir);

            if(directories.Count < 1)
            {
                wtc.WriteYellowLine("[WARNING] 0 applications discovered in " + appDir);
                wtc.WriteRedLine("[WARNING] Installer needs applications in order to function");
                wtc.WriteWhiteLine("Please check INI file for correct Application Directory. To create a new Application go to the Application Menu from Main");
                logger.Warn("0 Applications found in " + appDir);
            }
            else
            {
                foreach(string d in directories)
                {
                    logger.Debug("Trying to load " + d + " into Applications");
                    if(!File.Exists(d + "\\settings.ini"))
                    {
                        logger.Warn("Unable to find settings.ini in folder " + d);
                        logger.Error("Application will not be loaded into active set");
                    }
                    else
                    {
                        INI.IniFile ini = new INI.IniFile(d + "\\settings.ini");
                        try
                        {
                            Application.Application app = new Application.Application(ini.Section("AppInfo").Get("Name"), d + "\\settings.ini");
                            Application.ApplicationCollection.AddApplication(app);
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex.Message);
                            throw;
                        }
                    }

                }
            }
        }
Beispiel #2
0
        public static void Settings(Application.Application application)
        {
            Application.Application app = application;
            main = application;
            wtc.WriteYellow("settings");
            wtc.WriteWhite("[");
            wtc.WriteGreen(app.Name);
            wtc.WriteWhite("]");
            wtc.WriteBlue(">");
            wtc.WriteWhite(" ");
            string[] input = Console.ReadLine().ToLower().Trim().Split(' ');
            while (input[0] != "back" && input[0] != "return")
            {
                switch (input[0])
                {
                    case "help":
                        if (input.Length > 1)
                            SettingsHelp(input);
                        else
                            SettingsHelp();
                        break;
                    case "?":
                        if (input.Length > 1)
                            SettingsHelp(input);
                        else
                            SettingsHelp();
                        break;
                    case "clear":
                        Console.Clear();
                        break;
                    case "list":
                        SettingsList(input);
                        break;
                    case "switch":
                        app = SettingsSwitch(app, input);
                        break;
                    case "display":
                        SettingsDisplay(app);
                        break;
                    case "edit":
                        SettingsEdit(app);
                        break;
                    case "modify":
                        SettingsModify(app, input);
                        break;
                    case "back":
                        break;
                    case "return":
                        break;
                    default:
                        wtc.WriteRedLine("[ERROR] Unrecognized command");
                        break;
                }

                wtc.WriteYellow("settings");
                wtc.WriteWhite("[");
                wtc.WriteGreen(app.Name);
                wtc.WriteWhite("]");
                wtc.WriteBlue(">");
                wtc.WriteWhite(" ");
                input = Console.ReadLine().ToLower().Trim().Split(' ');
            }
        }
Beispiel #3
0
        private static Application.Application SettingsSwitch(Application.Application app, string[] input)
        {
            //reconstruct the input array
            string appName = "";
            for (int i = 1; i < input.Length; i++)
            {
                appName += input[i] + " ";
            }
            //Remove last space we added with reconstruction method
            appName = appName.Remove(appName.Length - 1, 1);
            try
            {
                foreach (Application.Application p in ApplicationCollection.GetApplications())
                {

                    if (p.Name.ToLower().Trim() == appName)
                    {
                        return p;
                    }
                }

                return app;
            }
            catch (Exception ex)
            {
                wtc.WriteRed("[ERROR] " + ex.Message);
                return app;
            }
        }
Beispiel #4
0
 private static void SettingsModify(Application.Application application, string[] input)
 {
     if(input.Length < 4)
     {
         wtc.WriteRed("[ERROR] Bad Syntax for Modify Command; Type ");
         wtc.WriteWhite("Help Modify ");
         wtc.WriteRedLine("For examples");
     }
     else
     {
         application.ChangeINI(input);
     }
 }
Beispiel #5
0
 private static void SettingsEdit(Application.Application app)
 {
     Process.Start(app.IniPath);
 }
Beispiel #6
0
 private static void SettingsDisplay(Application.Application application)
 {
     application.ReadINI();
 }
Beispiel #7
0
 public static void RemoveApplication(Application app)
 {
     applications.Remove(app);
 }
Beispiel #8
0
 public static void AddApplication(Application app)
 {
     applications.Add(app);
 }
Beispiel #9
0
        void Run()
        {
            //Main entry pint
            Console.WriteLine("[STARTUP] Installer is starting up...");

            //Call Startup to initialze our application;
            Startup();
            Application.Application main = new Application.Application("main", iniPath);
            Application.ApplicationCollection.AddApplication(main);
            LoadApplications();
            wtc.WriteGreenLine("Startup Complete, launching into main menu");

            if (bClearBeforeMenu)
                Console.Clear();

            bool running = true;

            wtc.WriteWhiteLine("======================");
            wtc.WriteWhiteLine("= Installer v0.0.0.1 =");
            wtc.WriteWhiteLine("======================");

            do
            {
                wtc.WriteBlue(">");
                wtc.WriteWhite(" ");
                string input = Console.ReadLine().ToLower().Trim();

                //receives user input, switch off of it;
                switch (input)
                {
                    case "help":
                        Menu.Help();
                        break;
                    case "?":
                        Menu.Help();
                        break;
                    case "clear":
                        Console.Clear();
                        break;
                    case "application":
                    case "applications":
                        Menu.Applications();
                        break;
                    case "setting":
                    case "settings":
                        Menu.Settings(main);
                        break;
                    case "quit":
                    case "q":
                    case "exit":
                    case "x":
                        logger.Debug("Exiting due to user input");
                        running = false;
                        break;
                    default:
                        Menu.Help();
                        break;
                }
            }
            while (running);
            {
            }
        }