Click here to Skip to main content
15,886,873 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
protected override Size ArrangeOverride(Size arrangeBounds)
        {
            Point currentPosition = new Point(OuterRadius, InnerRadius);
            int countChild = Children.Count - 1, i, j = 2, count = 0;
            double angle = 2 * Math.PI / 7, k = 0;
            double offsetOfx = 0.0, offsetOfy = 0.0;
            for (i = 0; i <= countChild; i++)
            {
                if (i == 0)
                {
                    UIElement child = Children[i];
                    Rect childRec = new Rect(117, 117, 48, 20);
                    child.Arrange(childRec);
                }
                else
                {
                    for (j = i; j <= countChild; j++)
                    {
                        count++;
                        if (count <= 7)
                        {
                            UIElement child = Children[j];
                            double currentAngle = j * angle;
                            offsetOfx = Math.Sin(currentAngle) * (OuterRadius + InnerRadius) / 2;
                            offsetOfy = (1 - Math.Cos(currentAngle)) * (OuterRadius + InnerRadius) / 2;
                            Rect childRec = new Rect(
                              new Point(currentPosition.X - child.DesiredSize.Width / 2, currentPosition.Y - child.DesiredSize.Height / 2),
                              new Point(currentPosition.X + child.DesiredSize.Width / 2, currentPosition.Y + child.DesiredSize.Height / 2));
                            child.Arrange(childRec);
                        }
                        else
                        {
                            break;
                        }

                        currentPosition.X = offsetOfx + OuterRadius;
                        currentPosition.Y = offsetOfy + (OuterRadius - InnerRadius) / 2;
                    }
                }
                if (i == 0)
                    i = 0;
                else
                    i = j - 1;
                count = 0;

                currentPosition.X = offsetOfx + OuterRadius;
                currentPosition.Y = offsetOfy + (OuterRadius - InnerRadius) / 2;
            }
            return new Size(2 * OuterRadius, 2 * OuterRadius);
        }


I try this program,

this program used to arrange the buttons in single circle only, if the 1st 7 buttons are arrange in one circle and next 7 buttons are arrange in another big circle , this shape was circle of circle,,, so what should i change in this program. please help to resolve me
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900