Theme.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System;
  2. using System.Collections.Generic;
  3. namespace DesktopClock;
  4. /// <summary>
  5. /// A defined color set.
  6. /// </summary>
  7. public readonly record struct Theme
  8. {
  9. /// <summary>
  10. /// Friendly name for the theme.
  11. /// </summary>
  12. public string Name { get; }
  13. /// <summary>
  14. /// The primary color, used in the text.
  15. /// </summary>
  16. public string PrimaryColor { get; }
  17. /// <summary>
  18. /// The secondary color, used in the background or outline.
  19. /// </summary>
  20. public string SecondaryColor { get; }
  21. public Theme(string name, string primaryColor, string secondaryColor)
  22. {
  23. Name = name;
  24. PrimaryColor = primaryColor;
  25. SecondaryColor = secondaryColor;
  26. }
  27. /// <summary>
  28. /// Built-in themes that the user can use without specifying their own palettes.
  29. /// </summary>
  30. /// <remarks>
  31. /// https://www.materialui.co/colors - A100, A700.
  32. /// </remarks>
  33. public static IReadOnlyList<Theme> DefaultThemes { get; } = new Theme[]
  34. {
  35. new("Light Text", "#F5F5F5", "#212121"),
  36. new("Dark Text", "#212121", "#F5F5F5"),
  37. new("Red", "#D50000", "#FF8A80"),
  38. new("Pink", "#C51162", "#FF80AB"),
  39. new("Purple", "#AA00FF", "#EA80FC"),
  40. new("Blue", "#2962FF", "#82B1FF"),
  41. new("Cyan", "#00B8D4", "#84FFFF"),
  42. new("Green", "#00C853", "#B9F6CA"),
  43. new("Orange", "#FF6D00", "#FFD180"),
  44. };
  45. /// <summary>
  46. /// Returns a random theme from <see cref="DefaultThemes"/>.
  47. /// </summary>
  48. public static Theme GetRandomDefaultTheme()
  49. {
  50. var random = new Random();
  51. return DefaultThemes[random.Next(0, DefaultThemes.Count)];
  52. }
  53. }