public static List <BSTheme> GetThemes() { List <BSTheme> themes = new List <BSTheme>(); DirectoryInfo DirInfo = new DirectoryInfo(HttpContext.Current.Server.MapPath("~/Themes/")); DirectoryInfo[] directories = DirInfo.GetDirectories(); foreach (DirectoryInfo directoryInfo in directories) { BSTheme _theme = Get(directoryInfo.Name); if (_theme != null) { themes.Add(_theme); } } return(themes); }
public static BSTheme Get(string themeName) { using (StreamReader srXmlFile = new StreamReader(HttpContext.Current.Server.MapPath(String.Format("~/Themes/{0}/Settings.xml", themeName)))) { XmlDocument _doc = new XmlDocument(); BSThemeSettings _Settings = new BSThemeSettings(); BSTheme _theme = new BSTheme(); _doc.Load(srXmlFile); XmlNode _nodeTheme = _doc.SelectSingleNode("theme"); _theme.Author = _nodeTheme["author"].InnerText; _theme.Description = _nodeTheme["description"].InnerText; _theme.Folder = _nodeTheme["folder"].InnerText; _theme.Name = _nodeTheme["name"].InnerText; _theme.ScreenShot = _nodeTheme["screenshot"].InnerText; _theme.UpdateUrl = _nodeTheme["updateurl"].InnerText; _theme.Version = _nodeTheme["version"].InnerText; _theme.WebSite = _nodeTheme["website"].InnerText; XmlNode _nodeSetting = _nodeTheme.SelectSingleNode("settings"); if (_nodeSetting != null && _nodeSetting.ChildNodes.Count > 0) { XmlNodeList _nodeKeyList = _nodeSetting.SelectNodes("add"); foreach (XmlNode node in _nodeKeyList) { BSThemeSetting _setting = new BSThemeSetting(); _setting.Title = node.Attributes["title"] != null ? node.Attributes["title"].Value : String.Empty; _setting.Description = node.Attributes["description"] != null ? node.Attributes["description"].Value : String.Empty; _setting.Key = node.Attributes["key"] != null ? node.Attributes["key"].Value : String.Empty; _setting.Value = node.Attributes["defaultValue"] != null ? node.Attributes["defaultValue"].Value : node.InnerText; string typeText = node.Attributes["type"].Value.ToLowerInvariant(); switch (typeText) { case "text": _setting.Type = ThemeSettingType.Text; break; case "number": _setting.Type = ThemeSettingType.Number; break; case "rich": _setting.Type = ThemeSettingType.Rich; break; case "choose": _setting.Type = ThemeSettingType.Choose; break; case "multiline": _setting.Type = ThemeSettingType.MultiLine; break; } BSSetting _savedSetting = BSSetting.GetSetting(String.Format("{0}_{1}", _theme.Name, _setting.Key)); if (_savedSetting != null) _setting.Value = _savedSetting.Value; _Settings.Add(_setting); } } _theme.Settings = _Settings; srXmlFile.Close(); return _theme; } }
public static BSTheme Get(string themeName) { using (StreamReader srXmlFile = new StreamReader(HttpContext.Current.Server.MapPath(String.Format("~/Themes/{0}/Settings.xml", themeName)))) { XmlDocument _doc = new XmlDocument(); BSThemeSettings _Settings = new BSThemeSettings(); BSTheme _theme = new BSTheme(); _doc.Load(srXmlFile); XmlNode _nodeTheme = _doc.SelectSingleNode("theme"); _theme.Author = _nodeTheme["author"].InnerText; _theme.Description = _nodeTheme["description"].InnerText; _theme.Folder = _nodeTheme["folder"].InnerText; _theme.Name = _nodeTheme["name"].InnerText; _theme.ScreenShot = _nodeTheme["screenshot"].InnerText; _theme.UpdateUrl = _nodeTheme["updateurl"].InnerText; _theme.Version = _nodeTheme["version"].InnerText; _theme.WebSite = _nodeTheme["website"].InnerText; XmlNode _nodeSetting = _nodeTheme.SelectSingleNode("settings"); if (_nodeSetting != null && _nodeSetting.ChildNodes.Count > 0) { XmlNodeList _nodeKeyList = _nodeSetting.SelectNodes("add"); foreach (XmlNode node in _nodeKeyList) { BSThemeSetting _setting = new BSThemeSetting(); _setting.Title = node.Attributes["title"] != null ? node.Attributes["title"].Value : String.Empty; _setting.Description = node.Attributes["description"] != null ? node.Attributes["description"].Value : String.Empty; _setting.Key = node.Attributes["key"] != null ? node.Attributes["key"].Value : String.Empty; _setting.Value = node.Attributes["defaultValue"] != null ? node.Attributes["defaultValue"].Value : node.InnerText; string typeText = node.Attributes["type"].Value.ToLowerInvariant(); switch (typeText) { case "text": _setting.Type = ThemeSettingType.Text; break; case "number": _setting.Type = ThemeSettingType.Number; break; case "rich": _setting.Type = ThemeSettingType.Rich; break; case "choose": _setting.Type = ThemeSettingType.Choose; break; case "multiline": _setting.Type = ThemeSettingType.MultiLine; break; } _Settings.Add(_setting); } } _theme.Settings = _Settings; srXmlFile.Close(); return(_theme); } }
private void AllThemes() { rpAllThemes.DataSource = BSTheme.GetThemes(); rpAllThemes.DataBind(); }