protected virtual void DrawOpenCloseMarks3D(ChartGraphics graph, ChartArea area, Series ser, DataPoint point, float xPosition, float width, float zPosition, float depth) { double logValue = vAxis.GetLogValue(point.YValues[2]); double logValue2 = vAxis.GetLogValue(point.YValues[3]); if ((logValue > vAxis.GetViewMaximum() || logValue < vAxis.GetViewMinimum()) && !(logValue2 > vAxis.GetViewMaximum())) { vAxis.GetViewMinimum(); } float num = (float)vAxis.GetLinearPosition(logValue); float num2 = (float)vAxis.GetLinearPosition(logValue2); SizeF absoluteSize = graph.GetAbsoluteSize(new SizeF(width, width)); float height = graph.GetRelativeSize(absoluteSize).Height; StockOpenCloseMarkStyle stockOpenCloseMarkStyle = openCloseStyle; string text = ""; if (point.IsAttributeSet("OpenCloseStyle")) { text = point["OpenCloseStyle"]; } else if (ser.IsAttributeSet("OpenCloseStyle")) { text = ser["OpenCloseStyle"]; } if (text != null && text.Length > 0) { if (string.Compare(text, "Candlestick", StringComparison.OrdinalIgnoreCase) == 0) { stockOpenCloseMarkStyle = StockOpenCloseMarkStyle.Candlestick; } else if (string.Compare(text, "Triangle", StringComparison.OrdinalIgnoreCase) == 0) { stockOpenCloseMarkStyle = StockOpenCloseMarkStyle.Triangle; } else if (string.Compare(text, "Line", StringComparison.OrdinalIgnoreCase) == 0) { stockOpenCloseMarkStyle = StockOpenCloseMarkStyle.Line; } } bool flag = true; bool flag2 = true; string text2 = ""; if (point.IsAttributeSet("ShowOpenClose")) { text2 = point["ShowOpenClose"]; } else if (ser.IsAttributeSet("ShowOpenClose")) { text2 = ser["ShowOpenClose"]; } if (text2 != null && text2.Length > 0) { if (string.Compare(text2, "Both", StringComparison.OrdinalIgnoreCase) == 0) { flag = true; flag2 = true; } else if (string.Compare(text2, "Open", StringComparison.OrdinalIgnoreCase) == 0) { flag = true; flag2 = false; } else if (string.Compare(text2, "Close", StringComparison.OrdinalIgnoreCase) == 0) { flag = false; flag2 = true; } } bool flag3 = false; if (xPosition - width / 2f < area.PlotAreaPosition.X || xPosition + width / 2f > area.PlotAreaPosition.Right()) { graph.SetClip(area.PlotAreaPosition.ToRectangleF()); flag3 = true; } if (forceCandleStick || stockOpenCloseMarkStyle == StockOpenCloseMarkStyle.Candlestick) { ColorConverter colorConverter = new ColorConverter(); Color color = point.Color; Color color2 = point.BackGradientEndColor; string text3 = point["PriceUpColor"]; if (text3 != null && text3.Length > 0) { try { color = (Color)colorConverter.ConvertFromString(text3); } catch { color = (Color)colorConverter.ConvertFromInvariantString(text3); } } text3 = point["PriceDownColor"]; if (text3 != null && text3.Length > 0) { try { color2 = (Color)colorConverter.ConvertFromString(text3); } catch { color2 = (Color)colorConverter.ConvertFromInvariantString(text3); } } RectangleF empty = RectangleF.Empty; empty.Y = Math.Min(num, num2); empty.X = xPosition - width / 2f; empty.Height = Math.Max(num, num2) - empty.Y; empty.Width = width; Color color3 = (num > num2) ? color : color2; Color color4 = (!(point.BorderColor == Color.Empty)) ? point.BorderColor : ((color3 == Color.Empty) ? point.Color : color3); Point3D[] array = new Point3D[2] { new Point3D(empty.X, empty.Y, zPosition + depth / 2f), new Point3D(empty.Right, empty.Bottom, zPosition + depth / 2f) }; area.matrix3D.TransformPoints(array); empty.Location = array[0].PointF; empty.Width = Math.Abs(array[1].X - array[0].X); empty.Height = Math.Abs(array[1].Y - array[0].Y); if (empty.Height > 1f) { graph.FillRectangleRel(empty, color3, point.BackHatchStyle, point.BackImage, point.BackImageMode, point.BackImageTransparentColor, point.BackImageAlign, point.BackGradientType, point.BackGradientEndColor, color4, point.BorderWidth, point.BorderStyle, ser.ShadowColor, ser.ShadowOffset, PenAlignment.Inset); } else { graph.DrawLineRel(color4, point.BorderWidth, point.BorderStyle, new PointF(empty.X, empty.Y), new PointF(empty.Right, empty.Y), ser.ShadowColor, ser.ShadowOffset); } } else if (stockOpenCloseMarkStyle == StockOpenCloseMarkStyle.Triangle) { GraphicsPath graphicsPath = new GraphicsPath(); Point3D[] array2 = new Point3D[3] { new Point3D(xPosition, num, zPosition + depth / 2f), new Point3D(xPosition - width / 2f, num + height / 2f, zPosition + depth / 2f), new Point3D(xPosition - width / 2f, num - height / 2f, zPosition + depth / 2f) }; area.matrix3D.TransformPoints(array2); array2[0].PointF = graph.GetAbsolutePoint(array2[0].PointF); array2[1].PointF = graph.GetAbsolutePoint(array2[1].PointF); array2[2].PointF = graph.GetAbsolutePoint(array2[2].PointF); if (flag && logValue <= vAxis.GetViewMaximum() && logValue >= vAxis.GetViewMinimum()) { graphicsPath.AddLine(array2[1].PointF, array2[0].PointF); graphicsPath.AddLine(array2[0].PointF, array2[2].PointF); graphicsPath.AddLine(array2[2].PointF, array2[2].PointF); graph.FillPath(new SolidBrush(point.Color), graphicsPath); } if (flag2 && logValue2 <= vAxis.GetViewMaximum() && logValue2 >= vAxis.GetViewMinimum()) { array2[0] = new Point3D(xPosition, num2, zPosition + depth / 2f); array2[1] = new Point3D(xPosition + width / 2f, num2 + height / 2f, zPosition + depth / 2f); array2[2] = new Point3D(xPosition + width / 2f, num2 - height / 2f, zPosition + depth / 2f); area.matrix3D.TransformPoints(array2); array2[0].PointF = graph.GetAbsolutePoint(array2[0].PointF); array2[1].PointF = graph.GetAbsolutePoint(array2[1].PointF); array2[2].PointF = graph.GetAbsolutePoint(array2[2].PointF); graphicsPath.Reset(); graphicsPath.AddLine(array2[1].PointF, array2[0].PointF); graphicsPath.AddLine(array2[0].PointF, array2[2].PointF); graphicsPath.AddLine(array2[2].PointF, array2[2].PointF); graph.FillPath(new SolidBrush(point.Color), graphicsPath); } graphicsPath?.Dispose(); } else { if (flag && logValue <= vAxis.GetViewMaximum() && logValue >= vAxis.GetViewMinimum()) { Point3D[] array3 = new Point3D[2] { new Point3D(xPosition - width / 2f, num, zPosition + depth / 2f), new Point3D(xPosition, num, zPosition + depth / 2f) }; area.matrix3D.TransformPoints(array3); graph.DrawLineRel(point.Color, point.BorderWidth, point.BorderStyle, array3[0].PointF, array3[1].PointF, ser.ShadowColor, ser.ShadowOffset); } if (flag2 && logValue2 <= vAxis.GetViewMaximum() && logValue2 >= vAxis.GetViewMinimum()) { Point3D[] array4 = new Point3D[2] { new Point3D(xPosition, num2, zPosition + depth / 2f), new Point3D(xPosition + width / 2f, num2, zPosition + depth / 2f) }; area.matrix3D.TransformPoints(array4); graph.DrawLineRel(point.Color, point.BorderWidth, point.BorderStyle, array4[0].PointF, array4[1].PointF, ser.ShadowColor, ser.ShadowOffset); } } if (flag3) { graph.ResetClip(); } }
public StockChart(StockOpenCloseMarkStyle style) { openCloseStyle = style; }