public static FlowDocument AsFlowDocument(AttackOption ao) { FlowDocument fd = NewFlowDocument(true, true); Paragraph name = new Paragraph(); name.FontWeight = FontWeights.Bold; name.Inlines.Add(ao.Name); fd.Blocks.Add(name); Regex rxExample = new Regex("Example"); string[] delims = { "<p>" }; foreach (string part in ao.Description.Split(delims, StringSplitOptions.RemoveEmptyEntries)) { if (part.Trim().Length == 0) { continue; } Paragraph p = new Paragraph(); if (rxExample.IsMatch(part)) { p.FontStyle = FontStyles.Italic; p.Inlines.Add(part); } else { p.Inlines.Add(part); } fd.Blocks.Add(p); } return(fd); }
private void dgAttackOptions_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { AttackOption ao = (AttackOption)dgAttackOptions.CurrentItem; if (ao != null) { AttackOptionView.Document = FlowDocumentConverter.AsFlowDocument(ao); } }