示例#1
0
        private void View()
        {
            ShowForm();
            Console.CursorVisible = false;

            Dictionary <ConsoleKey, Action> keyChoices = new Dictionary <ConsoleKey, Action>()
            {
                { ConsoleKey.Escape, () => { } }
            };

            if (HasPermissionTo(_RealLoggedUser.CanEdit))
            {
                ColoredConsole.Write("  [Enter] => Edit", 1, LastTextBoxY + 2, ConsoleColor.DarkGray);
                keyChoices.Add(ConsoleKey.Enter, FillForm);
            }

            if (HasPermissionTo(_RealLoggedUser.CanDelete))
            {
                ColoredConsole.Write(" [Delete] => Delete", 1, LastTextBoxY + 3, ConsoleColor.DarkGray);
                keyChoices.Add(ConsoleKey.Delete, AskAndDelete);
            }

            ReadKey <Action> readKey = new ReadKey <Action>(keyChoices);

            readKey.GetKey()();
        }
示例#2
0
 static MessageBox()
 {
     _readKey = new ReadKey <MessageBoxResult>(
         new Dictionary <ConsoleKey, MessageBoxResult>()
     {
         { ConsoleKey.Y, MessageBoxResult.Yes },
         { ConsoleKey.N, MessageBoxResult.No },
         { ConsoleKey.Escape, MessageBoxResult.No }
     });
 }
示例#3
0
        public bool ChooseListItem()
        {
            Id = -1;

            while (Id == -1)
            {
                GeneratePageMenuChoices();
                Show();
                ReadKey <Action> readKey = new ReadKey <Action>(GetKeyChoices());
                readKey.GetKey()();
            }

            return(Id != 0);
        }
示例#4
0
        private void View()
        {
            ShowForm();
            ColoredConsole.Write("  [Enter] => Edit", 1, LastTextBoxY + 2, ConsoleColor.DarkGray);
            ColoredConsole.Write(" [Delete] => Delete", 1, LastTextBoxY + 3, ConsoleColor.DarkGray);

            Console.CursorVisible = false;

            ReadKey <Action> readKey = new ReadKey <Action>(
                new Dictionary <ConsoleKey, Action>()
            {
                { ConsoleKey.Enter, FillForm },
                { ConsoleKey.Delete, AskAndDelete },
                { ConsoleKey.Escape, () => { } },
            });

            readKey.GetKey()();
        }