ThemeResourceDictionary.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using ClashDotNetFramework.Models.Enums;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. namespace ClashDotNetFramework.Models
  9. {
  10. public class ThemeResourceDictionary : ResourceDictionary
  11. {
  12. private Uri _classicSource;
  13. private Uri _modernSource;
  14. private Uri _darkSource;
  15. public Uri ClassicSource
  16. {
  17. get { return _classicSource; }
  18. set
  19. {
  20. _classicSource = value;
  21. UpdateSource();
  22. }
  23. }
  24. public Uri ModernSource
  25. {
  26. get { return _modernSource; }
  27. set
  28. {
  29. _modernSource = value;
  30. UpdateSource();
  31. }
  32. }
  33. public Uri DarkSource
  34. {
  35. get { return _darkSource; }
  36. set
  37. {
  38. _darkSource = value;
  39. UpdateSource();
  40. }
  41. }
  42. public void UpdateSource()
  43. {
  44. Uri source = null;
  45. switch (Global.Settings.Theme)
  46. {
  47. case ThemeType.Classic:
  48. source = ClassicSource;
  49. break;
  50. case ThemeType.Modern:
  51. source = ModernSource;
  52. break;
  53. case ThemeType.Dark:
  54. source = DarkSource;
  55. break;
  56. default:
  57. break;
  58. }
  59. if (source != null && base.Source != source)
  60. base.Source = source;
  61. }
  62. }
  63. }