protected override Size MeasureOverride(Size availableSize)
        {
            Size size       = new Size(Double.PositiveInfinity, Double.PositiveInfinity);
            Size resultSize = new Size();

            if (this.Children == null || this.Children.Count == 0)
            {
                return(resultSize);
            }

            RecalcParams();

            int iCurrentChildIndex = 0;

            dXMax = Double.MinValue;
            dYMax = Double.MinValue;

            dXMin = Double.MaxValue;
            dYMin = Double.MaxValue;

            foreach (UIElement child in Children)
            {
                double dAngle = ((double)(iCurrentChildIndex)) * dRenderAngleSpacing + StartAngle;
                double dX     = dRenderRadius * Math.Sin(dAngle * dDegToRad);

                // We invert the Y coordinate, because the origin in controls
                // is the upper left corner, rather than the lower left
                double dY = -dRenderRadius *Math.Cos(dAngle *dDegToRad);

                child.Measure(size);

                Point visualCenter = new Point();

                if (child is ICustomAlignedControl)
                {
                    ICustomAlignedControl mkchild = (ICustomAlignedControl)child;
                    visualCenter.X = mkchild.AlignReferencePoint.X;
                    visualCenter.Y = mkchild.AlignReferencePoint.Y;
                }
                else
                {
                    visualCenter.X = child.DesiredSize.Width * 0.5;
                    visualCenter.Y = child.DesiredSize.Height * 0.5;
                }

                dXMax = Math.Max(dXMax, dX + (child.DesiredSize.Width - visualCenter.X));
                dYMax = Math.Max(dYMax, dY + (child.DesiredSize.Height - visualCenter.Y));

                dXMin = Math.Min(dXMin, dX - (visualCenter.X));
                dYMin = Math.Min(dYMin, dY - (visualCenter.Y));
                iCurrentChildIndex++;
            }

            resultSize.Width  = dXMax - dXMin;
            resultSize.Height = dYMax - dYMin;

            return(resultSize);
        }
        private Vector GetChildOffset(UIElement child, double dAngle)
        {
            Vector Offset = new Vector();

            if (child is ICustomAlignedControl)
            {
                ICustomAlignedControl mkchild = (ICustomAlignedControl)child;
                Offset.X = dRenderRadius * Math.Sin(dAngle * dDegToRad) - dXMin - mkchild.AlignReferencePoint.X;
                Offset.Y = -dRenderRadius *Math.Cos(dAngle *dDegToRad) - dYMin - mkchild.AlignReferencePoint.Y;
            }
            else
            {
                Offset.X = dRenderRadius * Math.Sin(dAngle * dDegToRad) - dXMin - child.DesiredSize.Width * 0.5;
                Offset.Y = -dRenderRadius *Math.Cos(dAngle *dDegToRad) - dYMin - child.DesiredSize.Height * 0.5;
            }

            return(Offset);
        }