public override bool DrawPlot(Layer layer, ChartProperty property, bool onlyUpdateLastBar) { AxisX cAxisX = layer.AxisX; Rectangle cRectY = this.AxisY.AxisRectangle; int iIndex = 0; int iOldBKColor = __cGDI.SelectBackground(property.BackgroundColor); PowerLanguage.PenStyle cLinePen = this.ChartSetting.PenStyles[0]; IntPtr cOldPen = __cGDI.SelectPen(cLinePen); if (onlyUpdateLastBar) { iIndex = cAxisX.BarNumber + cAxisX.BarCount - 1; iIndex = (iIndex > cAxisX.DataCount) ? cAxisX.DataCount : iIndex; int iOffset = this.ConvertAxisScaleIndexToOffset(iIndex); int iX = cAxisX.ConvertBarNumberToWidth(iIndex).CenterPoint; int iPrevX = cAxisX.ConvertBarNumberToWidth(iIndex - 1).CenterPoint; if (!DrawClosingLine(iOffset, cRectY.Y, iX, iPrevX, new PowerLanguage.PenStyle(property.BackgroundColor, cLinePen.Width, cLinePen.Pattern))) { return(false); } } else { this.RefreshAxisY(property); __dPrevClose = double.NaN; int iCount = cAxisX.BarCount; int iStartIndex = cAxisX.BarNumber; for (int i = 0; i < iCount; i++) { iIndex = iStartIndex + i; if (iIndex > cAxisX.DataCount) { --iIndex; break; } else { if (__dPrevClose != double.NaN) { int iOffset = this.ConvertAxisScaleIndexToOffset(iIndex); int iX = cAxisX.ConvertBarNumberToWidth(iIndex).CenterPoint; int iPrevX = cAxisX.ConvertBarNumberToWidth(iIndex - 1).CenterPoint; DrawClosingLine(iOffset, cRectY.Y, iX, iPrevX, null); } } } if (this.PlotIndex == 0) //Plot 索引值為 0 才印出標題(其他的索引就不需要再印出標題) { DrawTitle(cRectY, property); } } __cGDI.RemoveObject(__cGDI.SelectPen(cOldPen)); if (!layer.Drawable) { layer.LegendIndex = iIndex; if (this.ChartSetting.IsShowNewPrice) //是否要顯示新價格線 { this.AxisY.Value = __cBars.Close[0]; //指定最新收盤價格 this.Painter.DrawAxisValueLabel(this.AxisY, this.ChartSetting.LegendColor, property); } } this.DrawLegend(layer.LegendIndex, property); __cGDI.SelectBackground(iOldBKColor); return(true); }
protected override void CreateAxisY(ChartProperty property, Rectangle axisRectangle) { InstrumentSettings cSettings = __cBars.Info as InstrumentSettings; this.AxisY = AbstractPlot.CreateAxisY(this.Painter, this.ChartSetting.Axis, cSettings.Property.PriceScaleRule as IPriceScale, property, axisRectangle); }