星火微课系统客户端
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

3 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. using Common.system;
  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 XHWK.WKTool.Skin
  9. {
  10. /// <summary>
  11. /// 皮肤配置
  12. /// 创建人:赵耀
  13. /// 创建时间:2021年6月18日
  14. /// </summary>
  15. public class SkinConfig
  16. {
  17. /// <summary>
  18. /// 皮肤列表 0白 1蓝 2黑色
  19. /// </summary>
  20. static List<ResourceDictionary> SkinList = new List<ResourceDictionary>();
  21. /// <summary>
  22. /// 初始化皮肤
  23. /// </summary>
  24. public static void InitSkin()
  25. {
  26. SkinList.Add(new ResourceDictionary()
  27. {
  28. Source = new Uri("pack://application:,,,/Skin/SkinDictionary_White.xaml", UriKind.Absolute)
  29. });
  30. SkinList.Add(new ResourceDictionary()
  31. {
  32. Source = new Uri("pack://application:,,,/Skin/SkinDictionary_TechnologyBlue.xaml", UriKind.Absolute)
  33. });
  34. int Index = 0;
  35. try
  36. {
  37. Index = int.Parse(APP.SkinStyle);
  38. }
  39. catch (Exception) {}
  40. ChangeSkinResource(SkinList[int.Parse(APP.SkinStyle)]);
  41. }
  42. /// <summary>
  43. /// 切换皮肤并保存 0白 1蓝 2黑色
  44. /// </summary>
  45. /// <param name="Index"> 0白 1蓝 2黑色</param>
  46. public static void SwitchSkin(int Index)
  47. {
  48. if (Index < SkinList.Count)
  49. {
  50. APP.SkinStyle = Index.ToString();
  51. FileToolsCommon.SetConfigValue("SkinStyle", APP.SkinStyle);
  52. ChangeSkinResource(SkinList[int.Parse(APP.SkinStyle)]);
  53. }
  54. }
  55. /// <summary>
  56. /// 更换皮肤资源
  57. /// </summary>
  58. /// <param name="skin"></param>
  59. private static void ChangeSkinResource(ResourceDictionary skin)
  60. {
  61. if(Application.Current.Resources.MergedDictionaries.Count<1)
  62. {
  63. Application.Current.Resources.MergedDictionaries.Add(skin);//[0] = new ResourceDictionary();
  64. //Application.Current.Resources.MergedDictionaries[0]=skin;
  65. }
  66. if (Application.Current.Resources.MergedDictionaries[0].Source.IsAbsoluteUri)
  67. {
  68. if (Application.Current.Resources.MergedDictionaries[0].Source.OriginalString != skin.Source.OriginalString)
  69. {
  70. Application.Current.Resources.MergedDictionaries[0] = skin;
  71. }
  72. }
  73. else
  74. {
  75. if (Application.Current.Resources.MergedDictionaries[0].Source.OriginalString.ToString('\\') != skin.Source.OriginalString.ToString('/'))
  76. {
  77. Application.Current.Resources.MergedDictionaries[0] = skin;
  78. }
  79. }
  80. }
  81. }
  82. /// <summary>
  83. /// 扩展方法
  84. /// </summary>
  85. public static class ExtensionMethod
  86. {
  87. public static string ToString(this string content, char split)
  88. {
  89. return content.Split(split).Last();
  90. }
  91. }
  92. }