protected void CopyAttributes(TextRun source, TextRun target) { target.Font = source.Font; target.WasListNumber = source.WasListNumber; target.RedlineCharPos = source.RedlineCharPos; target.WasField = source.WasField; target.RTL = source.RTL; }
private HighlightedTextRun MakeHighlightedText(TextRun template, string p, int offset) { HighlightedTextRun result = new HighlightedTextRun(template, p); result.RedlineCharPos += offset; return result; }
private string GrabNeededCharsAsHighlight(TextRun template, string text, int offset) { int grabChars = Math.Min(_charsToGrab, text.Length); HighlightedTextRun htr = MakeHighlightedText(template, text.Substring(0, grabChars), offset); _si.Content.Add(htr); _charsToGrab -= grabChars; text = text.Substring(grabChars); if (!string.IsNullOrEmpty(text)) { TextRun tr = template.Clone(); tr.Content = text; _si.Content.Add(tr); } return text; }
private void AddTargetObject(TextRun textRun) { string text = textRun.Content; if (_location.CharOffset > 0) { TextRun tr = textRun.Clone() ; tr.Content = text.Substring(0, _location.CharOffset); _si.Content.Add(tr); text = text.Substring(_location.CharOffset); } _charsToGrab = _location.Length; text = GrabNeededCharsAsHighlight(textRun, text, _location.CharOffset); }
private void AddFollowOnTarget(TextRun textRun) { GrabNeededCharsAsHighlight(textRun, textRun.Content, 0); }
internal TextRun Clone() { TextRun result = new TextRun(null); CopyAttributes(this, result); return result; }
private void ProcessText(TextRun textRun) { _location.TargetObject = textRun; if (textRun != null && textRun.Content != null) { foreach (char c in textRun.Content) { HandleChar(c); _location.CharOffset++; } } _location.CharOffset = 0; }
public HighlightedTextRun(TextRun template, string p) : base(null) { CopyAttributes(template, this); Content = p; }