void IChartCustomDrawer.Draw(DrawContext context, EDrawPhases phase) { if (Layout != phase) { return; } DOMPrice[] asks; DOMPrice[] bids; lock (this){ asks = Asks; bids = Bids; } if (null == asks || 0 == asks.Length) { return; } if (null == bids || 0 == bids.Length) { return; } if (context.FullRect == context.DrawRect) { draw_dom(asks, bids, context.graphics, new Point(50, 50)); } }
void IChartCustomDrawer.Draw(DrawContext context, EDrawPhases phase) { if (phase != EDrawPhases.Final) { return; } DOMPrice[] asks, bids; lock (this) { asks = Asks; bids = Bids; } //Output.WriteLine("asks len is {0}, bid len is {1}", asks.Length, bids.Length); PointF pricePt = context.Environment.ChartPoint2Point( new ChartPoint(Bars.Time[0], Bars.Close[0])); PointF rightEdge = context.Environment.ChartPoint2Point( new ChartPoint(Environment.RightScreenTime, Bars.Close[0])); PointF bidPt = context.Environment.ChartPoint2Point( new ChartPoint(Bars.LastBarTime, bids[0].Price)); PointF askPt = context.Environment.ChartPoint2Point( new ChartPoint(Bars.LastBarTime, asks[0].Price)); int barWidth = (int)Environment.BarSpacing; context.graphics.DrawLine(pricePen, pricePt, rightEdge); context.graphics.DrawLine(bidPen, bidPt.X - barsBefore * barWidth, bidPt.Y, bidPt.X + barsAfter * barWidth, bidPt.Y); context.graphics.DrawLine(askPen, askPt.X - barsBefore * barWidth, askPt.Y, askPt.X + barsAfter * barWidth, askPt.Y); }
void IChartCustomDrawer.Draw(DrawContext context, EDrawPhases phase) { if (phase != EDrawPhases.Final) { return; } RectangleF _dr = context.FullRect; ChartPoint DrPleft = context.Environment.Point2ChartPoint(new PointF { X = _dr.X, Y = _dr.Y }); ChartPoint DrPRight = context.Environment.Point2ChartPoint(new PointF { X = _dr.Width, Y = _dr.Height }); if (DrPleft.Time.Ticks > DrPRight.Time.Ticks) { return; } Bar[] BarsToRedraw = null; context.Environment.Bars.Get(DrPleft.Time, DrPRight.Time, out BarsToRedraw); if (!object.Equals(BarsToRedraw, null)) { int countBars = BarsToRedraw.Length; if (countBars > 0) { AreaPainter p = new AreaPainter(fillcolor, (byte)(255 - m_intensity)); PointF[] pf = new PointF[countBars * 2]; int full = countBars * 2 - 1; for (int i = 0, idx = 0; i < countBars; i++) { double high0 = m_IndicatorArea.GetValue("UpperBand", BarsToRedraw[i].Time.ToBinary()); double low0 = m_IndicatorArea.GetValue("LowerBand", BarsToRedraw[i].Time.ToBinary()); if (high0 < 0 || low0 < 0) { idx = 0; full -= 2; pf = new PointF[full + 1]; continue; } Bar b = BarsToRedraw[i]; pf[idx] = context.Environment.ChartPoint2Point(new ChartPoint { Price = high0, Time = b.Time }); pf[full - idx] = context.Environment.ChartPoint2Point(new ChartPoint { Price = low0, Time = b.Time }); idx++; } p.PaintArea(context.graphics, pf); } } context.DirtyRect = _dr; }