Ejemplo n.º 1
0
        public static MainMenu BuildInterfaceMenu()
        {
            /// Create leaves:
            IAction  showVersionRunnable   = new TestExamples.ShowVersion();
            MenuItem actionItemShowVer     = new ActionItem("Show Version", showVersionRunnable);
            IAction  charsCountRunnable    = new TestExamples.CharsCount();
            MenuItem actionItemCharCount   = new ActionItem("Chars Count", charsCountRunnable);
            IAction  countSpacesRunnable   = new TestExamples.CountSpaces();
            MenuItem actionItemCountSpaces = new ActionItem("Count Spaces", countSpacesRunnable);
            IAction  showTimeRunnable      = new TestExamples.ShowTime();
            MenuItem actionItemShowTime    = new ActionItem("Show Time", showTimeRunnable);
            IAction  showDateRunnable      = new TestExamples.ShowDate();
            MenuItem actionItemShowDate    = new ActionItem("Show Date", showDateRunnable);

            /// Create sub menus:
            SubMenu subMenuActions = new SubMenu("Actions");

            subMenuActions.AddMenuItem(actionItemCharCount);
            subMenuActions.AddMenuItem(actionItemCountSpaces);
            SubMenu subMenuVerAndActions = new SubMenu("Version and Actions");

            subMenuVerAndActions.AddMenuItem(actionItemShowVer);
            subMenuVerAndActions.AddMenuItem(subMenuActions);
            SubMenu subMenuDateAndTime = new SubMenu("Show Date/Time");

            subMenuDateAndTime.AddMenuItem(actionItemShowTime);
            subMenuDateAndTime.AddMenuItem(actionItemShowDate);

            /// Create Main menu
            MainMenu mainMenu = new MainMenu();

            mainMenu.AddItemToMainMenu(subMenuVerAndActions);
            mainMenu.AddItemToMainMenu(subMenuDateAndTime);

            return(mainMenu);
        }
Ejemplo n.º 2
0
        public static MainMenu BuildDelegateMenu()
        {
            /// Create ActionItems:
            ActionItemFunctionDelegate showVersionFunction = new TestExamples.ShowVersion().Invoke;
            MenuItem actionItem1 = new ActionItem("Show Version", showVersionFunction);
            ActionItemFunctionDelegate charsCountFunction = new TestExamples.CharsCount().Invoke;
            MenuItem actionItem2 = new ActionItem("Chars Count", charsCountFunction);
            ActionItemFunctionDelegate countSpacesFunction = new TestExamples.CountSpaces().Invoke;
            MenuItem actionItem3 = new ActionItem("Count Spaces", countSpacesFunction);
            ActionItemFunctionDelegate showTimeFunction = new TestExamples.ShowTime().Invoke;
            MenuItem actionItem4 = new ActionItem("Show Time", showTimeFunction);
            ActionItemFunctionDelegate showDateFunction = new TestExamples.ShowDate().Invoke;
            MenuItem actionItem5 = new ActionItem("Show Date", showDateFunction);

            /// Create SubMenus:
            SubMenu subMenu1 = new SubMenu("Actions");

            subMenu1.AddMenuItem(actionItem2);
            subMenu1.AddMenuItem(actionItem3);
            SubMenu subMenu2 = new SubMenu("Version and Actions");

            subMenu2.AddMenuItem(actionItem1);
            subMenu2.AddMenuItem(subMenu1);
            SubMenu subMenu3 = new SubMenu("Show Date/Time");

            subMenu3.AddMenuItem(actionItem4);
            subMenu3.AddMenuItem(actionItem5);

            /// Create MainMenu
            MainMenu mainMenu = new MainMenu();

            mainMenu.AddItemToMainMenu(subMenu2);
            mainMenu.AddItemToMainMenu(subMenu3);

            return(mainMenu);
        }