zoukankan      html  css  js  c++  java
  • Subtext为skin准备相关文件加载

          定制skin模板中的用户控件时,为了更好的管理样式,我们一般推荐定义样式表,然后在相应的地方添加样式,我们最好也不摇在用户控件中直接引入样式表,这样很容易出错。所以Subtext提供了一个配置文件Skins.config,其为一个定制的xml文件,专为skin设置,你可以为每套模板有选择性的添加样式文件,如下

    <?xml version="1.0"?>
    <SkinTemplates xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        
    <!--
            Note that multiple skins may share the same template folder.
            Each template folder by 
    default should have a style.css file. 
            This file does not need to be configured 
    in this section.
            
            For skins that share a template folder, the skins should be 
            distinguished by their stylesheet.  Note that when specifying 
            a StyleSheet
    ="" attribute, this style is rendered AFTER "style.css" 
            allowing the skin to 
    override template specific styles.
        
    -->
        
    <Skins>
            
    <SkinTemplate Name="AnotherEon001" TemplateFolder="AnotherEon001">
                
    <Styles>
                    
    <Style href="~/skins/_System/csharp.css" />
                    
    <Style href="~/skins/_System/commonstyle.css" />
                    
    <Style href="~/skins/_System/commonlayout.css" />
                    
    <Style href="print.css" media="print" />
                
    </Styles>
            
    </SkinTemplate>

            
    <SkinTemplate Name="BlueBook" TemplateFolder="RedBook" StyleSheet="Blue.css">
                
    <Scripts>
                    
    <Script Src="~/Admin/Resources/Scripts/niceForms.js" />
                
    </Scripts>
                
    <Styles>
                    
    <Style href="~/skins/_System/csharp.css" />
                    
    <Style href="~/skins/_System/commonstyle.css" />
                    
    <Style href="~/skins/_System/commonlayout.css" />
                    
    <Style href="niceforms-default.css" />
                    
    <Style href="print.css" media="print" />
                
    </Styles>
            
    </SkinTemplate>
    </Skins>
    </SkinTemplates>

    这里包含几个元素呢?

    一.SkinTemplates为根路径
    二.Skins表示模板集合
    三.SkinTemplate表示一个模板的内容包含Styles和Scripts
    四.Styles表示要加载的样式文件集合
    五.Scripts表示要加载的脚本文件集合

    页面会根据模板到这个配置文件里来读取并加载相关文件。

    xml定义好了,你该如何做呢.利用xml序列化的功能.你首先得为上面的几个对象定义实体类



    注意元数据属性,是为必须的,根据元数据熟悉属性再看看那个xml文件,意思是一一对应的。

    接着便是SkinTemplates的真正反序列化的过程了,接着呢你就可以来个迭代,来加载相关skin文件了。
    当然别忘了定义一个集合skins
            [XmlArray("Skins")]
            
    public List<SkinTemplate> Templates
            
    {
                
    get {return this._skinTemplates;}
                
    set {this._skinTemplates = value;}
            }
  • 相关阅读:
    中国大学MOOC-数据结构基础习题集、07-2、Insert or Merge
    NSDate相关
    切换中文键盘时覆盖输入框的完美解决方案
    自定义UITableView的右侧索引
    调用系统的短信和发送邮件功能,实现短信分享邮件分享
    程序出现警告,解决方式
    键盘隐藏问题
    java修饰符
    java覆盖和隐藏
    java嵌套类
  • 原文地址:https://www.cnblogs.com/Clingingboy/p/703190.html
Copyright © 2011-2022 走看看