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]"); } }
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?") } }); }
public CourseFormViewModel(Course course, IEnumerable <CFlag> AllFlags, IEnumerable <Course> AllCourses) { this.ID = course.ID; this.CourseName = course.CourseName; this.Length = course.Length; this.Notes = course.Notes; this.Flags = new FlagSelector[AllFlags.Count()]; int i = 0; foreach (CFlag f in AllFlags) { FlagSelector fs = new FlagSelector(f); fs.Selected = course.Flags.Contains(f); Flags[i] = fs; i++; } IEnumerable <Course> RequireableCourses = AllCourses.Where(c => c.ID != course.ID).Except(course.ReqFor); this.PreReqs = new CourseSelector[RequireableCourses.Count()]; i = 0; foreach (Course c in RequireableCourses) { CourseSelector cs = new CourseSelector(c); cs.Selected = course.PreReqs.Contains(c); PreReqs[i] = cs; i++; } this.ReqFor = course.ReqFor; }
public PersonFormViewModel(Person person, IEnumerable <Flag> AllFlags, IEnumerable <Borough> AllBoros, IEnumerable <Service> AllMHC) { this.ID = person.ID; this.TitleID = person.TitleID; this.Forename = person.Forename; this.Surname = person.Surname; this.PreferredName = person.PreferredName; this.DisplayName = person.GetFullName(); this.Gender = person.Gender; this.JobTitle = person.JobTitle; this.FinanceCode = person.FinanceCode; this.SubjectiveID = person.SubjectiveID; this.LineManID = person.LineManID; this.Phone = person.Phone; this.Email = person.Email; this.ESRID = person.ESRID; this.MiddleName = person.MiddleName; this.Comments = person.Comments; this.CohortID = person.CohortID; this.Flags = new FlagSelector[AllFlags.Count()]; int i = 0; foreach (Flag f in AllFlags) { FlagSelector fs = new FlagSelector(f); fs.Selected = person.Flags.Contains(f); Flags[i] = fs; i++; } this.Boroughs = new BoroughSelector[AllBoros.Count()]; i = 0; foreach (Borough b in AllBoros) { BoroughSelector bs = new BoroughSelector(b); bs.Selected = person.Boroughs.Contains(b); Boroughs[i] = bs; i++; } this.MHCs = new MHC[AllMHC.Count()]; i = 0; foreach (Service s in AllMHC) { MHC mhc = new MHC(s); mhc.Selected = person.Services.Contains(s); MHCs[i] = mhc; i++; } this.Services = person.Services.Where(s => s.Level == ServiceLevel.Speciality && s.Display).ToArray(); this.Memberships = person.MemberOf.ToArray(); }
protected static void AppendArgument(StringBuilder sb, string argname, FlagSelector value) { if(value != FlagSelector.Unspecified) { BeginArgument(sb, argname); switch(value) { case FlagSelector.True: sb.Append("true"); break; case FlagSelector.False: sb.Append("false"); break; case FlagSelector.Any: sb.Append("any"); break; default: throw new ApplicationException(); } } }
protected static void AppendArgument(StringBuilder sb, string argname, FlagSelector value) { if (value != FlagSelector.Unspecified) { BeginArgument(sb, argname); switch (value) { case FlagSelector.True: sb.Append("true"); break; case FlagSelector.False: sb.Append("false"); break; case FlagSelector.Any: sb.Append("any"); break; default: throw new ApplicationException(); } } }
public void HandleCommand(object command) { FlagSelector.HandleCommand(command); }