// Building the main menu using interfaces private static Interfaces.MainMenu buildMainMenuInterface() { // Create Executable Items IExecutable showTimeExecute = new MenuDelegatesAndInterfaces.ShowTime(); IExecutable showDateExcute = new MenuDelegatesAndInterfaces.ShowDate(); IExecutable countCapitalsExcute = new MenuDelegatesAndInterfaces.CountCapitals(); IExecutable showVersionExcute = new MenuDelegatesAndInterfaces.ShowVersion(); Interfaces.ExecutableItem executableItemShowTime = new Interfaces.ExecutableItem("Show Time", showTimeExecute); Interfaces.ExecutableItem executableItemShowDate = new Interfaces.ExecutableItem("Show Date", showDateExcute); Interfaces.ExecutableItem executableItemCountCapitals = new Interfaces.ExecutableItem("Count Capitals", countCapitalsExcute); Interfaces.ExecutableItem executableItemShowVersion = new Interfaces.ExecutableItem("Show Version", showVersionExcute); // Creates the sub menus: "Show Date/Time" and "Version and Capitals" Interfaces.SubMenu showDateAndTimeMenu = new Interfaces.SubMenu("Show Date/Time"); showDateAndTimeMenu.AddItem(executableItemShowTime); showDateAndTimeMenu.AddItem(executableItemShowDate); Interfaces.SubMenu VersionAndCapitalsMenu = new Interfaces.SubMenu("Version and Capitals"); VersionAndCapitalsMenu.AddItem(executableItemCountCapitals); VersionAndCapitalsMenu.AddItem(executableItemShowVersion); // Creates the Main Menu with both of the sub menus Interfaces.MainMenu mainMenuInterface = new Interfaces.MainMenu("Main Menu Using Interface"); mainMenuInterface.AddItemToMainMenu(showDateAndTimeMenu); mainMenuInterface.AddItemToMainMenu(VersionAndCapitalsMenu); return(mainMenuInterface); }
private static void InterfaceTest() { Interfaces.MainMenu m_MainMenu = new Interfaces.MainMenu(); Interfaces.SubMenu dateTimeMenu = new Interfaces.SubMenu("Show Date/Time", m_MainMenu.GetSubMenu()); Interfaces.FunctionItem showTime = new Interfaces.FunctionItem("Show Time"); showTime.AddFunction(new ShowTime()); dateTimeMenu.AddItem(showTime); Interfaces.FunctionItem showDate = new Interfaces.FunctionItem("Show Date"); showDate.AddFunction(new ShowDate()); dateTimeMenu.AddItem(showDate); Interfaces.SubMenu versionAndCapitalsMenu = new Interfaces.SubMenu("Version and Capitals", m_MainMenu.GetSubMenu()); Interfaces.FunctionItem countCapitals = new Interfaces.FunctionItem("Count Capitals"); countCapitals.AddFunction(new CountCapitals()); versionAndCapitalsMenu.AddItem(countCapitals); Interfaces.FunctionItem showVersion = new Interfaces.FunctionItem("Show Version"); showVersion.AddFunction(new ShowVersion()); versionAndCapitalsMenu.AddItem(showVersion); m_MainMenu.AddMenuItem(dateTimeMenu); m_MainMenu.AddMenuItem(versionAndCapitalsMenu); m_MainMenu.Show(); }