Unplanned
Last Updated: 30 Mar 2016 13:51 by ADMIN
ADMIN
Stefan
Created on: 11 Jun 2013 04:52
Category: UI Framework
Type: Bug Report
1
FIX. TPF - LightVisualElement - tabs are not rendered
To reproduce:

 public Form2() { InitializeComponent(); MyControl c = new MyControl(); c.Dock = DockStyle.Fill; this.Controls.Add(c); }

public class MyControl : RadControl
{
    protected override void CreateChildItems(RadElement parent)
    {
        base.CreateChildItems(parent);
        LightVisualElement element = new LightVisualElement();
        element.Text = "Hello" + "\t" + "World";
        element.StretchHorizontally = true;
        element.StretchVertically = true;
        parent.Children.Add(element);
    }
}

Workaround: 

   public partial class Form2 : Form

    {
        public Form2()
        {
            InitializeComponent();
            MyControl c = new MyControl();
            c.Dock = DockStyle.Fill;
            this.Controls.Add(c);
        }

        public class MyControl : RadControl
        {
            protected override void CreateChildItems(RadElement parent)
            {
                base.CreateChildItems(parent);
                LightVisualElement element = new MyElement();
                element.Text = "Hello" + "\t" + "World";
                element.StretchHorizontally = true;
                element.StretchVertically = true;
                parent.Children.Add(element);
            }

            public class TextGraphics : RadGdiGraphics
            {
                const float TabWidth = 100;

                public TextGraphics(Graphics g) : base(g)
                {
                }

                public override void DrawString(string drawString, Rectangle rectangle, Font font, Color color, ContentAlignment alignment, StringFormat stringFormat, Orientation orientation, bool flipText)
                {
                    stringFormat.SetTabStops(0, new float[] { TabWidth });
                    base.DrawString(drawString, rectangle, font, color, alignment, stringFormat, orientation, flipText);
                }

                public override void DrawString(string drawString, Rectangle rectangle, Font font, Color color, ContentAlignment alignment, StringFormat stringFormat, ShadowSettings shadow, System.Drawing.Text.TextRenderingHint textRendering, Orientation orientation, bool flipText)
                {
                    stringFormat.SetTabStops(0, new float[] { TabWidth });
                    base.DrawString(drawString, rectangle, font, color, alignment, stringFormat, shadow, textRendering, orientation, flipText);
                }

                public override void DrawString(string drawString, RectangleF rectangle, Font font, Color color, ContentAlignment alignment, StringFormat stringFormat, Orientation orientation, bool flipText)
                {
                    stringFormat.SetTabStops(0, new float[] { TabWidth });
                    base.DrawString(drawString, rectangle, font, color, alignment, stringFormat, orientation, flipText);
                }

                public override void DrawString(string drawString, RectangleF rectangle, Font font, Color color, ContentAlignment alignment, StringFormat stringFormat, ShadowSettings shadow, System.Drawing.Text.TextRenderingHint textRendering, Orientation orientation, bool flipText)
                {
                    stringFormat.SetTabStops(0, new float[] { TabWidth });
                    base.DrawString(drawString, rectangle, font, color, alignment, stringFormat, shadow, textRendering, orientation, flipText);
                }
            }

            public class MyElement : LightVisualElement
            {
                protected override void PaintElement(Telerik.WinControls.Paint.IGraphics graphics, float angle, SizeF scale)
                {
                    base.PaintElement(graphics, angle, scale);
                }

                protected override void PaintText(IGraphics graphics)
                {
                    graphics = new TextGraphics(graphics.UnderlayGraphics as Graphics);
                    base.PaintText(graphics);
                }
            }
        }
    }
0 comments