Exemplo n.º 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());
 }
Exemplo n.º 2
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));
        }