Пример #1
0
        public HelpDetailView GetHelpByCode(HelpCode helpCode)
        {
            var expression = base.GetFilterEnabled();

            expression = expression.And(h => h.HelpCode == (int)helpCode);

            return(_Respository.GetFeilds(u => new HelpDetailView {
                Title = u.Title, Id = u.Id, Description = u.Description, Attachment = u.Attachment, CoverUrl = u.CoverUrl
            }, expression)
                   .FirstOrDefault());
        }
Пример #2
0
        public void Show()
        {
            while (!Quit)
            {
                Clear();

                WriteLine($"{Style(TitleStyle, Title)}");
                WriteLine();
                if (MenuItems.Count > 0)
                {
                    WriteLine("Please select one of the following menu items: ");
                    WriteLine();
                    var length = MenuItems.Max(item => item.Key.Length);
                    foreach (IMenuItem item in MenuItems)
                    {
                        var key = item.Key.PadLeft(length);
                        WriteLine($"{Style(KeyStyle, key)}) {item.Name}");
                    }
                }
                else
                {
                    WriteLine("There are currently no menu items available.");
                }
                WriteLine();
                WriteLine($"type in '{Style(KeyStyle, QuitCode)}' to quit the application");

                var stylecode = "".AddColor().Foregorund.CyanColor().CurrentValue;

                Write($"Select menu: ");
INVALIDENTRY:
                var input = GetInput(stylecode).ToLower();

                ClearLinesBelow();

                Write("".AddStyle().Reset());


                if (input == QuitCode.ToLower())
                {
                    Quit = true;
                }
                else if (input == HelpCode.ToLower())
                {
                    WriteLine();
                    WriteLine("HELP".AddUnderline());
                    WriteLine($"{Style(KeyStyle, HelpCode)}: will display this message");
                    WriteLine($"{Style(KeyStyle, QuitCode)}: will terminate the console application");
                    WriteLine($"{Style(KeyStyle, HelpCode)} {Style(KeyStyle, "<KEY>")}: Will show you some help/description about the menu item specified as <KEY>");
                    RestoreCursorPosition();


                    goto INVALIDENTRY;
                }
                else if (input.StartsWith("help ") && MenuItems.Any(item => item.Key.ToLower() == input.Split(" ")[1].Trim()))
                {
                    var selectedMenu = MenuItems.Where(item => item.Key.ToLower() == input.Split(" ")[1].Trim()).SingleOrDefault();
                    WriteLine();
                    WriteLine($"{selectedMenu.Name.AddUnderline()}");
                    WriteLine($"{selectedMenu.Description}");
                    RestoreCursorPosition();
                    goto INVALIDENTRY;
                }
                else if (MenuItems.Any(item => item.Key.ToLower() == input))
                {
                    var selectedMenu = MenuItems.Where(item => item.Key.ToLower() == input).SingleOrDefault();

                    Clear();
                    //TODO: if we are in a submenu, we should not wait for a readkey and print press any key, also quit message should be different
                    selectedMenu.Execute();
                    WriteLine();
                    WriteLine("press any key to continue");
                    Console.ReadKey(true);
                }
                else
                {
                    Write($"{"ERROR".AddColor().Background.RedColor().Foregorund.White()}: Your menu selection was invalid. Please select a valid menu item or type in '{Style(KeyStyle, HelpCode)}' to view the help.");
                    RestoreCursorPosition();
                    goto INVALIDENTRY;
                }
            }
        }