static void GenerateSettings() { var settings = new Settings { ImageWidth = Questions.AskIntMessage("> Enter the desired image width: ", Color.Gray), ImageHeight = Questions.AskIntMessage("> Enter the desired image height: ", Color.Gray), WallpaperDisplayStyle = ShowEnumMenu <WallpaperDisplayStyle>(), Source = GenerateUnsplashSource(), Interval = new TimeSpan(0, 0, Questions.AskIntMessage("How often the wallpaper should be updated (In minutes)? "), 0, 0) }; Settings = settings; settings.Save(); CreateLoopTask(); }
public static T ShowEnumMenu <T>() { var enumValues = Enum.GetValues(typeof(T)).OfType <Enum>().ToList(); Console.WriteLine($"Select a {typeof(T)} member"); for (var i = 0; i < enumValues.Count; i++) { var member = enumValues[i]; var description = member.GetEnumDescription() == member.ToString() ? "" : " // " + member.GetEnumDescription(); Console.WriteLine($"[{i}] {member}{description}"); } var id = Questions.AskIntMessage("Pick a enum member (eg: 0): ", Color.Gray); return((T)Enum.Parse(typeof(T), id.ToString())); }