12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using Common.system;
-
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
-
- namespace XHWK.WKTool.Skin
- {
-
-
-
-
-
- public class SkinConfig
- {
-
-
-
- static List<ResourceDictionary> SkinList = new List<ResourceDictionary>();
-
-
-
- public static void InitSkin()
- {
- SkinList.Add(new ResourceDictionary()
- {
- Source = new Uri("pack://application:,,,/Skin/SkinDictionary_White.xaml", UriKind.Absolute)
- });
- SkinList.Add(new ResourceDictionary()
- {
- Source = new Uri("pack://application:,,,/Skin/SkinDictionary_TechnologyBlue.xaml", UriKind.Absolute)
- });
- int Index = 0;
- try
- {
- Index = int.Parse(App.SkinStyle);
- }
- catch (Exception) { }
- ChangeSkinResource(SkinList[int.Parse(App.SkinStyle)]);
- }
-
-
-
-
-
- public static void SwitchSkin(int Index)
- {
- if (Index < SkinList.Count)
- {
- App.SkinStyle = Index.ToString();
- FileToolsCommon.SetConfigValue("SkinStyle", App.SkinStyle);
- ChangeSkinResource(SkinList[int.Parse(App.SkinStyle)]);
- }
-
- }
-
-
-
-
-
- private static void ChangeSkinResource(ResourceDictionary skin)
- {
- if(Application.Current.Resources.MergedDictionaries.Count<1)
- {
- Application.Current.Resources.MergedDictionaries.Add(skin);
-
- }
- if (Application.Current.Resources.MergedDictionaries[0].Source.IsAbsoluteUri)
- {
- if (Application.Current.Resources.MergedDictionaries[0].Source.OriginalString != skin.Source.OriginalString)
- {
- Application.Current.Resources.MergedDictionaries[0] = skin;
- }
- }
- else
- {
- if (Application.Current.Resources.MergedDictionaries[0].Source.OriginalString.ToString('\\') != skin.Source.OriginalString.ToString('/'))
- {
- Application.Current.Resources.MergedDictionaries[0] = skin;
- }
- }
- }
- }
-
-
-
- public static class ExtensionMethod
- {
- public static string ToString(this string content, char split)
- {
- return content.Split(split).Last();
- }
- }
- }
|