Beispiel #1
0
        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);
        }
Beispiel #2
0
 private void AddAttributeToText(RichTextData data)
 {
     for (int i = 0; i < _attrStack.Count; i++)
     {
         TextAttributeBase attr = _attrStack.ElementAt(i);
         data.AddAttribute(attr);
     }
 }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
 public void AddAttribute(TextAttributeBase attr)
 {
     Attributes.Add(attr);
 }