本文整理汇总了C#中IRenderContext.DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawLine方法的具体用法?C# IRenderContext.DrawLine怎么用?C# IRenderContext.DrawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.DrawLine方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderLegend
/// <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);
}
示例2: RenderLegend
/// <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 xmid = (legendBox.Left + legendBox.Right) / 2;
double ymid = (legendBox.Top + legendBox.Bottom) / 2;
var pts = new[] { new ScreenPoint(legendBox.Left, ymid), new ScreenPoint(legendBox.Right, ymid) };
rc.DrawLine(pts, this.GetSelectableColor(this.ActualColor), this.StrokeThickness, LineStyleHelper.GetDashArray(this.ActualLineStyle));
var midpt = new ScreenPoint(xmid, ymid);
rc.DrawMarker(
midpt,
legendBox,
this.MarkerType,
this.MarkerOutline,
this.MarkerSize,
this.MarkerFill,
this.MarkerStroke,
this.MarkerStrokeThickness);
}
示例3: RenderFromXml
public static bool RenderFromXml(Stream xmlStream, IRenderContext renderContext, out Size imageSize)
{
XmlDocument doc = new XmlDocument();
doc.Load(xmlStream);
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(doc.NameTable);
namespaceManager.AddNamespace("p", PreviewNamespace);
XmlNode previewNode = doc.SelectSingleNode("/p:preview", namespaceManager);
imageSize = new Size(double.Parse(previewNode.Attributes["width"].InnerText), double.Parse(previewNode.Attributes["height"].InnerText));
XmlNodeList renderNodes = previewNode.ChildNodes;
foreach (XmlNode renderNode in renderNodes)
{
XmlElement renderElement = renderNode as XmlElement;
if (renderElement == null)
continue;
if (renderElement.Name == "line")
{
Point start = Point.Parse(renderElement.Attributes["start"].InnerText);
Point end = Point.Parse(renderElement.Attributes["end"].InnerText);
double thickness = double.Parse(renderElement.Attributes["thickness"].InnerText);
renderContext.DrawLine(start, end, thickness);
}
else if (renderElement.Name == "rect")
{
Point start = Point.Parse(renderElement.Attributes["start"].InnerText);
Size size = Size.Parse(renderElement.Attributes["size"].InnerText);
double thickness = double.Parse(renderElement.Attributes["thickness"].InnerText);
bool fill = bool.Parse(renderElement.Attributes["fill"].InnerText);
renderContext.DrawRectangle(start, size, thickness, fill);
}
else if (renderElement.Name == "ellipse")
{
Point centre = Point.Parse(renderElement.Attributes["centre"].InnerText);
double radiusx = double.Parse(renderElement.Attributes["rx"].InnerText);
double radiusy = double.Parse(renderElement.Attributes["ry"].InnerText);
double thickness = double.Parse(renderElement.Attributes["thickness"].InnerText);
bool fill = bool.Parse(renderElement.Attributes["fill"].InnerText);
renderContext.DrawEllipse(centre, radiusx, radiusy, thickness, fill);
}
else if (renderElement.Name == "path")
{
Point start = Point.Parse(renderElement.Attributes["start"].InnerText);
double thickness = double.Parse(renderElement.Attributes["thickness"].InnerText);
bool fill = bool.Parse(renderElement.Attributes["fill"].InnerText);
string data = renderElement.InnerText;
List<IPathCommand> pathCommands = new List<IPathCommand>();
using (MemoryStream dataStream = new MemoryStream(Convert.FromBase64String(data)))
{
BinaryReader reader = new BinaryReader(dataStream);
int numCommands = reader.ReadInt32();
for (int l = 0; l < numCommands; l++)
{
CommandType pType = (CommandType)reader.ReadInt32();
IPathCommand theCommand = null;
switch (pType)
{
case CommandType.MoveTo:
theCommand = new MoveTo();
break;
case CommandType.LineTo:
theCommand = new LineTo();
break;
case CommandType.CurveTo:
theCommand = new CurveTo();
break;
case CommandType.EllipticalArcTo:
theCommand = new EllipticalArcTo();
break;
case CommandType.QuadraticBeizerCurveTo:
theCommand = new QuadraticBeizerCurveTo();
break;
case CommandType.SmoothCurveTo:
theCommand = new SmoothCurveTo();
break;
case CommandType.SmoothQuadraticBeizerCurveTo:
theCommand = new SmoothQuadraticBeizerCurveTo();
break;
default:
theCommand = new ClosePath();
break;
}
theCommand.Read(reader);
pathCommands.Add(theCommand);
}
}
renderContext.DrawPath(start, pathCommands, thickness, fill);
}
else if (renderElement.Name == "text")
{
Point anchor = Point.Parse(renderElement.Attributes["anchor"].InnerText);
TextAlignment alignment = (TextAlignment)Enum.Parse(typeof(TextAlignment), renderElement.Attributes["alignment"].InnerText);
List<TextRun> runs = new List<TextRun>();
foreach (XmlNode runNode in renderElement.ChildNodes)
{
//.........这里部分代码省略.........
示例4: RenderLegend
/// <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 = this.LineStyle.GetDashArray();
rc.DrawLine(
new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, legendBox.Bottom) },
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
dashArray,
OxyPenLineJoin.Miter,
true);
// Shadow ends
if (this.ShadowEndColor.IsVisible() && this.ShadowEndLength > 0)
{
var highLeft = new ScreenPoint(xmid - (this.CandleWidth * 0.5 * this.ShadowEndLength) - 1, legendBox.Top);
var highRight = new ScreenPoint(xmid + (this.CandleWidth * 0.5 * this.ShadowEndLength), legendBox.Top);
rc.DrawLine(
new[] { highLeft, highRight },
this.GetSelectableColor(this.ShadowEndColor),
this.StrokeThickness,
dashArray,
this.LineJoin,
true);
var lowLeft = new ScreenPoint(xmid - (this.CandleWidth * 0.5 * this.ShadowEndLength) - 1, legendBox.Bottom);
var lowRight = new ScreenPoint(xmid + (this.CandleWidth * 0.5 * this.ShadowEndLength), legendBox.Bottom);
rc.DrawLine(
new[] { lowLeft, lowRight },
this.GetSelectableColor(this.ShadowEndColor),
this.StrokeThickness,
dashArray,
this.LineJoin,
true);
}
rc.DrawRectangleAsPolygon(
new OxyRect(xmid - (this.CandleWidth * 0.5), yclose, this.CandleWidth, yopen - yclose),
this.GetSelectableFillColor(this.ActualIncreasingFill),
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness);
}
示例5: RenderLegend
/// <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;
const double LegendStrokeThickness = 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,
LegendStrokeThickness,
LineStyle.Solid.GetDashArray(),
OxyPenLineJoin.Miter,
true);
rc.DrawLine(
new[] { new ScreenPoint(xmid, ybottom), new ScreenPoint(xmid, legendBox.Bottom) },
strokeColor,
LegendStrokeThickness,
LineStyle.Solid.GetDashArray(),
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,
LegendStrokeThickness,
LineStyle.Solid.GetDashArray(),
OxyPenLineJoin.Miter,
true);
// bottom whisker
rc.DrawLine(
new[]
{
new ScreenPoint(xmid - halfWhiskerWidth - 1, legendBox.Top),
new ScreenPoint(xmid + halfWhiskerWidth, legendBox.Top)
},
strokeColor,
LegendStrokeThickness,
LineStyle.Solid.GetDashArray(),
OxyPenLineJoin.Miter,
true);
}
if (this.ShowBox)
{
// box
rc.DrawRectangleAsPolygon(
new OxyRect(xmid - halfBoxWidth, ytop, 2 * halfBoxWidth, ybottom - ytop),
fillColor,
strokeColor,
LegendStrokeThickness);
}
// median
if (!this.ShowMedianAsDot)
{
rc.DrawLine(
new[] { new ScreenPoint(xmid - halfBoxWidth, ymid), new ScreenPoint(xmid + halfBoxWidth, ymid) },
strokeColor,
LegendStrokeThickness * this.MedianThickness,
LineStyle.Solid.GetDashArray(),
OxyPenLineJoin.Miter,
true);
}
else
{
var ellipseRect = new OxyRect(
xmid - this.MedianPointSize,
ymid - this.MedianPointSize,
this.MedianPointSize * 2,
this.MedianPointSize * 2);
rc.DrawEllipse(ellipseRect, fillColor, OxyColors.Undefined);
}
}
示例6: RenderLegend
/// <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);
rc.DrawLine(pts0, this.GetSelectableColor(this.ActualColor), this.StrokeThickness, this.ActualLineStyle.GetDashArray());
rc.DrawLine(pts1, this.GetSelectableColor(this.ActualColor2), this.StrokeThickness, this.ActualLineStyle.GetDashArray());
rc.DrawPolygon(pts, this.GetSelectableFillColor(this.ActualFill), OxyColors.Undefined);
}
示例7: Render
//.........这里部分代码省略.........
angle = endAngle;
stop = true;
}
double a = angle * Math.PI / 180;
var op = new ScreenPoint(mp.X + (outerRadius * Math.Cos(a)), mp.Y + (outerRadius * Math.Sin(a)));
outerPoints.Add(op);
var ip = new ScreenPoint(mp.X + (innerRadius * Math.Cos(a)), mp.Y + (innerRadius * Math.Sin(a)));
if (innerRadius + explodedRadius > 0)
{
innerPoints.Add(ip);
}
if (stop)
{
break;
}
angle += this.AngleIncrement;
}
innerPoints.Reverse();
if (innerPoints.Count == 0)
{
innerPoints.Add(mp);
}
innerPoints.Add(outerPoints[0]);
var points = outerPoints;
points.AddRange(innerPoints);
rc.DrawPolygon(points, slice.ActualFillColor, this.Stroke, this.StrokeThickness, null, OxyPenLineJoin.Bevel);
// Render label outside the slice
if (this.OutsideLabelFormat != null)
{
string label = string.Format(
this.OutsideLabelFormat, slice.Value, slice.Label, slice.Value / total * 100);
int sign = Math.Sign(Math.Cos(midAngleRadians));
// tick points
var tp0 = new ScreenPoint(
mp.X + ((outerRadius + this.TickDistance) * Math.Cos(midAngleRadians)),
mp.Y + ((outerRadius + this.TickDistance) * Math.Sin(midAngleRadians)));
var tp1 = new ScreenPoint(
tp0.X + (this.TickRadialLength * Math.Cos(midAngleRadians)),
tp0.Y + (this.TickRadialLength * Math.Sin(midAngleRadians)));
var tp2 = new ScreenPoint(tp1.X + (this.TickHorizontalLength * sign), tp1.Y);
// draw the tick line with the same color as the text
rc.DrawLine(new[] { tp0, tp1, tp2 }, this.ActualTextColor, 1, null, OxyPenLineJoin.Bevel);
// label
var labelPosition = new ScreenPoint(tp2.X + (this.TickLabelDistance * sign), tp2.Y);
rc.DrawText(
labelPosition,
label,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
sign > 0 ? HorizontalAlignment.Left : HorizontalAlignment.Right,
VerticalAlignment.Middle);
}
// Render a label inside the slice
if (this.InsideLabelFormat != null && !this.InsideLabelColor.IsUndefined())
{
string label = string.Format(
this.InsideLabelFormat, slice.Value, slice.Label, slice.Value / total * 100);
double r = (innerRadius * (1 - this.InsideLabelPosition)) + (outerRadius * this.InsideLabelPosition);
var labelPosition = new ScreenPoint(
mp.X + (r * Math.Cos(midAngleRadians)), mp.Y + (r * Math.Sin(midAngleRadians)));
double textAngle = 0;
if (this.AreInsideLabelsAngled)
{
textAngle = midAngle;
if (Math.Cos(midAngleRadians) < 0)
{
textAngle += 180;
}
}
var actualInsideLabelColor = this.InsideLabelColor.IsAutomatic() ? this.ActualTextColor : this.InsideLabelColor;
rc.DrawText(
labelPosition,
label,
actualInsideLabelColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
textAngle,
HorizontalAlignment.Center,
VerticalAlignment.Middle);
}
}
}
示例8: RenderLegend
/// <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 = LineStyle.Solid.GetDashArray();
var datacandlewidth = (this.CandleWidth > 0) ? this.CandleWidth : this.minDx * 0.80;
var fillUp = this.GetSelectableFillColor(this.PositiveColor);
var lineUp = this.GetSelectableColor(this.PositiveColor.ChangeIntensity(0.70));
var candlewidth = Math.Min(
legendBox.Width,
this.XAxis.Transform(this.data[0].X + datacandlewidth) - this.XAxis.Transform(this.data[0].X));
rc.DrawLine(
new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, legendBox.Bottom) },
lineUp,
this.StrokeThickness,
dashArray,
LineJoin.Miter,
true);
rc.DrawRectangleAsPolygon(
new OxyRect(xmid - (candlewidth * 0.5), yclose, candlewidth, yopen - yclose),
fillUp,
lineUp,
this.StrokeThickness);
}
示例9: RenderLegend
/// <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);
}
示例10: RenderBox
/// <summary>
/// Renders the border around the plot area.
/// </summary>
/// <remarks>
/// The border will only by rendered if there are axes in the plot.
/// </remarks>
/// <param name="rc">
/// The render context.
/// </param>
private void RenderBox(IRenderContext rc)
{
// The border is rendered by DrawBox to ensure that it is pixel aligned with the tick marks (cannot use DrawRectangle here).
if (this.Axes.Count > 0)
{
rc.DrawRectangleAsPolygon(this.PlotArea, null, this.PlotAreaBorderColor, this.PlotAreaBorderThickness);
foreach (var axis in this.Axes)
{
if (!axis.IsAxisVisible)
continue;
if (axis.IsHorizontal())
{
var start = this.PlotArea.Left +
this.PlotArea.Width * axis.StartPosition;
if (axis.StartPosition < 1 && axis.StartPosition > 0)
rc.DrawLine(new[] {
new ScreenPoint(start, this.PlotArea.Top),
new ScreenPoint(start, this.PlotArea.Bottom) },
this.PlotAreaBorderColor, this.PlotAreaBorderThickness,
null, OxyPenLineJoin.Miter, true);
var end = this.PlotArea.Left +
this.PlotArea.Width * axis.EndPosition;
if (axis.EndPosition < 1 && axis.EndPosition > 0)
rc.DrawLine(new[] {
new ScreenPoint(end, this.PlotArea.Top),
new ScreenPoint(end, this.PlotArea.Bottom) },
this.PlotAreaBorderColor, this.PlotAreaBorderThickness,
null, OxyPenLineJoin.Miter, true);
}
else
{
var start = this.PlotArea.Bottom -
this.PlotArea.Height * axis.StartPosition;
if (axis.StartPosition < 1 && axis.StartPosition > 0)
rc.DrawLine(new[] {
new ScreenPoint(this.PlotArea.Left, start),
new ScreenPoint(this.PlotArea.Right, start) },
this.PlotAreaBorderColor, this.PlotAreaBorderThickness,
null, OxyPenLineJoin.Miter, true);
var end = this.PlotArea.Bottom -
this.PlotArea.Height * axis.EndPosition;
if (axis.EndPosition < 1 && axis.EndPosition > 0)
rc.DrawLine(new[] {
new ScreenPoint(this.PlotArea.Left, end),
new ScreenPoint(this.PlotArea.Right, end) },
this.PlotAreaBorderColor, this.PlotAreaBorderThickness,
null, OxyPenLineJoin.Miter, true);
}
}
}
}
示例11: RenderLegend
/// <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 = this.LineStyle.GetDashArray();
var datacandlewidth = (this.CandleWidth > 0) ? this.CandleWidth : this.minDx * 0.80;
var candlewidth =
this.XAxis.Transform(this.Items[0].X + datacandlewidth) -
this.XAxis.Transform(this.Items[0].X);
rc.DrawLine(
new[] { new ScreenPoint(xmid, legendBox.Top), new ScreenPoint(xmid, legendBox.Bottom) },
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
dashArray,
LineJoin.Miter,
true);
rc.DrawRectangleAsPolygon(
new OxyRect(xmid - (candlewidth * 0.5), yclose, candlewidth, yopen - yclose),
this.GetSelectableFillColor(this.IncreasingColor),
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness);
}