/// <summary> /// Renders the legend symbol for the series on the specified rendering context. /// </summary> /// <param name="rc"> /// The rendering context. /// </param> /// <param name="legendBox"> /// The bounding rectangle of the legend box. /// </param> public override void RenderLegend(IRenderContext rc, OxyRect legendBox) { double xmid = (legendBox.Left + legendBox.Right) / 2; double yopen = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.7); double yclose = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.3); double[] dashArray = LineStyleHelper.GetDashArray(this.LineStyle); var color = this.GetSelectableColor(this.ActualColor); rc.DrawLine( new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, legendBox.Bottom) }, color, this.StrokeThickness, dashArray, OxyPenLineJoin.Miter, true); rc.DrawLine( new[] { new ScreenPoint(xmid - this.TickLength, yopen), new ScreenPoint(xmid, yopen) }, color, this.StrokeThickness, dashArray, OxyPenLineJoin.Miter, true); rc.DrawLine( new[] { new ScreenPoint(xmid + this.TickLength, yclose), new ScreenPoint(xmid, yclose) }, color, this.StrokeThickness, dashArray, OxyPenLineJoin.Miter, true); }
public void WritePolyline() { const string FileName = "SvgWriterTests_WritePolyLine.svg"; using (var s = File.Create(FileName)) { using (var w = new SvgWriter(s, 200, 200)) { w.WritePolyline( CreatePointList(), w.CreateStyle(OxyColors.Blue, OxyColors.Black, 2, LineStyleHelper.GetDashArray(LineStyle.Solid))); } } SvgAssert.IsValidFile(FileName); }
public void WriteLine() { const string FileName = "SvgWriterTests_WriteLine.svg"; using (var s = File.Create(FileName)) { using (var w = new SvgWriter(s, 200, 200)) { w.WriteLine( new ScreenPoint(10, 10), new ScreenPoint(150, 80), w.CreateStyle(null, OxyColors.Black, 2, LineStyleHelper.GetDashArray(LineStyle.Solid))); } } SvgAssert.IsValidFile(FileName); }
/// <summary> /// Renders the legend symbol for the line series on the /// specified rendering context. /// </summary> /// <param name="rc"> /// The rendering context. /// </param> /// <param name="legendBox"> /// The bounding rectangle of the legend box. /// </param> public override void RenderLegend(IRenderContext rc, OxyRect legendBox) { double y0 = (legendBox.Top * 0.2) + (legendBox.Bottom * 0.8); double y1 = (legendBox.Top * 0.4) + (legendBox.Bottom * 0.6); double y2 = (legendBox.Top * 0.8) + (legendBox.Bottom * 0.2); var pts0 = new[] { new ScreenPoint(legendBox.Left, y0), new ScreenPoint(legendBox.Right, y0) }; var pts1 = new[] { new ScreenPoint(legendBox.Right, y2), new ScreenPoint(legendBox.Left, y1) }; var pts = new List <ScreenPoint>(); pts.AddRange(pts0); pts.AddRange(pts1); var color = this.GetSelectableColor(this.ActualColor); rc.DrawLine(pts0, color, this.StrokeThickness, LineStyleHelper.GetDashArray(this.ActualLineStyle)); rc.DrawLine(pts1, color, this.StrokeThickness, LineStyleHelper.GetDashArray(this.ActualLineStyle)); rc.DrawPolygon(pts, this.GetSelectableFillColor(this.Fill), null); }
/// <summary> /// Renders the legend symbol for the series on the specified rendering context. /// </summary> /// <param name="rc"> /// The rendering context. /// </param> /// <param name="legendBox"> /// The bounding rectangle of the legend box. /// </param> public override void RenderLegend(IRenderContext rc, OxyRect legendBox) { double xmid = (legendBox.Left + legendBox.Right) / 2; double yopen = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.7); double yclose = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.3); double[] dashArray = LineStyleHelper.GetDashArray(this.LineStyle); rc.DrawLine( new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, legendBox.Bottom) }, this.GetSelectableColor(this.ActualColor), this.StrokeThickness, dashArray, OxyPenLineJoin.Miter, true); rc.DrawRectangleAsPolygon( new OxyRect(xmid - (this.CandleWidth * 0.5), yclose, this.CandleWidth, yopen - yclose), this.GetSelectableFillColor(this.ActualColor), this.GetSelectableColor(this.ActualColor), this.StrokeThickness); }
public void WriteRectangle() { const string FileName = "SvgWriterTests_WriteRectangle.svg"; using (var s = File.Create(FileName)) { using (var w = new SvgWriter(s, 200, 200)) { w.WriteRectangle( 10, 20, 150, 80, w.CreateStyle( OxyColors.Green, OxyColors.Black, 2, LineStyleHelper.GetDashArray(LineStyle.Solid))); } } SvgAssert.IsValidFile(FileName); }
public Pen(Color c, double th, LineStyle ls) { Color = c; Thickness = th; DashArray = LineStyleHelper.GetDashArray(ls); }
/// <summary> /// Renders the legend symbol on the specified rendering context. /// </summary> /// <param name="rc"> /// The rendering context. /// </param> /// <param name="legendBox"> /// The legend rectangle. /// </param> public override void RenderLegend(IRenderContext rc, OxyRect legendBox) { double xmid = (legendBox.Left + legendBox.Right) / 2; double ybottom = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.7); double ytop = legendBox.Top + ((legendBox.Bottom - legendBox.Top) * 0.3); double ymid = (ybottom + ytop) * 0.5; var halfBoxWidth = legendBox.Width * 0.24; var halfWhiskerWidth = halfBoxWidth * this.WhiskerWidth; double strokeThickness = 1; var strokeColor = this.GetSelectableColor(this.Stroke); var fillColor = this.GetSelectableFillColor(this.Fill); rc.DrawLine( new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, ytop) }, strokeColor, strokeThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); rc.DrawLine( new[] { new ScreenPoint(xmid, ybottom), new ScreenPoint(xmid, legendBox.Bottom) }, strokeColor, strokeThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); if (this.WhiskerWidth > 0) { // top whisker rc.DrawLine( new[] { new ScreenPoint(xmid - halfWhiskerWidth - 1, legendBox.Bottom), new ScreenPoint(xmid + halfWhiskerWidth, legendBox.Bottom) }, strokeColor, strokeThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); // bottom whisker rc.DrawLine( new[] { new ScreenPoint(xmid - halfWhiskerWidth - 1, legendBox.Top), new ScreenPoint(xmid + halfWhiskerWidth, legendBox.Top) }, strokeColor, strokeThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); } if (this.ShowBox) { // box rc.DrawRectangleAsPolygon( new OxyRect(xmid - halfBoxWidth, ytop, 2 * halfBoxWidth, ybottom - ytop), fillColor, strokeColor, strokeThickness); } // median if (!this.ShowMedianAsDot) { rc.DrawLine( new[] { new ScreenPoint(xmid - halfBoxWidth, ymid), new ScreenPoint(xmid + halfBoxWidth, ymid) }, strokeColor, strokeThickness * this.MedianThickness, LineStyleHelper.GetDashArray(LineStyle.Solid), OxyPenLineJoin.Miter, true); } else { var ellipseRect = new OxyRect( xmid - this.MedianPointSize, ymid - this.MedianPointSize, this.MedianPointSize * 2, this.MedianPointSize * 2); rc.DrawEllipse(ellipseRect, fillColor, null); } }