⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thememanager.cs

📁 本系统是在asp版《在线文件管理器》的基础上设计制作
💻 CS
字号:
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Collections;
using System.Collections.Specialized;
using System.IO;
using System.Web.Caching;
using CommunityServer.Blogs.Components;
using CommunityServer.Components;
using CommunityServer.Configuration;

namespace CommunityServer.Blogs.Controls
{
	/// <summary>
	/// Summary description for ThemeManager.
	/// </summary>
	public class ThemeManager
	{
        private NameValueCollection SkinList = new NameValueCollection();
        private Hashtable ThemeList = new Hashtable();
		private ThemeManager()
		{
			
		}

        public static ThemeManager Instance()
        {
           ThemeManager tm = CSCache.Get("ThemeManager") as ThemeManager;
            if(tm == null)
            {
                tm = new ThemeManager();
                CacheDependency dep = new CacheDependency(null, new string[]{CSConfiguration.CacheKey});
                CSCache.Insert("ThemeManager", tm, dep);
            }

            return tm;
        }

        public string SkinPath(string theme, string skin)
        {
            string key = theme + "|" + skin;

            string path = SkinList[key] as string;
            if(path == null)
            {

                path = WalkThemes(theme, skin);
                if(path != null)
                {
                       if(WeblogConfiguration.Instance().EnableSkinCache)
                           SkinList[key] = path;
                }
                else
                    throw new CSException(CSExceptionType.SkinNotFound, string.Format("The Skin {0} could not be found",skin));
            }

            return path;
        }

        protected string WalkThemes(string theme, string skin)
        {
            bool found = false;
            string path = null;
            while(!found)
            {
                ThemeConfig config = GetTheme(theme);

                if(config == null)
                    break;

                if(FileExists(config.ThemeDirectoryPath, skin))
                {
                    path = WeblogConfiguration.Instance().ThemeLocation + theme + "/"  + skin;
                    found = true;
                }
                else
                {
                    if(config.HasParent)
                        theme = config.Parent;
                    else
                        found = true;
                }
            }

            return path;
        }

        public ThemeConfig GetTheme(string name)
        {
            ThemeConfig config = ThemeList[name] as ThemeConfig;
            if(config == null)
            {
                config = ThemeConfig.Create(name);
                ThemeList[name] = config;
            }

            return config;
        }

        bool FileExists(string dir, string file)
        {
            string path = Path.Combine(dir,file.Replace("/", @"\"));
            return File.Exists(path);
        }

        
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -