Example #1
0
        private float[] findScalePrices2(PriceGraphicMapping PriceMapping)
        {
            double height = PriceMapping.PriceRect.PriceHeight;
            //最小比例是5,然后依次是10、20、40、100、500、1000、2000
            int scalePriceInterval = 0;

            for (int i = 0; i < ARR_SCALEPRICE.Length; i++)
            {
                int interval = ARR_SCALEPRICE[i];
                if (height / interval < 5)
                {
                }
                //if (height > interval && height < 3 * interval)
                //{
                //    scalePriceInterval = interval;
                //    break;
                //}
                //if (height < interval)
                //{
                //    int index = i - 1;
                //    index = index >= 0 ? index : 0;
                //    scalePriceInterval = ARR_SCALEPRICE[index];
                //    break;
                //}
            }
            float lowPrice = ((int)(PriceMapping.PriceRect.PriceBottom / scalePriceInterval) + 1) * scalePriceInterval;

            float[] arr = new float[2];
            arr[0] = lowPrice;
            arr[1] = lowPrice + scalePriceInterval;
            return(arr);
        }
Example #2
0
        public void Paint(Graphics g, PriceGraphicMapping priceGraphic, IPriceShape shape)
        {
            switch (shape.GetShapeType())
            {
            case PriceShapeType.Point:
                shapePainter_Point.Paint(g, priceGraphic, shape);
                break;

            case PriceShapeType.Line:
                shapePainter_Line.Paint(g, priceGraphic, shape);
                break;

            case PriceShapeType.PolyLine:
                shapePainter_PolyLine.Paint(g, priceGraphic, shape);
                break;

            case PriceShapeType.Label:
                shapePainter_Label.Paint(g, priceGraphic, shape);
                break;

            case PriceShapeType.Rect:
                shapePainter_Rect.Paint(g, priceGraphic, shape);
                break;
            }
        }
Example #3
0
        private PointF GetPointF(PriceGraphicMapping priceGraphic, PricePoint pricePoint)
        {
            float x1 = priceGraphic.CalcX(pricePoint.X);
            float y1 = priceGraphic.CalcY(pricePoint.Y);

            return(new PointF(x1, y1));
        }
Example #4
0
        private void DrawMount(Graphics g, IKLineBar chart, int index, PriceGraphicMapping priceMapping, float blockWidth, float blockPadding)
        {
            Rectangle rectangle = priceMapping.DrawRect;
            bool      isRed     = chart.End > chart.Start;
            //Brush b = new SolidBrush(isRed ? Color.Red : Color.LightSeaGreen);
            Brush  b       = isRed ? this.colorConfig.Brush_CandleBlockUp : this.colorConfig.Brush_CandleBlockDown;
            Pen    p       = new Pen(b);
            double XMiddle = priceMapping.CalcX(index);
            double YTop    = priceMapping.CalcY(chart.Mount);
            double YBottom = rectangle.Bottom;

            double halfBlockWidth = (blockWidth - blockPadding) / 2;

            float XLeft  = (float)(XMiddle - halfBlockWidth);
            float XRight = (float)(XMiddle + halfBlockWidth);

            if (isRed)
            {
                g.DrawRectangle(p, (int)XLeft, (int)YTop, (int)halfBlockWidth * 2, (int)(YBottom - YTop));
            }
            else
            {
                g.FillRectangle(b, (int)XLeft, (int)YTop, (int)halfBlockWidth * 2, (int)(YBottom - YTop));
            }
        }
Example #5
0
        public Point GetCrossHairPoint(int selectIndex)
        {
            PriceGraphicMapping priceMapping = this.drawer.Drawer_Chart.PriceMapping;
            float x = priceMapping.CalcX(selectIndex);
            float y = priceMapping.CalcY(drawer.DataProvider.GetKLineData().Arr_End[selectIndex]);

            return(new Point((int)x, (int)y));
        }
Example #6
0
        public void Paint(Graphics g, PriceGraphicMapping priceGraphic, IPriceShape shape)
        {
            PriceShape_Point point = (PriceShape_Point)shape;
            float            x1    = priceGraphic.CalcX(point.X);
            float            y1    = priceGraphic.CalcY(point.Y);
            float            w     = point.Width;

            g.FillEllipse(new SolidBrush(point.Color), x1 - point.Width / 2, y1 - point.Width / 2, point.Width, point.Width);
        }
Example #7
0
        public void Paint(Graphics g, PriceGraphicMapping priceGraphic, IPriceShape shape)
        {
            PriceShape_Label label = (PriceShape_Label)shape;
            float            x1    = priceGraphic.CalcX(label.Point.X);
            float            y1    = priceGraphic.CalcY(label.Point.Y);
            Font             font  = label.Font != null ? label.Font : new Font("宋体", 14.2f, FontStyle.Regular);
            StringFormat     sf    = label.StringFormat != null ? label.StringFormat : new StringFormat(StringFormatFlags.DirectionVertical);

            g.DrawString(label.Text, font, new SolidBrush(label.Color), new PointF(x1, y1), sf);
        }
Example #8
0
        public void Paint(Graphics g, PriceGraphicMapping priceGraphic, IPriceShape shape)
        {
            PriceShape_PolyLine line = (PriceShape_PolyLine)shape;

            PointF[] points = new PointF[line.Points.Count];
            for (int i = 0; i < line.Points.Count; i++)
            {
                points[i] = GetPointF(priceGraphic, line.Points[i]);
            }
            g.DrawLines(new Pen(line.Color, line.Width), points);
        }
Example #9
0
        public void Paint(Graphics g, PriceGraphicMapping priceGraphic, IPriceShape shape)
        {
            PriceShape_Line line = (PriceShape_Line)shape;
            float           x1   = priceGraphic.CalcX(line.StartPoint.X);
            float           y1   = priceGraphic.CalcY(line.StartPoint.Y);

            float x2 = priceGraphic.CalcX(line.EndPoint.X);
            float y2 = priceGraphic.CalcY(line.EndPoint.Y);

            g.DrawLine(new Pen(line.Color, line.Width), x1, y1, x2, y2);
        }
Example #10
0
        public void DrawFrame(Graphics g, Rectangle rect, PriceGraphicMapping priceMapping)
        {
            Rectangle rectangleScale = rect;

            g.DrawRectangle(colorConfig.Pen_FrameLine, rectangleScale);
            float       price  = priceMapping.PriceRect.PriceTop / 2;
            int         y      = (int)priceMapping.CalcY(price);
            ColorConfig config = colorConfig;

            g.DrawLine(config.Pen_CandleFrameScaleLine, new Point((int)rectangleScale.X, y), new Point((int)rectangleScale.Right, (int)y));

            String label = price.ToString();

            g.DrawString(label, config.Font_CandleFrameScaleFont, config.Brush_CandleFrameScaleBrush, new Point((int)rectangleScale.X - label.Length * 8 - 5, (int)y - 5));
        }
Example #11
0
        public void DrawFrame(Graphics g, Rectangle frameRect, PriceGraphicMapping priceMapping)
        {
            Rectangle rectangleScale = frameRect;

            g.DrawRectangle(this.colorConfig.Pen_FrameLine, rectangleScale);

            float[] prices = findScalePrices(priceMapping);

            double xLeft  = rectangleScale.X;
            double xRight = rectangleScale.X + rectangleScale.Width;
            double lowY   = priceMapping.CalcY(prices[0]);
            double highY  = priceMapping.CalcY(prices[1]);

            drawScaleLine(g, xLeft, xRight, lowY, prices[0]);
            drawScaleLine(g, xLeft, xRight, highY, prices[1]);
        }
Example #12
0
        public void Paint(Graphics g, PriceGraphicMapping priceGraphic, IPriceShape shape)
        {
            PriceShape_Rect point = (PriceShape_Rect)shape;
            float           x1    = priceGraphic.CalcX(point.PriceLeft);
            float           y1    = priceGraphic.CalcY(point.PriceTop);
            float           x2    = priceGraphic.CalcX(point.PriceRight);
            float           y2    = priceGraphic.CalcY(point.PriceBottom);

            if (!point.FillRect)
            {
                g.DrawRectangle(new Pen(point.Color), x1, y1, x2 - x1, y2 - y1);
            }
            else
            {
                g.FillRectangle(new SolidBrush(point.Color), x1, y1, x2 - x1, y2 - y1);
            }
        }
Example #13
0
        public override void Paint(Graphics graphic)
        {
            base.Paint(graphic);
            if (priceRect == null)
            {
                return;
            }
            PriceGraphicMapping mapping = new PriceGraphicMapping(DisplayRect, priceRect);

            graphic.SmoothingMode      = SmoothingMode.AntiAlias;
            graphic.InterpolationMode  = InterpolationMode.HighQualityBicubic;
            graphic.CompositingQuality = CompositingQuality.HighQuality;

            for (int i = 0; i < shapes.Count; i++)
            {
                shapePainter.Paint(graphic, mapping, shapes[i]);
            }

            graphic.SmoothingMode = SmoothingMode.None;
        }
Example #14
0
        private void DrawCandle(Graphics g, IKLineBar chart, int index, PriceGraphicMapping priceMapping, float blockWidth, float blockPadding)
        {
            bool  isRed = chart.End > chart.Start;
            Brush b     = isRed ? this.ColorConfig.Brush_CandleBlockUp : this.ColorConfig.Brush_CandleBlockDown;

            if (chart.End.Equals(chart.Start))
            {
                b = this.ColorConfig.Brush_CandleFlat;
            }

            Pen   p            = new Pen(b);
            float XMiddle      = priceMapping.CalcX(index);
            float YTop         = priceMapping.CalcY(chart.High);
            float YBottom      = priceMapping.CalcY(chart.Low);
            float YBlockTop    = (float)priceMapping.CalcY(isRed ? chart.End : chart.Start);
            float YBlockBottom = (float)priceMapping.CalcY(isRed ? chart.Start : chart.End);

            //画上影线和下影线
            g.DrawLine(p, new PointF(XMiddle, YTop), new PointF(XMiddle, YBlockTop));
            g.DrawLine(p, new PointF(XMiddle, YBottom), new PointF(XMiddle, YBlockBottom));

            float halfBlockWidth = (blockWidth - blockPadding) / 2;

            float XLeft  = XMiddle - halfBlockWidth;
            float XRight = XMiddle + halfBlockWidth;

            //画block
            if (chart.End == chart.Start)
            {
                g.DrawLine(p, XLeft, YBlockBottom, XRight, YBlockBottom);
            }
            else if (isRed)
            {
                g.DrawRectangle(p, XLeft, YBlockTop, halfBlockWidth * 2, YBlockBottom - YBlockTop);
            }
            else
            {
                g.FillRectangle(b, XLeft, YBlockTop, halfBlockWidth * 2, YBlockBottom - YBlockTop);
            }
        }
Example #15
0
 public void DrawCandle(Graphics g, IKLineData data, int startIndex, int endIndex, PriceGraphicMapping priceMapping, float blockWidth, float blockPadding)
 {
     for (int i = startIndex; i <= endIndex; i++)
     {
         DrawCandle(g, new KLineBar_KLineData(data, i), i, priceMapping, blockWidth, blockPadding);
     }
     //DrawCandle(g, DataProvider.GetCurrentChart(), endIndex);
 }
Example #16
0
 public void DrawMount(Graphics g, IKLineData klineData, int startIndex, int endIndex, PriceGraphicMapping priceMapping, float blockWidth, float blockPadding)
 {
     if (endIndex < startIndex)
     {
         return;
     }
     for (int i = startIndex; i <= endIndex; i++)
     {
         DrawMount(g, new KLineBar_KLineData(klineData, i), i, priceMapping, blockWidth, blockPadding);
     }
 }