static IDictionary <Option, IInputTool> GenerateOptions() { int minAge = 1; int maxAge = 200; return(new Dictionary <Option, IInputTool> { { Option.Name, new RegexInput(@"^[a-zA-ZåäöÅÄÖ0-9 ,.!?]+$") { Title = "Name", Header = "What is your name?", ErrorMessage = $"Must be alphanumeric, comma ',' or space ' '" } }, { Option.Age, new IntegerInput((val) => val >= minAge && val <= maxAge) { Title = "Age", Header = "How old are you?", ErrorMessage = $"Must be in range {minAge}-{maxAge}", Footer = "Limpistol för lösa tånaglar" } }, { Option.Gender, new Selector <string>(new string[] { "♂ - Male", "♀ - Female", "o - Other" }) { Title = "Gender", Header = "What's your gender?" } }, { Option.Style, GeneratePlayStyleSelector() }, { Option.Weapon, new EnumSelector <Weapon> { Title = "Weapon", Header = "Choose your prefered weapon" } }, { Option.Armour, new EnumSelector <Armour> { Title = "Armour", Header = "Choose prefered armour" } }, { Option.Badges, FlagSelector.New <Badges>(Title: "Simmärken", Header: "Vilka simmärken har du tagit?") } }); }
static void Main(string[] args) { try { var root = new FolderBrowserDialog() { SelectedPath = "." }; var exit = new EnumSelector <Confirm> { Header = "Do you want to quit?" }; var extensions = FlagSelector.New <Extensions>(); var exts = Enum.GetValues(typeof(Extensions)).Cast <Extensions>(); extensions.AllowCancel = false; Selector <object> menu; do { extensions.Activate(); root.ShowDialog(); menu = CreateMenu(root.SelectedPath, exit, exts.Where(x => extensions.Value.HasFlag(x)).Select(x => $".{x}")); if (menu == null) { DisplayErrorMessage("Cannot select folder. It contains no textfiles.", "[Press enter to load another folder]"); continue; } menu.Activate(); } while (exit.Value != Confirm.Yes); } catch (Exception ex) { DisplayErrorMessage($"An error has occured:\n{ex.Message}", "[Press enter to exit]"); } }