Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ConsoleMenu mainMenu = new ConsoleMenu(
                new ConsoleMenuItem[]
            {
                new ConsoleMenuItem()
                {
                    Key = "1", Description = "Print hello world", Visible = true
                },
                new ConsoleMenuItem()
                {
                    Key = "2", Description = "Print goodbye world", Visible = true
                },
                new ConsoleMenuItem()
                {
                    Key = "3", Description = "Exit from menu", Visible = true
                }
            }
                );

            mainMenu.NextMenuItemKey     = ConsoleKey.DownArrow;
            mainMenu.PreviousMenuItemKey = ConsoleKey.UpArrow;
            mainMenu.SelectMenuItemKey   = ConsoleKey.Enter;

            mainMenu.Display();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            try
            {
                var pipeline1 = new MicroservicePipeline("AzureStorageTest1");
                var pipeline2 = new MicroservicePipeline("AzureStorageTest2");
                var mainMenu  = new ConsoleMenu("Azure Storage DataCollector validation");

                pipeline1
                .ConfigurationSetFromConsoleArgs(args)
                .AddEncryptionHandlerAes("myid", Convert.FromBase64String("hNCV1t5sA/xQgDkHeuXYhrSu8kF72p9H436nQoLDC28="), keySize: 256)
                //.AddAzureStorageDataCollector(handler:"myid")
                ;


                mainMenu.AddMicroservicePipeline(pipeline1);
                mainMenu.AddMicroservicePipeline(pipeline2);

                mainMenu.AddOption("Aruba", (m, o) => pipeline1.Service.DataCollection.LogException(new Exception()));

                mainMenu.Show();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
Exemplo n.º 3
0
        public override Program.DisplayState QueryForAdditionalParameterInInteractiveMode()
        {
            string input = null;

            customService.Clear();
            do
            {
                ConsoleMenu.Title       = "Enter additional Service Name to check";
                ConsoleMenu.Information = @"This scanner enumerate all well known services attributed to remote desktop solutions.
You can enter additional service to check. Enter them one by one and complete with an empty line.
Use the name provided in the service list. Example: Enter 'TeamViewer5' for the service 'TeamViewer version 5'.
Or just press enter to use the default.";
                input = ConsoleMenu.AskForString();
                if (!String.IsNullOrEmpty(input))
                {
                    if (!customService.Contains(input))
                    {
                        customService.Add(input);
                    }
                }
                else
                {
                    break;
                }
            } while (true);
            return(base.QueryForAdditionalParameterInInteractiveMode());
        }
Exemplo n.º 4
0
        public virtual Program.DisplayState QueryForAdditionalParameterInInteractiveMode()
        {
            var choices = new List <ConsoleMenuItem>()
            {
                new ConsoleMenuItem("all", "This is a domain. Scan all computers."),
                new ConsoleMenuItem("one", "This is a computer. Scan only this computer."),
                new ConsoleMenuItem("workstation", "Scan all computers except servers."),
                new ConsoleMenuItem("server", "Scan all servers."),
                new ConsoleMenuItem("domaincontrollers", "Scan all domain controllers."),
                new ConsoleMenuItem("file", "Import items from a file (one computer per line)."),
            };

            ConsoleMenu.Title       = "Select the scanning mode";
            ConsoleMenu.Information = "This scanner can collect all the active computers from a domain and scan them one by one automatically. Or scan only one computer";
            int choice = ConsoleMenu.SelectMenu(choices);

            if (choice == 0)
            {
                return(Program.DisplayState.Exit);
            }
            ScanningMode = choice;
            if (choice == 6)
            {
                return(Program.DisplayState.AskForFile);
            }
            return(Program.DisplayState.AskForServer);
        }
Exemplo n.º 5
0
        public void MainMenu()
        {
            string[] itemsMenu = { "Сгенерировать массив", "Ввести массив", "Отсортировать", "Выход" };

            bool end = false;

            while (!end)
            {
                string headline = $"Массив: {ArrayToString(Program.Array)}\n" +
                                  $"Упорядоченный по возрастанию массив: {ArrayToString(Program.SortArray)}\n" +
                                  $"Упорядоченный по убыванию массив: {ArrayToString(Program.ReversSortArray)}";
                int choice = ConsoleMenu.Show(headline, itemsMenu);

                try
                {
                    switch (choice)
                    {
                    case 0: RandomArray(); break;

                    case 1: KeyboardArray(); break;

                    case 2: SortArray(); break;

                    case 3: end = true; break;
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.ReadKey();
                }
            }
        }
Exemplo n.º 6
0
        public override bool QueryForAdditionalParameterInInteractiveMode()
        {
            string input = null;

            customService.Clear();
            do
            {
                ConsoleMenu.Title       = "Enter additional Service Name to check";
                ConsoleMenu.Information = @"This scanner enumerate all well known services attributed to antivirus suppliers.
You can enter additional service to check. Enter them one by one and complete with an empty line.
Use the name provided in the service list. Example: Enter 'SepMasterService' for the service 'Symantec Endpoint Protection'.
Or just press enter to use the default.";
                input = ConsoleMenu.AskForString();
                if (!String.IsNullOrEmpty(input))
                {
                    if (!customService.Contains(input))
                    {
                        customService.Add(input);
                    }
                }
                else
                {
                    break;
                }
            } while (true);
            return(base.QueryForAdditionalParameterInInteractiveMode());
        }
Exemplo n.º 7
0
        public MainMenuScreen(int width, int height)
        {
            background = new Background {
                BackgroundColor = ConsoleColor.DarkBlue, Width = width, MinHeight = height
            };
            menu = new ConsoleMenu("JUKE - Main Menu",
                                   new ConsoleMenuItem {
                ID = "Library", Label = "Show library"
            },
                                   new ConsoleMenuItem {
                ID = "Queue", Label = "Show queue"
            },
                                   new ConsoleMenuItem {
                ID = "Player", Label = "Show player"
            },
                                   new ConsoleMenuItem {
                ID = ScreenName.Admin.ToString(), Label = "Admin controls"
            },
                                   new ConsoleMenuItem {
                ID = "Quit", Label = "Quit"
            }
                                   )
            {
                Width           = width / 3,
                Left            = width / 2, Top = 0,
                BackgroundColor = ConsoleColor.Black,
                ForegroundColor = ConsoleColor.White,
                SelectedColor   = ConsoleColor.Green
            };

            menu.InstanceItemSelected += MenuOnItemSelected;

            Width     = width;
            MinHeight = height;
        }
Exemplo n.º 8
0
        public override void Display()
        {
            ConsoleMenu.Intro();
            base.Display();

            string gin = Input.ReadString("Enter the Gin combination: ");

            if (string.IsNullOrWhiteSpace(gin))
            {
                Output.WriteLine(ConsoleColor.Red, "Invalid Gin string given.");
                Input.ReadString("Press [Enter] to navigate home");
                Program.NavigateTo <MainMenu>();
            }

            string tonic = Input.ReadString("Enter the Tonic combination: ");

            if (string.IsNullOrWhiteSpace(tonic))
            {
                Output.WriteLine(ConsoleColor.Red, "Invalid Tonic string given.");
                Input.ReadString("Press [Enter] to navigate home");
                Program.NavigateTo <MainMenu>();
            }

            string garnish = Input.ReadString("Enter the Garnish combination: ");

            if (string.IsNullOrWhiteSpace(garnish))
            {
                Output.WriteLine(ConsoleColor.Red, "Invalid Garnish string given.");
                Input.ReadString("Press [Enter] to navigate home");
                Program.NavigateTo <MainMenu>();
            }

            string comment = Input.ReadString("Enter a comment for the combination: ");

            if (string.IsNullOrWhiteSpace(comment))
            {
                Output.WriteLine(ConsoleColor.Red, "Invalid Comment string given.");
                Input.ReadString("Press [Enter] to navigate home");
                Program.NavigateTo <MainMenu>();
            }

            int rating = Input.ReadInt("Enter a rating for the combination between 1-5: ", 1, 5);

            (Combination, Rating)combination = Operations.CreateCombination(gin, tonic, garnish, comment, rating);
            if (combination.Item1 != null && combination.Item2 != null)
            {
                Output.WriteLine(ConsoleColor.Green, "\n-------------------------------------------------------");
                Output.WriteLine(ConsoleColor.Green, "Added The Following into the database: ");
                Output.WriteLine(ConsoleColor.Green, combination.Item1.ToString());
                Output.WriteLine(ConsoleColor.Green, combination.Item2.ToString());
                Output.WriteLine(ConsoleColor.Green, "-------------------------------------------------------");
            }
            else
            {
                Output.WriteLine(ConsoleColor.Red, "Failed to create Combination. May already exist");
            }

            Input.ReadString("Press [Enter] to navigate home");
            Program.NavigateTo <MainMenu>();
        }
Exemplo n.º 9
0
        static void Main(string[] args)
        {
            ConsoleMenu menu    = new ConsoleMenu();
            ConsoleMenu subMenu = new ConsoleMenu();

            subMenu.AddCommand("Do nothing", (sm) =>
            {
                Console.WriteLine("nothing done");
                Console.ReadKey();
            });
            subMenu.AddCommand("Do something else", (sm) =>
            {
                Console.WriteLine("still not doing jack shit");
                Console.ReadKey();
            });
            menu.AddSubMenu("Action 1: submenu", subMenu);
            menu.AddCommand("You may prefer action 2", (m) =>
            {
                Console.WriteLine("Action 2 Called");
                Console.ReadKey();
            });
            menu.AddCommand("Exit", (m) =>
            {
                m.Exit();
            });

            // navigate the menu with arrow keys and select with enter or use number as shortcut
            menu.Show();
        }
Exemplo n.º 10
0
        public static void Edit()
        {
            bool exited = false;

            while (categories.Count > 0 && !exited)
            {
                ConsoleMenu menu = new ConsoleMenu();
                menu.Add("*Back*", () => exited = true);

                foreach (Categories c in categories)
                {
                    menu.Add(c.Name, () => EditCategory(c));
                }

                menu.Configure(c =>
                {
                    c.EnableFilter      = true;
                    c.FilterPrompt      = "\nSearch for category: ";
                    c.WriteHeaderAction = () => Console.WriteLine($"Select a category to edit\n");
                    c.Selector          = "--> ";
                    c.RunOnce           = true;
                })
                .Show();
            }
        }
Exemplo n.º 11
0
        private static ConsoleMenu AnimalsInCategory(Categories c, ConsoleMenu ret = null, Action <int> action = null)
        {
            List <Guid> cleanUp = new List <Guid>();

            ListCategories(categories.IndexOf(c));
            c.Animals.ForEach(x =>
            {
                Animals s = AnimalManager.animals.Find(a => a.ID.Equals(x));
                if (s != null)
                {
                    if (ret != null)
                    {
                        ret.Add(s.ToString(), () => action(c.Animals.IndexOf(x)));
                    }
                    else
                    {
                        Console.WriteLine($"-- {c.Animals.IndexOf(x)}) {s}");
                    }
                }
                else
                {
                    cleanUp.Add(x);
                }
            }
                              );

            cleanUp.ForEach(x => c.Animals.Remove(x));
            if (cleanUp.Any())
            {
                Utils.Save();
            }
            return(ret);
        }
Exemplo n.º 12
0
        public static void Run()
        {
            DataStorageHandler.SaveChanges();
            Console.Clear();
            string prompt = "Welkom bij de Bioscoop";

            string[]    options     = { "Login", "Registreren", "Zaal bekijken" };
            ConsoleMenu StartPagina = new ConsoleMenu(prompt, options);

            StartPagina.DisplayOptions();
            int selectedIndex = StartPagina.Run();

            if (options[selectedIndex] == "Login")
            {
                LoginPage.Login();
            }
            else if (options[selectedIndex] == "Registreren")
            {
                LoginPage.Registreren();
            }
            else if (options[selectedIndex] == "Zaal bekijken")
            {
                ReservationPage.Run();
            }
        }
        static void Main(string[] args)
        {
            Database.UpdateDataset();
            Console.Clear();
            ConsoleMenu menu       = new ConsoleMenu();
            string      headerText = "  ____                              _                   _____                  _     " +
                                     Environment.NewLine + " / __ \\                            | |                 / ____|                | |    " +
                                     Environment.NewLine + "| |  | |  _   _    __ _   _ __     | |       _   _    | (___     __ _    ___  | |__  " +
                                     Environment.NewLine + "| |  | | | | | |  / _` | | '_ \\    | |      | | | |    \\___ \\   / _` |  / __| | '_ \\ " +
                                     Environment.NewLine + "| |__| | | |_| | | (_| | | | | |   | |____  | |_| |    ____) | | (_| | | (__  | | | |" +
                                     Environment.NewLine + " \\___\\_\\  \\__,_|  \\__,_| |_| |_|   |______|  \\__, |   |_____/   \\__,_|  \\___| |_| |_|" +
                                     Environment.NewLine + "                                              __/ |                                  " +
                                     Environment.NewLine + "                                             |___/                                   ";

            menu.Header   = headerText;
            menu.SubTitle = "\n-----------------------------------MENU---------------------------------------";
            menu.addMenuItem(1, "Them sach", Interface.addBook);
            menu.addMenuItem(2, "Xem tat ca sach", Interface.showAllBooks);
            menu.addMenuItem(3, "Tim kiem sach", Interface.findBook);
            menu.addMenuItem(4, "Sua thong tin sach", Interface.modifyBook);
            menu.addMenuItem(5, "Xoa sach", Interface.deleteBook);
            menu.addMenuItem(0, "Thoat", Program.exit);
            menu.showMenu();
            Console.ReadKey();
        }
Exemplo n.º 14
0
        // Recursive function that renders a ConsoleMenu. Since Render() is an infinite loop
        // you never exit this recursive menu.
        static void Loop()
        {
            rec++;
            ConsoleMenu cm = new ConsoleMenu();

            cm.greeting = "Welcome to the ConsoleMenu demo! (layer " + rec + ")";
            cm.items    = new ConsoleMenuItem[] {
                new ConsoleMenuItem {
                    key         = ToCKI(ConsoleKey.D1, '1'),
                    execute     = new Action(Act),
                    description = "Do something"
                },
                new ConsoleMenuItem {
                    key         = ToCKI(ConsoleKey.D2, '2'),
                    execute     = new Action(DoNothing),
                    description = "Do nothing"
                },
                ConsoleMenuItem.separator,
                new ConsoleMenuItem {
                    key         = ToCKI(ConsoleKey.D3, '3'),
                    execute     = new Action(Loop),
                    description = "Define recursion"
                }
            };
            cm.Render();
            return;
        }
Exemplo n.º 15
0
        static void Main(string[] args)
        {
            string headerText = "  __  __                     _____           _                 " +
                                Environment.NewLine + " |  \\/  |                   / ____|         | |                " +
                                Environment.NewLine + " | \\  / | ___ _ __  _   _  | (___  _   _ ___| |_ ___ _ __ ___" +
                                Environment.NewLine + " | |\\/| |/ _ \\ '_ \\| | | |  \\___ \\| | | / __| __/ _ \\ '_ ` _ \\" +
                                Environment.NewLine + " | |  | |  __/ | | | |_| |  ____) | |_| \\__ \\ ||  __/ | | | | |" +
                                Environment.NewLine + " |_|  |_|\\___|_| |_|\\__,_| |_____/ \\__, |___/\\__\\___|_| |_| |_|" +
                                Environment.NewLine + "                                    __/ |    " +
                                Environment.NewLine + "                                   |___/             ";


            Console.Clear();

            // Setup the menu
            ConsoleMenu mainMenu = new ConsoleMenu();

            ConsoleMenu subMenu1 = new ConsoleMenu("==>");

            subMenu1.SubTitle = "---------------- Secret Menu -----------------";
            subMenu1.addMenuItem(0, "backToMain", subMenu1.hideMenu);
            subMenu1.ParentMenu = mainMenu;

            mainMenu.Header = headerText;
            subMenu1.Header = mainMenu.Header;

            mainMenu.SubTitle = "-------------------- Menu ----------------------";
            mainMenu.addMenuItem(0, "Hello World!", HelloWorld);
            mainMenu.addMenuItem(1, "Secret Menu", subMenu1.showMenu);
            mainMenu.addMenuItem(2, "Exit", Exit);
            // Display the menu
            mainMenu.showMenu();
        }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            var config = ManualConfig.CreateEmpty()
                         .With(JitOptimizationsValidator.DontFailOnError)
                         .With(ConsoleLogger.Default)
                         .With(MemoryDiagnoser.Default)
                         .With(EnvironmentAnalyser.Default)
                         .With(BenchmarkDotNet.Columns.DefaultColumnProviders.Instance);

            var menu = new ConsoleMenu();

            var testTypes = CollectTypes();

            menu.Add("All", () => RunBenchmark(testTypes, config));

            foreach (var type in testTypes.OrderBy(t => t.FullName))
            {
                menu.Add(TestName(type), () => RunBenchmark(type, config));
            }

            menu.Add("Exit", ConsoleMenu.Close);

            menu.Configure(menuConfig =>
            {
                menuConfig.ItemForegroundColor         = ConsoleColor.White;
                menuConfig.SelectedItemForegroundColor = ConsoleColor.Green;
                menuConfig.ClearConsole = true;
            }
                           );

            menu.Show();
        }
Exemplo n.º 17
0
        private void RunBenchmarkDotNetTests(string[] args, IConfig config)
        {
            var benchmarkClasses = FindClassesWithMethodAttribute();

            config = config ?? DefaultConfig;

            var menu = new ConsoleMenu(args, level: 1);

            menu.Add("All tests", () =>
            {
                var benchmarks = benchmarkClasses.Select(c => BenchmarkConverter.TypeToBenchmarks(c, config)).ToArray();
                BenchmarkDotNet.Running.BenchmarkRunner.Run(benchmarks);
                Environment.Exit(0);
            });
            foreach (var benchmarkClass in benchmarkClasses)
            {
                menu.Add(benchmarkClass.Name, () =>
                {
                    BenchmarkDotNet.Running.BenchmarkRunner.Run(benchmarkClass, config);
                    Environment.Exit(0);
                });
            }
            menu.Add("Exit", ConsoleMenu.Close);
            menu.Configure(conf => { conf.EnableFilter = true; conf.WriteHeaderAction = () => { Console.WriteLine(this.header); }; });
            menu.Show();
        }
Exemplo n.º 18
0
        private static Task Main()
        {
            var done = false;

            while (!done)
            {
                Console.Clear();
                var items = new List <ConsoleMenuItem>();
                AddMenuItems(items);
                //Exit
                items.AddRange(new List <ConsoleMenuItem>
                {
                    //Exit
                    new ConsoleMenuSeparator(),
                    new ConsoleMenuItem <string>("Exit", _ =>
                    {
                        done = true;
                    }, null)
                });
                var menu = new ConsoleMenu("Test ConsoleTools stuff", items);
                menu.RunConsoleMenu();
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 19
0
        public SongBrowserOverlay(Screen parent, IList <Song> songs) : base(parent)
        {
            this.songs = songs;

            var background = new Background
            {
                BackgroundColor = ConsoleColor.Black,
                ForegroundColor = ConsoleColor.Green,
                Top             = 0,
                Left            = 0,
                MinHeight       = Console.WindowHeight,
                Width           = Console.WindowWidth
            };

            var items = new List <ConsoleMenuItem>();

            foreach (var song in songs)
            {
                items.Add(new ConsoleMenuItem {
                    ID = song.Name, Label = song.Name
                });
            }

            menu = new ConsoleMenu("Songs", items.ToArray());
            menu.InstanceItemSelected += MenuOnInstanceItemSelected;

            AddComponent(background);
            AddComponent(menu);
        }
Exemplo n.º 20
0
        static void Main(string[] args)
        {
            const string BaseAddress = "http://localhost:18018";
            var          config      = new HttpSelfHostConfiguration(BaseAddress);
            var          container   = new WindsorContainer();

            ConfigDi(container);
            config.DependencyResolver = new WindsorDependencyResolver(container);

            config.Routes.MapHttpRoute(
                "API Collection", "api/{controller}s",
                new { id = RouteParameter.Optional });

            config.Routes.MapHttpRoute(
                "API Default", "api/{controller}/{id}",
                new { id = RouteParameter.Optional });

            var server = new HttpSelfHostServer(config);

            server.OpenAsync().ConfigureAwait(false).GetAwaiter().GetResult();
            var client = new HttpClient(
                new CachingHandler()
            {
                InnerHandler = new HttpClientHandler()
            });

            client.BaseAddress = new Uri(BaseAddress);

            var menu = new ConsoleMenu(client);

            menu.Menu().ConfigureAwait(false).GetAwaiter().GetResult();
        }
Exemplo n.º 21
0
        //private NextLifecycle _gridUpdate; //BoardGame in iteration #2

        public GOLEngine()
        {
            _display   = new Displayer();
            _gameBoard = new BoardGame();
            //_gridUpdate = new NextLifecycle();
            _menu = new ConsoleMenu();
        }
Exemplo n.º 22
0
        static void Main(string[] args)
        {
            ConsoleMenu cm = new ConsoleMenu();

            cm.greeting = "Welcome to the ConsoleMenu demo!";
            cm.items    = new ConsoleMenuItem[] {
                new ConsoleMenuItem {
                    key         = ToCKI(ConsoleKey.D1, '1'),
                    execute     = new Action(Act),
                    description = "Do something"
                },
                new ConsoleMenuItem {
                    key         = ToCKI(ConsoleKey.D2, '2'),
                    execute     = new Action(DoNothing),
                    description = "Do nothing"
                },
                ConsoleMenuItem.separator,
                new ConsoleMenuItem {
                    key         = ToCKI(ConsoleKey.D3, '3'),
                    execute     = new Action(Loop),
                    description = "Define recursion"
                }
            };
            cm.Render();
        }
Exemplo n.º 23
0
        private static void TestConsoleMenu()
        {
            var running = true;
            var menu    = new ConsoleMenu(ConsoleMenuType.StringInput, 1, 1, 3);

            menu.MenuOptions.Add(new ConsoleMenuOption("Do something", () => Console.WriteLine("This is the first option")));
            menu.MenuOptions.Add(new ConsoleMenuOption("Do something else", () => Console.WriteLine("This is the second option")));
            menu.MenuOptions.Add(new ConsoleMenuOption("Do something 3", () => Console.WriteLine("This is the third option")));
            menu.MenuOptions.Add(new ConsoleMenuOption("Exit", () => running = false));

            while (running)
            {
                menu.RenderMenu();
                menu.WaitForResult();
                Console.WriteLine();
                Console.WriteLine();

                //if (menu.ConsoleMenuType == ConsoleMenuType.KeyPress)
                //{
                //    menu.ConsoleMenuType = ConsoleMenuType.StringInput;
                //}
                //else
                //{
                //    menu.ConsoleMenuType = ConsoleMenuType.KeyPress;
                //}
            }
        }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            MyListInt myListInt = new MyListInt();

            string[] itemsMenu = { "Добавить элемент",                         "Удалить элемент",                          "Показать",
                                   "Найти сумму всех положительных элементов", "Найти сумму всех отрицательных элементов", "Выход" };
            bool     end = false;

            do
            {
                int choice = ConsoleMenu.Show(itemsMenu);

                switch (choice)
                {
                case 0: AddItem(myListInt); break;

                case 1: RemoveItem(myListInt); break;

                case 2: ShowItems(myListInt); break;

                case 3: SumAllPlus(myListInt); break;

                case 4: SumAllMinus(myListInt); break;

                case 5: end = true; break;
                }
            } while (!end);
        }
Exemplo n.º 25
0
 public bool Print(ConsoleMenu consoleMenu)
 {
     Console.Clear();
     Console.WriteLine("Print");
     Console.ReadKey();
     return(true);
 }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            // Ask for Capacity
            ConsoleMenu Menuclass = new ConsoleMenu();

            Menuclass.WriteMeny();
        }
Exemplo n.º 27
0
        public void SimpleScenario()
        {
            const string input   = @"2
";
            var          console = new TestConsole(input);

            var menu = new ConsoleMenu()
            {
                console = console
            }
            .Add("One", () => { })
            .Add("Two", () => { })
            .Add("Close", ConsoleMenu.Close)
            .Add("Exit", () => Environment.Exit(0))
            .Configure(m =>
            {
                m.SelectedItemBackgroundColor = console.ForegroundColor;
                m.SelectedItemForegroundColor = console.BackgroundColor;
                m.ItemBackgroundColor         = console.BackgroundColor;
                m.ItemForegroundColor         = console.ForegroundColor;
                m.WriteHeaderAction           = () => console.WriteLine("Pick an option:");
                m.WriteItemAction             = item => console.Write("[{0}] {1}", item.Index, item.Name);
            });

            menu.Show();

            Assert.Equal(@"Pick an option:
   [0] One
   [1] Two
>> [2] Close
   [3] Exit

", console.ToString());
        }
Exemplo n.º 28
0
        /// <summary>
        /// The entry point of the program, where the program control starts and ends.
        /// </summary>
        /// <param name="args">string[]</param>
        public static void Main(string[] args)
        {
            //TODO: Implement DH logic
            //TODO: Implement double round robin
            //TODO: Refactor TeamGroupTree into Composite-Leaf pattern
            //TODO: Implement full season (162 games)

            ConfigurationManager.Init(Constants.CONFIG_FILE_PATH, Constants.CONFIG_FILE_DELIMITER);
            StoredProcedureManager.Init(ConfigurationManager.GetConfigurationValue("STORED_PROCEDURES_DIRECTORY"));
            VenueManager.Init(ConfigurationManager.GetConfigurationValue("STADIUM_FILE_DIRECTORY"), true);
            SABRMetricsManager.Init(ConfigurationManager.GetConfigurationValue("SABRMETRICS_DIRECTORY"), true);

            ConsoleMenu menu             = new ConsoleMenu(ConfigurationManager.GetConfigurationValue("TITLE"), true);
            MenuChoice  chooseTeam       = new MenuChoice(ViewTeamInformation.Display, "View Team", true);
            MenuChoice  chooseLeague     = new MenuChoice(ViewLeagueInformation.Display, "View League", true);
            MenuChoice  playRoundRobin   = new MenuChoice(PlayRoundRobin.SelectYear, "Play Round Robin!", true);
            MenuChoice  playSeries       = new MenuChoice(PlaySeries.SetUpSeries, "Play Series", true);
            MenuChoice  playWorldSeries  = new MenuChoice(PlayChampionshipSeries.SelectWorldSeries, "Replay Championship Series", true);
            MenuChoice  cleanGamesFolder = new MenuChoice(CleanGamesFolder.LoadCleanGamesFolder, "Clean Games Folder", true);
            MenuChoice  exit             = new MenuChoice(ProgramExit.Exit, "Exit", true);

            menu.AddItem(chooseTeam);
            menu.AddItem(chooseLeague);
            menu.AddItem(playRoundRobin);
            menu.AddItem(playSeries);
            menu.AddItem(playWorldSeries);
            menu.AddItem(cleanGamesFolder);
            menu.AddItem(exit);
            menu.Run();
        }
Exemplo n.º 29
0
        public override void Display()
        {
            ConsoleMenu.Intro();
            base.Display();

            Globals.Username = Input.ReadString("Enter your Username: "******"The Username {0} does not exist.", Globals.Username);
            }

            if (didLogIn)
            {
                Program.NavigateTo <MainMenu>();
            }
            else
            {
                Input.ReadString("Press [Enter] to navigate home");
                Program.NavigateHome();
            }
        }
Exemplo n.º 30
0
        public void Run()
        {
            Console.Write("Input a date: ");
            var userInput = Console.ReadLine();

            dt = DateTime.MinValue;
            if (DateTime.TryParse(userInput, out dt))
            {
                var actions = new Dictionary <String, Action>();
                actions["Add Days"]        = AddDays;
                actions["Add Months"]      = AddMonths;
                actions["Add Years"]       = AddYears;
                actions["Subtract Days"]   = SubtractDays;
                actions["Subtract Months"] = SubtractMonths;
                actions["Subtract Years"]  = SubtractYears;
                actions["Get Day of Week"] = GetDayOfWeek;
                //
                var menu = new ConsoleMenu(
                    actions,
                    "Select one of the next options:",
                    "Verify your last action!",
                    "0");
                //
                menu.Run();
            }
            else
            {
                Console.WriteLine("You typed an invalid date.");
            }
        }
Exemplo n.º 31
0
        static void Main(string[] args)
        {
            var menu = new ConsoleMenu<Smartphones>(Console.OpenStandardOutput(), Console.OpenStandardInput())
                           {
                               Header = "Please select a Smartphone:"
                           };

            menu.ShowMenu();

            Console.WriteLine();
            Console.WriteLine("Your selection: " + menu.SelectedMenuEntry.ToString().Replace("_", " "));
            Console.WriteLine();

            Console.ReadKey();
        }
        /// <summary>
        /// The display four items menu.
        /// </summary>
        /// <param name="str1">
        /// The string 1.
        /// </param>
        /// <param name="str2">
        /// The string 2.
        /// </param>
        /// <param name="str3">
        /// The string 3.
        /// </param>
        /// <param name="str4">
        /// The string 4.
        /// </param>
        /// <param name="ev1">
        /// The event 1.
        /// </param>
        /// <param name="ev2">
        /// The event 2.
        /// </param>
        /// <param name="ev3">
        /// The event 3.
        /// </param>
        /// <param name="ev4">
        /// The event 4.
        /// </param>
        /// <param name="output">
        /// The output.
        /// </param>
        private static void DisplayFourItemsMenu(
            string str1, 
            string str2, 
            string str3, 
            string str4, 
            EventHandler ev1, 
            EventHandler ev2, 
            EventHandler ev3, 
            EventHandler ev4, 
            IConsoleWrapper<ConsoleColor, ConsoleKeyInfo> output)
        {
            var buttons = new List<ConsoleButton<ConsoleColor>>
                              {
                                  new ConsoleButton<ConsoleColor>(
                                      20,
                                      3,
                                      ConsoleColor.Blue,
                                      ConsoleColor.Yellow,
                                      ConsoleColor.Yellow,
                                      ConsoleColor.Blue,
                                      str1),
                                  new ConsoleButton<ConsoleColor>(
                                      20,
                                      3,
                                      ConsoleColor.Blue,
                                      ConsoleColor.Yellow,
                                      ConsoleColor.Yellow,
                                      ConsoleColor.Blue,
                                      str2),
                                  new ConsoleButton<ConsoleColor>(
                                      20,
                                      3,
                                      ConsoleColor.Blue,
                                      ConsoleColor.Yellow,
                                      ConsoleColor.Yellow,
                                      ConsoleColor.Blue,
                                      str3),
                                  new ConsoleButton<ConsoleColor>(
                                      20,
                                      3,
                                      ConsoleColor.Blue,
                                      ConsoleColor.Yellow,
                                      ConsoleColor.Yellow,
                                      ConsoleColor.Blue,
                                      str4)
                              };

            buttons[0].ClickEvent += ev1;
            buttons[1].ClickEvent += ev2;
            buttons[2].ClickEvent += ev3;
            buttons[3].ClickEvent += ev4;

            output.Clear();
            var menu = new ConsoleMenu(25, 10, 1, 1, ConsoleColor.DarkBlue, ConsoleColor.Gray, buttons, output);
            menu.Start();
        }
Exemplo n.º 33
0
        static void Main(string[] args)
        {
            try
            {
                _menu = new ConsoleMenu("MRS Test Data Generator")
                {
                    new MenuEntry("Generate DivideByZeroExceptions", GenerateDivideByZeroExceptions),
                    new MenuEntry("Generate Message With No Rule Match", GenerateMessageWithNoRuleMatch),
                    new MenuEntry("Generate SQL Exceptions", GenerateSqlExceptions),
                    new MenuEntry("Generate 100 Messages", GenerateLargeQuantityOfRandomExceptions),
                    new MenuEntry("Exit", Exit)
                };

                RabbitBus.Start();

                while (true)
                {
                    _menu.Write("Choose an option above to generate error messages.", 19, 13, ConsoleColor.Black, ConsoleColor.White);
                    var choice = _menu.ChooseListBoxItem(25, 3, ConsoleColor.DarkCyan, ConsoleColor.White);
                    _menu.ExecuteEntry(choice);
                    _menu.Write("Test data generated, press any key to continue...", 17, 15, ConsoleColor.Blue, ConsoleColor.White);
                    Console.ReadKey();
                    _menu.Reset();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
Exemplo n.º 34
0
 public ConsoleMenuItem(string text, ConsoleMenu.MenuCallback mc)
 {
     this.Mc = mc;
     this.Text = text;
 }