예제 #1
0
 public override void DrawControl(bool selected)
 {
     Console.Write(Name + " ");
     ConsoleColorHelper.Write("[", ConsoleColor.Cyan);
     ConsoleColorHelper.Write(Value ? "X" : " ", ConsoleColor.Yellow);
     ConsoleColorHelper.WriteLine("]", ConsoleColor.Cyan);
 }
예제 #2
0
        public static void Run(string?name, FileInfo?path, string?arguments, bool?admin, bool?allUsers)
        {
            if (name == null || (path == null || !path.Exists) || arguments == null || admin == null || allUsers == null)
            {
                var steps = GetWizardSteps(name, path, arguments, admin, allUsers);
                steps = ConsoleStepWizard.UserWizard("Let's guide you through settings up a new startup program", steps);
                System.Console.WriteLine();

                var startupProgram = ParseUserInfo(steps, name, path, arguments, admin, allUsers);
                ValidateInformationWithUser(startupProgram);
                System.Console.WriteLine();
                ConsoleColorHelper.ConsoleWriteColored(ConsoleColor.Green, "Does this look correct? y/n: ");

                var correct = ConsoleStepWizard.PromptUserForBool("y", "n", "Does this look correct? y/n: ");
                if (correct)
                {
                    ExecuteHandler(startupProgram);
                }
                else
                {
                    System.Console.WriteLine("Sorry to hear that, please try again");
                }
            }
            else
            {
                var startupProgram = ParseUserInfo(new List <ConsoleStep>(), name, path, arguments, admin, allUsers);
                ExecuteHandler(startupProgram);
            }
        }
        /// <summary>
        /// Asks the AI for a guess.
        /// </summary>
        /// <param name="combinations">Combinations left.</param>
        /// <param name="code">Secret code that user came up with.</param>
        private void AskAI(List <string> combinations, string code)
        {
            computerRound++;

            if (computerRound == timeLimit)
            {
                Console.WriteLine(DynamicConsoleTexts.GetComputerLostInformation(computerRound, code));
                Console.ReadKey();
                DisplayStartingWindow();
            }

            Tuple <List <string>, string> answer = AI.PlayWithAI(combinations, code);

            Console.Beep();
            Console.Clear();
            Console.WriteLine(StaticConsoleTexts.ComputerAnswer);

            foreach (char color in answer.Item2.ToCharArray())
            {
                ConsoleColorHelper.WriteColor(color);
            }

            Console.WriteLine($"\n{StaticConsoleTexts.IsCorrect}");

            foreach (char color in code.ToCharArray())
            {
                ConsoleColorHelper.WriteColor(color);
            }

            AskUserIfTheAnswerIsCorrect(answer, code);
        }
예제 #4
0
 public override void DrawControl(bool selected)
 {
     Console.Write(Name + " ");
     ConsoleColorHelper.Write("/ ", ConsoleColor.Cyan);
     ConsoleColorHelper.Write(SelectedItem, ConsoleColor.Yellow);
     ConsoleColorHelper.Write(" /", ConsoleColor.Cyan);
     Console.WriteLine();
 }
예제 #5
0
 private static void ValidateInformationWithUser(StartupProgram data)
 {
     Console.Write($"{NameId}: ");
     ConsoleColorHelper.ConsoleWriteLineColored(ConsoleColor.Green, $"{data.Name}");
     Console.Write($"{PathId}: ");
     ConsoleColorHelper.ConsoleWriteLineColored(ConsoleColor.Green, $"{data.File}");
     Console.Write($"{ArgumentsId}: ");
     ConsoleColorHelper.ConsoleWriteLineColored(ConsoleColor.Green, $"{data.Arguments}");
     Console.Write($"{AdministratorId}: ");
     ConsoleColorHelper.ConsoleWriteLineColored(ConsoleColor.Green, $"{data.Administrator}");
     Console.Write($"{AllUserId}: ");
     ConsoleColorHelper.ConsoleWriteLineColored(ConsoleColor.Green, $"{data.AllUsers}");
 }
        /// <summary>
        /// Generate colorful rectangles instead of plain characters.
        /// </summary>
        /// <param name="rounds">List of all rounds that have been played.</param>
        private void GenerateGameBoard(List <Round> rounds)
        {
            foreach (Round round in rounds)
            {
                if (gameType == GameType.Colors)
                {
                    foreach (char color in round.Input)
                    {
                        ConsoleColorHelper.WriteColor(color);
                    }
                }
                else
                {
                    foreach (char numeral in round.Input)
                    {
                        Console.Write(numeral);
                    }
                }

                Console.Write(" ");
                int emptyCounter = 0;

                foreach (char tip in round.Output)
                {
                    if (tip != Answers.WRONG_GUESS)
                    {
                        ConsoleColorHelper.WriteColor(tip);
                    }
                    else
                    {
                        emptyCounter++;
                    }
                }

                for (int i = 0; i < emptyCounter; i++)
                {
                    ConsoleColorHelper.WriteColor(Answers.WRONG_GUESS);
                }

                Console.Write(GetStatus(round.Output) + "\n");
            }
        }
        private static void DisplayIssue(Issue issue, IConsole console, int indentLevel)
        {
            console.WriteIndent(indentLevel);
            console.Write($"#{issue.Number} ", ConsoleColor.DarkGreen);
            console.Write(issue.Title);
            console.Write($" @{issue.User.Login}", ConsoleColor.DarkMagenta);

            console.Write(" ");
            foreach (var issueLabel in issue.Labels)
            {
                var labelColors = ConsoleColorHelper.FromHex(issueLabel.Color);
                console.BackgroundColor = labelColors.BackgroundCololr;
                console.ForegroundColor = labelColors.ForegroundColor;
                console.Write($"{issueLabel.Name}");
                console.ResetColor();

                console.Write(" ");
            }

            console.WriteLine();
        }
예제 #8
0
 public override void DrawControl(bool selected)
 {
     ConsoleColorHelper.WriteLine(Name, ConsoleColor.Cyan);
 }
예제 #9
0
        public async Task <int> OnExecuteAsync(IConsole console)
        {
            try
            {
                var(issue, repositoryInfo) = await GetIssueAsync(Issue);

                // Open the issue in the browser
                if (Browser)
                {
                    _browserService.OpenBrowser(issue.HtmlUrl);
                }
                else
                {
                    console.Write(issue.Title);
                    console.Write($" ({repositoryInfo.Owner.Login}/{repositoryInfo.Name}#{issue.Number})", ConsoleColor.Yellow);
                    console.WriteLine();
                    console.WriteLine();

                    console.WriteLine(issue.Body);
                    console.WriteLine();

                    if (issue.Labels != null && issue.Labels.Count > 0)
                    {
                        foreach (var issueLabel in issue.Labels)
                        {
                            var labelColors = ConsoleColorHelper.FromHex(issueLabel.Color);
                            console.BackgroundColor = labelColors.BackgroundCololr;
                            console.ForegroundColor = labelColors.ForegroundColor;
                            console.Write($"{issueLabel.Name}");
                            console.ResetColor();

                            console.Write(" ");
                        }
                        console.WriteLine();
                        console.WriteLine();
                    }

                    console.Write("Opened by: ");
                    console.Write(issue.User.Login, ConsoleColor.Blue);
                    console.WriteLine();

                    console.Write("Status: ");
                    console.Write($"{issue.State.Value}", ConsoleColor.Blue);
                    if (issue.State.Value == ItemState.Closed && issue.ClosedAt.HasValue)
                    {
                        console.Write(" by ");
                        console.Write(issue.ClosedBy.Login, ConsoleColor.Blue);
                        console.Write(" on ");
                        console.Write(issue.ClosedAt.Value.ToString("d"), ConsoleColor.Blue);
                    }
                    console.WriteLine();

                    if (issue.State.Value == ItemState.Open)
                    {
                        console.Write("Assigned to: ");
                        if (issue.Assignees == null || issue.Assignees.Count == 0)
                        {
                            console.Write("UNASSIGNED", ConsoleColor.Blue);
                        }
                        else
                        {
                            console.Write(string.Join(", ", issue.Assignees.Select(a => a.Login)), ConsoleColor.Blue);
                        }
                        console.WriteLine();
                    }
                }
            }
            catch (CommandValidationException ex)
            {
                _reporter.Error(ex.Message);

                return(1);
            }

            return(0);
        }