public static TextAttributeBase ParseTextAttribute(string txt) { TextAttributeBase rlt = null; if (CLOSE_TAG_REG.IsMatch(txt)) { rlt = new TextAttributeBase(); Match match = CLOSE_TAG_REG.Match(txt); string name = match.Groups[1].Value; rlt.Type = TextAttributeBase.TextAttributeType.Close; rlt.Name = name; } else if (OPEN_TAG_REG.IsMatch(txt)) { rlt = new TextAttributeBase(); Match match = OPEN_TAG_REG.Match(txt); string name = match.Groups[1].Value; if (match.Groups.Count > 2) { string value = match.Groups[2].Value; rlt.Value = value.Replace("=", ""); } rlt.Type = TextAttributeBase.TextAttributeType.Open; rlt.Name = name; } return(rlt); }
private void AddAttributeToText(RichTextData data) { for (int i = 0; i < _attrStack.Count; i++) { TextAttributeBase attr = _attrStack.ElementAt(i); data.AddAttribute(attr); } }
private void DoAttribute(TextToken token) { TextAttributeBase attr = RichTextParseHelper.ParseTextAttribute(token.Value); if (attr.Type == TextAttributeBase.TextAttributeType.Close) { TextAttributeBase prevAttr = _attrStack.Peek(); if (prevAttr.Name == attr.Name && prevAttr.Type == TextAttributeBase.TextAttributeType.Open) { _attrStack.Pop(); } } else { _attrStack.Push(attr); } }
public void AddAttribute(TextAttributeBase attr) { Attributes.Add(attr); }