本文整理汇总了C#中System.Windows.Forms.RichTextBox.GetDefaultParaFormat方法的典型用法代码示例。如果您正苦于以下问题:C# RichTextBox.GetDefaultParaFormat方法的具体用法?C# RichTextBox.GetDefaultParaFormat怎么用?C# RichTextBox.GetDefaultParaFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.RichTextBox
的用法示例。
在下文中一共展示了RichTextBox.GetDefaultParaFormat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFromReader
private static void ReadFromReader(RichTextBox rtb, List<KeyValuePair<int, int>> links,
XmlReader reader)
{
CHARFORMAT cf = rtb.GetDefaultCharFormat(); // to apply character formatting
PARAFORMAT pf = rtb.GetDefaultParaFormat(); // to apply paragraph formatting
Stack<CHARFORMAT> scf = new Stack<CHARFORMAT>();
Stack<PARAFORMAT> spf = new Stack<PARAFORMAT>();
int hyperlinkStart = -1;
string hyperlink = null;
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element:
switch (reader.Name.ToLower())
{
case "b":
cf.dwMask |= CFM.WEIGHT | CFM.BOLD;
cf.dwEffects |= CFE.BOLD;
cf.wWeight = FW.BOLD;
break;
case "i":
cf.dwMask |= CFM.ITALIC;
cf.dwEffects |= CFE.ITALIC;
break;
case "u":
cf.dwMask |= CFM.UNDERLINE | CFM.UNDERLINETYPE;
cf.dwEffects |= CFE.UNDERLINE;
cf.bUnderlineType = CFU.UNDERLINE;
break;
case "s":
cf.dwMask |= CFM.STRIKEOUT;
cf.dwEffects |= CFE.STRIKEOUT;
break;
case "sup":
cf.dwMask |= CFM.SUPERSCRIPT;
cf.dwEffects |= CFE.SUPERSCRIPT;
break;
case "sub":
cf.dwMask |= CFM.SUBSCRIPT;
cf.dwEffects |= CFE.SUBSCRIPT;
break;
case "a":
hyperlinkStart = HandleHyperlinkStart(rtb, reader, out hyperlink);
break;
case "p":
pf = HandleParagraphElement(reader, pf, spf);
break;
case "li":
pf = HandleListItem(pf, spf);
break;
case "font":
cf = HandleFontElement(reader, cf, scf);
break;
}
break;
case XmlNodeType.EndElement:
switch (reader.Name)
{
case "b":
cf.dwEffects &= ~CFE.BOLD;
cf.wWeight = FW.NORMAL;
break;
case "i":
cf.dwEffects &= ~CFE.ITALIC;
break;
case "u":
cf.dwEffects &= ~CFE.UNDERLINE;
break;
case "s":
cf.dwEffects &= ~CFE.STRIKEOUT;
break;
case "sup":
cf.dwEffects &= ~CFE.SUPERSCRIPT;
break;
case "sub":
cf.dwEffects &= ~CFE.SUBSCRIPT;
break;
case "a":
hyperlinkStart = HandleHyperlinkEnd(rtb, links, hyperlinkStart, hyperlink);
break;
case "p":
pf = spf.Pop();
break;
case "li":
pf = spf.Pop();
break;
case "font":
cf = scf.Pop();
break;
}
break;
case XmlNodeType.Text:
case XmlNodeType.Whitespace:
case XmlNodeType.SignificantWhitespace:
pf = HandleTextAndWhitespace(rtb, pf, cf, reader.Value);
break;
case XmlNodeType.XmlDeclaration:
//.........这里部分代码省略.........