示例#1
0
        private static void MainMenu()
        {
            var menu = new MenuPage("Main Menu");

            menu.Add("Manage Service", ManageServiceMenu, () => true);
            menu.Add("Run in console", () => {
                Console.Clear();
                Console.ResetColor();
                var service = new TTService();
                service.Initialize();
                Console.ReadKey(true);
                service.Finalize(ComputerStateType.Shutdown);
                Console.WriteLine("Press any key to return to the menu...");
                Console.ReadKey(true);
                return(false);
            }, () => Service == null || Service.Status != ServiceControllerStatus.Running);
            menu.Add("Debug", DebugMenu, () => Service != null && Service.Status != ServiceControllerStatus.Running);
            menu.Add("Exit", () => true, () => true, '0');

            while (true)
            {
                Console.Clear();
                var selected = menu.Show();
                if (selected.Callback())
                {
                    return;
                }
            }
        }
示例#2
0
        private static void Main(string[] args)
        {
            if (Environment.UserInteractive)
            {
                var menu = new MenuPage("Main Menu");
                menu.Add("Manage Service", ManageService, () => true);
                menu.Add("Run in console", () => {
                    Console.Clear();
                    Console.ResetColor();
                    var service = new TTService();
                    service.Initialize();
                    Console.ReadKey(true);
                    service.Finalize(ComputerStateType.Shutdown);
                    Console.WriteLine("Press any key to return to the menu...");
                    Console.ReadKey(true);
                    return(false);
                }, () => Service == null || Service.Status != ServiceControllerStatus.Running);
                menu.Add("Show hardware info", () => {
                    ShowHardwareInfo();
                    return(false);
                }, () => Service != null && Service.Status != ServiceControllerStatus.Running);
                menu.Add("Exit", () => true, () => true, '0');

                while (true)
                {
                    Console.Clear();
                    var selected = menu.Show();
                    if (selected.Callback())
                    {
                        return;
                    }
                }
            }
            else
            {
                ServiceBase.Run(new TTService());
            }
        }