Exemplo n.º 1
0
        /// <summary>
        /// To calculate the desired size of <see cref="MultiLevelLabelsPanel"/> based on its children's available size
        /// </summary>
        /// <param name="availableSize">The Available Size</param>
        /// <returns>Returns the desired size of <see cref="MultiLevelLabelsPanel"/></returns>
        private Size CalculateDesiredSize(Size availableSize)
        {
            double actualValue = 0;

            actualValue = textBlockRecycler.Max(txtBlock => txtBlock.DesiredSize.Height)
                          + (borderPadding + margin.Top + margin.Bottom);
            var desiredValue = Math.Max(actualValue, Axis.LabelExtent)
                               * groupedLabels.Count();

            if (!Axis.ShowLabelBorder &&
                Axis.MultiLevelLabelsBorderType != BorderType.None)
            {
                desiredValue += Axis.LabelBorderWidth;
            }
            if (Axis.Orientation == Orientation.Horizontal)
            {
                height      = actualValue;
                desiredSize = new Size(availableSize.Width, desiredValue);
            }
            else
            {
                width       = actualValue;
                desiredSize = new Size(desiredValue, availableSize.Height);
            }

            return(desiredSize);
        }