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

Center Groups

2 Answers 103 Views
Panorama
This is a migrated thread and some comments may be shown as answers.
Andre
Top achievements
Rank 1
Andre asked on 24 Jan 2013, 04:47 PM
Is there a quick way to center groups similar to the attached picture? Or do i have to do the calculations manually in the resize event?

2 Answers, 1 is accepted

Sort by
0
Andre
Top achievements
Rank 1
answered on 26 Jan 2013, 04:07 AM
I suppose i could do something along the lines of this (ignoring title and padding) in the resize event. But then i get into positioning each and every group. Also, is there not an easy way to calc the current size of a group.

  float newWidth = (radPanorama1.Width/2) - (tileGroupElement1.CellSize.Width * tileGroupElement1.ColumnsCount)/2;
 
float newHeight = (radPanorama1.Height / 2) - (tileGroupElement1.CellSize.Height * tileGroupElement1.RowsCount) / 2;
 
           tileGroupElement1.PositionOffset = new SizeF(newWidth, newHeight);
0
Jack
Telerik team
answered on 29 Jan 2013, 02:37 PM
Hello Andre,

It is not easy to get the actual width of a group element because it is valid only when calling its parent element ArrangeOverride method. However, you can center groups both horizontally and vertically by using a custom RadPanoramaElement and overriding its ArrangeOverride method. Consider the following code:
public class CustomPanorama : RadPanorama
{
    public override string ThemeClassName
    {
        get
        {
            return typeof(RadPanorama).FullName;
        }
        set { }
    }
 
    protected override RadPanoramaElement CreatePanoramaElement()
    {
        return new CustomPanoramaElement();
    }
}
 
public class CustomPanoramaElement : RadPanoramaElement
{
    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(RadPanoramaElement);
        }
    }
 
    protected override SizeF ArrangeOverride(SizeF finalSize)
    {
        base.ArrangeOverride(finalSize);
 
        this.GroupLayout.Arrange(new RectangleF(
            (finalSize.Width - this.GroupLayout.DesiredSize.Width) / 2,
            (finalSize.Height - this.GroupLayout.DesiredSize.Height) / 2, this.GroupLayout.DesiredSize.Width, this.GroupLayout.DesiredSize.Height));
 
        return finalSize;
    }
}

If you have further questions, do not hesitate to contact me.
 
All the best,
Jack
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
Tags
Panorama
Asked by
Andre
Top achievements
Rank 1
Answers by
Andre
Top achievements
Rank 1
Jack
Telerik team
Share this question
or