Пример #1
0
 /// <summary>
 /// Draw a point on the each point of the collections.
 /// </summary>
 /// <param name="layerIndex"></param>
 /// <param name="points"></param>
 /// <param name="color"></param>
 /// <param name="opacity"></param>
 /// <param name="pointType"></param>
 public System.Drawing.Point DrawPoints(int layerIndex, System.Drawing.PointF[] points, System.Drawing.Color color, float opacity = 1, int pointType = 0)
 {
     SharpDX.Vector2[] tmpPointArray = DrawingBase.Convertor.ToVector2(points);
     if (pointType == 1)
     {
         pointsLine.Width = Width;
     }
     pointsLine.Begin();
     for (int index = 0; index < tmpPointArray.Length; index++)
     {
         if (pointType == 0)
         {
             pointsLine.Draw(ShapesFiller.GetFillEllipseArray(tmpPointArray[index].X - Width / 2, tmpPointArray[index].Y - Width / 2, Width, Width).ToArray(), Convertor.ColorConvertor(color, opacity));
         }
         if (pointType == 1)
         {
             pointsLine.Draw(new SharpDX.Vector2[] { new SharpDX.Vector2(tmpPointArray[index].X - Width / 2, tmpPointArray[index].Y),
                                                     new SharpDX.Vector2(tmpPointArray[index].X + Width / 2, tmpPointArray[index].Y) }, Convertor.ColorConvertor(color, opacity / 2));
         }
         if (pointType == 2)
         {
             pointsLine.Draw(ShapesDrawer.GetDrawStarArray(tmpPointArray[index].X, tmpPointArray[index].Y, 5).ToArray(), Convertor.ColorConvertor(color, opacity));
         }
         if (pointType == 3)
         {
             pointsLine.Draw(ShapesDrawer.GetDrawXArray(tmpPointArray[index].X, tmpPointArray[index].Y, 5).ToArray(), Convertor.ColorConvertor(color, opacity));
         }
         if (pointType == 4)
         {
             pointsLine.Draw(ShapesDrawer.GetDrawDiamondArray(tmpPointArray[index].X, tmpPointArray[index].Y, 5).ToArray(), Convertor.ColorConvertor(color, opacity));
         }
     }
     pointsLine.End();
     return(new System.Drawing.Point());
 }
Пример #2
0
        /// <summary>
        /// Draw a point on the each point of the collections.
        /// </summary>
        /// <param name="layerIndex"></param>
        /// <param name="points"></param>
        /// <param name="color"></param>
        /// <param name="opacity"></param>
        /// <param name="pointType"></param>
        public System.Drawing.Point DrawPoints(int layerIndex, System.Drawing.PointF[] points, System.Drawing.Color color, float opacity = 1, int pointType = 0)
        {
            this.opacity = opacity;
            if (curentColor != color)
            {
                SetLineColor(color, opacity);
            }
            Vector2[] tmpPointList = DrawingBase.Convertor.ToVector2(points);
            {
                if (device.layers[layerIndex] != null)
                {
                    for (int index = 0; index < tmpPointList.Length; index++)
                    {
                        if (pointType == 0)
                        {
                            device.layers[layerIndex].FillEllipse(new SharpDX.Direct2D1.Ellipse(tmpPointList[index], Width / 2, Width / 2), brush);
                        }
                        else if (pointType == 1)
                        {
                            device.layers[layerIndex].FillRectangle(new RectangleF(tmpPointList[index].X - Width / 2, tmpPointList[index].Y - Width / 2, Width, Width), brush);
                        }
                        else if (pointType == 2)
                        {
                            List <SharpDX.Vector2> startPoints = ShapesDrawer.GetDrawStarArray(tmpPointList[index].X, tmpPointList[index].Y, 5);
                            for (int i = 1; i < startPoints.Count; i++)
                            {
                                device.layers[layerIndex].DrawLine(startPoints[i], startPoints[i - 1], brush);
                            }
                        }
                        else if (pointType == 3)
                        {
                            float wid = 5;
                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointList[index].X - wid / 2, tmpPointList[index].Y - wid / 2),
                                                               new SharpDX.Vector2(tmpPointList[index].X + wid / 2, tmpPointList[index].Y + wid / 2), brush);
                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointList[index].X - wid / 2, tmpPointList[index].Y + wid / 2),
                                                               new SharpDX.Vector2(tmpPointList[index].X + wid / 2, tmpPointList[index].Y - wid / 2), brush);
                        }
                        else if (pointType == 4)
                        {
                            float wid = 5;
                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointList[index].X, tmpPointList[index].Y - wid / 2),
                                                               new SharpDX.Vector2(tmpPointList[index].X + wid / 2, tmpPointList[index].Y), brush);

                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointList[index].X + wid / 2, tmpPointList[index].Y),
                                                               new SharpDX.Vector2(tmpPointList[index].X, tmpPointList[index].Y + wid / 2), brush);

                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointList[index].X, tmpPointList[index].Y + wid / 2),
                                                               new SharpDX.Vector2(tmpPointList[index].X - wid / 2, tmpPointList[index].Y), brush);

                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointList[index].X - wid / 2, tmpPointList[index].Y),
                                                               new SharpDX.Vector2(tmpPointList[index].X, tmpPointList[index].Y - wid / 2), brush);
                        }
                    }
                    device.layers[layerIndex].Transform = Matrix.Identity;
                }
            }
            return(new System.Drawing.Point());
        }
Пример #3
0
        /// <summary>
        /// Draw a point on the each point of the collections.
        /// </summary>
        /// <param name="points"></param>
        /// <param name="xAxesCenterHeight"></param>
        /// <param name="yAxesCenterWidth"></param>
        /// <param name="HeightRate"></param>
        /// <param name="WidthRate"></param>
        /// <param name="xAxesMaxValue"></param>
        /// <param name="color"></param>
        /// <param name="pointType"></param>
        /// <param name="opacity"></param>
        /// <param name="autoShift"></param>
        /// <param name="keepInRightOfYAxis"></param>
        public System.Drawing.Point DrawPoints(int layerIndex, Charting.Base.DataPointCollection points, float xAxesCenterHeight, float yAxesCenterWidth, float HeightRate, float WidthRate, float xAxesMaxValue, System.Drawing.Color color, int pointType = 0, float opacity = 1, bool autoShift = true, bool keepInRightOfYAxis = false, bool isDrawPointLabel = false)
        {
            this.opacity = opacity;
            if (curentColor != color)
            {
                SetLineColor(color, opacity);
            }
            SharpDX.Vector2[] tmpPointArray;
            float             MinX;
            float             tmpYAxesCenterWidth = yAxesCenterWidth;

            tmpPointArray = DrawingBase.Convertor.convertDataPointToVector2Array(points, HeightRate, WidthRate, out MinX);
            if (tmpPointArray.Length > 0)
            {
                if (autoShift)
                {
                    if (points.GetLast().XValue > xAxesMaxValue)
                    {
                        tmpYAxesCenterWidth = -((float)points.GetLast().XValue - xAxesMaxValue) * WidthRate + yAxesCenterWidth;
                    }
                    else
                    {
                        tmpYAxesCenterWidth = -tmpPointArray[0].X + yAxesCenterWidth;
                    }
                }
                if (keepInRightOfYAxis)
                {
                    if (MinX < 0)
                    {
                        tmpYAxesCenterWidth = tmpYAxesCenterWidth - MinX;
                    }
                }

                if (device.layers[layerIndex] != null)
                {
                    device.layers[layerIndex].Transform = Matrix.Translation(tmpYAxesCenterWidth, xAxesCenterHeight, 0);
                    for (int index = 0; index < tmpPointArray.Length; index++)
                    {
                        if (pointType == 0)
                        {
                            device.layers[layerIndex].FillEllipse(new SharpDX.Direct2D1.Ellipse(tmpPointArray[index], Width / 2, Width / 2), brush);
                        }
                        else if (pointType == 1)
                        {
                            device.layers[layerIndex].FillRectangle(new RectangleF(tmpPointArray[index].X - Width / 2, tmpPointArray[index].Y - Width / 2, Width, Width), brush);
                        }
                        else if (pointType == 2)
                        {
                            List <SharpDX.Vector2> startPoints = ShapesDrawer.GetDrawStarArray(tmpPointArray[index].X, tmpPointArray[index].Y, 5);
                            for (int i = 1; i < startPoints.Count; i++)
                            {
                                device.layers[layerIndex].DrawLine(startPoints[i], startPoints[i - 1], brush);
                            }
                        }
                        else if (pointType == 3)
                        {
                            float wid = 5;
                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointArray[index].X - wid / 2, tmpPointArray[index].Y - wid / 2),
                                                               new SharpDX.Vector2(tmpPointArray[index].X + wid / 2, tmpPointArray[index].Y + wid / 2), brush);
                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointArray[index].X - wid / 2, tmpPointArray[index].Y + wid / 2),
                                                               new SharpDX.Vector2(tmpPointArray[index].X + wid / 2, tmpPointArray[index].Y - wid / 2), brush);
                        }
                        else if (pointType == 4)
                        {
                            float wid = 5;
                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointArray[index].X, tmpPointArray[index].Y - wid / 2),
                                                               new SharpDX.Vector2(tmpPointArray[index].X + wid / 2, tmpPointArray[index].Y), brush);

                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointArray[index].X + wid / 2, tmpPointArray[index].Y),
                                                               new SharpDX.Vector2(tmpPointArray[index].X, tmpPointArray[index].Y + wid / 2), brush);

                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointArray[index].X, tmpPointArray[index].Y + wid / 2),
                                                               new SharpDX.Vector2(tmpPointArray[index].X - wid / 2, tmpPointArray[index].Y), brush);

                            device.layers[layerIndex].DrawLine(new SharpDX.Vector2(tmpPointArray[index].X - wid / 2, tmpPointArray[index].Y),
                                                               new SharpDX.Vector2(tmpPointArray[index].X, tmpPointArray[index].Y - wid / 2), brush);
                        }

                        if (isDrawPointLabel)
                        {
                            var str = points[index].YValues[0].ToString();
                            if (points[index].Tag != null)
                            {
                                str = points[index].Tag.ToString();
                            }
                            Matrix3x2 tempMat = device.layers[layerIndex].Transform;
                            textWrt.Draw(layerIndex, str,
                                         new System.Drawing.Rectangle((int)(tmpPointArray[index].X + tmpYAxesCenterWidth) - 20, (int)(tmpPointArray[index].Y + xAxesCenterHeight) - 15, 40, 40), Charting.Base.FontDrawFlags.Center, color, 1, 0);
                            device.layers[layerIndex].Transform = tempMat;
                        }
                    }
                    device.layers[layerIndex].Transform = Matrix.Identity;
                }
            }
            return(new System.Drawing.Point());
        }
        static void Main(string[] args)
        {
            ShapesDrawer shapeDrawer = new ShapesDrawer();

            shapeDrawer.Draw();
        }
Пример #5
0
        /// <summary>
        /// Draw a point on the each point of the collections.
        /// </summary>
        /// <param name="points"></param>
        /// <param name="xAxesCenterHeight"></param>
        /// <param name="yAxesCenterWidth"></param>
        /// <param name="HeightRate"></param>
        /// <param name="WidthRate"></param>
        /// <param name="xAxesMaxValue"></param>
        /// <param name="color"></param>
        /// <param name="pointType"></param>
        /// <param name="opacity"></param>
        /// <param name="autoShift"></param>
        /// <param name="keepInRightOfYAxis"></param>
        public System.Drawing.Point DrawPoints(int layerIndex, Charting.Base.DataPointCollection points, float xAxesCenterHeight, float yAxesCenterWidth, float HeightRate, float WidthRate, float xAxesMaxValue, System.Drawing.Color color, int pointType = 0, float opacity = 1, bool autoShift = true, bool keepInRightOfYAxis = false, bool isDrawPointLabel = false)
        {
            SharpDX.Vector2[] tmpPointArray;
            float             MinX;
            float             tmpYAxesCenterWidth = yAxesCenterWidth;

            tmpPointArray = DrawingBase.Convertor.convertDataPointToVector2Array(points, HeightRate, WidthRate, out MinX);
            if (tmpPointArray.Length > 1)
            {
                if (autoShift)
                {
                    if (points.GetLast().XValue > xAxesMaxValue)
                    {
                        tmpYAxesCenterWidth = -((float)points.GetLast().XValue - xAxesMaxValue) * WidthRate + yAxesCenterWidth;
                    }
                    else
                    {
                        tmpYAxesCenterWidth = -tmpPointArray[0].X + yAxesCenterWidth;
                    }
                }
                if (keepInRightOfYAxis)
                {
                    if (MinX < 0)
                    {
                        tmpYAxesCenterWidth = tmpYAxesCenterWidth - MinX;
                    }
                }
                if (tmpPointArray[0].X + tmpYAxesCenterWidth < device.padding.Left)
                {
                    if (tmpPointArray.Length > 1)
                    {
                        tmpPointArray[0] = tmpPointArray[1];
                    }
                }
                if (pointType == 1)
                {
                    pointsLine.Width = Width;
                }
                else
                {
                    pointsLine.Width = 1;
                }
                pointsLine.Begin();
                device.device.SetTransform(0, SharpDX.Matrix.Translation(tmpYAxesCenterWidth, xAxesCenterHeight, 0));
                for (int index = 0; index < tmpPointArray.Length; index++)
                {
                    if (pointType == 0)
                    {
                        pointsLine.Draw(ShapesFiller.GetFillEllipseArray(tmpPointArray[index].X - Width / 2, tmpPointArray[index].Y - Width / 2, Width, Width).ToArray(), Convertor.ColorConvertor(color, opacity));
                    }
                    if (pointType == 1)
                    {
                        pointsLine.Draw(new SharpDX.Vector2[] { new SharpDX.Vector2(tmpPointArray[index].X - Width / 2, tmpPointArray[index].Y),
                                                                new SharpDX.Vector2(tmpPointArray[index].X + Width / 2, tmpPointArray[index].Y) }, Convertor.ColorConvertor(color, opacity / 2));
                    }
                    if (pointType == 2)
                    {
                        pointsLine.Draw(ShapesDrawer.GetDrawStarArray(tmpPointArray[index].X, tmpPointArray[index].Y, 5).ToArray(), Convertor.ColorConvertor(color, opacity));
                    }
                    if (pointType == 3)
                    {
                        pointsLine.Draw(ShapesDrawer.GetDrawXArray(tmpPointArray[index].X, tmpPointArray[index].Y, 5).ToArray(), Convertor.ColorConvertor(color, opacity));
                    }
                    if (pointType == 4)
                    {
                        pointsLine.Draw(ShapesDrawer.GetDrawDiamondArray(tmpPointArray[index].X, tmpPointArray[index].Y, 5).ToArray(), Convertor.ColorConvertor(color, opacity));
                    }
                }
                pointsLine.End();
            }
            return(new System.Drawing.Point((int)tmpYAxesCenterWidth, (int)xAxesCenterHeight));
        }