public void Test() { MainMenu mainMenu = new MainMenu(InterfaceTestTexts.k_MainMenuTitle); SubMenu showDateTime; SubMenu actionsSubMenu; SubMenu versionAndActionsSubMenu; ActionableItem.MenuObjectFunctionToCallDelegate callCharsCount; ActionableItem.MenuObjectFunctionToCallDelegate callCountSpaces; ActionableItem.MenuObjectFunctionToCallDelegate callShowTime; ActionableItem.MenuObjectFunctionToCallDelegate callShowDate; ActionableItem.MenuObjectFunctionToCallDelegate callShowVersion; callShowVersion = new ActionableItem.MenuObjectFunctionToCallDelegate(ShowVersion); callCharsCount = new ActionableItem.MenuObjectFunctionToCallDelegate(CharsCount); callCountSpaces = new ActionableItem.MenuObjectFunctionToCallDelegate(CountSpaces); callShowTime = new ActionableItem.MenuObjectFunctionToCallDelegate(ShowTime); callShowDate = new ActionableItem.MenuObjectFunctionToCallDelegate(ShowDate); // Create the main menu mainMenu.AddMenuItemMenu("Version and Actions"); mainMenu.AddMenuItemMenu("Show Date/Time"); // Create Version and Actions sub menu versionAndActionsSubMenu = (SubMenu)mainMenu.GetMenuItem(1); versionAndActionsSubMenu.AddMenuItemFunction("Show Version", callShowVersion); versionAndActionsSubMenu.AddMenuItemMenu("Actions"); // Create the Actions sub sub menu actionsSubMenu = (SubMenu)versionAndActionsSubMenu.GetMenuItem(2); actionsSubMenu.AddMenuItemFunction("Chars Count", callCharsCount); actionsSubMenu.AddMenuItemFunction("Count Spaces", callCountSpaces); // create the Show Date/Time sub menu showDateTime = (SubMenu)mainMenu.GetMenuItem(2); showDateTime.AddMenuItemFunction("Show Time", callShowTime); showDateTime.AddMenuItemFunction("Show Date", callShowDate); mainMenu.Show(); }
/// <summary> /// This method adds a new FUNCTION item to the current menu. /// </summary> /// <param name="i_functionTitle"> The name (title) of the function.</param> /// <param name="i_functionToCall"> A delegate to the function that will activate it.</param> public void AddMenuItemFunction(string i_functionTitle, ActionableItem.MenuObjectFunctionToCallDelegate i_functionToCall) { GeneralMenu newMenuItem = new ActionableItem(i_functionTitle, this, i_functionToCall); m_menu.Add(newMenuItem); }