コード例 #1
0
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        {
            base.Plot(graphics, bounds, min, max);

            if (Bars == null)
            {
                return;
            }

            int lastBar  = Math.Min(this.LastBarIndexPainted, Bars.Count - 1);
            int firstBar = this.FirstBarIndexPainted;

            int x, yHigh, yClose, yOpen, yLow;

            using (Pen drawPen = new Pen(Color.Transparent, ShadowWidth), HiLoPen = new Pen(hiloBarColor))
            {
                for (int index = firstBar; index <= lastBar; index++)
                {
                    if ((index <= lastcalcbar) && (index >= Math.Max(1, startbar)))
                    {
                        x      = ChartControl.GetXByBarIdx(BarsArray[0], index);
                        yHigh  = ChartControl.GetYByValue(this, HAHigh.Get(index));
                        yClose = ChartControl.GetYByValue(this, HAClose.Get(index));
                        yOpen  = ChartControl.GetYByValue(this, HAOpen.Get(index));
                        yLow   = ChartControl.GetYByValue(this, HALow.Get(index));

                        if (Direction.Get(index) > 0)
                        {
                            drawPen.Color = BarColorUp;
                        }
                        else if (Direction.Get(index) < 0)
                        {
                            drawPen.Color = BarColorDown;
                        }
                        else
                        {
                            drawPen.Color = BarColorWarn;
                        }

                        graphics.DrawLine(HiLoPen, x, yHigh, x, yLow);
                        graphics.DrawLine(drawPen, x, yOpen, x, yClose);
                    }
                }
            }
        }
コード例 #2
0
        public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
        {
            if (Bars == null || ChartControl == null)
            {
                return;
            }

            int barPaintWidth = Math.Max(3, 1 + 2 * ((int)Bars.BarsData.ChartStyle.BarWidth - 1) + 2 * shadowWidth);

            for (int idx = FirstBarIndexPainted; idx <= LastBarIndexPainted; idx++)
            {
                if (idx - Displacement < 0 || idx - Displacement >= BarsArray[0].Count || (!ChartControl.ShowBarsRequired && idx - Displacement < BarsRequired))
                {
                    continue;
                }
                double valH = HAHigh.Get(idx);
                double valL = HALow.Get(idx);
                double valC = HAClose.Get(idx);
                double valO = HAOpen.Get(idx);
                int    x    = ChartControl.GetXByBarIdx(BarsArray[0], idx);
                int    y1   = ChartControl.GetYByValue(this, valO);
                int    y2   = ChartControl.GetYByValue(this, valH);
                int    y3   = ChartControl.GetYByValue(this, valL);
                int    y4   = ChartControl.GetYByValue(this, valC);

                graphics.DrawLine(shadowPen, x, y2, x, y3);

                if (y4 == y1)
                {
                    graphics.DrawLine(shadowPen, x - barPaintWidth / 2, y1, x + barPaintWidth / 2, y1);
                }
                else
                {
                    if (y4 > y1)
                    {
                        graphics.FillRectangle(brushDown, x - barPaintWidth / 2, y1, barPaintWidth, y4 - y1);
                    }
                    else
                    {
                        graphics.FillRectangle(brushUp, x - barPaintWidth / 2, y4, barPaintWidth, y1 - y4);
                    }
                    graphics.DrawRectangle(shadowPen, (x - barPaintWidth / 2) + (shadowPen.Width / 2), Math.Min(y4, y1), barPaintWidth - shadowPen.Width, Math.Abs(y4 - y1));
                }
            }
        }