Exemplo n.º 1
0
    private dfMarkupBox createImageBox(dfAtlas atlas, string source, dfMarkupStyle style)
    {
        if (source.ToLowerInvariant().StartsWith("http://"))
        {
            return(null);
        }
        else if (atlas != null && atlas[source] != null)
        {
            var spriteBox = new dfMarkupBoxSprite(this, dfMarkupDisplayType.inline, style);
            spriteBox.LoadImage(atlas, source);

            return(spriteBox);
        }
        else
        {
            var texture = dfMarkupImageCache.Load(source);
            if (texture != null)
            {
                var textureBox = new dfMarkupBoxTexture(this, dfMarkupDisplayType.inline, style);
                textureBox.LoadTexture(texture);

                return(textureBox);
            }
        }

        return(null);
    }
Exemplo n.º 2
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     style = base.applyTextStyleAttributes(style);
     style.PreserveWhitespace = true;
     style.Preformatted = true;
     if (style.Align == dfMarkupTextAlign.Justify)
     {
         style.Align = dfMarkupTextAlign.Left;
     }
     dfMarkupBox _dfMarkupBox = null;
     if (style.BackgroundColor.a <= 0.1f)
     {
         _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
     }
     else
     {
         dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
         _dfMarkupBoxSprite.LoadImage(base.Owner.Atlas, base.Owner.BlankTextureSprite);
         _dfMarkupBoxSprite.Style.Color = style.BackgroundColor;
         _dfMarkupBox = _dfMarkupBoxSprite;
     }
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });
     if (_dfMarkupAttribute != null)
     {
         _dfMarkupBox.Margins = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
     }
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "padding" });
     if (_dfMarkupAttribute1 != null)
     {
         _dfMarkupBox.Padding = dfMarkupBorders.Parse(_dfMarkupAttribute1.Value);
     }
     container.AddChild(_dfMarkupBox);
     base._PerformLayoutImpl(_dfMarkupBox, style);
     _dfMarkupBox.FitToContents(false);
 }
Exemplo n.º 3
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (this.ChildNodes.Count == 0)
        {
            return;
        }

        style = applyTextStyleAttributes(style);

        var topMargin = container.Children.Count == 0 ? 0 : style.LineHeight;

        dfMarkupBox paragraphBox = null;

        if (style.BackgroundColor.a > 0.005f)
        {
            var spriteBox = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
            spriteBox.Atlas       = this.Owner.Atlas;
            spriteBox.Source      = this.Owner.BlankTextureSprite;
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;
        }
        else
        {
            paragraphBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }

        paragraphBox.Margins = new dfMarkupBorders(0, 0, topMargin, style.LineHeight);

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute("margin");
        if (marginAttribute != null)
        {
            paragraphBox.Margins = dfMarkupBorders.Parse(marginAttribute.Value);
        }

        var paddingAttribute = findAttribute("padding");
        if (paddingAttribute != null)
        {
            paragraphBox.Padding = dfMarkupBorders.Parse(paddingAttribute.Value);
        }

        #endregion

        container.AddChild(paragraphBox);

        base._PerformLayoutImpl(paragraphBox, style);

        if (paragraphBox.Children.Count > 0)
        {
            paragraphBox.Children[paragraphBox.Children.Count - 1].IsNewline = true;
        }

        paragraphBox.FitToContents(true);
    }
Exemplo n.º 4
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        style = applyTextStyleAttributes(style);

        style.PreserveWhitespace = true;
        style.Preformatted       = true;

        if (style.Align == dfMarkupTextAlign.Justify)
        {
            style.Align = dfMarkupTextAlign.Left;
        }

        dfMarkupBox paragraphBox = null;

        if (style.BackgroundColor.a > 0.1f)
        {
            var spriteBox = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
            spriteBox.LoadImage(this.Owner.Atlas, this.Owner.BlankTextureSprite);
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;
        }
        else
        {
            paragraphBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute("margin");
        if (marginAttribute != null)
        {
            paragraphBox.Margins = dfMarkupBorders.Parse(marginAttribute.Value);
        }

        var paddingAttribute = findAttribute("padding");
        if (paddingAttribute != null)
        {
            paragraphBox.Padding = dfMarkupBorders.Parse(paddingAttribute.Value);
        }

        #endregion

        container.AddChild(paragraphBox);

        base._PerformLayoutImpl(paragraphBox, style);

        paragraphBox.FitToContents();
    }
Exemplo n.º 5
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        if (base.ChildNodes.Count == 0)
        {
            return;
        }
        style = base.applyTextStyleAttributes(style);
        int         num          = (container.Children.Count != 0 ? style.LineHeight : 0);
        dfMarkupBox _dfMarkupBox = null;

        if (style.BackgroundColor.a <= 0.005f)
        {
            _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }
        else
        {
            dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style)
            {
                Atlas  = base.Owner.Atlas,
                Source = base.Owner.BlankTextureSprite
            };
            _dfMarkupBoxSprite.Style.Color = style.BackgroundColor;
            _dfMarkupBox = _dfMarkupBoxSprite;
        }
        _dfMarkupBox.Margins = new dfMarkupBorders(0, 0, num, style.LineHeight);
        dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });

        if (_dfMarkupAttribute != null)
        {
            _dfMarkupBox.Margins = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
        }
        dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "padding" });

        if (_dfMarkupAttribute1 != null)
        {
            _dfMarkupBox.Padding = dfMarkupBorders.Parse(_dfMarkupAttribute1.Value);
        }
        container.AddChild(_dfMarkupBox);
        base._PerformLayoutImpl(_dfMarkupBox, style);
        if (_dfMarkupBox.Children.Count > 0)
        {
            _dfMarkupBox.Children[_dfMarkupBox.Children.Count - 1].IsNewline = true;
        }
        _dfMarkupBox.FitToContents(true);
    }
Exemplo n.º 6
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count != 0)
     {
         style = base.applyTextStyleAttributes(style);
         int         top = (container.Children.Count != 0) ? style.LineHeight : 0;
         dfMarkupBox box = null;
         if (style.BackgroundColor.a > 0.005f)
         {
             dfMarkupBoxSprite sprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style)
             {
                 Atlas  = base.Owner.Atlas,
                 Source = base.Owner.BlankTextureSprite
             };
             sprite.Style.Color = style.BackgroundColor;
             box = sprite;
         }
         else
         {
             box = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
         }
         box.Margins = new dfMarkupBorders(0, 0, top, style.LineHeight);
         string[]          names     = new string[] { "margin" };
         dfMarkupAttribute attribute = base.findAttribute(names);
         if (attribute != null)
         {
             box.Margins = dfMarkupBorders.Parse(attribute.Value);
         }
         string[]          textArray2 = new string[] { "padding" };
         dfMarkupAttribute attribute2 = base.findAttribute(textArray2);
         if (attribute2 != null)
         {
             box.Padding = dfMarkupBorders.Parse(attribute2.Value);
         }
         container.AddChild(box);
         base._PerformLayoutImpl(box, style);
         if (box.Children.Count > 0)
         {
             box.Children[box.Children.Count - 1].IsNewline = true;
         }
         box.FitToContents(true);
     }
 }
Exemplo n.º 7
0
 protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
 {
     if (base.ChildNodes.Count == 0)
     {
         return;
     }
     style = base.applyTextStyleAttributes(style);
     int num = (container.Children.Count != 0 ? style.LineHeight : 0);
     dfMarkupBox _dfMarkupBox = null;
     if (style.BackgroundColor.a <= 0.005f)
     {
         _dfMarkupBox = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
     }
     else
     {
         dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style)
         {
             Atlas = base.Owner.Atlas,
             Source = base.Owner.BlankTextureSprite
         };
         _dfMarkupBoxSprite.Style.Color = style.BackgroundColor;
         _dfMarkupBox = _dfMarkupBoxSprite;
     }
     _dfMarkupBox.Margins = new dfMarkupBorders(0, 0, num, style.LineHeight);
     dfMarkupAttribute _dfMarkupAttribute = base.findAttribute(new string[] { "margin" });
     if (_dfMarkupAttribute != null)
     {
         _dfMarkupBox.Margins = dfMarkupBorders.Parse(_dfMarkupAttribute.Value);
     }
     dfMarkupAttribute _dfMarkupAttribute1 = base.findAttribute(new string[] { "padding" });
     if (_dfMarkupAttribute1 != null)
     {
         _dfMarkupBox.Padding = dfMarkupBorders.Parse(_dfMarkupAttribute1.Value);
     }
     container.AddChild(_dfMarkupBox);
     base._PerformLayoutImpl(_dfMarkupBox, style);
     if (_dfMarkupBox.Children.Count > 0)
     {
         _dfMarkupBox.Children[_dfMarkupBox.Children.Count - 1].IsNewline = true;
     }
     _dfMarkupBox.FitToContents(true);
 }
Exemplo n.º 8
0
 private dfMarkupBox createImageBox(dfAtlas atlas, string source, dfMarkupStyle style)
 {
     if (!source.ToLowerInvariant().StartsWith("http://"))
     {
         if ((atlas != null) && (atlas[source] != null))
         {
             dfMarkupBoxSprite sprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.inline, style);
             sprite.LoadImage(atlas, source);
             return(sprite);
         }
         Texture texture = dfMarkupImageCache.Load(source);
         if (texture != null)
         {
             dfMarkupBoxTexture texture2 = new dfMarkupBoxTexture(this, dfMarkupDisplayType.inline, style);
             texture2.LoadTexture(texture);
             return(texture2);
         }
     }
     return(null);
 }
Exemplo n.º 9
0
    protected override void _PerformLayoutImpl(dfMarkupBox container, dfMarkupStyle style)
    {
        style = base.applyTextStyleAttributes(style);
        style.PreserveWhitespace = true;
        style.Preformatted       = true;
        if (style.Align == dfMarkupTextAlign.Justify)
        {
            style.Align = dfMarkupTextAlign.Left;
        }
        dfMarkupBox box = null;

        if (style.BackgroundColor.a > 0.1f)
        {
            dfMarkupBoxSprite sprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.block, style);
            sprite.LoadImage(base.Owner.Atlas, base.Owner.BlankTextureSprite);
            sprite.Style.Color = style.BackgroundColor;
            box = sprite;
        }
        else
        {
            box = new dfMarkupBox(this, dfMarkupDisplayType.block, style);
        }
        string[]          names     = new string[] { "margin" };
        dfMarkupAttribute attribute = base.findAttribute(names);

        if (attribute != null)
        {
            box.Margins = dfMarkupBorders.Parse(attribute.Value);
        }
        string[]          textArray2 = new string[] { "padding" };
        dfMarkupAttribute attribute2 = base.findAttribute(textArray2);

        if (attribute2 != null)
        {
            box.Padding = dfMarkupBorders.Parse(attribute2.Value);
        }
        container.AddChild(box);
        base._PerformLayoutImpl(box, style);
        box.FitToContents(false);
    }
Exemplo n.º 10
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        style = applyTextStyleAttributes( style );

        style.PreserveWhitespace = true;
        style.Preformatted = true;

        if( style.Align == dfMarkupTextAlign.Justify )
        {
            style.Align = dfMarkupTextAlign.Left;
        }

        dfMarkupBox paragraphBox = null;

        if( style.BackgroundColor.a > 0.1f )
        {

            var spriteBox = new dfMarkupBoxSprite( this, dfMarkupDisplayType.block, style );
            spriteBox.LoadImage( this.Owner.Atlas, this.Owner.BlankTextureSprite );
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;

        }
        else
        {
            paragraphBox = new dfMarkupBox( this, dfMarkupDisplayType.block, style );
        }

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {
            paragraphBox.Margins = dfMarkupBorders.Parse( marginAttribute.Value );
        }

        var paddingAttribute = findAttribute( "padding" );
        if( paddingAttribute != null )
        {
            paragraphBox.Padding = dfMarkupBorders.Parse( paddingAttribute.Value );
        }

        #endregion

        container.AddChild( paragraphBox );

        base._PerformLayoutImpl( paragraphBox, style );

        paragraphBox.FitToContents();
    }
Exemplo n.º 11
0
    protected override void _PerformLayoutImpl( dfMarkupBox container, dfMarkupStyle style )
    {
        if( this.ChildNodes.Count == 0 )
            return;

        style = applyTextStyleAttributes( style );

        var topMargin = container.Children.Count == 0 ? 0 : style.LineHeight;

        dfMarkupBox paragraphBox = null;

        if( style.BackgroundColor.a > 0.005f )
        {

            var spriteBox = new dfMarkupBoxSprite( this, dfMarkupDisplayType.block, style );
            spriteBox.Atlas = this.Owner.Atlas;
            spriteBox.Source = this.Owner.BlankTextureSprite;
            spriteBox.Style.Color = style.BackgroundColor;

            paragraphBox = spriteBox;

        }
        else
        {
            paragraphBox = new dfMarkupBox( this, dfMarkupDisplayType.block, style );
        }

        paragraphBox.Margins = new dfMarkupBorders( 0, 0, topMargin, style.LineHeight );

        #region Allow overriding of margins and padding

        var marginAttribute = findAttribute( "margin" );
        if( marginAttribute != null )
        {
            paragraphBox.Margins = dfMarkupBorders.Parse( marginAttribute.Value );
        }

        var paddingAttribute = findAttribute( "padding" );
        if( paddingAttribute != null )
        {
            paragraphBox.Padding = dfMarkupBorders.Parse( paddingAttribute.Value );
        }

        #endregion

        container.AddChild( paragraphBox );

        base._PerformLayoutImpl( paragraphBox, style );

        if( paragraphBox.Children.Count > 0 )
        {
            paragraphBox.Children[ paragraphBox.Children.Count - 1 ].IsNewline = true;
        }

        paragraphBox.FitToContents( true );
    }
Exemplo n.º 12
0
    private dfMarkupBox createImageBox( dfAtlas atlas, string source, dfMarkupStyle style )
    {
        if( source.ToLowerInvariant().StartsWith( "http://" ) )
        {
            return null;
        }
        else if( atlas != null && atlas[ source ] != null )
        {

            var spriteBox = new dfMarkupBoxSprite( this, dfMarkupDisplayType.inline, style );
            spriteBox.LoadImage( atlas, source );

            return spriteBox;

        }
        else
        {
            var texture = dfMarkupImageCache.Load( source );
            if( texture != null )
            {

                var textureBox = new dfMarkupBoxTexture( this, dfMarkupDisplayType.inline, style );
                textureBox.LoadTexture( texture );

                return textureBox;

            }
        }

        return null;
    }
Exemplo n.º 13
0
 private dfMarkupBox createImageBox(dfAtlas atlas, string source, dfMarkupStyle style)
 {
     if (source.ToLowerInvariant().StartsWith("http://"))
     {
         return null;
     }
     if (atlas != null && atlas[source] != null)
     {
         dfMarkupBoxSprite _dfMarkupBoxSprite = new dfMarkupBoxSprite(this, dfMarkupDisplayType.inline, style);
         _dfMarkupBoxSprite.LoadImage(atlas, source);
         return _dfMarkupBoxSprite;
     }
     Texture texture = dfMarkupImageCache.Load(source);
     if (texture == null)
     {
         return null;
     }
     dfMarkupBoxTexture _dfMarkupBoxTexture = new dfMarkupBoxTexture(this, dfMarkupDisplayType.inline, style);
     _dfMarkupBoxTexture.LoadTexture(texture);
     return _dfMarkupBoxTexture;
 }