private static void applyLinkStyle(RichTextBox rtb, List<KeyValuePair<int, int>> links) { // apply links style CHARFORMAT ncf = new CHARFORMAT(CFM.LINK, CFE.LINK); foreach (var pair in links) { rtb.Select(pair.Key, pair.Value); rtb.SetCharFormat(ncf); } }
private static PARAFORMAT HandleTextAndWhitespace(RichTextBox rtb, PARAFORMAT pf, CHARFORMAT cf, string strData) { bool bNewParagraph = (strData.IndexOf("\r\n", 0) >= 0) || (strData.IndexOf("\n", 0) >= 0); if (strData.Length > 0) { // now, add text to control int nStartCache = rtb.SelectionStart; rtb.SelectedText = strData; rtb.Select(nStartCache, strData.Length); // apply format rtb.SetParaFormat(pf); rtb.SetCharFormat(cf); } // reposition to final rtb.Select(rtb.TextLength + 1, 0); // new paragraph requires to reset alignment if (bNewParagraph) { pf.dwMask = PFM.ALIGNMENT | PFM.NUMBERING; pf.wAlignment = PFA.LEFT; pf.wNumbering = 0; } return pf; }
private static bool ProcessSignificantWhitespace(RichTextBox rtb, ref CHARFORMAT cf, ref PARAFORMAT pf, string strData) { bool bNewParagraph = (strData.IndexOf("\r\n", 0) >= 0) || (strData.IndexOf("\n", 0) >= 0); if (strData.Length > 0) { // now, add text to control int nStartCache = rtb.SelectionStart; rtb.SelectedText = strData; rtb.Select(nStartCache, strData.Length); // apply format rtb.SetParaFormat(pf); rtb.SetCharFormat(cf); } // reposition to final rtb.Select(rtb.TextLength + 1, 0); return bNewParagraph; }