public void TestHightlighting1() { NoteSectionsToInlineListConverter converter = new NoteSectionsToInlineListConverter(); List<Section> sections = new List<Section>(); sections.Add(new Section() { Text="the quick ", Weight = NoteWeight.Normal}); sections.Add(new Section() { Text="brown fox", Weight = NoteWeight.Bold}); sections.Add(new Section() { Text=" jump", Weight = NoteWeight.Normal}); sections.Add(new Section() { Text="ed over the lazy dog", Weight = NoteWeight.Normal}); List<HighlightMatch> highlights = new List<HighlightMatch>() { new HighlightMatch(20, 6) }; converter.Convert(sections, typeof(List<System.Windows.Documents.Inline>), null, null, highlights); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) return null; if (targetType != typeof(List<Inline>)) { throw new Exception("targetType must be of type List<Inline>."); } if (false == value is string) { throw new Exception("value must be of type string."); } List<Section> sections = new MarkedupTextToNoteSectionsConverter().Convert(value, typeof(List<Section>), null, null) as List<Section>; List<Inline> result = new NoteSectionsToInlineListConverter().Convert(sections, typeof(List<Inline>), null, null) as List<Inline>; return result; }