private static TextDecorationCollection GetUnderlineTextDecorations(XmlReader reader, Inline inline) { TextDecoration textDecoration; Color?color = GetColor(reader[ColorAttribute, WordprocessingMLNamespace]); Brush brush = color.HasValue ? new SolidColorBrush(color.Value) : inline.Foreground; TextDecorationCollection textDecorations = new TextDecorationCollection { (textDecoration = new TextDecoration { Location = TextDecorationLocation.Underline, Pen = new Pen { Brush = brush } }) }; switch (GetValueAttribute(reader)) { case "single": break; case "double": textDecoration.PenOffset = inline.FontSize * 0.05; textDecoration = textDecoration.Clone(); textDecoration.PenOffset = inline.FontSize * -0.05; textDecorations.Add(textDecoration); break; case "dotted": textDecoration.Pen.DashStyle = DashStyles.Dot; break; case "dash": textDecoration.Pen.DashStyle = DashStyles.Dash; break; case "dotDash": textDecoration.Pen.DashStyle = DashStyles.DashDot; break; case "dotDotDash": textDecoration.Pen.DashStyle = DashStyles.DashDotDot; break; case "none": // fallthrough default: // If underline type is none or unsupported then it will be ignored. return(null); } return(textDecorations); }