This is a migrated thread and some comments may be shown as answers.

Panel with Shape and Background image

4 Answers 551 Views
Panel
This is a migrated thread and some comments may be shown as answers.
Aleksej
Top achievements
Rank 1
Aleksej asked on 18 Sep 2014, 07:27 AM
I have the rounded panel (pic.1). When I add the picture of a background, curves vanish (pic.2). How to solve a problem?

4 Answers, 1 is accepted

Sort by
0
Aleksej
Top achievements
Rank 1
answered on 22 Sep 2014, 01:30 PM
Up!
0
Stefan
Telerik team
answered on 22 Sep 2014, 01:49 PM
Hi Aleksej,

Thank you for writing.

Here is a sample implementation of an element with clipped image, which you can host in RadPanel. I hope that you find it useful.
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    InitializeComponent();
 
    RadPanel panel = new RadPanel();
    panel.Size = new System.Drawing.Size(302, 302);
    panel.Parent = this;
 
    panel.PanelElement.PanelBorder.ForeColor = Color.Red;
    panel.PanelElement.PanelBorder.BorderThickness = new Padding(3);
    panel.PanelElement.Shape = new RoundRectShape(45);
 
    MyElement imp = new MyElement();
    imp.Image = Image.FromFile(@"C:\Users\stefanov\Desktop\a.png");
    imp.ImageLayout = ImageLayout.Tile;
    imp.Shape = panel.PanelElement.Shape;
    panel.PanelElement.Children.Add(imp);
}
 
class MyElement : LightVisualElement
{
    protected override void PaintElement(Telerik.WinControls.Paint.IGraphics graphics, float angle, SizeF scale)
    {
        object state = graphics.SaveState();
 
        Graphics g = (graphics.UnderlayGraphics as Graphics);
 
        Rectangle rect = new Rectangle(0, 0, this.Bounds.Width , this.Bounds.Height );
        g.SetClip(this.Shape.CreatePath(rect), CombineMode.Intersect);
         
        base.PaintElement(graphics, angle, scale);
        
         graphics.RestoreState(state);
    }
}

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Aleksej
Top achievements
Rank 1
answered on 23 Sep 2014, 06:22 AM
Thanks! And why not to realize it in RadPanel?
0
Stefan
Telerik team
answered on 23 Sep 2014, 03:39 PM
Hello,

We will consider it if we have more request for such functionality.

Regards,
Stefan
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
Panel
Asked by
Aleksej
Top achievements
Rank 1
Answers by
Aleksej
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or