protected static void FindSkinAndTheme(out Skin skin, out Theme theme)
 {
   IScreenManager screenManager = ServiceRegistration.Get<IScreenManager>();
   ISkinResourceBundle bundle = screenManager.CurrentSkinResourceBundle;
   theme = bundle as Theme;
   skin = bundle as Skin;
   if (theme != null)
     skin = bundle.InheritedSkinResources as Skin;
 }
Beispiel #2
0
 public bool Install(Skin skin)
 {
   Uninstall();
   string location = "/Skins/" + skin.Name;
   IPluginManager pluginManager = ServiceRegistration.Get<IPluginManager>();
   PluginItemMetadata md = pluginManager.GetPluginItemMetadata(location, BACKGROUND_PLUGIN_ITEM_ID);
   if (md == null)
     return false;
   try
   {
     _backgroundLocation = location;
     _backgroundManager = pluginManager.RequestPluginItem<IBackgroundManager>(
           _backgroundLocation, BACKGROUND_PLUGIN_ITEM_ID, this);
     _backgroundManager.Install();
     return true;
   }
   catch (PluginInvalidStateException e)
   {
     ServiceRegistration.Get<ILogger>().Warn("Cannot install background manager for {0}", e, location);
   }
   return false;
 }
 /// <summary>
 /// Initializes the <see cref="InheritedSkinResources"/> property.
 /// </summary>
 /// <param name="skins">All available skins.</param>
 /// <param name="defaultSkin">The default skin of the skin manager.</param>
 internal abstract void SetupResourceChain(IDictionary<string, Skin> skins, Skin defaultSkin);
Beispiel #4
0
 public Theme(string name, Skin parentSkin): base(name)
 {
   _parentSkin = parentSkin;
 }
Beispiel #5
0
 internal override void SetupResourceChain(IDictionary<string, Skin> skins, Skin defaultSkin)
 {
   CheckMetadataInitialized();
   Theme inheritTheme;
   if (_basedOnTheme != null && _parentSkin.Themes.TryGetValue(_basedOnTheme, out inheritTheme))
     InheritedSkinResources = inheritTheme;
   else
   {
     SkinResources parentDefaultTheme = _parentSkin.DefaultTheme;
     InheritedSkinResources = parentDefaultTheme != null && parentDefaultTheme != this ? parentDefaultTheme : _parentSkin;
   }
   _inheritedSkinResources.SetupResourceChain(skins, defaultSkin);
 }
Beispiel #6
0
 public bool InstallBackgroundManager(Skin skin)
 {
   // Loading and disposing of the background manager will be handled by the BackgroundManagerData class
   UninstallBackgroundManager();
   SkinResources current = skin;
   while (current != null)
   {
     if (current is Skin && _backgroundManagerData.Install((Skin) current))
       return true;
     current = current.InheritedSkinResources;
   }
   return false;
 }
Beispiel #7
0
    /// <summary>
    /// Will reload all skins from the file system.
    /// </summary>
    public void ReloadSkins()
    {
      // We won't clear the skins so we don't loose our object references to the skins
      foreach (Skin skin in _skins.Values)
      {
        skin.Release();
        skin.ClearRootDirectories();
      }

      foreach (string rootDirectoryPath in GetSkinRootDirectoryPaths())
        if (Directory.Exists(rootDirectoryPath))
          try
          {
            foreach (string skinDirectoryPath in Directory.GetDirectories(rootDirectoryPath))
            {
              string skinName = Path.GetFileName(skinDirectoryPath) ?? string.Empty;
              if (skinName.StartsWith("."))
                continue;
              Skin skin;
              if (!_skins.TryGetValue(skinName, out skin))
                skin = _skins[skinName] = new Skin(skinName);
              skin.AddRootDirectory(skinDirectoryPath);
            }
          }
          catch (Exception e)
          {
            ServiceRegistration.Get<ILogger>().Warn("SkinManager: Error loading skins from directory '{0}'", e, rootDirectoryPath);
          }
        else
          ServiceRegistration.Get<ILogger>().Warn("SkinManager: Skin resource directory '{0}' doesn't exist", rootDirectoryPath);
    }
Beispiel #8
0
 internal override void SetupResourceChain(IDictionary<string, Skin> skins, Skin defaultSkin)
 {
   CheckMetadataInitialized();
   Skin basedOnSkin;
   if (_basedOnSkin != null && skins.TryGetValue(_basedOnSkin, out basedOnSkin))
   {
     Theme basedOnTheme;
     if (_basedOnTheme != null && basedOnSkin.Themes.TryGetValue(_basedOnTheme, out basedOnTheme))
       InheritedSkinResources = basedOnTheme;
     else
       InheritedSkinResources = basedOnSkin.DefaultTheme ?? (SkinResources) basedOnSkin;
   }
   else
     InheritedSkinResources = this == defaultSkin ? null : defaultSkin.DefaultTheme ?? (SkinResources) defaultSkin;
   if (_inheritedSkinResources != null)
     _inheritedSkinResources.SetupResourceChain(skins, defaultSkin);
 }
Beispiel #9
0
 public Theme(string name, Skin parentSkin) : base(name)
 {
     _parentSkin = parentSkin;
 }
Beispiel #10
0
 /// <summary>
 /// Initializes the <see cref="InheritedSkinResources"/> property.
 /// </summary>
 /// <param name="skins">All available skins.</param>
 /// <param name="defaultSkin">The default skin of the skin manager.</param>
 internal abstract void SetupResourceChain(IDictionary <string, Skin> skins, Skin defaultSkin);