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();
        }
Exemplo n.º 2
0
        public void Run()
        {
            MainMenu      menu              = new MainMenu("Main Menu");
            SubMenu       dateTimeMenu      = new SubMenu("Show date and time");
            SubMenu       verisonAndCapital = new SubMenu("Verison and Capital");
            ShowTime      showTime          = new ShowTime("Show time");
            ShowDate      showDate          = new ShowDate("Show date");
            CountCapitals countCapitals     = new CountCapitals("Count Capitals");
            ShowVerison   showVerison       = new ShowVerison("Show verison");

            menu.AddItem(dateTimeMenu);
            menu.AddItem(verisonAndCapital);
            dateTimeMenu.AddItem(showTime);
            dateTimeMenu.AddItem(showDate);
            verisonAndCapital.AddItem(countCapitals);
            verisonAndCapital.AddItem(showVerison);
            menu.Show();
        }
Exemplo n.º 3
0
        public void Run()
        {
            Menu          versionAndCapitalsMenu = new Menu("Version and Capitals", m_MainMenu.Menu.Level + 1);
            Menu          showDateAndTime        = new Menu("Show date/time", m_MainMenu.Menu.Level + 1);
            ShowDate      showDate      = new ShowDate("Show Date");
            ShowTime      showTime      = new ShowTime("Show Time");
            ShowVersion   showVersion   = new ShowVersion("Show Version");
            CountCapitals countCapitals = new CountCapitals("Count Capitals");

            m_MainMenu.Add(showDateAndTime);
            m_MainMenu.Add(versionAndCapitalsMenu);
            showDateAndTime.Add(showDate);
            showDateAndTime.Add(showTime);
            versionAndCapitalsMenu.Add(showVersion);
            versionAndCapitalsMenu.Add(countCapitals);
            try
            {
                m_MainMenu.Show();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }