Beispiel #1
0
        public string CopyFile(string source, string dest)
        {
            if (!File.Exists(source))
            {
                ConsoleHandler.append_Force("Unable to copy plugin. Source plugin does not exist");
                return("");
            }

            if (File.Exists(dest))
            {
                FileInfo f        = new FileInfo(dest);
                string   filename = f.Name;
                string   fileExt  = f.Extension;
                string   destDir  = dest.Replace(filename, "");

                int i = 1;
                while (File.Exists(dest))
                {
                    dest = destDir + filename.Replace(fileExt, "") + " - Copy " + i + fileExt;
                    i++;
                }
            }
            File.Copy(source, dest);
            return(dest);
        }
Beispiel #2
0
        private Int32 Run()
        {
            if (!this.TryParse())
            {
                this.ShowHelp();
                return(-1);
            }

            this.ApplyLogger();

            if (this.arguments.IsHelp)
            {
                this.ShowHelp();
                return(0);
            }

            if (this.arguments.IsVersion)
            {
                this.ShowVersion();
                return(0);
            }

            if (this.arguments.IsSettings)
            {
                this.ShowSettings();
                return(0);
            }

            this.handler = new ConsoleHandler(this.logger);
            this.handler.ConsoleEvent += this.OnHandlerConsoleEvent;

            // Track command line arguments.
            this.logger.Verbose(
                MethodBase.GetCurrentMethod(),
                this.arguments.ToString());

            try
            {
                this.arguments.ValidateSourceOrThrow();
                this.arguments.ValidateTargetOrThrow();
            }
            catch (Exception exception)
            {
                this.logger.Critical(
                    MethodBase.GetCurrentMethod(),
                    exception);

                this.HitAnyKey();
                return(-1);
            }

            this.HitAnyKey();

            this.Process();

            this.HitAnyKey();

            return(0);
        }
Beispiel #3
0
    public static void Main()
    {
        Clock          theClock = new Clock();
        ConsoleHandler dc       = new ConsoleHandler();

        dc.Register(theClock);
        theClock.Run();
    }
Beispiel #4
0
 private static void RegisterHandlers()
 {
     _handler = new CompanyAddHandler(_unityContainer);
     _handler.Add(new CompanyEditHandler(_unityContainer));
     _handler.Add(new CompanyListingHandler(_unityContainer));
     _handler.Add(new CompanySearchHandler(_unityContainer));
     _handler.Add(new CompanyDeleteHandler(_unityContainer));
 }
Beispiel #5
0
 private void BloonTypesToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Console.getInstance().Visible == false)
     {
         Console.getInstance().Visible = true;
     }
     ConsoleHandler.append("BLOON TYPES:\n>> Red:  0\n>> Blue:  1\n>> Green:  2\n>> Yellow:  3\n>> Pink:  4\n>> Black:  5\n>> White:  6\n>> Lead:  7\n>> Zebra:  8\n>> Rainbow:  9\n>> Ceramic:  10\n>> MOAB:  11\n>> BFB:  12\n>> ZOMG:  13");
 }
Beispiel #6
0
        static void Main(string[] args)
        {
            ConsoleHandler consoleHandler = new ConsoleHandler();
            PhoneBook      phoneBook      = new PhoneBook();
            MenuList       menuList       = new MenuList();

            menuList.Menu();
        }
Beispiel #7
0
        public ConsoleHandlerTest()
        {
            _consoleMock = new Mock <IConsole>();
            _dateRange   = new ConsoleHandler(_consoleMock.Object);

            Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture("pl-PL");
            Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture("pl-PL");
        }
Beispiel #8
0
        static void Main(string[] args)
        {
            //Logger Log = new Logger("../../../Log.txt");

            IDisplayHandler displayHandler = new ConsoleHandler();

            displayHandler.DisplayMenu();
        }
        static void Main( string[] args )
        {
            ConsoleHandler handler = new ConsoleHandler( 80, 30 );

            SnakeGame snake = new SnakeGame( handler );
            snake.Start();

            Console.ReadKey();
        }
        public override void WriteErrorLine(string value)
        {
            string       output      = value ?? "null";
            ConsoleColor origFgColor = ConsoleHandler.ForegroundColor;

            ConsoleHandler.ForegroundColor = ConsoleColor.Red;
            ConsoleHandler.WriteLine(output);
            ConsoleHandler.ForegroundColor = origFgColor;
        }
Beispiel #11
0
        public static void GetAnnouncement()
        {
            WebHandler web    = new WebHandler();
            string     url    = "https://raw.githubusercontent.com/TDToolbox/BTDToolbox-2019_LiveFIles/master/toolbox%20announcements";
            string     answer = web.WaitOn_URL(url);


            ConsoleHandler.append(answer);
        }
Beispiel #12
0
        private int CountStartingCards()
        {
            numStarterCards = 0;
            string cardPath  = CurrentProjectVariables.PathToProjectFiles + "\\Assets\\JSON\\BattleCardDefinitions";
            var    cardFiles = Directory.GetFiles(cardPath);

            string[] cards_length2 = new string[0];
            string[] cards_length3 = new string[0];

            foreach (var item in cardFiles)
            {
                if (!item.Contains("CacheList"))
                {
                    json = File.ReadAllText(item);
                    if (JSON_Reader.IsValidJson(json))
                    {
                        newCard = new Card();
                        newCard = Card.FromJson(json);
                        if (newCard.StartingCard)
                        {
                            numStarterCards++;
                            string[] split    = item.Split('\\');
                            string   filename = split[split.Length - 1].Replace("\\", "");

                            if (filename.Replace(".json", "").Length == 1)
                            {
                                Array.Resize(ref startingCards_array, startingCards_array.Length + 1);
                                startingCards_array[startingCards_array.Length - 1] = filename;
                            }
                            else if (filename.Replace(".json", "").Length == 2)
                            {
                                Array.Resize(ref cards_length2, cards_length2.Length + 1);
                                cards_length2[cards_length2.Length - 1] = filename;
                            }
                            else if (filename.Replace(".json", "").Length == 3)
                            {
                                Array.Resize(ref cards_length3, cards_length3.Length + 1);
                                cards_length3[cards_length3.Length - 1] = filename;
                            }
                        }
                    }
                    else
                    {
                        ConsoleHandler.append_Force_CanRepeat(item + "  has invalid JSON");
                    }
                }
            }
            //organize cards in numeric order
            int startingCards_arraySize = startingCards_array.Length;

            Array.Resize(ref startingCards_array, startingCards_array.Length + cards_length2.Length + cards_length3.Length);
            Array.Copy(cards_length2, 0, startingCards_array, startingCards_arraySize, cards_length2.Length);
            Array.Copy(cards_length3, 0, startingCards_array, startingCards_arraySize + cards_length2.Length, cards_length3.Length);

            TotalStartingCards_Label.Text = "Total starting cards : " + numStarterCards;
            return(numStarterCards);
        }
Beispiel #13
0
        protected override void BeforeRun()
        {
            fs = new CosmosVFS();
            VFSManager.RegisterVFS(fs);
            Console.Clear();
            if (!File.Exists(main_part + "AirOS.cfg"))
            {
                Setup.StartSetup.Step1();
            }
            else
            {
                if (File.Exists(main_part + "lang.cfg"))
                {
                    string lang = File.ReadAllText(main_part + "lang.cfg");
                    if (lang == "de")
                    {
                        SetKeyboardScanMap(new DE_Standard());
                    }
                    else if (lang == "us")
                    {
                        SetKeyboardScanMap(new US_Standard());
                    }
                }
                Console.Write("Enter Username: "******":");
                if (loguser == newuser[0])
                {
                    Console.Write("Enter Password: "******"Welcome Back {0}", newuser[0]);

                        /*         Network.NetworkInit.Init();
                         *       Network.NetworkInit.Enable();
                         *       System.Utilities.WaitSeconds(1);
                         *       Network.NetworkInterfaces.Init();
                         *       System.Utilities.WaitSeconds(3);*/
                        return;
                    }
                    else
                    {
                        System.Utilities.ErrorScreen("0x101", "Your Login Details are incorrect!", 5, true);
                    }
                }
                else
                {
                    System.Utilities.ErrorScreen("0x101", "Your Login Details are incorrect!", 5, true);
                }
            }
        }
Beispiel #14
0
        public static ProjectClass.ProjectFile ReadProject(string projFile)
        {
            if (project != null)
            {
                CurrentProjectVariables.ResetProjectVariables();
            }

            if (project == null)
            {
                project = new ProjectClass.ProjectFile();
            }

            if (!File.Exists(projFile))
            {
                ConsoleHandler.append("Something went wrong when trying to read the" +
                                      "project. Project not found...");
                return(null);

                //Create new project
                //CreateProject();  //Commented out until im sure this is what needs to happen next
            }

            if (!IsProjectVald(projFile))
            {
                return(null);
            }

            string json = File.ReadAllText(projFile);

            project = JsonConvert.DeserializeObject <ProjectClass.ProjectFile>(json);

            CurrentProjectVariables.ProjectName            = project.ProjectName.Replace("\\", "");
            CurrentProjectVariables.PathToProjectFiles     = project.PathToProjectFiles.Replace("\\\\", "\\");
            CurrentProjectVariables.PathToProjectClassFile = project.PathToProjectClassFile.Replace("\\\\", "\\");
            CurrentProjectVariables.GameName              = project.GameName;
            CurrentProjectVariables.GamePath              = project.GamePath.Replace("\\\\", "\\");
            CurrentProjectVariables.GameVersion           = project.GameVersion;
            CurrentProjectVariables.JetPassword           = project.JetPassword;
            CurrentProjectVariables.ExportPath            = project.ExportPath;
            CurrentProjectVariables.DateLastOpened        = project.DateLastOpened;
            CurrentProjectVariables.JsonEditor_OpenedTabs = project.JsonEditor_OpenedTabs;
            CurrentProjectVariables.ModifiedFiles         = project.ModifiedFiles;

            CurrentProjectVariables.UseNKHook       = false;
            CurrentProjectVariables.DontAskAboutNKH = false;
            if (CurrentProjectVariables.GameName == "BTD5")
            {
                if (NKHook.DoesNkhExist())
                {
                    CurrentProjectVariables.UseNKHook       = project.UseNKHook;
                    CurrentProjectVariables.DontAskAboutNKH = project.DontAskAboutNKH;
                }
            }

            return(project);
        }
Beispiel #15
0
        private void SaveSpecialty(string path, SpecialtyBuildingClass specialty)
        {
            ConsoleHandler.append("Saving specialty building");
            string text = specialty.ToJson();

            StreamWriter serialize = new StreamWriter(path, false);

            serialize.Write(text);
            serialize.Close();
        }
 /// <summary>
 /// Отличается от стандартного метода Console тем, что если передаваемый объект не IConvertible, то он будет сериализирован в json строку.
 /// </summary>
 public void Write(object objToWrite, ConsoleColor?cc = null, bool prettyJson = false)
 {
     ConsoleHandler.Write(
         JsonSerializeHelper.Inst.ToConvertibleOrJson(objToWrite, new JsonSerializeOptions()
     {
         WithNormalFormating = prettyJson
     }),
         cc
         );
 }
Beispiel #17
0
        private void SaveTowerDef(string path, Tower_Class.Tower tower)
        {
            ConsoleHandler.append("Saving TowerDefiniton");
            string text = tower.ToJson();

            StreamWriter serialize = new StreamWriter(path, false);

            serialize.Write(text);
            serialize.Close();
        }
Beispiel #18
0
        private void SaveTowerSpriteDef(string path, TowerSpriteUpgrade towerSprite)
        {
            ConsoleHandler.append("Saving TowerSpriteUpgrade file");
            string text = towerSprite.ToJson();

            StreamWriter serialize = new StreamWriter(path, false);

            serialize.Write(text);
            serialize.Close();
        }
Beispiel #19
0
 private void EZ_Base_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.F5)
     {
         SaveFile();
         ConsoleHandler.append_CanRepeat("Saved " + Files_ComboBox.SelectedItem.ToString());
         GeneralMethods.CompileJet("launch");
         ConsoleHandler.append_CanRepeat("Launching " + game);
     }
 }
Beispiel #20
0
 public static void OpenTutorial(string tutorialName)
 {
     if (tutorials == null)
     {
         ConsoleHandler.append("Tutorial list is null. Unable to open tutorial");
         return;
     }
     ConsoleHandler.append("Opening tutorial:  " + tutorialName);
     Browser browser = new Browser(Main.getInstance(), tutorials[tutorialName]);
 }
Beispiel #21
0
        private void SaveUpgradesFile(UpgradesFile upgrades, string savePath)
        {
            ConsoleHandler.append("Saving UpgradeDefinition file");
            string text = upgrades.ToJson();

            StreamWriter serialize = new StreamWriter(savePath, false);

            serialize.Write(text);
            serialize.Close();
        }
Beispiel #22
0
        private void CreateTutorialsFile()
        {
            ConsoleHandler.append("Creating new tutorials list");
            if (File.Exists(tutorialFilePath))
            {
                File.Delete(tutorialFilePath);
            }

            File.Create(tutorialFilePath).Close();
        }
Beispiel #23
0
 public static void SaveZipFile(ZipFile zip)
 {
     try
     {
         zip.Password = CurrentProjectVariables.JetPassword;
         zip.Save();
         zip.Dispose();
     }
     catch (Exception e) { ConsoleHandler.append_CanRepeat("SaveZipFile Exception: " + e.Message); }
 }
Beispiel #24
0
 public static void LaunchNKH()
 {
     if(!DoesNkhExist())
     {
         ConsoleHandler.append("Unable to find NKHook5-Injector.exe. Failed to launch...");
         return;
     }
     ConsoleHandler.append("Launching NKHook");
     Process.Start(nkhEXE);
 }
Beispiel #25
0
 public void OnClientDisconnect(IClient client)
 {
     PingHandler.Disconnect(client);
     RegistryEditorHandler.Disconnect(client);
     FileExplorerHandler.Disconnect(client);
     TaskManagerHandler.Disconnect(client);
     ConsoleHandler.Disconnect(client);
     ClipboardHandler.Disconnect(client);
     StartupManagerhandler.Disconnect(client);
     ConnectionsHandler.Disconnect(client);
 }
        private static void Main()
        {
            const string address       = @"https://localhost:44391/api/";
            var          consoleOutput = new ConsoleOutput();

            CommandLineHandler handler = BuildHandler(address, consoleOutput);

            var console = new ConsoleHandler(handler, consoleOutput);

            console.Run();
        }
Beispiel #27
0
        public void AddToTowerSelctionMenu()
        {
            string towerSelFilePath = TowerSelectFiles[TowerSelPos];

            if (!File.Exists(towerSelFilePath))
            {
                ConsoleHandler.append_Force("Unable to find the Tower Selection file!");
                return;
            }

            string text = CheckJSONFromFile(towerSelFilePath);

            if (!Guard.IsStringValid(text))
            {
                FileInfo file = new FileInfo(towerSelFilePath);
                ConsoleHandler.append_Force("The Tower Select File  " + file.Name + "  has has invalid text/JSON. Unable to add tower to TowerSelectionMenu");
                return;
            }

            ConsoleHandler.append("Creating new tower entry in TowerSelectionMenu");
            TowerSelectionMenu menu    = TowerSelectionMenu.FromJson(text);
            TowerSelectItem    newItem = new TowerSelectItem();
            bool foundBaseTower        = false;

            if (UseBaseTower)
            {
                newItem = TowerSelMenu_DupBaseTower();
                if (!Guard.IsStringValid(newItem.ToString()))
                {
                    foundBaseTower = false;
                    ConsoleHandler.append("Unable to find chosen base tower in tower selection menu files. Using blank values instead.");
                }
                else
                {
                    foundBaseTower = true;
                }
            }

            if (!UseBaseTower || !foundBaseTower)
            {
                newItem = TowerSelMenu_EmptyTower(newItem);
            }

            if (newItem == null)
            {
                return;
            }
            if (menu == null)
            {
                return;
            }

            AddTowerToSelMenu(newItem, menu);
        }
Beispiel #28
0
 private void RefreshStartCards_LB()
 {
     startingCards_array = new string[0];
     if (CountStartingCards() < 15)
     {
         ConsoleHandler.force_append_Notice("ERROR! You need at least 15 starter cards or the game will crash!");
         this.Focus();
     }
     StartingCards_LB.Items.Clear();
     StartingCards_LB.Items.AddRange(startingCards_array);
 }
Beispiel #29
0
 private void Calc_NumOfRounds_button_Click(object sender, EventArgs e)
 {
     if (Editor_TextBox.TextLength > 0)
     {
         NumOfRounds_Label.Text = "Num of rounds: " + Count("new RoundDef()", Editor_TextBox.Text);
     }
     else
     {
         ConsoleHandler.append("You need to input code before you can calculate the number of rounds...");
     }
 }
        public BenchmarkClassicExecutor(Benchmark benchmark, IBenchmarkLogger logger)
        {
            this.benchmark = benchmark;
            this.logger = logger;

            if (consoleHandler == null)
            {
                consoleHandler = new ConsoleHandler(logger);
                Console.CancelKeyPress += consoleHandler.EventHandler;
            }
        }
        public override void Write(ConsoleColor foregroundColor, ConsoleColor backgroundColor, string value)
        {
            ConsoleColor origFgColor = ConsoleHandler.ForegroundColor;
            ConsoleColor origBgColor = ConsoleHandler.BackgroundColor;

            ConsoleHandler.ForegroundColor = foregroundColor;
            ConsoleHandler.BackgroundColor = backgroundColor;
            ConsoleHandler.Write(value ?? "null");
            ConsoleHandler.ForegroundColor = origFgColor;
            ConsoleHandler.BackgroundColor = origBgColor;
        }
Beispiel #32
0
        private static void Main()
        {
            using (var container = GetContainer())
            {
                var printer        = new ConsoleBoardPrinter();
                var consoleHandler = new ConsoleHandler(printer);
                var game           = container.Resolve <Func <IUiHandler, IGame> >()(consoleHandler);

                game.Start();
            }
        }
 public void Execute(ConsoleHandler consoleHandler)
 {
     consoleHandler.AddCommand("cd", "<directory>", "change the working directory", consoleHandler.ChangeDirectory, 1);
     consoleHandler.AddCommand("help", null, "prints the help menu", consoleHandler.PrintHelp);
     consoleHandler.AddCommand("clear", null, "clears the console", consoleHandler.ClearConsole);
     consoleHandler.AddCommand("print", "<path to file>", "prints a file to the console", consoleHandler.PrintFile, 1);
     consoleHandler.AddCommand("cp", "<source> <destination>", "copy a file or a directory", consoleHandler.CopyFile, 2);
     consoleHandler.AddCommand("echo", "<strings with colour codes and variables>", "print a formatted string", consoleHandler.Echo, -1);
     consoleHandler.AddCommand("ps", null, "print a list of running processes", consoleHandler.ProcessList);
     consoleHandler.AddCommand("kill", "<PID or name of executable>", "terminate a process", consoleHandler.KillProcess, 1);
     consoleHandler.AddCommand("ls", "<path>", "list the contents of a directory", consoleHandler.ListDirectoryContents, -1);
     consoleHandler.AddCommand("mkdir", "<path>", "create a directory", consoleHandler.CreateDirectory, 1);
     consoleHandler.AddCommand("mv", "<source> <destination>", "move a file/directory", consoleHandler.MoveFile, 2);
     consoleHandler.AddCommand("pwd", null, "print the working directory", consoleHandler.PrintWorkingDirectory);
     consoleHandler.AddCommand("rm", "<files/directories to be removed>", "remove files or directories recursively", consoleHandler.RemoveFile, -1);
     consoleHandler.AddCommand("osinfo", null, "retrieve information about the operating system", consoleHandler.OperatingSystemInformation);
     consoleHandler.AddCommand("alias", "<aliased command and arguments>", "defines an alias for a command", consoleHandler.DefineAlias, -1);
     consoleHandler.AddCommand("unalias", "<alias>", "removes an existing alias", consoleHandler.RemoveAlias, 1);
     consoleHandler.AddCommand("aliases", null, "print a list of the aliases available", consoleHandler.ListAliases);
 }
        public ExecuteResult Execute(BuildResult buildResult, Benchmark benchmark, ILogger logger, IDiagnoser compositeDiagnoser = null)
        {
            if (consoleHandler == null)
            {
                consoleHandler = new ConsoleHandler(logger);
                Console.CancelKeyPress += consoleHandler.EventHandler;
            }

            var exeName = Path.Combine(buildResult.DirectoryPath, "Program.exe");
            var args = string.Empty;

            if (File.Exists(exeName))
            {
                try
                {
                    var startInfo = CreateStartInfo(benchmark, exeName, args);
                    using (var process = Process.Start(startInfo))
                    {
                        if (process != null)
                        {
                            if (compositeDiagnoser != null)
                                compositeDiagnoser.ProcessStarted(process);

                            consoleHandler.SetProcess(process);
                            var result = ExecuteImpl(process, exeName, benchmark, logger, compositeDiagnoser);

                            if (compositeDiagnoser != null)
                                compositeDiagnoser.ProcessStopped(process);

                            return result;
                        }
                    }
                }
                finally
                {
                    consoleHandler?.ClearProcess();
                }
            }
            return new ExecuteResult(false, new string[0]);
        }
        private ExecuteResult Execute(Benchmark benchmark, ILogger logger, string exeName, string workingDirectory, string args, IDiagnoser diagnoser)
        {
            if (consoleHandler == null)
            {
                consoleHandler = new ConsoleHandler(logger);
                Console.CancelKeyPress += consoleHandler.EventHandler;
            }

            try
            {
                using (var process = new Process { StartInfo = CreateStartInfo(benchmark, exeName, args, workingDirectory) })
                {
                    var loggerWithDiagnoser = new SynchronousProcessOutputLoggerWithDiagnoser(logger, process, diagnoser, benchmark);

                    return Execute(process, benchmark, loggerWithDiagnoser, diagnoser, logger);
                }
            }
            finally
            {
                consoleHandler.ClearProcess();
            }
        }