Пример #1
0
        public void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension)
        {
            ChartGraphics chartGraphics = this as ChartGraphics;

            if (chartGraphics == null || !chartGraphics.IsMetafile)
            {
                RenderingObject.DrawCurve(pen, points, offset, numberOfSegments, tension);
                return;
            }
            PointF[] array = null;
            if (offset == 0 && numberOfSegments == points.Length - 1)
            {
                RenderingObject.DrawCurve(pen, points, offset, numberOfSegments, tension);
                return;
            }
            if (offset == 0 && numberOfSegments < points.Length - 1)
            {
                array = new PointF[numberOfSegments + 2];
                for (int i = 0; i < numberOfSegments + 2; i++)
                {
                    array[i] = points[i];
                }
            }
            else if (offset > 0 && offset + numberOfSegments == points.Length - 1)
            {
                array = new PointF[numberOfSegments + 2];
                for (int j = 0; j < numberOfSegments + 2; j++)
                {
                    array[j] = points[offset + j - 1];
                }
                offset = 1;
            }
            else if (offset > 0 && offset + numberOfSegments < points.Length - 1)
            {
                array = new PointF[numberOfSegments + 3];
                for (int k = 0; k < numberOfSegments + 3; k++)
                {
                    array[k] = points[offset + k - 1];
                }
                offset = 1;
            }
            RenderingObject.DrawCurve(pen, array, offset, numberOfSegments, tension);
        }
 public void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension)
 {
     RenderingObject.DrawCurve(pen, points, offset, numberOfSegments, tension);
 }
Пример #3
0
        /// <summary>
        /// Draws a cardinal spline through a specified array of PointF structures
        /// using a specified tension. The drawing begins offset from
        /// the beginning of the array.
        /// </summary>
        /// <param name="pen">Pen object that determines the color, width, and height of the curve.</param>
        /// <param name="points">Array of PointF structures that define the spline.</param>
        /// <param name="offset">Offset from the first element in the array of the points parameter to the starting point in the curve.</param>
        /// <param name="numberOfSegments">Number of segments after the starting point to include in the curve.</param>
        /// <param name="tension">Value greater than or equal to 0.0F that specifies the tension of the curve.</param>
        internal void DrawCurve(
            Pen pen,
            PointF[] points,
            int offset,
            int numberOfSegments,
            float tension
            )
        {
            ChartGraphics chartGraphics = this as ChartGraphics;

            if (chartGraphics == null || !chartGraphics.IsMetafile)
            {
                RenderingObject.DrawCurve(pen, points, offset, numberOfSegments, tension);
            }
            else
            {
                // Special handling required for the metafiles. We cannot pass large array of
                // points because they will be persisted inside EMF file and cause exponential
                // increase in emf file size. Draw curve method uses additional 2, 3 or 4 points
                // depending on which segement is drawn.
                PointF[] pointsExact = null;
                if (offset == 0 && numberOfSegments == points.Length - 1)
                {
                    // In case the array contains the minimum required number of points
                    // to draw segments - just call the curve drawing method
                    RenderingObject.DrawCurve(pen, points, offset, numberOfSegments, tension);
                }
                else
                {
                    if (offset == 0 && numberOfSegments < points.Length - 1)
                    {
                        // Segment is at the beginning of the array with more points following
                        pointsExact = new PointF[numberOfSegments + 2];
                        for (int index = 0; index < numberOfSegments + 2; index++)
                        {
                            pointsExact[index] = points[index];
                        }
                    }
                    else if (offset > 0 && (offset + numberOfSegments) == points.Length - 1)
                    {
                        // Segment is at the end of the array with more points prior to it
                        pointsExact = new PointF[numberOfSegments + 2];
                        for (int index = 0; index < numberOfSegments + 2; index++)
                        {
                            pointsExact[index] = points[offset + index - 1];
                        }
                        offset = 1;
                    }
                    else if (offset > 0 && (offset + numberOfSegments) < points.Length - 1)
                    {
                        // Segment in the middle of the array with points prior and following it
                        pointsExact = new PointF[numberOfSegments + 3];
                        for (int index = 0; index < numberOfSegments + 3; index++)
                        {
                            pointsExact[index] = points[offset + index - 1];
                        }
                        offset = 1;
                    }

                    // Render the curve using minimum number of required points in the array
                    RenderingObject.DrawCurve(pen, pointsExact, offset, numberOfSegments, tension);
                }
            }
        }