Example #1
0
        /// <summary>
        ///   Splits a pie slice into two on the split angle.
        /// </summary>
        /// <param name="splitAngle">
        ///   Angle at which splitting is performed.
        /// </param>
        /// <returns>
        ///   An array of two pie  slices.
        /// </returns>
        internal PieSlice[] Split(float splitAngle)
        {
            // if split angle equals one of bounding angles, then nothing to split
            if (Math.Abs(StartAngle - splitAngle) < float.Epsilon || Math.Abs(EndAngle - splitAngle) < float.Epsilon)
                return new[] { (PieSlice)Clone() };

            float actualStartAngle = GetActualAngle(StartAngle);
            float newSweepAngle = (splitAngle - actualStartAngle + 360) % 360;
            using (PieSlice pieSlice1 = new PieSlice(BoundingRectangle, SliceHeight, actualStartAngle,
                newSweepAngle, m_surfaceColor, m_shadowStyle, m_edgeColorType))
            {
                pieSlice1.InitializeSides(true, false);

                newSweepAngle = GetActualAngle(EndAngle) - splitAngle;
                using (PieSlice pieSlice2 = new PieSlice(BoundingRectangle, SliceHeight, splitAngle, newSweepAngle,
                    m_surfaceColor, m_shadowStyle, m_edgeColorType))
                {
                    pieSlice2.InitializeSides(false);
                    return new[] { (PieSlice)pieSlice1.Clone(), (PieSlice)pieSlice2.Clone() };
                }
            }
        }
Example #2
0
 /// <summary>
 ///   Return the index of the foremost pie slice i.e. the one crossing
 ///   90 degrees boundary.
 /// </summary>
 /// <param name="pieSlices">
 ///   Array of <c>PieSlice</c> objects to examine.
 /// </param>
 /// <returns>
 ///   Index of the foremost pie slice.
 /// </returns>
 private int GetForemostPieSlice(PieSlice[] pieSlices)
 {
     Debug.Assert(pieSlices != null && pieSlices.Length > 0);
     for (int i = 0; i < pieSlices.Length; ++i)
     {
         PieSlice pieSlice = pieSlices[i];
         if (((pieSlice.StartAngle <= 90) && ((pieSlice.StartAngle + pieSlice.SweepAngle) >= 90)) ||
             ((pieSlice.StartAngle + pieSlice.SweepAngle > 360) && ((pieSlice.StartAngle) <= 450) && (pieSlice.StartAngle + pieSlice.SweepAngle) >= 450))
         {
             return i;
         }
     }
     Debug.Assert(false, "Foremost pie slice not found");
     return -1;
 }
Example #3
0
        /// <summary>
        ///   Splits a pie slice into two on the split angle.
        /// </summary>
        /// <param name="splitAngle">
        ///   Angle at which splitting is performed.
        /// </param>
        /// <returns>
        ///   An array of two pie  slices.
        /// </returns>
        internal PieSlice[] Split(float splitAngle) {
            // if split angle equals one of bounding angles, then nothing to split
            if (StartAngle == splitAngle || this.EndAngle == splitAngle)
                return new PieSlice[] { (PieSlice)Clone() };

            float transformedSplitAngle = TransformAngle(splitAngle);

            float actualStartAngle = GetActualAngle(StartAngle);
            float newSweepAngle = (splitAngle - actualStartAngle + 360) % 360;
            PieSlice pieSlice1 = new PieSlice(BoundingRectangle, SliceHeight, actualStartAngle, newSweepAngle, m_surfaceColor, m_shadowStyle, m_edgeColorType);
            pieSlice1.InitializeSides(true, false);

            newSweepAngle = GetActualAngle(EndAngle) - splitAngle;
            PieSlice pieSlice2 = new PieSlice(BoundingRectangle, SliceHeight, splitAngle, newSweepAngle, m_surfaceColor, m_shadowStyle, m_edgeColorType);
            pieSlice2.InitializeSides(false, true);
            return new PieSlice[] { pieSlice1, pieSlice2 };
        }