Novacode.Paragraph.UnderlineColor C# (CSharp) Method

UnderlineColor() public method

For use with Append() and AppendLine()
public UnderlineColor ( Color underlineColor ) : Paragraph
underlineColor Color The underline color to use, if no underline is set, a single line will be used.
return Paragraph
        public Paragraph UnderlineColor(Color underlineColor)
        {
            foreach (XElement run in runs)
            {
                XElement rPr = run.Element(XName.Get("rPr", DocX.w.NamespaceName));
                if (rPr == null)
                {
                    run.AddFirst(new XElement(XName.Get("rPr", DocX.w.NamespaceName)));
                    rPr = run.Element(XName.Get("rPr", DocX.w.NamespaceName));
                }

                XElement u = rPr.Element(XName.Get("u", DocX.w.NamespaceName));
                if (u == null)
                {
                    rPr.SetElementValue(XName.Get("u", DocX.w.NamespaceName), string.Empty);
                    u = rPr.Element(XName.Get("u", DocX.w.NamespaceName));
                    u.SetAttributeValue(XName.Get("val", DocX.w.NamespaceName), "single");
                }

                u.SetAttributeValue(XName.Get("color", DocX.w.NamespaceName), underlineColor.ToHex());
            }

            return this;
        }