Example #1
0
 private static void AddAttributeValue(this Paragraph paragraph, string value, XamlStyles styles)
 {
     if (value.StartsWith("{}"))
     {
         paragraph.AddRun(value, styles.TextStyle);
     }
     else if (value.StartsWith("{") && value.EndsWith("}"))
     {
         paragraph.AddMarkupValue(value, styles);
     }
     else
     {
         paragraph.AddRun(value, styles.AttributeValueStyle);
     }
 }
Example #2
0
        private static void AddMarkupBody(this Paragraph paragraph, string value, XamlStyles styles)
        {
            var indexOfNonspace = FindNonspaceInMarkup(value);
            var spaceText       = indexOfNonspace < 0 ? value : value.Substring(0, indexOfNonspace);

            paragraph.AddRun(spaceText, styles.AttributeValueStyle);
            if (indexOfNonspace < 0)
            {
                return;
            }
            value = value.Substring(indexOfNonspace);
            if (value.StartsWith("{}"))
            {
                var indexOfComma = FindCommaInMarkup(value);
                var text         = indexOfComma < 0 ? value : value.Substring(0, indexOfComma);
                paragraph.AddRun(text, styles.TextStyle);
                if (indexOfComma < 0)
                {
                    return;
                }
                value = value.Substring(indexOfComma);
            }
            else if (value.StartsWith("{"))
            {
                var indexOfClosedBrace = FindClosedBraceInMarkup(value);
                if (indexOfClosedBrace < 0)
                {
                    paragraph.AddRun(value, styles.ErrorStyle);
                    return;
                }
                paragraph.AddMarkupValue(value.Substring(0, indexOfClosedBrace), styles);
                value = value.Substring(indexOfClosedBrace + 1);
            }
            // TODO:
            // Path=Title, StringFormat={}{0}AVS, ElementName=window
            paragraph.AddRun(value, styles.AttributeValueStyle);
        }