本文整理汇总了C#中System.Windows.Documents.DocumentNode.InheritFormatState方法的典型用法代码示例。如果您正苦于以下问题:C# DocumentNode.InheritFormatState方法的具体用法?C# DocumentNode.InheritFormatState怎么用?C# DocumentNode.InheritFormatState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.DocumentNode
的用法示例。
在下文中一共展示了DocumentNode.InheritFormatState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateDocumentNode
// Helper for IXamlContentHandler.StartElement.
private DocumentNode CreateDocumentNode(ConverterState converterState, DocumentNodeType documentNodeType, DocumentNode dnTop, XamlTag xamlTag)
{
DocumentNode documentNode = new DocumentNode(documentNodeType);
if (dnTop != null)
{
documentNode.InheritFormatState(dnTop.FormatState);
}
// Handle implicit formatting properties.
switch (xamlTag)
{
case XamlTag.XTBold:
documentNode.FormatState.Bold = true;
break;
case XamlTag.XTHyperlink:
{
long lColor = 0;
documentNode.FormatState.UL = ULState.ULNormal;
if (XamlParserHelper.ConvertToColor(converterState, "#FF0000FF", ref lColor))
{
documentNode.FormatState.CF = lColor;
}
}
break;
case XamlTag.XTItalic:
documentNode.FormatState.Italic = true;
break;
case XamlTag.XTUnderline:
documentNode.FormatState.UL = ULState.ULNormal;
break;
case XamlTag.XTList:
documentNode.FormatState.Marker = MarkerStyle.MarkerBullet;
documentNode.FormatState.StartIndex = 1;
// Set the default left margin for a list.
documentNode.FormatState.LI = 720;
break;
}
return documentNode;
}
示例2: while
XamlToRtfError IXamlContentHandler.Characters(string characters)
{
XamlToRtfError xamlToRtfError = XamlToRtfError.None;
ConverterState converterState = _writer.ConverterState;
DocumentNodeArray dna = converterState.DocumentNodeArray;
DocumentNode dnTop = dna.TopPending();
DocumentNode dn;
int index = 0;
while (xamlToRtfError == XamlToRtfError.None && index < characters.Length)
{
// Move past opening CRLF
while (index < characters.Length && IsNewLine(characters[index]))
{
index++;
}
int end = index;
while (end < characters.Length && !IsNewLine(characters[end]))
{
end++;
}
if (index != end)
{
string newCharacters = characters.Substring(index, end - index);
dn = new DocumentNode(DocumentNodeType.dnText);
if (dnTop != null)
{
dn.InheritFormatState(dnTop.FormatState);
}
dna.Push(dn);
dn.IsPending = false;
if (xamlToRtfError == XamlToRtfError.None)
{
FontTableEntry e = converterState.FontTable.FindEntryByIndex((int)dn.FormatState.Font);
int cp = (e == null) ? 1252 : e.CodePage;
XamlParserHelper.AppendRTFText(dn.Content, newCharacters, cp);
}
}
index = end;
}
return xamlToRtfError;
}