本文整理汇总了C#中Styles.AddStyle方法的典型用法代码示例。如果您正苦于以下问题:C# Styles.AddStyle方法的具体用法?C# Styles.AddStyle怎么用?C# Styles.AddStyle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Styles
的用法示例。
在下文中一共展示了Styles.AddStyle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseStyleDefinition
/// <summary>
/// Parses a style definition block within the keyword «\styles».
/// </summary>
private Style ParseStyleDefinition(Styles styles)
{
// StyleName [: BaseStyleName]
// {
// ...
// }
Style style = null;
try
{
string styleName = _scanner.Token;
string baseStyleName = null;
if (Symbol != Symbol.Identifier && Symbol != Symbol.StringLiteral)
ThrowParserException(DomMsgID.StyleNameExpected, styleName);
ReadCode();
if (Symbol == Symbol.Colon)
{
ReadCode();
if (Symbol != Symbol.Identifier && Symbol != Symbol.StringLiteral)
ThrowParserException(DomMsgID.StyleNameExpected, styleName);
// If baseStyle is not valid, choose InvalidStyleName by default.
baseStyleName = _scanner.Token;
if (styles.GetIndex(baseStyleName) == -1)
{
ReportParserInfo(DdlErrorLevel.Warning, DomMsgID.UseOfUndefinedBaseStyle, baseStyleName);
baseStyleName = StyleNames.InvalidStyleName;
}
ReadCode();
}
// Get or create style.
style = styles[styleName];
if (style != null)
{
// Reset base style.
if (baseStyleName != null)
style.BaseStyle = baseStyleName;
}
else
{
// Style does not exist and no base style is given, choose InvalidStyleName by default.
if (String.IsNullOrEmpty(baseStyleName))
{
baseStyleName = StyleNames.InvalidStyleName;
ReportParserInfo(DdlErrorLevel.Warning, DomMsgID.UseOfUndefinedStyle, styleName);
}
style = styles.AddStyle(styleName, baseStyleName);
}
// Parse definition (if any).
if (Symbol == Symbol.BraceLeft)
{
ParseAttributeBlock(style);
}
}
catch (DdlParserException ex)
{
ReportParserException(ex);
AdjustToNextBlock();
}
return style;
}