コード例 #1
0
        private static void DelegateTest()
        {
            Delegates.MainMenu m_MainMenu = new Delegates.MainMenu();

            Delegates.SubMenu      dateTimeMenu = new Delegates.SubMenu("Show Date/Time", m_MainMenu.GetSubMenu());
            Delegates.FunctionItem showTime     = new Delegates.FunctionItem("Show Time");
            ShowTime showTimeInstance           = new ShowTime();

            showTime.AddFunction(new SelectFunctionDelegate(showTimeInstance.Invoke));
            dateTimeMenu.AddItem(showTime);
            Delegates.FunctionItem showDate = new Delegates.FunctionItem("Show Date");
            ShowDate showDateInstance       = new ShowDate();

            showDate.AddFunction(showDateInstance.Invoke);
            dateTimeMenu.AddItem(showDate);

            Delegates.SubMenu      versionAndCapitalsMenu = new Delegates.SubMenu("Version and Capitals", m_MainMenu.GetSubMenu());
            Delegates.FunctionItem countCapitals          = new Delegates.FunctionItem("Count Capitals");
            CountCapitals          countCapitalsInstance  = new CountCapitals();

            countCapitals.AddFunction(countCapitalsInstance.Invoke);
            versionAndCapitalsMenu.AddItem(countCapitals);
            Delegates.FunctionItem showVersion         = new Delegates.FunctionItem("Show Version");
            ShowVersion            showVersionInstance = new ShowVersion();

            showVersion.AddFunction(showVersionInstance.Invoke);
            versionAndCapitalsMenu.AddItem(showVersion);

            m_MainMenu.AddMenuItem(dateTimeMenu);
            m_MainMenu.AddMenuItem(versionAndCapitalsMenu);

            m_MainMenu.Show();
        }
コード例 #2
0
        private static Delegates.MainMenu createDelegateMainMenu()
        {
            Utils actions = new Utils();

            Delegates.MainMenu        mainMenu     = new Delegates.MainMenu();
            List <Delegates.MenuItem> subMenuItems = new List <Delegates.MenuItem>();

            Delegates.MenuItem versionAndSpacesMenu = new Delegates.MenuItem("Version and Spaces");
            Delegates.MenuItem countAction          = new Delegates.MenuItem("Count Spaces");
            Delegates.MenuItem showVersionAction    = new Delegates.MenuItem("Show Version");
            countAction.Initialize(new Delegates.ActionItemDelegate(actions.CountSpaces));
            showVersionAction.Initialize(new Delegates.ActionItemDelegate(actions.ShowVersion));
            subMenuItems.Add(countAction);
            subMenuItems.Add(showVersionAction);
            versionAndSpacesMenu.Initialize(subMenuItems);
            subMenuItems.Clear();

            Delegates.MenuItem showDateTimeMenu = new Delegates.MenuItem("Show Date/Time");
            Delegates.MenuItem dateAction       = new Delegates.MenuItem("Show Date");
            Delegates.MenuItem timeAction       = new Delegates.MenuItem("Show Time");
            dateAction.Initialize(new Delegates.ActionItemDelegate(actions.ShowDate));
            timeAction.Initialize(new Delegates.ActionItemDelegate(actions.ShowTime));
            subMenuItems.Add(dateAction);
            subMenuItems.Add(timeAction);
            showDateTimeMenu.Initialize(subMenuItems);
            subMenuItems.Clear();

            subMenuItems.Add(versionAndSpacesMenu);
            subMenuItems.Add(showDateTimeMenu);
            mainMenu.Initialize(subMenuItems);

            return(mainMenu);
        }
 public static void Main()
 {
     Interfaces.MainMenu interfaceMenu = buildMainMenuInterface();
     Delegates.MainMenu  delegateMenu  = buildMainMenuDelegates();
     interfaceMenu.Show();
     delegateMenu.Show();
 }
コード例 #4
0
        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);
        }
        // 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);
        }
コード例 #6
0
        public static Delegates.MainMenu CreateDelegatesMenu()
        {
            Delegates.MainMenu DelegatesmainMenu = new Delegates.MainMenu();
            Delegates.MenuItem subMenu1          = new Delegates.MenuItem("Show Date/Time");
            Delegates.MenuItem subMenu2          = new Delegates.MenuItem("Version and Digits");

            Delegates.ActionItem showTimeMethod    = new Delegates.ActionItem("Show Time");
            Delegates.ActionItem showDateMethod    = new Delegates.ActionItem("Show Date");
            Delegates.ActionItem countDigitsMethod = new Delegates.ActionItem("Count Digits");
            Delegates.ActionItem ShowVersionMethod = new Delegates.ActionItem("Show Version");

            DelegatesmainMenu.AddSubItem(subMenu1);
            DelegatesmainMenu.AddSubItem(subMenu2);

            showTimeMethod.m_ActionItemEvent += sr_MenuMethods.ShowTime.ShowTime_Method;
            subMenu1.AddSubItem(showTimeMethod);
            showDateMethod.m_ActionItemEvent += sr_MenuMethods.ShowDate.ShowDate_Method;
            subMenu1.AddSubItem(showDateMethod);
            countDigitsMethod.m_ActionItemEvent += sr_MenuMethods.CountDigits.CountDigits_Method;
            subMenu2.AddSubItem(countDigitsMethod);
            ShowVersionMethod.m_ActionItemEvent += sr_MenuMethods.ShowVersion.ShowVersion_Method;
            subMenu2.AddSubItem(ShowVersionMethod);

            return(DelegatesmainMenu);
        }
コード例 #7
0
        internal static void DelegateMenu(Delegates.MainMenu i_Menu)
        {
            Delegates.MenuItem versionAndDigit = new Delegates.MenuItem("Version and Digits");
            i_Menu.AddToMainMenu(versionAndDigit);

            Delegates.MenuItem countCapital = new Delegates.MenuItem("Count Capital");
            countCapital.m_Action += CountCapitalAction;
            versionAndDigit.AddToSubMenu(countCapital);

            Delegates.MenuItem showVersion = new Delegates.MenuItem("Show Version");
            showVersion.m_Action += ShowVersionAction;
            versionAndDigit.AddToSubMenu(showVersion);

            Delegates.MenuItem dateAndTime = new Delegates.MenuItem("Show Date/Time");
            i_Menu.AddToMainMenu(dateAndTime);

            Delegates.MenuItem showTime = new Delegates.MenuItem("Show Time");
            showTime.m_Action += ShowTimeAction;
            dateAndTime.AddToSubMenu(showTime);

            Delegates.MenuItem showDate = new Delegates.MenuItem("Show Date");
            showDate.m_Action += ShowDateAction;
            dateAndTime.AddToSubMenu(showDate);

            i_Menu.Show();
        }
コード例 #8
0
 private static void startMenus()
 {
     Interfaces.MainMenu mainMenuInterfaces = createInterfacesMainMenu();
     Delegates.MainMenu  mainMenuDelegates  = createDelegateMainMenu();
     mainMenuInterfaces.Show();
     mainMenuDelegates.Show();
 }
コード例 #9
0
        public static void Run()
        {
            m_DelegateMainMenu = new Delegates.MainMenu("Delegate Main Menu Title!");
            Delegates.SubMenu firstSubMenu  = new Delegates.SubMenu("Version and Capitals");
            Delegates.SubMenu secondSubMenu = new Delegates.SubMenu("Show Date/Time");

            Delegates.ActionNode countCapitals = new Delegates.ActionNode("Count Capitals", new Methods.CountCapitals().Execute);
            Delegates.ActionNode showVersion   = new Delegates.ActionNode("Show Version", new Methods.ShowVersion().Execute);
            Delegates.ActionNode showTime      = new Delegates.ActionNode("Show time", new Methods.ShowTime().Execute);
            Delegates.ActionNode showDate      = new Delegates.ActionNode("Show Date", new Methods.ShowDate().Execute);

            // Build main menu
            m_DelegateMainMenu.ListOfMenuNodes.AddMenuNode(firstSubMenu);
            m_DelegateMainMenu.ListOfMenuNodes.AddMenuNode(secondSubMenu);

            // Build version and capitals
            firstSubMenu.AddMenuNode(countCapitals);
            firstSubMenu.AddMenuNode(showVersion);

            // Build show and date
            secondSubMenu.AddMenuNode(showTime);
            secondSubMenu.AddMenuNode(showDate);

            m_DelegateMainMenu.Show();
        }
コード例 #10
0
        public static void Main()
        {
            Interfaces.MainMenu interfaceMainMenu = InitializeMenu.CreateInterfaceMenu();
            interfaceMainMenu.Show();

            Delegates.MainMenu DelegateMainMenu = InitializeMenu.CreateDelegatesMenu();
            DelegateMainMenu.Show();
        }
コード例 #11
0
        public static void Main()
        {
            Interfaces.MainMenu firstTest  = new Interfaces.MainMenu();
            Delegates.MainMenu  secondTest = new Delegates.MainMenu();

            firstTest.Show();
            secondTest.Show();
        }
コード例 #12
0
        public static void Main()
        {
            Interfaces.MainMenu mainMenuInterface = new Interfaces.MainMenu(InterfaceProgramUtils.MainMenuCreator());
            mainMenuInterface.Show();

            Delegates.MainMenu mainMenu = MainMenuDelegatesBuilder.Build();
            mainMenu.Show();
        }
コード例 #13
0
 public DelegateMenuTest()
 {
     Delegates.MainMenu dateTimeMenu = m_Menu.AddMenu("Show Date/Time");
     dateTimeMenu.AddItem("Show date").Displaying += new ShowDate().Run;
     dateTimeMenu.AddItem("Show time").Displaying += new ShowTime().Run;
     Delegates.MainMenu infoAndVersionMenu = m_Menu.AddMenu("Version and digit");
     infoAndVersionMenu.AddItem("Show virsion").Displaying += new ShowVersion().Run;
     infoAndVersionMenu.AddItem("Count digits").Displaying += new CountDigits().Run;
 }
コード例 #14
0
        public static void Main()
        {
            Interfaces.MainMenu InterfaceMenu = Menus.CreateMainMenuInterfaces();

            InterfaceMenu.Show();

            Delegates.MainMenu DelegateMenu = Menus.CreateMainMenuDelegate();

            DelegateMenu.Show();
        }
コード例 #15
0
 private static void showDelegateMenu()
 {
     Delegates.MainMenu mainMenu     = new Delegates.MainMenu();
     Delegates.Menu     dateTimeMenu = mainMenu.AddMenu("Show Date/Time");
     dateTimeMenu.AddItem("Show Time", new TimeAction().ExecuteItem);
     dateTimeMenu.AddItem("Show Date", new DateAction().ExecuteItem);
     Delegates.Menu versionAndDigits = mainMenu.AddMenu("Version and Digits");
     versionAndDigits.AddItem("Count Digits", new CountDigitsAction().ExecuteItem);
     versionAndDigits.AddItem("Show Version", new VersionAction().ExecuteItem);
     mainMenu.Show();
 }
コード例 #16
0
ファイル: Program.cs プロジェクト: erezlev13/Menu-Builder
        public static void Main()
        {
            Interfaces.MainMenu mainMenuInterfaces = CreateMenuWithInterfaces();
            mainMenuInterfaces.Show();

            Console.WriteLine("Switch to menu builder with delegates");
            Thread.Sleep(800);
            Console.Clear();

            Delegates.MainMenu mainMenuDelegates = CreateMenuWithDelegates();
            mainMenuDelegates.Show();
        }
コード例 #17
0
        public static void BuildMenuDelegate(string i_Title)
        {
            m_MainMenuDelegate = new Delegates.MainMenu(i_Title);

            m_MainMenuDelegate.AddSubMenu("Version and Captials");
            m_MainMenuDelegate.AddSubMenu("Show Date/Time");

            m_MainMenuDelegate.Items[1].AddSubMenu("Count Capitals", DelegateMethods.CountCapitals);
            m_MainMenuDelegate.Items[1].AddSubMenu("Show Version", DelegateMethods.ShowVersion);
            m_MainMenuDelegate.Items[2].AddSubMenu("Show Time", DelegateMethods.ShowTime);
            m_MainMenuDelegate.Items[2].AddSubMenu("Show Date", DelegateMethods.ShowDate);
        }
コード例 #18
0
        public static void Main()
        {
            Menu.Interfaces.MainMenu interfacesMenu1 = new Menu.Interfaces.MainMenu("Interfaces Menu");
            InterfacesMenu.CreateInterfacesMenuForTest(interfacesMenu1);
            InterfacesMenu.RunInterfacesMenu(interfacesMenu1);

            Console.Clear();

            Delegates.MainMenu delegatesMenu1 = new Delegates.MainMenu("Deletgates Menu");
            DelegatesMenu.CreateDelegatesMenuForTest(delegatesMenu1);
            DelegatesMenu.RunDelegatesMenu(delegatesMenu1);
        }
コード例 #19
0
        internal void Run()
        {
            Console.Title           = "Menus";
            Console.ForegroundColor = ConsoleColor.White;
            Console.BackgroundColor = ConsoleColor.Black;

            InterfaceMainMenu interfaceMainMenu = InitInterfaceMainMenu();
            DelegateMainMenu  delegateMainMenu  = InitDelegateMainMenu();

            interfaceMainMenu.Show();
            delegateMainMenu.Show();
        }
コード例 #20
0
        public static void Main()
        {
            Interfaces.MainMenu interfaceMenu = new Interfaces.MainMenu("Main Menu With Intefaces");
            InterFaceMenu(interfaceMenu);

            Ex02.ConsoleUtils.Screen.Clear();
            Console.WriteLine("Changing Menu..");
            System.Threading.Thread.Sleep(2000);
            Ex02.ConsoleUtils.Screen.Clear();

            Delegates.MainMenu delegateMenu = new Delegates.MainMenu("Main Menu With Delegates");
            DelegateMenu(delegateMenu);
        }
コード例 #21
0
ファイル: Program.cs プロジェクト: guybiecher/C--HW4
        private static void runDelegateImplementaion()
        {
            //Menu Item 1
            Delegates.SubMenuItem actionsAndInfo = new Delegates.SubMenuItem("Actions and Info");

            //Menu Item 1.1
            FunctionMenuItem displayVersion = new FunctionMenuItem("Display Version");

            displayVersion.m_ExecuteFunction += DisplayVersion.Display;
            actionsAndInfo.AddMenuItem(displayVersion);

            //Menu Item 1.2
            Delegates.SubMenuItem actions = new Delegates.SubMenuItem("Actions");

            //Menu Item 1.2.1
            FunctionMenuItem spaceCounter = new FunctionMenuItem("Count Spaces");

            spaceCounter.m_ExecuteFunction += SpaceCounter.Count;
            actions.AddMenuItem(spaceCounter);

            //Menu Item 1.2.2
            FunctionMenuItem charsCounter = new FunctionMenuItem("Chars Count");

            charsCounter.m_ExecuteFunction += CharsCounter.Count;
            actions.AddMenuItem(charsCounter);
            actionsAndInfo.AddMenuItem(actions);

            //Menu Item 2
            Delegates.SubMenuItem dateAndTime = new Delegates.SubMenuItem("Show Date/Time");

            //Menu Item 2.1
            FunctionMenuItem showTime = new FunctionMenuItem("Show Time");

            showTime.m_ExecuteFunction += DisplayTime.Display;
            dateAndTime.AddMenuItem(showTime);

            //Menu Item 2.2
            FunctionMenuItem showDate = new FunctionMenuItem("Show Date");

            showDate.m_ExecuteFunction += DisplayDate.Display;
            dateAndTime.AddMenuItem(showDate);

            /* Prepare main menu */
            Delegates.SubMenuItem mainMenu = new Delegates.SubMenuItem("Main Menu - Delegates Implemented");
            mainMenu.AddMenuItem(actionsAndInfo);
            mainMenu.AddMenuItem(dateAndTime);
            Delegates.MainMenu interfaceMainMenu = new Delegates.MainMenu(mainMenu);

            /* execute */
            interfaceMainMenu.Show();
        }
        private static void delegateMenuTest()
        {
            Delegates.MainMenu firstMainMenu = new Delegates.MainMenu("Delegate Main Menu");

            Delegates.Menu dateTimeMenu         = firstMainMenu.AddSubMenuItem("Show Date/Time");
            Delegates.Menu versionAndDigitsMenu = firstMainMenu.AddSubMenuItem("Version and Digits");

            dateTimeMenu.AddActionMenuItem("Show Date", new DateOperation().Operate);
            dateTimeMenu.AddActionMenuItem("Show Time", new TimeOperation().Operate);
            versionAndDigitsMenu.AddActionMenuItem("Count Digits", new CountDigitsOperation().Operate);
            versionAndDigitsMenu.AddActionMenuItem("Show Version", new ShowVersionOperation().Operate);

            firstMainMenu.ShowMenu();
        }
コード例 #23
0
        public static Delegates.MainMenu CreateMainMenuDelegate()
        {
            Delegates.MainMenu myMenu   = new Delegates.MainMenu("Main Menu - Delegates");
            Delegates.MainMenu subMenu1 = new Delegates.MainMenu("Version and Digits");
            Delegates.MainMenu subMenu2 = new Delegates.MainMenu("Show Date / Time");

            subMenu1.AddMenuItem("Count Capitals", MethodsDelegates.CountCapitals);
            subMenu1.AddMenuItem("Show Version", MethodsDelegates.ShowVersion);
            myMenu.AddMenuItem(subMenu1);
            myMenu.AddMenuItem(subMenu2);
            subMenu2.AddMenuItem("Show Time", MethodsDelegates.ShowTime);
            subMenu2.AddMenuItem("Show Date", MethodsDelegates.ShowDate);

            return(myMenu);
        }
コード例 #24
0
ファイル: Program.cs プロジェクト: Ziv3r/Main-Menu-Classs
        private static void delegateMenu()
        {
            Delegates.MainMenu mainMenuDelegates    = new Delegates.MainMenu("Main Menu");
            DelegatesTest      dateAndTimeDelegates = new DelegatesTest();
            int showDateTimeHashCode = mainMenuDelegates.AddNewMenuItemUnder(mainMenuDelegates.RootHashCode, "Show Date/Time");
            int showVersionAndDigits = mainMenuDelegates.AddNewMenuItemUnder(mainMenuDelegates.RootHashCode, "Version and Digits");

            mainMenuDelegates.AddNewOperationItemUnder(showDateTimeHashCode, "Show Date", dateAndTimeDelegates.ShowDate_Click);
            mainMenuDelegates.AddNewOperationItemUnder(showDateTimeHashCode, "Show Time", dateAndTimeDelegates.ShowTime_Click);

            mainMenuDelegates.AddNewOperationItemUnder(showVersionAndDigits, "Count Digits", dateAndTimeDelegates.CountDigits_Click);
            mainMenuDelegates.AddNewOperationItemUnder(showVersionAndDigits, "Show Version", dateAndTimeDelegates.ShowVersion_Click);

            mainMenuDelegates.Show();
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: gabiwe/Ex04
        public static void Main()
        {
            List <Interfaces.MenuItem> menuItemsWithInterfaces = InterfacesMenuCreator.BuildMenuItemsWithInterfaces();

            Interfaces.MainMenu mainMenuWithInterfaces = new Interfaces.MainMenu();
            mainMenuWithInterfaces.Build(menuItemsWithInterfaces);
            mainMenuWithInterfaces.Title = "Main Menu With Interfaces!";
            mainMenuWithInterfaces.Show();

            List <Delegates.MenuItem> menuItemsWithDelegates = DelegatesMenuCreator.BuildMenuItemsWithDelegates();

            Delegates.MainMenu mainMenuWithDelegates = new Delegates.MainMenu();
            mainMenuWithDelegates.Build(menuItemsWithDelegates);
            mainMenuWithDelegates.Title = "Main Menu With Delegates!";
            mainMenuWithDelegates.Show();
        }
コード例 #26
0
ファイル: Program.cs プロジェクト: Tshron/Dev-Files
        // $G$ CSS-010 (-3) Private method should start with a lower case letter.
        private static void BeginTests()
        {
            int MenuDepth = 1;

            TestInterface testInterface = new TestInterface();

            Interfaces.MainMenu interfaceMainMenu = testInterface.BuildMenu();
            testInterface.LoopMenu(interfaceMainMenu, MenuDepth);

            TestDelegates testDelegates = new TestDelegates();

            Delegates.MainMenu delegatesMainMenu = testDelegates.BuildMenu();
            testDelegates.LoopMenu(delegatesMainMenu, MenuDepth);

            Console.WriteLine("Menu Closed");
            Console.Read();
        }
コード例 #27
0
ファイル: DelegatesBasedMenu.cs プロジェクト: kamilyan/Menus
        public void ExecuteDelegatesBasedMenu()
        {
            Delegates.MainMenu mainMenu = new Delegates.MainMenu("Delegates Based Menu");
            mainMenu.AddAnotherSubMenu(new Delegates.MenuItem("Show Date/Time"));     // Menu location on List is 0 in mainmenu
            mainMenu.AddAnotherSubMenu(new Delegates.MenuItem("Version and Digits")); // Menu location on List is 1 in mainmenu

            // Date and time Insertion
            Delegates.MenuItem ShowDateAndTimeMenu = mainMenu.GetSubMenuByIndex(0);
            ShowDateAndTimeMenu.AddAnotherSubMenu(new Delegates.ActionMenu(new Date().PreformAction, "Show Date"));
            ShowDateAndTimeMenu.AddAnotherSubMenu(new Delegates.ActionMenu(new Time().PreformAction, "Show Time"));

            // Version and Digits Insertion
            Delegates.MenuItem ShowVersionAndDigits = mainMenu.GetSubMenuByIndex(1);
            ShowVersionAndDigits.AddAnotherSubMenu(new Delegates.ActionMenu(new Version().PreformAction, "Show Version"));
            ShowVersionAndDigits.AddAnotherSubMenu(new Delegates.ActionMenu(new Digits().PreformAction, "Count Spaces"));

            mainMenu.Show();
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: erezlev13/Menu-Builder
        private static Delegates.MainMenu CreateMenuWithDelegates()
        {
            Delegates.MainMenu menu = new Delegates.MainMenu("Main Menu");
            Delegates.MenuItem MenuItemVersionSpaces = new Delegates.MenuItem("Version and Spaces");
            Delegates.MenuItem MenuItemShowDateTime  = new Delegates.MenuItem("Show Date/Time");
            menu.CreateMainMenu(MenuItemVersionSpaces, MenuItemShowDateTime);

            Delegates.MenuItem countSpaces = new Delegates.MenuItem("Count Spaces");
            countSpaces.MethodWasActivated += MethodImplementationDelegates.CountSpaces_MethodAction;
            Delegates.MenuItem showVersion = new Delegates.MenuItem("Show Version");
            showVersion.MethodWasActivated += MethodImplementationDelegates.ShowVersion_MethodAction;
            menu.MenuItems[0].AddToSubMenu(countSpaces, showVersion);

            Delegates.MenuItem showDate = new Delegates.MenuItem("Show Date");
            showDate.MethodWasActivated += MethodImplementationDelegates.ShowDate_MethodAction;
            Delegates.MenuItem showTime = new Delegates.MenuItem("Show Time");
            showTime.MethodWasActivated += MethodImplementationDelegates.ShowTime_MethodAction;
            menu.MenuItems[1].AddToSubMenu(showDate, showTime);

            return(menu);
        }
コード例 #29
0
ファイル: Program.cs プロジェクト: wwwsapir/CSharpEx4
        private static void delegateMenuTest()
        {
            Delegates.MainMenu firstMainMenu = new Delegates.MainMenu();

            // First Layer:
            Delegates.Menu dateTimeMenu          = firstMainMenu.AddSubMenuItem("Show Date/Time");
            Delegates.Menu versionAndActionsMenu = firstMainMenu.AddSubMenuItem("Version and Actions");

            // Second Layer:
            dateTimeMenu.AddActionMenuItem("Show Date", new DateOperation().Operate);
            dateTimeMenu.AddActionMenuItem("Show Time", new TimeOperation().Operate);
            Delegates.Menu actionsMenu = versionAndActionsMenu.AddSubMenuItem("Actions");
            versionAndActionsMenu.AddActionMenuItem("Show Version", new ShowVersionOperation().Operate);

            // Third Layer:
            actionsMenu.AddActionMenuItem("Count Spaces", new CountSpacesOperation().Operate);
            actionsMenu.AddActionMenuItem("Count Words", new CountWordsOperation().Operate);

            // Show the menu:
            firstMainMenu.ShowMenu();
        }
コード例 #30
0
ファイル: Program.cs プロジェクト: ShirlyEzer/portfolio
        private static void RunDelegateMenu()
        {
            Delegates.MasterItem mainMenuDelegate = new Delegates.MasterItem("Main Menu - Delegate");
            Delegates.MainMenu delegatesMainMenu = new Delegates.MainMenu(mainMenuDelegate);
            Delegates.MasterItem timeMenuDelegate = new Delegates.MasterItem("Time Menu");
            Delegates.LeafItem wordsCounterItemDelegate = new Delegates.LeafItem("Words Counter");
            Delegates.LeafItem showVersionItemDelegate = new Delegates.LeafItem("Show Version");
            Delegates.LeafItem showTimeItemDelegate = new Delegates.LeafItem("Show Time");
            Delegates.LeafItem showDateItemDelegate = new Delegates.LeafItem("Show Date");

            wordsCounterItemDelegate.DoAction += WordsCounterMethod;
            showVersionItemDelegate.DoAction += ShowVersionMethod;
            showTimeItemDelegate.DoAction += ShowTimeMethod;
            showDateItemDelegate.DoAction += ShowDateMethod;
            timeMenuDelegate.AddItem(showTimeItemDelegate);
            timeMenuDelegate.AddItem(showDateItemDelegate);
            mainMenuDelegate.AddItem(timeMenuDelegate);
            mainMenuDelegate.AddItem(wordsCounterItemDelegate);
            mainMenuDelegate.AddItem(showVersionItemDelegate);
            delegatesMainMenu.Show();
        }
コード例 #31
0
        public static void runDelegates()
        {
            Delegates.MainMenu MainMenu           = new Delegates.MainMenu("Main Menu - Delegates");
            Delegates.MenuItem ShowDateOrTime     = new Delegates.MenuItem(1, "Show Date/Time");
            Delegates.MenuItem VersionAndCapitals = new Delegates.MenuItem(2, "Version And Capitals");
            MainMenu.AddMenuItem(ShowDateOrTime);
            MainMenu.AddMenuItem(VersionAndCapitals);
            Delegates.MenuItem ShowTime       = new Delegates.ActionMenuItem(1, "Show Time");
            Delegates.MenuItem ShowDate       = new Delegates.ActionMenuItem(2, "Show Date");
            Delegates.MenuItem CountCapitals  = new Delegates.ActionMenuItem(1, "Count Capitals");
            Delegates.MenuItem DisplayVersion = new Delegates.ActionMenuItem(2, "Display Version");
            ShowDateOrTime.AddSubItem(ShowTime);
            ShowDateOrTime.AddSubItem(ShowDate);
            VersionAndCapitals.AddSubItem(CountCapitals);
            VersionAndCapitals.AddSubItem(DisplayVersion);
            ShowDate.AttachObserver(new Delegates.ReportChosenDelegate(ShowCurrentDate));
            ShowTime.AttachObserver(new Delegates.ReportChosenDelegate(ShowCurrentTime));
            CountCapitals.AttachObserver(new Delegates.ReportChosenDelegate(CountCapitalsMethod));
            DisplayVersion.AttachObserver(new Delegates.ReportChosenDelegate(DisplayVersionMethod));

            MainMenu.Show();
        }