Example #1
0
        /// <summary>
        /// Draw the line.
        /// </summary>
        internal void Draw(int layerIndex)
        {
            if (Visible)
            {
                try
                {
                    if (device != null)
                    {
                        if (points.Count > 0)
                        {
                            float Y_Center = YAxis.Center + ofset.Y * YAxis.HeightRate;
                            float X_Center = XAxis.Center + ofset.X * XAxis.WidthRate;
                            if (XAxis.Labels.Count > 0)
                            {
                                X_Center = XAxis.Center + ofset.X * XAxis.WidthRate + XAxis.WidthRate / 2;
                            }
                            if (isPointOfChartLinedTogether || chartType == SeriesChartType.Line)
                            {
                                transLate = mainPolyLine.Draw(layerIndex, points, Y_Center, X_Center, YAxis.HeightRate, XAxis.WidthRate, XAxis.Maximum, color, 1, AutoShift, KeepInRightOfYAxis);
                            }

                            switch (chartType)
                            {
                            case SeriesChartType.Point_Ellipse:
                                transLate = mainPolyLine.DrawPoints(layerIndex, points, Y_Center, X_Center, YAxis.HeightRate, XAxis.WidthRate, XAxis.Maximum, color, 0, 1, AutoShift, KeepInRightOfYAxis, isDrawPointLabel);
                                break;

                            case SeriesChartType.Point_Rectangle:
                                transLate = mainPolyLine.DrawPoints(layerIndex, points, Y_Center, X_Center, YAxis.HeightRate, XAxis.WidthRate, XAxis.Maximum, color, 1, 1, AutoShift, KeepInRightOfYAxis, isDrawPointLabel);
                                break;

                            case SeriesChartType.Point_Star:
                                transLate = mainPolyLine.DrawPoints(layerIndex, points, Y_Center, X_Center, YAxis.HeightRate, XAxis.WidthRate, XAxis.Maximum, color, 2, 1, AutoShift, KeepInRightOfYAxis, isDrawPointLabel);
                                break;

                            case SeriesChartType.Point_X:
                                transLate = mainPolyLine.DrawPoints(layerIndex, points, Y_Center, X_Center, YAxis.HeightRate, XAxis.WidthRate, XAxis.Maximum, color, 3, 1, AutoShift, KeepInRightOfYAxis, isDrawPointLabel);
                                break;

                            case SeriesChartType.Point_Diamond:
                                transLate = mainPolyLine.DrawPoints(layerIndex, points, Y_Center, X_Center, YAxis.HeightRate, XAxis.WidthRate, XAxis.Maximum, color, 4, 1, AutoShift, KeepInRightOfYAxis, isDrawPointLabel);
                                break;
                            }
                            int textPositionY = (int)(Y_Center - points[0].YValues[0] * YAxis.HeightRate);
                            if (textPosition != null)
                            {
                                textPositionY = (int)(Y_Center - textPosition.Value * YAxis.HeightRate);
                            }
                            labelTextWriter.Draw(layerIndex, Text, new Rectangle(new Point((int)X_Center, textPositionY), new Size(20, 200)), FontDrawFlags.Left, LineColor, 1, 0);
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    xPFT.Exceptions.ExceptionHandler.LogError(ex);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Draw the label on the device.
        /// </summary>
        /// <param name="parentControl"></param>
        /// <param name="axesType"></param>
        public void Draw(int layerIndex, ChartArea parentControl, AxisDirection axesType, bool isDrawString = true)
        {
            try
            {
                if (axesType == AxisDirection.Vertical)
                {
                    if (IsAxisTitle)
                    {
                        if (axis.series.Count == 0)
                        {
                            textWriter.Draw(layerIndex, Text[0], textRectangle, xPFT.Charting.Base.FontDrawFlags.Left, axis.TitleColor, 1, (float)System.Math.PI / 2);
                        }
                        else
                        {
                            textWriter.Draw(layerIndex, Text[0], new Rectangle(textRectangle.X, textRectangle.Y + 15, textRectangle.Width, textRectangle.Height),
                                            xPFT.Charting.Base.FontDrawFlags.Left, axis.TitleColor, 1, (float)System.Math.PI / 2);
                            points[0]  = new PointF(textRectangle.X - textRectangle.Height / 2, textRectangle.Location.Y);
                            points[1]  = new PointF(textRectangle.X - textRectangle.Height / 2, textRectangle.Location.Y + 10);
                            line.Width = axis.series[0].LineThickness;

                            if (axis.series[0].ChartType == SeriesChartType.Line)
                            {
                                line.Pattern = axis.series[0].LinePattern;
                                line.Draw(layerIndex, points, axis.series[0].LineColor);
                            }
                            else
                            {
                                switch (axis.series[0].ChartType)
                                {
                                case SeriesChartType.Point_Ellipse:
                                    line.DrawPoints(layerIndex, points, axis.series[0].LineColor, 1, 0);
                                    break;

                                case SeriesChartType.Point_Rectangle:
                                    line.DrawPoints(layerIndex, points, axis.series[0].LineColor, 1, 1);
                                    break;

                                case SeriesChartType.Point_Star:
                                    line.DrawPoints(layerIndex, points, axis.series[0].LineColor, 1, 2);
                                    break;

                                case SeriesChartType.Point_X:
                                    line.DrawPoints(layerIndex, points, axis.series[0].LineColor, 1, 3);
                                    break;

                                case SeriesChartType.Point_Diamond:
                                    line.DrawPoints(layerIndex, points, axis.series[0].LineColor, 1, 4);
                                    break;
                                }
                            }
                        }
                    }
                    else
                    {
                        if (isDrawString)
                        {
                            if (axis.LabelInTrueSide)
                            {
                                textWriter.Draw(layerIndex, Text[0], textRectangle, xPFT.Charting.Base.FontDrawFlags.Right, color, 1, 0);
                            }
                            else
                            {
                                textWriter.Draw(layerIndex, Text[0], textRectangle, xPFT.Charting.Base.FontDrawFlags.Left, color, 1, 0);
                            }
                        }
                        else
                        {
                            if (axis.LabelInTrueSide)
                            {
                                points[0].X += 1;
                            }
                            else
                            {
                                points[0].X -= 1;
                            }
                        }
                        line.Draw(layerIndex, points, color);
                    }
                }
                else
                {
                    if (IsAxisTitle)
                    {
                        textWriter.Draw(layerIndex, Text[0], textRectangle, xPFT.Charting.Base.FontDrawFlags.Right, axis.TitleColor, 1, 0);
                    }
                    else
                    {
                        if (isDrawString)
                        {
                            textWriter.Draw(layerIndex, Text[0], textRectangle, xPFT.Charting.Base.FontDrawFlags.Center, color, 1, 0);
                            textWriter.Draw(layerIndex, Text[1], new Rectangle(textRectangle.X, textRectangle.Y + (int)(Font.Height * 0.8), textRectangle.Width, textRectangle.Height), xPFT.Charting.Base.FontDrawFlags.Center, color, 1, 0);
                        }
                        else
                        {
                            if (axis.LabelInTrueSide)
                            {
                                points[0].Y -= 1;
                            }
                            else
                            {
                                points[0].Y += 1;
                            }
                        }
                        line.Draw(layerIndex, points, color);
                    }
                }
            }
            catch (System.Exception ex)
            {
                xPFT.Exceptions.ExceptionHandler.LogError(ex);
            }
        }