Example #1
0
 public void BuildMenu()
 {
     Ex04.Menus.Delegates.MainMenu menu1    = new Ex04.Menus.Delegates.MainMenu();
     Ex04.Menus.Delegates.SubMenu  subMenu1 = new Ex04.Menus.Delegates.SubMenu("Show Date/Time");
     Ex04.Menus.Delegates.SubMenu  subMenu2 = new Ex04.Menus.Delegates.SubMenu("Version and Capitals");
     menu1.AddMenu(new Method(subMenu1.Name, subMenu1.Run));
     subMenu1.AddMenu(new Method(new ShowDate().Name, ShowTheDate));
     subMenu1.AddMenu(new Method(new ShowTime().Name, ShowTheTime));
     menu1.AddMenu(new Method(subMenu2.Name, subMenu2.Run));
     subMenu2.AddMenu(new Method(new ShowVersion().Name, ShowTheVersion));
     subMenu2.AddMenu(new Method(new CountCapitals().Name, CountCapitalLetters));
     menu1.Show();
 }
Example #2
0
        private static Ex04.Menus.Delegates.MainMenu buildDelegateMenu()
        {
            Ex04.Menus.Delegates.MainMenu mainMenu = new Ex04.Menus.Delegates.MainMenu("Main Menu (Delegates)");

            Ex04.Menus.Delegates.SubMenu versionAndCapitals = new Ex04.Menus.Delegates.SubMenu("Version and Capitals");
            versionAndCapitals.Add(new Ex04.Menus.Delegates.ActionItem("Count Capitals", new MenuOptionsForTester.CountCaptials().Do));
            versionAndCapitals.Add(new Ex04.Menus.Delegates.ActionItem("Show Version", new MenuOptionsForTester.ShowVersion().Do));
            mainMenu.Add(versionAndCapitals);

            Ex04.Menus.Delegates.SubMenu dateAndTime = new Ex04.Menus.Delegates.SubMenu("Show Date/Time");
            dateAndTime.Add(new Ex04.Menus.Delegates.ActionItem("Show Time", new MenuOptionsForTester.ShowCurrTime().Do));
            dateAndTime.Add(new Ex04.Menus.Delegates.ActionItem("Show Date", new MenuOptionsForTester.ShowCurrDate().Do));
            mainMenu.Add(dateAndTime);

            return(mainMenu);
        }