context: using System;
  using System.Collections;
  using System.Collections.Generic;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  
  namespace GitStatistics.PieChart
  {
      /// <summary>
      ///   Object representing 3D pie.
      /// </summary>
      public class PieSlice : Object, IDisposable
      {
          /// <summary>
          ///   Angle offset used to define reference angle for gradual shadow.
          /// </summary>
          private const float ShadowAngle = 20F;
  
          /// <summary>
          ///   Actual start angle.
          /// </summary>
          private readonly float _actualStartAngle;
  
          /// <summary>
          ///   Actual sweep angle.
          /// </summary>
          private readonly float _actualSweepAngle;
  
          /// <summary>
          ///   Style used for shadow.
          /// </summary>
          private readonly ShadowStyle _shadowStyle = ShadowStyle.NoShadow;
  
          /// <summary>
          ///   Color of the surface.
          /// </summary>
          private readonly Color _surfaceColor = Color.Empty;
  
          /// <summary>
          ///   <c>Brush</c> used to render slice ending cut side.
          /// </summary>
          protected Brush BrushEndSide;
  
          /// <summary>
          ///   <c>Brush</c> used to render pie slice periphery (cylinder outer surface).
          /// </summary>
          protected Brush BrushPeripherySurface;
  
          /// <summary>
          ///   <c>Brush</c> used to render slice starting cut side.
          /// </summary>
          protected Brush BrushStartSide;
  
          /// <summary>
          ///   <c>Brush</c> used to render slice top surface.
          /// </summary>
          protected Brush BrushSurface;
  
          /// <summary>
          ///   <c>Brush</c> used to render slice top surface when highlighted.
          /// </summary>
          protected Brush BrushSurfaceHighlighted;
  
          /// <summary>
          ///   <c>PointF</c> corresponding to pie slice center.
          /// </summary>
          protected PointF Center;
  
          /// <summary>
          ///   <c>PointF</c> corresponding to the lower pie slice center.
          /// </summary>
          protected PointF CenterBelow;
  
          /// <summary>
          ///   <c>Quadrilateral</c> representing the end side.
          /// </summary>
          protected Quadrilateral EndSide = Quadrilateral.Empty;
  
          /// <summary>
          ///   <c>Pen</c> object used to draw pie slice edges.
          /// </summary>
          protected Pen Pen;
  
          /// <summary>
          ///   <c>PointF</c> on the periphery corresponding to the end cut 
          ///   side.
          /// </summary>
          protected PointF PointEnd;
  
          /// <summary>
          ///   <c>PointF</c> on the periphery corresponding to the end cut 
          ///   side.
          /// </summary>
          protected PointF PointEndBelow;
  
          /// <summary>
          ///   <c>PointF</c> on the periphery corresponding to the start cut 
          ///   side.
          /// </summary>
          protected PointF PointStart;
  
          /// <summary>
          ///   <c>PointF</c> on the periphery corresponding to the start cut 
          ///   side.
          /// </summary>
          protected PointF PointStartBelow;
  
          /// <summary>
          ///   <c>Quadrilateral</c> representing the start side.
          /// </summary>
          protected Quadrilateral StartSide = Quadrilateral.Empty;
  
          /// <summary>
          ///   Initializes a new instance of flat <c>PieSlice</c> class with given 
          ///   bounds and visual style.
          /// </summary>
          /// <param name = "xBoundingRect">
          ///   x-coordinate of the upper-left corner of the rectangle that is 
          ///   used to draw the top surface of the pie slice.
          /// </param>
          /// <param name = "yBoundingRect">
          ///   y-coordinate of the upper-left corner of the rectangle that is 
          ///   used to draw the top surface of the pie slice.
          /// </param>
          /// <param name = "widthBoundingRect">
          ///   Width of the rectangle that is used to draw the top surface of 
          ///   the pie slice.
          /// </param>
          /// <param name = "heightBoundingRect">
          ///   Height of the rectangle that is used to draw the top surface of 
          ///   the pie slice.
          /// </param>
          /// <param name = "startAngle">
          ///   Starting angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "sweepAngle">
          ///   Sweep angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "surfaceColor">
          ///   Color used to paint the pie slice.
          /// </param>
          public PieSlice(float xBoundingRect, float yBoundingRect, float widthBoundingRect,
                          float heightBoundingRect, float startAngle, float sweepAngle, Color surfaceColor)
              : this(
                  xBoundingRect, yBoundingRect, widthBoundingRect, heightBoundingRect, 0F, startAngle, sweepAngle,
                  surfaceColor, ShadowStyle.NoShadow, EdgeColorType.NoEdge)
          {
          }
  
          /// <summary>
          ///   Initializes a new instance of <c>PieSlice</c> class with given 
          ///   bounds and visual style.
          /// </summary>
          /// <param name = "xBoundingRect">
          ///   x-coordinate of the upper-left corner of the rectangle that is 
          ///   used to draw the top surface of the pie slice.
          /// </param>
          /// <param name = "yBoundingRect">
          ///   y-coordinate of the upper-left corner of the rectangle that is 
          ///   used to draw the top surface of the pie slice.
          /// </param>
          /// <param name = "widthBoundingRect">
          ///   Width of the rectangle that is used to draw the top surface of 
          ///   the pie slice.
          /// </param>
          /// <param name = "heightBoundingRect">
          ///   Height of the rectangle that is used to draw the top surface of 
          ///   the pie slice.
          /// </param>
          /// <param name = "sliceHeight">
          ///   Height of the pie slice.
          /// </param>
          /// <param name = "startAngle">
          ///   Starting angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "sweepAngle">
          ///   Sweep angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "surfaceColor">
          ///   Color used to paint the pie slice.
          /// </param>
          /// <param name = "shadowStyle">
          ///   Shadow style used for slice rendering.
          /// </param>
          /// <param name = "edgeColorType">
          ///   Edge color style used for slice rendering.
          /// </param>
          public PieSlice(float xBoundingRect, float yBoundingRect, float widthBoundingRect,
                          float heightBoundingRect, float sliceHeight, float startAngle, float sweepAngle,
                          Color surfaceColor, ShadowStyle shadowStyle, EdgeColorType edgeColorType)
          {
              // set some persistent values
              _actualStartAngle = startAngle;
              _actualSweepAngle = sweepAngle;
              _surfaceColor = surfaceColor;
              _shadowStyle = shadowStyle;
              // create pens for rendering
              var edgeLineColor = EdgeColor.GetRenderingColor(edgeColorType, surfaceColor);
              Pen = new Pen(edgeLineColor) {LineJoin = LineJoin.Round};
              InitializePieSlice(xBoundingRect, yBoundingRect, widthBoundingRect, heightBoundingRect, sliceHeight);
          }
  
          /// <summary>
          ///   Initializes a new instance of <c>PieSlice</c> class with given 
          ///   bounds and visual style.
          /// </summary>
          /// <param name = "boundingRect">
          ///   Bounding rectangle used to draw the top surface of the slice.
          /// </param>
          /// <param name = "sliceHeight">
          ///   Pie slice height.
          /// </param>
          /// <param name = "startAngle">
          ///   Starting angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "sweepAngle">
          ///   Sweep angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "surfaceColor">
          ///   Color used to render pie slice surface.
          /// </param>
          /// <param name = "shadowStyle">
          ///   Shadow style used in rendering.
          /// </param>
          /// <param name = "edgeColorType">
          ///   Edge color type used for rendering.
          /// </param>
          public PieSlice(RectangleF boundingRect, float sliceHeight, float startAngle, float sweepAngle,
                          Color surfaceColor, ShadowStyle shadowStyle, EdgeColorType edgeColorType)
              : this(
                  boundingRect.X, boundingRect.Y, boundingRect.Width, boundingRect.Height, sliceHeight, startAngle,
                  sweepAngle, surfaceColor, shadowStyle, edgeColorType)
          {
          }
  
          /// <summary>
          ///   Initializes a new instance of <c>PieSlice</c> class with given 
          ///   bounds and visual style.
          /// </summary>
          /// <param name = "xBoundingRect">
          ///   x-coordinate of the upper-left corner of the rectangle that is 
          ///   used to draw the top surface of the pie slice.
          /// </param>
          /// <param name = "yBoundingRect">
          ///   y-coordinate of the upper-left corner of the rectangle that is 
          ///   used to draw the top surface of the pie slice.
          /// </param>
          /// <param name = "widthBoundingRect">
          ///   Width of the rectangle that is used to draw the top surface of 
          ///   the pie slice.
          /// </param>
          /// <param name = "heightBoundingRect">
          ///   Height of the rectangle that is used to draw the top surface of 
          ///   the pie slice.
          /// </param>
          /// <param name = "sliceHeight">
          ///   Height of the pie slice.
          /// </param>
          /// <param name = "startAngle">
          ///   Starting angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "sweepAngle">
          ///   Sweep angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "surfaceColor">
          ///   Color used to render pie slice surface.
          /// </param>
          /// <param name = "shadowStyle">
          ///   Shadow style used in rendering.
          /// </param>
          /// <param name = "edgeColorType">
          ///   Edge color type used for rendering.
          /// </param>
          /// <param name = "edgeLineWidth">
          ///   Edge line width.
          /// </param>
          public PieSlice(float xBoundingRect, float yBoundingRect, float widthBoundingRect,
                          float heightBoundingRect, float sliceHeight, float startAngle, float sweepAngle,
                          Color surfaceColor, ShadowStyle shadowStyle, EdgeColorType edgeColorType, float edgeLineWidth)
              : this(xBoundingRect, yBoundingRect, widthBoundingRect, heightBoundingRect,
                     sliceHeight, startAngle, sweepAngle, surfaceColor, shadowStyle, edgeColorType)
          {
              Pen.Width = edgeLineWidth;
          }
  
          /// <summary>
          ///   Initializes a new instance of <c>PieSlice</c> class with given 
          ///   bounds and visual style.
          /// </summary>
          /// <param name = "boundingRect">
          ///   Bounding rectangle used to draw the top surface of the pie slice.
          /// </param>
          /// <param name = "sliceHeight">
          ///   Pie slice height.
          /// </param>
          /// <param name = "startAngle">
          ///   Starting angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "sweepAngle">
          ///   Sweep angle (in degrees) of the pie slice.
          /// </param>
          /// <param name = "surfaceColor">
          ///   Color used to render pie slice surface.
          /// </param>
          /// <param name = "shadowStyle">
          ///   Shadow style used in rendering.
          /// </param>
          /// <param name = "edgeColorType">
          ///   Edge color type used for rendering.
          /// </param>
          /// <param name = "edgeLineWidth">
          ///   Edge line width.
          /// </param>
          public PieSlice(Rectangle boundingRect, float sliceHeight, float startAngle, float sweepAngle,
                          Color surfaceColor, ShadowStyle shadowStyle, EdgeColorType edgeColorType,
                          float edgeLineWidth)
              : this(
                  boundingRect.X, boundingRect.Y, boundingRect.Width, boundingRect.Height, sliceHeight, startAngle,
                  sweepAngle, surfaceColor, shadowStyle, edgeColorType, edgeLineWidth)
          {
          }
  
          /// <summary>
          ///   Gets starting angle (in degrees) of the pie slice.
          /// </summary>
          public float StartAngle { get; protected set; }
  
          /// <summary>
          ///   Gets sweep angle (in degrees) of the pie slice.
          /// </summary>
          public float SweepAngle { get; protected set; }
  
          /// <summary>
          ///   Gets ending angle (in degrees) of the pie slice.
          /// </summary>
          public float EndAngle
          {
              get { return (StartAngle + SweepAngle)%360; }
          }
  
          /// <summary>
          ///   Gets or sets the bounding rectangle.
          /// </summary>
          protected internal RectangleF BoundingRectangle { get; set; }
  
          /// <summary>
          ///   Gets or sets the slice height.
          /// </summary>
  
gt:         protected internal float SliceHeight { get; set; }