// building the main menu using delegates private static Delegates.MainMenu buildMainMenuDelegates() { ExecutableHandler showTimeExecute = new MenuDelegatesAndInterfaces.ShowTime().Execute; ExecutableHandler showDateExcute = new MenuDelegatesAndInterfaces.ShowDate().Execute; ExecutableHandler countCapitalsExcute = new MenuDelegatesAndInterfaces.CountCapitals().Execute; ExecutableHandler showVersionExcute = new MenuDelegatesAndInterfaces.ShowVersion().Execute; Delegates.ExecutableItem executableItemShowTime = new Delegates.ExecutableItem("Show Time", showTimeExecute); Delegates.ExecutableItem executableItemShowDate = new Delegates.ExecutableItem("Show Date", showDateExcute); Delegates.ExecutableItem executableItemCountCapitals = new Delegates.ExecutableItem("Count Capitals Letters", countCapitalsExcute); Delegates.ExecutableItem executableItemShowVersion = new Delegates.ExecutableItem("Show Version", showVersionExcute); // Creates the sub menus: "Show Date/Time" and "Version and Capitals" Delegates.SubMenu showDateAndTimeMenu = new Delegates.SubMenu("Show Date/Time"); showDateAndTimeMenu.AddItem(executableItemShowTime); showDateAndTimeMenu.AddItem(executableItemShowDate); Delegates.SubMenu VersionAndCapitalsMenu = new Delegates.SubMenu("Version and Capitals"); VersionAndCapitalsMenu.AddItem(executableItemCountCapitals); VersionAndCapitalsMenu.AddItem(executableItemShowVersion); // Creates the Main Menu with both of the sub menus Delegates.MainMenu mainMenuDelegate = new Delegates.MainMenu("Main Menu Using Delegate"); mainMenuDelegate.AddItemToMainMenu(showDateAndTimeMenu); mainMenuDelegate.AddItemToMainMenu(VersionAndCapitalsMenu); return(mainMenuDelegate); }
private void InitializeDelegateMenu(out Delegates.MainMenu o_menu) { o_menu = new Delegates.MainMenu(" --- Delegate Main Menu --- "); // Initialize SubMenu - showTimeAndDateSubMenu: Delegates.ExecutableItem showTimeAndDateSubMenu = new Delegates.SubMenu("Show Date/Time", null); Delegates.ExecutableItem showTimeMenuAction = new Delegates.ExecutableItem("Show Time"); showTimeMenuAction.Clicked += this.showTime; Delegates.ExecutableItem showDateMenuAction = new Delegates.ExecutableItem("Show Date"); showDateMenuAction.Clicked += this.showDate; // Add showTimeMenuAction and showDateMenuAction to SubMenu ((Delegates.SubMenu)showTimeAndDateSubMenu).AddItemToMenu(showTimeMenuAction); ((Delegates.SubMenu)showTimeAndDateSubMenu).AddItemToMenu(showDateMenuAction); // Initialize SubMenu - versionAndCountDigitSubMenu: Delegates.ExecutableItem showVersionAndcountDigitsSubMenu = new Delegates.SubMenu("Version and Count Digits", null); Delegates.ExecutableItem countDigitsMenuAction = new Delegates.ExecutableItem("Count Digits"); countDigitsMenuAction.Clicked += this.countDigits; Delegates.ExecutableItem versionMenuAction = new Delegates.ExecutableItem("Show Version"); versionMenuAction.Clicked += this.showVersion; // Add versionMenuAction and countDigitsMenuAction to SubMenu ((Delegates.SubMenu)showVersionAndcountDigitsSubMenu).AddItemToMenu(countDigitsMenuAction); ((Delegates.SubMenu)showVersionAndcountDigitsSubMenu).AddItemToMenu(versionMenuAction); // Add showTimeAndDateSubMenu and ShowVersionAndcountDigitsSubMenu to the MainMenu. o_menu.AddItemToMenu(showTimeAndDateSubMenu); o_menu.AddItemToMenu(showVersionAndcountDigitsSubMenu); }
private void countDigits(Delegates.ExecutableItem i_ItemInMenuSender) { CountDigits countDigits = new CountDigits(); countDigits.PrintCountDigits(); }
private void showVersion(Delegates.ExecutableItem i_ItemInMenuSender) { ShowVersion version = new ShowVersion(); version.PrintVersion(); }
private void showDate(Delegates.ExecutableItem i_ItemInMenuSender) { ShowDate date = new ShowDate(); date.printDate(); }
// ---------------------- Actions items ---------------------- private void showTime(Delegates.ExecutableItem i_ItemInMenuSender) { ShowTime time = new ShowTime(); time.printTime(); }