Esempio n. 1
0
        /// <summary>
        /// Looks the themes table for the specified name and creates the Theme
        /// object
        /// </summary>
        /// <param name="name">Name of the Theme</param>
        /// <returns>true on success</returns>
        public bool SetActiveTheme(String name)
        {
            bool retVal = true;
            var themeName = name.ToLower();
            Log.Debug("Set active Theme to " + themeName);

            if (!_themesLookupTable.ContainsKey(themeName))
            {
                Log.Debug("Could not find Theme " + themeName + " in the table");
                return false;
            }
            Log.Debug("Found Theme " + themeName + " in the table");

            var themeDir = _themesLookupTable[themeName];
            var themeFile = Path.Combine(themeDir, ThemeConfigFileName);

            Log.Debug("Creating Theme " + name + ", themeDir: " + themeDir);

            // create the Theme object. This parses the Theme xml file and
            // creates the Theme object
            var theme = Theme.Create(name, themeDir, themeFile);
            if (theme != null)
            {
                if (_activeTheme != null)
                {
                    _activeTheme.Dispose();
                }

                _activeTheme = theme;
                ActiveThemeName = name;
                Log.Debug("Created Theme successfully. active Theme is " + _activeTheme.Name);
            }
            else
            {
                Log.Debug("Error creating Theme");
                retVal = false;
            }
            return retVal;
        }
Esempio n. 2
0
        /// <summary>
        /// Class factory to create a Theme object with the specified name. skinDir
        /// directory contains all the assets for the Theme. Skinfile is the xml
        /// file that contains references to all the theme assets.
        /// </summary>
        /// <param name="themeName">Name of the theme</param>
        /// <param name="skinDir">directory where theme assets are located</param>
        /// <param name="themeFile">name of the theme config file</param>
        /// <returns></returns>
        public static Theme Create(String themeName, String skinDir, String themeFile)
        {
            Theme theme = null;

            if (!File.Exists(themeFile))
            {
                return null;
            }

            try
            {
                var doc = new XmlDocument();

                doc.Load(themeFile);

                // create the colorschemes object by parsing the colorschemes nodes
                var colorSchemesNode = doc.SelectSingleNode("/ACAT/Skin/ColorSchemes");
                if (colorSchemesNode != null)
                {
                    theme = new Theme(themeName) { Colors = ColorSchemes.Create(colorSchemesNode, skinDir) };
                }
            }
            catch (Exception ex)
            {
                Log.Debug(ex.ToString());
            }

            return theme;
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes the singleton instance of the manager
 /// </summary>
 private ThemeManager()
 {
     ActiveThemeName = "DefaultSkin";
     DefaultTheme = Theme.Create(ActiveThemeName);
     _activeTheme = Theme.Create(ActiveThemeName);
 }