style.cs

来自「本系统是在asp版《在线文件管理器》的基础上设计制作」· CS 代码 · 共 57 行

CS
57
字号
//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System;
using System.Web.UI;
using CommunityServer.Blogs.Components;
using CommunityServer.Components;

namespace CommunityServer.Blogs.Controls
{
	/// <summary>
	/// Renders 1 to 3 style sheets depeneding on user preferences
	/// </summary>
	public class Style : Control
	{
		public Style()
		{
			WeblogConfig = WeblogConfiguration.Instance();
		}

        protected WeblogConfiguration WeblogConfig = null;

        protected override void Render(HtmlTextWriter writer)
        {
            Weblog weblog = Weblogs.GetWeblog(CSContext.Current.ApplicationKey,true,true);
            if(weblog != null)
            {
                writer.WriteLine(styleFormat,CSSPath(weblog.Theme,"style.css"),"screen");

                if(WeblogConfig.EnableThemes && weblog.SecondaryCSS != null)
                    writer.WriteLine(styleFormat,CSSPath(weblog.Theme, weblog.SecondaryCSS),"screen");


                if(WeblogConfig.EnableThemes && weblog.CSSOverride != null)
                    writer.WriteLine(styleFormat, BlogUrls.Instance().CustomCSS(weblog.ApplicationKey),"screen");
                
            }
            
        }

        protected string CSSPath(string theme, string fileName)
        {
            if(theme == null || !WeblogConfig.EnableThemes)
                theme = WeblogConfig.DefaultTheme;

            string path = string.Format("{0}{1}/style/{2}",WeblogConfig.ThemeLocation,theme,fileName);
            return this.ResolveUrl(path);
        }

        static string styleFormat = "<link rel=\"stylesheet\" href=\"{0}\" type=\"text/css\" media=\"{1}\" />";

	}
}

⌨️ 快捷键说明

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