Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }