Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Problems.GrammaticalOptimization/SharpVectorCss/Css/CssFontFaceRule.cs @ 13918

Last change on this file since 13918 was 12762, checked in by aballeit, 9 years ago

#2283 GUI updates, Tree-chart, MCTS Version 2 (prune leaves)

File size: 2.7 KB
Line 
1// <developer>niklas@protocol7.com</developer>
2// <completed>80</completed>
3
4using System;
5using System.Collections.Generic;
6using System.Text.RegularExpressions;
7
8namespace SharpVectors.Dom.Css
9{
10  /// <summary>
11  /// The CSSFontFaceRule interface represents a @font-face rule in a CSS style sheet. The @font-face rule is used to hold a set of font descriptions.
12  /// </summary>
13  public class CssFontFaceRule : CssRule, ICssFontFaceRule
14  {
15    #region Static members
16
17    private static Regex regex = new Regex(@"^@font-face");
18   
19    /// <summary>
20    /// Parses a string containging CSS and creates a CssFontFaceRule instance if found as the first content
21    /// </summary>
22    internal static CssRule Parse(ref string css, object parent, bool readOnly,
23            IList<string> replacedStrings, CssStyleSheetType origin)
24    {
25      Match match = regex.Match(css);
26      if(match.Success)
27      {
28        CssFontFaceRule rule = new CssFontFaceRule(match, parent, readOnly,
29                    replacedStrings, origin);
30        css = css.Substring(match.Length);
31
32        rule.style = new CssStyleDeclaration(ref css, rule, true, origin);
33
34        return rule;
35      }
36      else
37      {
38        // didn't match => do nothing
39        return null;
40      }
41    }
42
43    #endregion
44
45    #region Constructors
46    /// <summary>
47    /// The constructor for CssFontFaceRule
48    /// </summary>
49    /// <param name="match">The Regex match that found the charset rule</param>
50    /// <param name="parent">The parent rule or parent stylesheet</param>
51    /// <param name="readOnly">True if this instance is readonly</param>
52    /// <param name="replacedStrings">An array of strings that have been replaced in the string used for matching. These needs to be put back use the DereplaceStrings method</param>
53    /// <param name="origin">The type of CssStyleSheet</param>
54    internal CssFontFaceRule(Match match, object parent, bool readOnly,
55            IList<string> replacedStrings, CssStyleSheetType origin)
56            : base(parent, true, replacedStrings, origin)
57    {
58      // always read-only
59     
60    }
61    #endregion
62
63    #region Implementation of ICssFontFaceRule
64    private CssStyleDeclaration style;
65    /// <summary>
66    /// The declaration-block of this rule.
67    /// </summary>
68    public ICssStyleDeclaration Style
69    {
70      get
71      {
72        return style;
73      }
74    }
75    #endregion
76
77    #region Implementation of ICssRule
78    /// <summary>
79    /// The type of the rule. The expectation is that binding-specific casting methods can be used to cast down from an instance of the CSSRule interface to the specific derived interface implied by the type.
80    /// </summary>
81    public override CssRuleType Type
82    {
83      get
84      {
85        return CssRuleType.FontFaceRule;
86      }
87    }
88    #endregion
89  }
90}
Note: See TracBrowser for help on using the repository browser.