コード例 #1
0
    private dfMarkupElement parseElement(Queue <dfMarkupElement> tokens)
    {
        dfMarkupElement element = tokens.Dequeue();

        if (element is dfMarkupString)
        {
            return(((dfMarkupString)element).SplitWords());
        }
        dfMarkupTag original = (dfMarkupTag)element;

        if (!original.IsClosedTag && !original.IsEndTag)
        {
            while (tokens.Count > 0)
            {
                dfMarkupElement node = this.parseElement(tokens);
                if (node is dfMarkupTag)
                {
                    dfMarkupTag tag2 = (dfMarkupTag)node;
                    if (tag2.IsEndTag)
                    {
                        if (tag2.TagName == original.TagName)
                        {
                            break;
                        }
                        return(this.refineTag(original));
                    }
                }
                original.AddChildNode(node);
            }
        }
        return(this.refineTag(original));
    }
コード例 #2
0
    protected internal override void OnMouseUp(dfMouseEventArgs args)
    {
        base.OnMouseUp(args);

        isMouseDown = false;

        if (Vector2.Distance(scrollPosition, mouseDownScrollPosition) <= 2)
        {
            if (hitTestTag(args) == mouseDownTag)
            {
                var linkTag = mouseDownTag;
                while (linkTag != null && !(linkTag is dfMarkupTagAnchor))
                {
                    linkTag = linkTag.Parent as dfMarkupTag;
                }

                if (linkTag is dfMarkupTagAnchor)
                {
                    Signal("OnLinkClicked", this, linkTag);

                    if (this.LinkClicked != null)
                    {
                        this.LinkClicked(this, linkTag as dfMarkupTagAnchor);
                    }
                }
            }
        }

        mouseDownTag            = null;
        mouseDownScrollPosition = scrollPosition;
    }
コード例 #3
0
 private dfMarkupTag refineTag(dfMarkupTag original)
 {
     if (!original.IsEndTag)
     {
         if (tagTypes == null)
         {
             tagTypes = new Dictionary <string, Type>();
             foreach (Type type in Assembly.GetExecutingAssembly().GetExportedTypes())
             {
                 if (typeof(dfMarkupTag).IsAssignableFrom(type))
                 {
                     object[] customAttributes = type.GetCustomAttributes(typeof(dfMarkupTagInfoAttribute), true);
                     if ((customAttributes != null) && (customAttributes.Length != 0))
                     {
                         for (int i = 0; i < customAttributes.Length; i++)
                         {
                             string tagName = ((dfMarkupTagInfoAttribute)customAttributes[i]).TagName;
                             tagTypes[tagName] = type;
                         }
                     }
                 }
             }
         }
         if (tagTypes.ContainsKey(original.TagName))
         {
             Type     type2 = tagTypes[original.TagName];
             object[] args  = new object[] { original };
             return((dfMarkupTag)Activator.CreateInstance(type2, args));
         }
     }
     return(original);
 }
コード例 #4
0
ファイル: dfMarkupParser.cs プロジェクト: sknchan/LegacyRust
    private dfMarkupElement parseElement(Queue <dfMarkupElement> tokens)
    {
        dfMarkupElement _dfMarkupElement = tokens.Dequeue();

        if (_dfMarkupElement is dfMarkupString)
        {
            return(((dfMarkupString)_dfMarkupElement).SplitWords());
        }
        dfMarkupTag _dfMarkupTag = (dfMarkupTag)_dfMarkupElement;

        if (_dfMarkupTag.IsClosedTag || _dfMarkupTag.IsEndTag)
        {
            return(this.refineTag(_dfMarkupTag));
        }
        while (tokens.Count > 0)
        {
            dfMarkupElement _dfMarkupElement1 = this.parseElement(tokens);
            if (_dfMarkupElement1 is dfMarkupTag)
            {
                dfMarkupTag _dfMarkupTag1 = (dfMarkupTag)_dfMarkupElement1;
                if (_dfMarkupTag1.IsEndTag)
                {
                    if (_dfMarkupTag1.TagName != _dfMarkupTag.TagName)
                    {
                        return(this.refineTag(_dfMarkupTag));
                    }
                    break;
                }
            }
            _dfMarkupTag.AddChildNode(_dfMarkupElement1);
        }
        return(this.refineTag(_dfMarkupTag));
    }
コード例 #5
0
ファイル: dfMarkupParser.cs プロジェクト: sknchan/LegacyRust
    private dfMarkupTag refineTag(dfMarkupTag original)
    {
        if (original.IsEndTag)
        {
            return(original);
        }
        if (dfMarkupParser.tagTypes == null)
        {
            dfMarkupParser.tagTypes = new Dictionary <string, Type>();
            Type[] exportedTypes = Assembly.GetExecutingAssembly().GetExportedTypes();
            for (int i = 0; i < (int)exportedTypes.Length; i++)
            {
                Type type = exportedTypes[i];
                if (typeof(dfMarkupTag).IsAssignableFrom(type))
                {
                    object[] customAttributes = type.GetCustomAttributes(typeof(dfMarkupTagInfoAttribute), true);
                    if (customAttributes != null && (int)customAttributes.Length != 0)
                    {
                        for (int j = 0; j < (int)customAttributes.Length; j++)
                        {
                            string tagName = ((dfMarkupTagInfoAttribute)customAttributes[j]).TagName;
                            dfMarkupParser.tagTypes[tagName] = type;
                        }
                    }
                }
            }
        }
        if (!dfMarkupParser.tagTypes.ContainsKey(original.TagName))
        {
            return(original);
        }
        Type item = dfMarkupParser.tagTypes[original.TagName];

        return((dfMarkupTag)Activator.CreateInstance(item, new object[] { original }));
    }
コード例 #6
0
 protected internal override void OnMouseDown(dfMouseEventArgs args)
 {
     base.OnMouseDown(args);
     this.mouseDownTag            = this.hitTestTag(args);
     this.mouseDownScrollPosition = this.scrollPosition;
     this.scrollMomentum          = Vector2.zero;
     this.touchStartPosition      = args.Position;
     this.isMouseDown             = true;
 }
コード例 #7
0
    private dfMarkupElement parseTag(System.Text.RegularExpressions.Match tag)
    {
        var tagName = tag.Groups["tag"].Value.ToLowerInvariant();

        if (tag.Value.StartsWith("</"))
        {
            return(new dfMarkupTag(tagName)
            {
                IsEndTag = true
            });
        }

        var element = new dfMarkupTag(tagName);

        var attributes = tag.Groups["attr"].Value;
        var matches    = ATTR_PATTERN.Matches(attributes);

        for (int i = 0; i < matches.Count; i++)
        {
            var attrMatch = matches[i];

            var key   = attrMatch.Groups["key"].Value;
            var value = dfMarkupEntity.Replace(attrMatch.Groups["value"].Value);

            if (value.StartsWith("\""))
            {
                value = value.Trim('"');
            }
            else if (value.StartsWith("'"))
            {
                value = value.Trim('\'');
            }

            if (string.IsNullOrEmpty(value))
            {
                continue;
            }

            if (key == "style")
            {
                parseStyleAttribute(element, value);
            }
            else
            {
                element.Attributes.Add(new dfMarkupAttribute(key, value));
            }
        }

        if (tag.Value.EndsWith("/>") || tagName == "br" || tagName == "img")
        {
            element.IsClosedTag = true;
        }

        return(element);
    }
コード例 #8
0
    private void parseStyleAttribute(dfMarkupTag element, string text)
    {
        MatchCollection matchs = STYLE_PATTERN.Matches(text);

        for (int i = 0; i < matchs.Count; i++)
        {
            Match  match = matchs[i];
            string name  = match.Groups["key"].Value.ToLowerInvariant();
            string str2  = match.Groups["value"].Value;
            element.Attributes.Add(new dfMarkupAttribute(name, str2));
        }
    }
コード例 #9
0
ファイル: dfMarkupParser.cs プロジェクト: sknchan/LegacyRust
    private void parseStyleAttribute(dfMarkupTag element, string text)
    {
        MatchCollection matchCollections = dfMarkupParser.STYLE_PATTERN.Matches(text);

        for (int i = 0; i < matchCollections.Count; i++)
        {
            Match  item           = matchCollections[i];
            string lowerInvariant = item.Groups["key"].Value.ToLowerInvariant();
            string value          = item.Groups["value"].Value;
            element.Attributes.Add(new dfMarkupAttribute(lowerInvariant, value));
        }
    }
コード例 #10
0
    private void parseStyleAttribute(dfMarkupTag element, string text)
    {
        var matches = STYLE_PATTERN.Matches(text);

        for (int i = 0; i < matches.Count; i++)
        {
            var match = matches[i];

            var key   = match.Groups["key"].Value.ToLowerInvariant();
            var value = match.Groups["value"].Value;

            element.Attributes.Add(new dfMarkupAttribute(key, value));
        }
    }
コード例 #11
0
ファイル: dfMarkupTag.cs プロジェクト: HexHash/LegacyRust
 public dfMarkupTag(dfMarkupTag original)
 {
     this.TagName = original.TagName;
     this.Attributes = original.Attributes;
     this.IsEndTag = original.IsEndTag;
     this.IsClosedTag = original.IsClosedTag;
     this.IsInline = original.IsInline;
     this.id = original.id;
     List<dfMarkupElement> childNodes = original.ChildNodes;
     for (int i = 0; i < childNodes.Count; i++)
     {
         base.AddChildNode(childNodes[i]);
     }
 }
コード例 #12
0
    public dfMarkupTag(dfMarkupTag original)
    {
        this.TagName     = original.TagName;
        this.Attributes  = original.Attributes;
        this.IsEndTag    = original.IsEndTag;
        this.IsClosedTag = original.IsClosedTag;
        this.IsInline    = original.IsInline;
        this.id          = original.id;
        List <dfMarkupElement> childNodes = original.ChildNodes;

        for (int i = 0; i < childNodes.Count; i++)
        {
            base.AddChildNode(childNodes[i]);
        }
    }
コード例 #13
0
 public dfMarkupTag(dfMarkupTag original)
 {
     this.TagName     = original.TagName;
     this.Attributes  = original.Attributes;
     this.IsEndTag    = original.IsEndTag;
     this.IsClosedTag = original.IsClosedTag;
     this.IsInline    = original.IsInline;
     this.id          = original.id;
     System.Collections.Generic.List <dfMarkupElement> childNodes = original.ChildNodes;
     for (int i = 0; i < childNodes.Count; i++)
     {
         dfMarkupElement node = childNodes[i];
         base.AddChildNode(node);
     }
 }
コード例 #14
0
    private dfMarkupElement parseTag(Match tag)
    {
        string tagName = tag.Groups["tag"].Value.ToLowerInvariant();

        if (tag.Value.StartsWith("</"))
        {
            return(new dfMarkupTag(tagName)
            {
                IsEndTag = true
            });
        }
        dfMarkupTag     element = new dfMarkupTag(tagName);
        string          input   = tag.Groups["attr"].Value;
        MatchCollection matchs  = ATTR_PATTERN.Matches(input);

        for (int i = 0; i < matchs.Count; i++)
        {
            Match  match = matchs[i];
            string name  = match.Groups["key"].Value;
            string str4  = dfMarkupEntity.Replace(match.Groups["value"].Value);
            if (str4.StartsWith("\""))
            {
                char[] trimChars = new char[] { '"' };
                str4 = str4.Trim(trimChars);
            }
            else if (str4.StartsWith("'"))
            {
                char[] chArray2 = new char[] { '\'' };
                str4 = str4.Trim(chArray2);
            }
            if (!string.IsNullOrEmpty(str4))
            {
                if (name == "style")
                {
                    this.parseStyleAttribute(element, str4);
                }
                else
                {
                    element.Attributes.Add(new dfMarkupAttribute(name, str4));
                }
            }
        }
        if ((tag.Value.EndsWith("/>") || (tagName == "br")) || (tagName == "img"))
        {
            element.IsClosedTag = true;
        }
        return(element);
    }
コード例 #15
0
 private void releaseMarkupReferences()
 {
     this.mouseDownTag = null;
     if (this.viewportBox != null)
     {
         this.viewportBox.Release();
     }
     if (this.elements != null)
     {
         for (int i = 0; i < this.elements.Count; i++)
         {
             this.elements[i].Release();
         }
         this.elements.Release();
     }
 }
コード例 #16
0
    /// <summary>
    /// Refines a generic dfMarkupTag instance into a more specific
    /// derived class instance, if one can be determined
    /// </summary>
    /// <param name="original"></param>
    /// <returns></returns>
    private dfMarkupTag refineTag(dfMarkupTag original)
    {
        // Don't bother refining end tags, they only exist to indicate
        // when we are done parsing/processing a tag that has child
        // elements.
        if (original.IsEndTag)
        {
            return(original);
        }

        if (tagTypes == null)
        {
            tagTypes = new Dictionary <string, Type>();

            var assemblyTypes = getAssemblyTypes();

            for (int i = 0; i < assemblyTypes.Length; i++)
            {
                var type = assemblyTypes[i];

                if (!typeof(dfMarkupTag).IsAssignableFrom(type))
                {
                    continue;
                }

                var attributes = type.GetCustomAttributes(typeof(dfMarkupTagInfoAttribute), true);
                if (attributes == null || attributes.Length == 0)
                {
                    continue;
                }

                for (int x = 0; x < attributes.Length; x++)
                {
                    var tagName = ((dfMarkupTagInfoAttribute)attributes[x]).TagName;
                    tagTypes[tagName] = type;
                }
            }
        }

        if (tagTypes.ContainsKey(original.TagName))
        {
            var tagType = tagTypes[original.TagName];
            return((dfMarkupTag)Activator.CreateInstance(tagType, original));
        }

        return(original);
    }
コード例 #17
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
    public dfMarkupTag( dfMarkupTag original )
        : base()
    {
        this.TagName = original.TagName;
        this.Attributes = original.Attributes;
        this.IsEndTag = original.IsEndTag;
        this.IsClosedTag = original.IsClosedTag;
        this.IsInline = original.IsInline;
        this.id = original.id;

        var children = original.ChildNodes;
        for( int i = 0; i < children.Count; i++ )
        {
            var child = children[ i ];
            AddChildNode( child );
        }
    }
コード例 #18
0
ファイル: dfMarkupParser.cs プロジェクト: sknchan/LegacyRust
    private dfMarkupElement parseTag(Match tag)
    {
        string lowerInvariant = tag.Groups["tag"].Value.ToLowerInvariant();

        if (tag.Value.StartsWith("</"))
        {
            return(new dfMarkupTag(lowerInvariant)
            {
                IsEndTag = true
            });
        }
        dfMarkupTag     _dfMarkupTag     = new dfMarkupTag(lowerInvariant);
        string          value            = tag.Groups["attr"].Value;
        MatchCollection matchCollections = dfMarkupParser.ATTR_PATTERN.Matches(value);

        for (int i = 0; i < matchCollections.Count; i++)
        {
            Match  item = matchCollections[i];
            string str  = item.Groups["key"].Value;
            string str1 = dfMarkupEntity.Replace(item.Groups["value"].Value);
            if (str1.StartsWith("\""))
            {
                str1 = str1.Trim(new char[] { '\"' });
            }
            else if (str1.StartsWith("'"))
            {
                str1 = str1.Trim(new char[] { '\'' });
            }
            if (!string.IsNullOrEmpty(str1))
            {
                if (str != "style")
                {
                    _dfMarkupTag.Attributes.Add(new dfMarkupAttribute(str, str1));
                }
                else
                {
                    this.parseStyleAttribute(_dfMarkupTag, str1);
                }
            }
        }
        if (tag.Value.EndsWith("/>") || lowerInvariant == "br" || lowerInvariant == "img")
        {
            _dfMarkupTag.IsClosedTag = true;
        }
        return(_dfMarkupTag);
    }
コード例 #19
0
    public dfMarkupTag(dfMarkupTag original)
        : base()
    {
        this.TagName     = original.TagName;
        this.Attributes  = original.Attributes;
        this.IsEndTag    = original.IsEndTag;
        this.IsClosedTag = original.IsClosedTag;
        this.IsInline    = original.IsInline;
        this.id          = original.id;

        var children = original.ChildNodes;

        for (int i = 0; i < children.Count; i++)
        {
            var child = children[i];
            AddChildNode(child);
        }
    }
コード例 #20
0
ファイル: dfMarkupTagList.cs プロジェクト: Virobeast2/RCLIENT
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count != 0)
     {
         style.Align = dfMarkupTextAlign.Left;
         dfMarkupBox box = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
         container.AddChild(box);
         this.calculateBulletWidth(style);
         for (int i = 0; i < base.ChildNodes.Count; i++)
         {
             dfMarkupTag tag = base.ChildNodes[i] as dfMarkupTag;
             if ((tag != null) && (tag.TagName == "li"))
             {
                 tag.PerformLayout(box, style);
             }
         }
         box.FitToContents(false);
     }
 }
コード例 #21
0
ファイル: dfMarkupTagList.cs プロジェクト: sknchan/LegacyRust
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (base.ChildNodes.Count == 0)
        {
            return;
        }
        style.Align = dfMarkupTextAlign.Left;
        dfMarkupBox _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);

        container.AddChild(_dfMarkupBox);
        this.calculateBulletWidth(style);
        for (int i = 0; i < base.ChildNodes.Count; i++)
        {
            dfMarkupTag item = base.ChildNodes[i] as dfMarkupTag;
            if (item != null && !(item.TagName != "li"))
            {
                item.PerformLayout(_dfMarkupBox, style);
            }
        }
        _dfMarkupBox.FitToContents(false);
    }
コード例 #22
0
ファイル: dfMarkupTagList.cs プロジェクト: Virobeast2/RCLIENT
 private void calculateBulletWidth(dfMarkupStyle style)
 {
     if (base.TagName == "ul")
     {
         Vector2 vector = style.Font.MeasureText("•", style.FontSize, style.FontStyle);
         this.BulletWidth = Mathf.CeilToInt(vector.x);
     }
     else
     {
         int num = 0;
         for (int i = 0; i < base.ChildNodes.Count; i++)
         {
             dfMarkupTag tag = base.ChildNodes[i] as dfMarkupTag;
             if ((tag != null) && (tag.TagName == "li"))
             {
                 num++;
             }
         }
         string  text    = new string('X', num.ToString().Length) + ".";
         Vector2 vector2 = style.Font.MeasureText(text, style.FontSize, style.FontStyle);
         this.BulletWidth = Mathf.CeilToInt(vector2.x);
     }
 }
コード例 #23
0
 protected internal override void OnMouseUp(dfMouseEventArgs args)
 {
     base.OnMouseUp(args);
     this.isMouseDown = false;
     if (Vector2.Distance(this.scrollPosition, this.mouseDownScrollPosition) <= 2f && this.hitTestTag(args) == this.mouseDownTag)
     {
         dfMarkupTag parent = this.mouseDownTag;
         while (parent != null && !(parent is dfMarkupTagAnchor))
         {
             parent = parent.Parent as dfMarkupTag;
         }
         if (parent is dfMarkupTagAnchor)
         {
             base.Signal("OnLinkClicked", new object[] { parent });
             if (this.LinkClicked != null)
             {
                 this.LinkClicked(this, parent as dfMarkupTagAnchor);
             }
         }
     }
     this.mouseDownTag            = null;
     this.mouseDownScrollPosition = this.scrollPosition;
 }
コード例 #24
0
ファイル: dfMarkupTagList.cs プロジェクト: sknchan/LegacyRust
    private void calculateBulletWidth(dfMarkupStyle style)
    {
        if (base.TagName == "ul")
        {
            Vector2 vector2 = style.Font.MeasureText("•", style.FontSize, style.FontStyle);
            this.BulletWidth = Mathf.CeilToInt(vector2.x);
            return;
        }
        int num = 0;

        for (int i = 0; i < base.ChildNodes.Count; i++)
        {
            dfMarkupTag item = base.ChildNodes[i] as dfMarkupTag;
            if (item != null && item.TagName == "li")
            {
                num++;
            }
        }
        string  str      = string.Concat(new string('X', num.ToString().Length), ".");
        Vector2 vector21 = style.Font.MeasureText(str, style.FontSize, style.FontStyle);

        this.BulletWidth = Mathf.CeilToInt(vector21.x);
    }
コード例 #25
0
ファイル: dfRichTextLabel.cs プロジェクト: Virobeast2/RCLIENT
 protected internal override void OnMouseUp(dfMouseEventArgs args)
 {
     base.OnMouseUp(args);
     this.isMouseDown = false;
     if ((Vector2.Distance(this.scrollPosition, this.mouseDownScrollPosition) <= 2f) && (this.hitTestTag(args) == this.mouseDownTag))
     {
         dfMarkupTag mouseDownTag = this.mouseDownTag;
         while ((mouseDownTag != null) && !(mouseDownTag is dfMarkupTagAnchor))
         {
             mouseDownTag = mouseDownTag.Parent as dfMarkupTag;
         }
         if (mouseDownTag is dfMarkupTagAnchor)
         {
             object[] objArray1 = new object[] { mouseDownTag };
             base.Signal("OnLinkClicked", objArray1);
             if (this.LinkClicked != null)
             {
                 this.LinkClicked(this, mouseDownTag as dfMarkupTagAnchor);
             }
         }
     }
     this.mouseDownTag            = null;
     this.mouseDownScrollPosition = this.scrollPosition;
 }
コード例 #26
0
 public dfMarkupTagHeading(dfMarkupTag original) : base(original)
 {
 }
コード例 #27
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagFont( dfMarkupTag original )
     : base(original)
 {
 }
コード例 #28
0
ファイル: dfMarkupTagFont.cs プロジェクト: sknchan/LegacyRust
 public dfMarkupTagFont(dfMarkupTag original) : base(original)
 {
 }
コード例 #29
0
    private void releaseMarkupReferences()
    {
        this.mouseDownTag = null;

        if( viewportBox != null )
        {
            viewportBox.Release();
        }

        if( elements != null )
        {

            for( int i = 0; i < elements.Count; i++ )
            {
                elements[ i ].Release();
            }

            elements.Release();

        }
    }
コード例 #30
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagParagraph( dfMarkupTag original )
     : base(original)
 {
 }
コード例 #31
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagItalic( dfMarkupTag original )
     : base(original)
 {
 }
コード例 #32
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagHeading( dfMarkupTag original )
     : base(original)
 {
 }
コード例 #33
0
ファイル: dfRichTextLabel.cs プロジェクト: HexHash/LegacyRust
 protected internal override void OnMouseUp(dfMouseEventArgs args)
 {
     base.OnMouseUp(args);
     this.isMouseDown = false;
     if (Vector2.Distance(this.scrollPosition, this.mouseDownScrollPosition) <= 2f && this.hitTestTag(args) == this.mouseDownTag)
     {
         dfMarkupTag parent = this.mouseDownTag;
         while (parent != null && !(parent is dfMarkupTagAnchor))
         {
             parent = parent.Parent as dfMarkupTag;
         }
         if (parent is dfMarkupTagAnchor)
         {
             base.Signal("OnLinkClicked", new object[] { parent });
             if (this.LinkClicked != null)
             {
                 this.LinkClicked(this, parent as dfMarkupTagAnchor);
             }
         }
     }
     this.mouseDownTag = null;
     this.mouseDownScrollPosition = this.scrollPosition;
 }
コード例 #34
0
    protected internal override void OnMouseDown( dfMouseEventArgs args )
    {
        base.OnMouseDown( args );

        this.mouseDownTag = hitTestTag( args );
        this.mouseDownScrollPosition = scrollPosition;

        scrollMomentum = Vector2.zero;
        touchStartPosition = args.Position;
        isMouseDown = true;
    }
コード例 #35
0
    protected internal override void OnMouseUp( dfMouseEventArgs args )
    {
        base.OnMouseUp( args );

        isMouseDown = false;

        if( Vector2.Distance( scrollPosition, mouseDownScrollPosition ) <= 2 )
        {

            if( hitTestTag( args ) == mouseDownTag )
            {

                var linkTag = mouseDownTag;
                while( linkTag != null && !( linkTag is dfMarkupTagAnchor ) )
                {
                    linkTag = linkTag.Parent as dfMarkupTag;
                }

                if( linkTag is dfMarkupTagAnchor )
                {

                    Signal( "OnLinkClicked", linkTag );

                    if( this.LinkClicked != null )
                    {
                        this.LinkClicked( this, linkTag as dfMarkupTagAnchor );
                    }

                }

            }

        }

        mouseDownTag = null;
        mouseDownScrollPosition = scrollPosition;
    }
コード例 #36
0
ファイル: dfMarkupParser.cs プロジェクト: HexHash/LegacyRust
 private dfMarkupTag refineTag(dfMarkupTag original)
 {
     if (original.IsEndTag)
     {
         return original;
     }
     if (dfMarkupParser.tagTypes == null)
     {
         dfMarkupParser.tagTypes = new Dictionary<string, Type>();
         Type[] exportedTypes = Assembly.GetExecutingAssembly().GetExportedTypes();
         for (int i = 0; i < (int)exportedTypes.Length; i++)
         {
             Type type = exportedTypes[i];
             if (typeof(dfMarkupTag).IsAssignableFrom(type))
             {
                 object[] customAttributes = type.GetCustomAttributes(typeof(dfMarkupTagInfoAttribute), true);
                 if (customAttributes != null && (int)customAttributes.Length != 0)
                 {
                     for (int j = 0; j < (int)customAttributes.Length; j++)
                     {
                         string tagName = ((dfMarkupTagInfoAttribute)customAttributes[j]).TagName;
                         dfMarkupParser.tagTypes[tagName] = type;
                     }
                 }
             }
         }
     }
     if (!dfMarkupParser.tagTypes.ContainsKey(original.TagName))
     {
         return original;
     }
     Type item = dfMarkupParser.tagTypes[original.TagName];
     return (dfMarkupTag)Activator.CreateInstance(item, new object[] { original });
 }
コード例 #37
0
 public dfMarkupTagBold(dfMarkupTag original) : base(original)
 {
 }
コード例 #38
0
 public dfMarkupTagAnchor(dfMarkupTag original) : base(original)
 {
 }
コード例 #39
0
 public dfMarkupTagItalic(dfMarkupTag original) : base(original)
 {
 }
コード例 #40
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagAnchor( dfMarkupTag original )
     : base(original)
 {
 }
コード例 #41
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagSpan( dfMarkupTag original )
     : base(original)
 {
 }
コード例 #42
0
ファイル: dfMarkupParser.cs プロジェクト: HexHash/LegacyRust
 private dfMarkupElement parseTag(Match tag)
 {
     string lowerInvariant = tag.Groups["tag"].Value.ToLowerInvariant();
     if (tag.Value.StartsWith("</"))
     {
         return new dfMarkupTag(lowerInvariant)
         {
             IsEndTag = true
         };
     }
     dfMarkupTag _dfMarkupTag = new dfMarkupTag(lowerInvariant);
     string value = tag.Groups["attr"].Value;
     MatchCollection matchCollections = dfMarkupParser.ATTR_PATTERN.Matches(value);
     for (int i = 0; i < matchCollections.Count; i++)
     {
         Match item = matchCollections[i];
         string str = item.Groups["key"].Value;
         string str1 = dfMarkupEntity.Replace(item.Groups["value"].Value);
         if (str1.StartsWith("\""))
         {
             str1 = str1.Trim(new char[] { '\"' });
         }
         else if (str1.StartsWith("'"))
         {
             str1 = str1.Trim(new char[] { '\'' });
         }
         if (!string.IsNullOrEmpty(str1))
         {
             if (str != "style")
             {
                 _dfMarkupTag.Attributes.Add(new dfMarkupAttribute(str, str1));
             }
             else
             {
                 this.parseStyleAttribute(_dfMarkupTag, str1);
             }
         }
     }
     if (tag.Value.EndsWith("/>") || lowerInvariant == "br" || lowerInvariant == "img")
     {
         _dfMarkupTag.IsClosedTag = true;
     }
     return _dfMarkupTag;
 }
コード例 #43
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagBold( dfMarkupTag original )
     : base(original)
 {
 }
コード例 #44
0
ファイル: dfMarkupParser.cs プロジェクト: HexHash/LegacyRust
 private void parseStyleAttribute(dfMarkupTag element, string text)
 {
     MatchCollection matchCollections = dfMarkupParser.STYLE_PATTERN.Matches(text);
     for (int i = 0; i < matchCollections.Count; i++)
     {
         Match item = matchCollections[i];
         string lowerInvariant = item.Groups["key"].Value.ToLowerInvariant();
         string value = item.Groups["value"].Value;
         element.Attributes.Add(new dfMarkupAttribute(lowerInvariant, value));
     }
 }
コード例 #45
0
 public dfMarkupTagParagraph(dfMarkupTag original) : base(original)
 {
 }
コード例 #46
0
ファイル: dfMarkupTagList.cs プロジェクト: Virobeast2/RCLIENT
 public dfMarkupTagList(dfMarkupTag original) : base(original)
 {
 }
コード例 #47
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagImg( dfMarkupTag original )
     : base(original)
 {
     this.IsClosedTag = true;
 }
コード例 #48
0
ファイル: dfMarkupParser.cs プロジェクト: kvelury/apocalyptia
    private void parseStyleAttribute( dfMarkupTag element, string text )
    {
        var matches = STYLE_PATTERN.Matches( text );
        for( int i = 0; i < matches.Count; i++ )
        {

            var match = matches[ i ];

            var key = match.Groups[ "key" ].Value.ToLowerInvariant();
            var value = match.Groups[ "value" ].Value;

            element.Attributes.Add( new dfMarkupAttribute( key, value ) );

        }
    }
コード例 #49
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagListItem( dfMarkupTag original )
     : base(original)
 {
 }
コード例 #50
0
ファイル: dfMarkupParser.cs プロジェクト: kvelury/apocalyptia
    private dfMarkupElement parseTag( Match tag )
    {
        var tagName = tag.Groups[ "tag" ].Value.ToLowerInvariant();
        if( tag.Value.StartsWith( "</" ) )
        {
            return new dfMarkupTag( tagName ) { IsEndTag = true };
        }

        var element = new dfMarkupTag( tagName );

        var attributes = tag.Groups[ "attr" ].Value;
        var matches = ATTR_PATTERN.Matches( attributes );
        for( int i = 0; i < matches.Count; i++ )
        {

            var attrMatch = matches[ i ];

            var key = attrMatch.Groups[ "key" ].Value;
            var value = dfMarkupEntity.Replace( attrMatch.Groups[ "value" ].Value );

            if( value.StartsWith( "\"" ) )
                value = value.Trim( '"' );
            else if( value.StartsWith( "'" ) )
                value = value.Trim( '\'' );

            if( string.IsNullOrEmpty( value ) )
                continue;

            if( key == "style" )
            {
                parseStyleAttribute( element, value );
            }
            else
            {
                element.Attributes.Add( new dfMarkupAttribute( key, value ) );
            }

        }

        if( tag.Value.EndsWith( "/>" ) || tagName == "br" || tagName == "img" )
        {
            element.IsClosedTag = true;
        }

        return element;
    }
コード例 #51
0
ファイル: dfMarkupTags.cs プロジェクト: AhrenLi/2048
 public dfMarkupTagPre( dfMarkupTag original )
     : base(original)
 {
 }
コード例 #52
0
ファイル: dfMarkupParser.cs プロジェクト: kvelury/apocalyptia
    /// <summary>
    /// Refines a generic dfMarkupTag instance into a more specific
    /// derived class instance, if one can be determined
    /// </summary>
    /// <param name="original"></param>
    /// <returns></returns>
    private dfMarkupTag refineTag( dfMarkupTag original )
    {
        // Don't bother refining end tags, they only exist to indicate
        // when we are done parsing/processing a tag that has child
        // elements.
        if( original.IsEndTag )
            return original;

        if( tagTypes == null )
        {

            tagTypes = new Dictionary<string, Type>();

            var assemblyTypes = getAssemblyTypes();

            for( int i = 0; i < assemblyTypes.Length; i++ )
            {

                var type = assemblyTypes[ i ];

                if( !typeof( dfMarkupTag ).IsAssignableFrom( type ) )
                {
                    continue;
                }

                var attributes = type.GetCustomAttributes( typeof( dfMarkupTagInfoAttribute ), true );
                if( attributes == null || attributes.Length == 0 )
                    continue;

                for( int x = 0; x < attributes.Length; x++ )
                {
                    var tagName = ( (dfMarkupTagInfoAttribute)attributes[ x ] ).TagName;
                    tagTypes[ tagName ] = type;
                }

            }

        }

        if( tagTypes.ContainsKey( original.TagName ) )
        {
            var tagType = tagTypes[original.TagName];
            return (dfMarkupTag)Activator.CreateInstance( tagType, original );
        }

        return original;
    }