/// <summary> /// 設定使用者自訂的動作介面(繪製操作介面) /// </summary> /// <param name="name">IAction 介面動作名稱</param> /// <param name="pen">筆刷樣式</param> /// <returns>返回值: true=設定成功, false=設定失敗</returns> public bool SetCustomAction(string name, PowerLanguage.PenStyle pen = null) { bool bRet = __cBehavior.SetCustomAction(name, pen); int iCount = __cLayers.Count; for (int i = 0; i < iCount; i++) { __cLayers[i].Drawable = bRet; } this.Refresh(); return(bRet); }
private bool DrawClosingLine(int offset, int top, int x, int prevX, PowerLanguage.PenStyle erasePen) { double dClose = 0; bool bCheck = CheckBarsValue(offset, out dClose); if (bCheck) { int iPrevClose = top + this.AxisY.ConvertValueToHeight(__dPrevClose); int iCurrentClose = top + this.AxisY.ConvertValueToHeight(dClose); if (erasePen != null) { int iLastClose = top + this.AxisY.ConvertValueToHeight(__dLastClose); IntPtr cOldPen = __cGDI.SelectPen(erasePen); __cGDI.DrawLine(prevX, iPrevClose, x, iLastClose); __cGDI.SelectPen(cOldPen); } __dLastClose = dClose; __cGDI.DrawLine(prevX, iPrevClose, x, iCurrentClose); } return(bCheck); }
private void SetChartSetting() { PenStyle[] cPenStyles = new PenStyle[2]; int iChartIndex = listChartType.SelectedIndex; switch (iChartIndex) { case 0: //美國線 __cChartSetting.ChartType = EChartType.OHLC; break; case 1: //HLC線 __cChartSetting.ChartType = EChartType.HLC; break; case 2: //蠟燭線 __cChartSetting.ChartType = EChartType.Candlestick; cPenStyles = new PenStyle[3]; break; case 3: //收盤線 __cChartSetting.ChartType = EChartType.CloseLine; break; } cPenStyles[0] = new PenStyle(colorUp.SelectedColor, comboUpWidth.SelectedIndex + 1); cPenStyles[1] = new PenStyle(colorDown.SelectedColor, comboDownWidth.SelectedIndex + 1); if (iChartIndex == 2) { cPenStyles[2] = new PenStyle(colorLine.SelectedColor, comboLineWidth.SelectedIndex + 1); } __cChartSetting.PenStyles = cPenStyles; __cChartSetting.IsSubChart = listSubChart.SelectedIndex == 0; __cChartSetting.IsShowNewPrice = checkShowNewPrice.Checked; //座標資訊設定 AxisSetting cAxisSetting = new AxisSetting(); int iAxisIndex = listAxisRange.SelectedIndex; switch (iAxisIndex) { case 0: //目前區間 cAxisSetting.AxisScope = EAxisScope.CurrentScope; break; case 1: //全部數列 cAxisSetting.AxisScope = EAxisScope.AllScope; break; case 2: //變動大小 cAxisSetting.AxisScope = EAxisScope.ChangeScope; break; case 3: //價格區間 cAxisSetting.AxisScope = EAxisScope.PriceScaleScope; break; } if (checkMargin.Checked) { double dValue = 0; if (double.TryParse(txtTopMargin.Text, out dValue)) { cAxisSetting.MarginTop = dValue; } if (double.TryParse(txtBottomMargin.Text, out dValue)) { cAxisSetting.MarginBottom = dValue; } } if (checkManualAxis.Checked) { double dValue = 0; if (radioScaleGap.Checked) { if (double.TryParse(txtScaleGap.Text, out dValue)) { cAxisSetting.ScaleMode = EAxisScaleMode.ScaleGap; } } else if (radioScaleCount.Checked) { if (double.TryParse(txtScaleCount.Text, out dValue)) { cAxisSetting.ScaleMode = EAxisScaleMode.ScaleCount; } } else { cAxisSetting.ScaleMode = EAxisScaleMode.None; } cAxisSetting.ScaleValue = dValue; } else { cAxisSetting.ScaleMode = EAxisScaleMode.None; } __cChartSetting.Axis = cAxisSetting; }
/// <summary> /// 設定使用者自訂畫筆樣式 /// </summary> /// <param name="pen">筆刷樣式</param> public void SetCustomPenStyle(PowerLanguage.PenStyle pen) { __cBehavior.SetCustomPenStyle(pen); }
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); }