Esempio n. 1
0
    public static void Main(string[] argv)
    {
        //create instance with menu header, set true for looped menu cursor
        ConsoleMenu menu = new ConsoleMenu("Example menu", true);


        //adding items into menu
        menu.AddItem(new Button("Yes"));                                                      //item index 0
        menu.AddItem(new Button("No"));                                                       //item index 1
        menu.AddItem(new Input("Name"));                                                      //item index 2
        menu.AddItem(new Switcher("Music"));                                                  //item index 3
        menu.AddItem(new Option("Difficulty", new string[] { "Easy", "Normal", "Hard" }, 1)); //item index 4

        //method Display() returns index of pressed button and show interactive menu in console
        int menu_id = menu.Display();

        //write id of pressed button
        Console.WriteLine(menu_id);

        //write data of menu item with index 2
        Console.WriteLine(menu.GetData()[2]);

        //write data of menu item with index 3
        Console.WriteLine(menu.GetData()[3]);

        //write data of menu item with index 4
        Console.WriteLine(menu.GetData()[4]);
    }
Esempio n. 2
0
 private void OnShowActionMenu(IMessage msg)
 {
     UI.Message.ShowActionMenuMsg menuMsg = msg as UI.Message.ShowActionMenuMsg;
     m_ActionMenu.Clear();
     m_ActionMenu.AddItem <ConsoleMenuItemText>((int)EActionMenuOption.Attack).SetText("攻击");
     m_ActionMenu.AddItem <ConsoleMenuItemText>((int)EActionMenuOption.Standby).SetText("待机");
     m_ActionMenu.ResetCursor();
     m_ActionMenu.Show(true);
     GameManager.Instance.UIMgr.SetActivate(this, true);
 }
        /// <summary>
        /// Loads the view team inforamtion.
        /// </summary>
        /// <param name="mainMenu">ConsoleMenu</param>
        public static void LoadChampionshipSeries(ConsoleMenu mainMenu)
        {
            ConsoleMenu playWorldSeriesMenu      = new ConsoleMenu("Play Championship Series Menu", true);
            MenuChoice  promptForWorldSeriesYear = new MenuChoice(SelectWorldSeries, "Display Team Information", true);

            playWorldSeriesMenu.AddItem(promptForWorldSeriesYear);
            mainMenu.AddItem(playWorldSeriesMenu);
        }
Esempio n. 4
0
        /// <summary>
        /// Loads the view team inforamtion.
        /// </summary>
        /// <param name="mainMenu">ConsoleMenu</param>
        public static void LoadPlaySeries(ConsoleMenu mainMenu)
        {
            ConsoleMenu playSeriesMenu = new ConsoleMenu("Play Series Menu", true);
            MenuChoice  setupTeams     = new MenuChoice(SetUpSeries, "Set up Series", true);

            playSeriesMenu.AddItem(setupTeams);
            mainMenu.AddItem(playSeriesMenu);
        }
 /// <summary>
 /// Loads the view team inforamtion.
 /// </summary>
 /// <param name="mainMenu">ConsoleMenu</param>
 public static void LoadViewTeamInforamtion(ConsoleMenu mainMenu)
 {
     theMenu = mainMenu;
     viewTeamInformationMenu = new ConsoleMenu("View Team Information", true);
     displayTeamInformation  = new MenuChoice(Display, "Display Team Information", true);
     viewTeamInformationMenu.AddItem(displayTeamInformation);
     theMenu.AddItem(viewTeamInformationMenu);
 }
Esempio n. 6
0
        /// <summary>
        /// Loads the round robin.
        /// </summary>
        public static void LoadRoundRobin(ConsoleMenu mainMenu)
        {
            ConsoleMenu playRoundRobinMenu      = new ConsoleMenu("Play Round Robin", true);
            MenuChoice  promptForRoundRobinYear = new MenuChoice(SelectYear, "Select Year", true);

            playRoundRobinMenu.AddItem(promptForRoundRobinYear);
            mainMenu.AddItem(playRoundRobinMenu);
        }
        /// <summary>
        /// Loads the view league inforamtion.
        /// </summary>
        /// <param name="mainMenu">ConsoleMenu</param>
        public static void LoadViewLeagueInforamtion(ConsoleMenu mainMenu)
        {
            ConsoleMenu viewTeamInformationMenu  = new ConsoleMenu("View League Information", true);
            MenuChoice  displayLeagueInformation = new MenuChoice(Display, "Display League Information", true);

            viewTeamInformationMenu.AddItem(displayLeagueInformation);
            mainMenu.AddItem(viewTeamInformationMenu);
        }
Esempio n. 8
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();
        }
        /// <summary>
        /// Loads the team.
        /// </summary>
        /// <param name="searchTerm">string</param>
        /// <param name="secondPass">bool</param>
        /// <param name="capitalizeNames">If set to <c>true</c> capitalize names.</param>
        private static Team LoadTeam(string searchTerm, bool secondPass = false, bool capitalizeNames = true)
        {
            Team team     = null;
            Db   database = null;

            try
            {
                database = new Db(MainClass.conn);
                team     = DatabaseTeamLoader.LoadTeamFromTeamID(searchTerm, year, database);
                if (team != null)
                {
                    team.CapitalizeNames = capitalizeNames;
                    return(team);
                }
            }
            catch (Exception ex)
            {
                //Eat this one
                ex.Message.ToString();
                //Console.WriteLine($"Unable to load team with search term '{searchTerm}'");
                //Console.WriteLine(ex.Message);
            }
            //First check to see if we get multiple teams
            if (!secondPass)
            {
                keys = DatabaseTeamLoader.GetMultipleKeys(searchTerm, year, database);
                Console.WriteLine($"Found {keys.Count} results for search term '{searchTerm} {year}.'");
                teamChoices = new ConsoleMenu("Teams...", true);

                foreach (string key in keys.Keys)
                {
                    Console.WriteLine(keys[key]);
                    MenuChoice teamChoice = new MenuChoice(ChooseTeam, keys[key], true);
                    teamChoices.AddItem(teamChoice);
                }
                teamChoices.Parent = displayTeamInformation;
                teamChoices.Run();
            }
            else if (keys.Count == 2)
            {
                team = DatabaseTeamLoader.LoadTeamFromFranchiseID(searchTerm, year, database);
                team.CapitalizeNames = capitalizeNames;
            }
            else if (keys.Count == 1)
            {
                team = DatabaseTeamLoader.LoadTeamFromFranchiseID(searchTerm, year, database);
                team.CapitalizeNames = capitalizeNames;
            }
            return(team);
        }