コード例 #1
0
        public void Run()
        {
            ConsoleWriter.ShowMaximum();

            ConsoleWriter.WriteLine("Welcome to SignalR Test Tool !!", Color.Yellow);

            ConsoleWriter.WriteLine();

            ConsolePosition.MainMenuLastPosition = new Point(Console.CursorLeft, Console.CursorTop);

            var consoleFlow = new ConsoleWizard
            {
                CursorPositionChanged = OnCursorPositionChanged
            };

            var menuSelectionPage = new ConsoleOptionsPage("What would you like to do ?", ConsoleColor.Cyan);

            menuSelectionPage.AddOption("Start a new load test");
            menuSelectionPage.AddOption("Start sending message on an running load");
            menuSelectionPage.AddOption("Stop the load test");
            menuSelectionPage.AddOption("Stop sending message on an running load");
            consoleFlow.AddPage(menuSelectionPage);

            menuSelectionPage.EnableOption(0);
            menuSelectionPage.DisableOption(1);
            menuSelectionPage.DisableOption(2);
            menuSelectionPage.DisableOption(3);

            MenuSelectedCommand command = null;

            do
            {
                ConsoleWriter.ClearConsole(ConsolePosition.MainMenuLastPosition.Y);

                ConsoleWriter.WriteLine();

                var data = consoleFlow.Run();

                var selecteIndex = data.GetMainMenuSelectedIndex();

                if (selecteIndex == 0)
                {
                    command = new MenuSelectedCommand(menuSelectionPage);
                }

                if (selecteIndex.HasValue)
                {
                    command.Execute(selecteIndex.Value);
                }
            } while (true);
        }