示例#1
0
 /// <summary>
 /// Removes the theme.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="theme">The theme.</param>
 public void RemoveTheme(ResourceDictionary source, Theme theme)
 {
     source.Guard("source");
     theme.Guard("theme");
     lock (LoadedThemes)
     {
         ResourceDictionary dict;
         if (!LoadedThemes.TryGetValue(theme.UniqueId, out dict))
         {
             return;
         }
         source.MergedDictionaries.Remove(dict);
     }
 }
示例#2
0
 /// <summary>
 /// Applies the theme.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="theme">The theme.</param>
 public void ApplyTheme(ResourceDictionary target, Theme theme)
 {
     target.Guard("target");
     theme.Guard("theme");
     lock (LoadedThemes)
     {
         ResourceDictionary dict;
         RemoveTheme(target, theme);
         if (!LoadedThemes.TryGetValue(theme.UniqueId, out dict))
         {
             var resource       = theme.GetResourceLocation();
             var sourceAssembly = theme.GetType().Assembly;
             dict = new ResourceDictionary {
                 Source = RuntimeHelper.MakePackUri(sourceAssembly, resource)
             };
         }
         target.MergedDictionaries.Add(dict);
     }
 }
示例#3
0
 /// <summary>
 /// Removes the theme.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <param name="theme">The theme.</param>
 public void RemoveTheme(ResourceDictionary source, Theme theme)
 {
     source.Guard("source");
     theme.Guard("theme");
     lock (LoadedThemes)
     {
         ResourceDictionary dict;
         if (!LoadedThemes.TryGetValue(theme.UniqueId, out dict))
             return;
         source.MergedDictionaries.Remove(dict);
     }
 }
示例#4
0
 /// <summary>
 /// Applies the theme.
 /// </summary>
 /// <param name="target"></param>
 /// <param name="theme">The theme.</param>
 public void ApplyTheme(ResourceDictionary target, Theme theme)
 {
     target.Guard("target");
     theme.Guard("theme");
     lock (LoadedThemes)
     {
         ResourceDictionary dict;
         RemoveTheme(target, theme);
         if (!LoadedThemes.TryGetValue(theme.UniqueId, out dict))
         {
             var resource = theme.GetResourceLocation();
             var sourceAssembly = theme.GetType().Assembly;
             var pack = RuntimeHelper.MakePackUri(sourceAssembly, resource);
             dict = new ResourceDictionary { Source =  pack };
         }
         target.MergedDictionaries.Add(dict);
     }
 }