Example #1
0
 private static void RenderLabel(CommonElements common, ChartGraphics graph, CategoryNode node, DataPoint dataPoint, DataPointAttributes dataPointAttributes, string text, float startAngle, float sweepAngle, PointF centerAbsolute, float radiusAbsolute, int dataPointIndex, GraphicsPath sliceGraphicsPath)
 {
     if (!string.IsNullOrEmpty(text))
     {
         SizeF      size                = graph.MeasureString(text.Replace("\\n", "\n"), dataPointAttributes.Font, new SizeF(1000f, 1000f), new StringFormat(StringFormat.GenericTypographic));
         SizeF      relativeSize        = graph.GetRelativeSize(size);
         float      num                 = relativeSize.Width / (float)text.Length;
         float      num2                = relativeSize.Width + num;
         float      num3                = (float)(relativeSize.Height + relativeSize.Height / 8.0);
         float      sliceCenterAngle    = SunburstChart.GetSliceCenterAngle(startAngle, sweepAngle);
         float      labelAngle          = SunburstChart.GetLabelAngle(sliceCenterAngle);
         PointF     sliceCenterRelative = SunburstChart.GetSliceCenterRelative(graph, sliceCenterAngle, centerAbsolute, radiusAbsolute);
         RectangleF rectangleF          = new RectangleF((float)(sliceCenterRelative.X - num2 / 2.0), (float)(sliceCenterRelative.Y - num3 / 2.0), num2, num3);
         if (!rectangleF.IsEmpty)
         {
             int num4 = (int)labelAngle + dataPointAttributes.FontAngle;
             if (!graph.CanLabelFitInSlice(sliceGraphicsPath, rectangleF, num4) && !SunburstChart.CanFitInResizedArea(text, dataPointAttributes.Font, relativeSize, sliceCenterRelative, graph, sliceGraphicsPath, rectangleF, num4, radiusAbsolute, out rectangleF))
             {
                 return;
             }
             if (dataPoint != null)
             {
                 graph.DrawPointLabelStringRel(common, text, dataPoint.Font, new SolidBrush(dataPoint.FontColor), rectangleF, SunburstChart.format, (int)labelAngle + dataPoint.FontAngle, rectangleF, dataPoint.LabelBackColor, dataPoint.LabelBorderColor, dataPoint.LabelBorderWidth, dataPoint.LabelBorderStyle, dataPoint.series, dataPoint, dataPointIndex);
             }
             else
             {
                 graph.DrawLabelBackground(num4, sliceCenterRelative, rectangleF, dataPointAttributes.LabelBackColor, dataPointAttributes.LabelBorderColor, dataPointAttributes.LabelBorderWidth, dataPointAttributes.LabelBorderStyle);
                 graph.MapCategoryNodeLabel(common, node, rectangleF);
                 graph.DrawStringRel(text, dataPointAttributes.Font, new SolidBrush(dataPointAttributes.FontColor), rectangleF, SunburstChart.format, num4);
             }
         }
     }
 }