本文整理汇总了C#中IRenderContext.DrawPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawPolygon方法的具体用法?C# IRenderContext.DrawPolygon怎么用?C# IRenderContext.DrawPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.DrawPolygon方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public override void Render(IRenderContext rc, PlotModel model, AxisLayer axisLayer, int pass)
{
base.Render(rc, model, axisLayer, pass);
var points = new List<ScreenPoint>();
if (this.IsHorizontal())
{
var xmax = this.Transform(this.ActualMaximum);
points.Add(new ScreenPoint(xmax + 4, model.PlotArea.Bottom - 4));
points.Add(new ScreenPoint(xmax + 18, model.PlotArea.Bottom));
points.Add(new ScreenPoint(xmax + 4, model.PlotArea.Bottom + 4));
//// etc.
}
else
{
var ymax = this.Transform(this.ActualMaximum);
points.Add(new ScreenPoint(model.PlotArea.Left - 4, ymax - 4));
points.Add(new ScreenPoint(model.PlotArea.Left, ymax - 18));
points.Add(new ScreenPoint(model.PlotArea.Left + 4, ymax - 4));
//// etc.
}
rc.DrawPolygon(points, OxyColors.Black, OxyColors.Undefined);
}
示例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 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);
}
示例3: RenderLabelBackground
/// <summary>
/// Renders the contour label background.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="cl">The contour label.</param>
private void RenderLabelBackground(IRenderContext rc, ContourLabel cl)
{
if (this.LabelBackground.IsInvisible())
{
return;
}
// Calculate background polygon
var size = rc.MeasureText(cl.Text, this.ActualFont, this.ActualFontSize, this.ActualFontWeight);
double a = cl.Angle / 180 * Math.PI;
double dx = Math.Cos(a);
double dy = Math.Sin(a);
double ux = dx * 0.6;
double uy = dy * 0.6;
double vx = -dy * 0.5;
double vy = dx * 0.5;
double x = cl.Position.X;
double y = cl.Position.Y;
var bpts = new[]
{
new ScreenPoint(x - (size.Width * ux) - (size.Height * vx), y - (size.Width * uy) - (size.Height * vy)),
new ScreenPoint(x + (size.Width * ux) - (size.Height * vx), y + (size.Width * uy) - (size.Height * vy)),
new ScreenPoint(x + (size.Width * ux) + (size.Height * vx), y + (size.Width * uy) + (size.Height * vy)),
new ScreenPoint(x - (size.Width * ux) + (size.Height * vx), y - (size.Width * uy) + (size.Height * vy))
};
rc.DrawPolygon(bpts, this.LabelBackground, OxyColors.Undefined);
}
示例4: Render
/// <summary>
/// Renders the series on the specified render context.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="model">The model.</param>
public override void Render(IRenderContext rc, PlotModel model)
{
if (this.Slices.Count == 0)
{
return;
}
double total = this.slices.Sum(slice => slice.Value);
if (Math.Abs(total) < double.Epsilon)
{
return;
}
// todo: reduce available size due to the labels
double radius = Math.Min(model.PlotArea.Width, model.PlotArea.Height) / 2;
double outerRadius = radius * (this.Diameter - this.ExplodedDistance);
double innerRadius = radius * this.InnerDiameter;
double angle = this.StartAngle;
var midPoint = new ScreenPoint(
(model.PlotArea.Left + model.PlotArea.Right) * 0.5, (model.PlotArea.Top + model.PlotArea.Bottom) * 0.5);
foreach (var slice in this.slices)
{
var outerPoints = new List<ScreenPoint>();
var innerPoints = new List<ScreenPoint>();
double sliceAngle = slice.Value / total * this.AngleSpan;
double endAngle = angle + sliceAngle;
double explodedRadius = slice.IsExploded ? this.ExplodedDistance * radius : 0.0;
double midAngle = angle + (sliceAngle / 2);
double midAngleRadians = midAngle * Math.PI / 180;
var mp = new ScreenPoint(
midPoint.X + (explodedRadius * Math.Cos(midAngleRadians)),
midPoint.Y + (explodedRadius * Math.Sin(midAngleRadians)));
// Create the pie sector points for both outside and inside arcs
while (true)
{
bool stop = false;
if (angle >= endAngle)
{
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
//.........这里部分代码省略.........
示例5: Render
/// <summary>
/// Renders the text annotation.
/// </summary>
/// <param name="rc">The render context.</param>
public override void Render(IRenderContext rc)
{
base.Render(rc);
var position = this.Transform(this.TextPosition) + this.Offset;
var clippingRectangle = this.GetClippingRect();
var textSize = rc.MeasureText(this.Text, this.ActualFont, this.ActualFontSize, this.ActualFontWeight);
rc.SetClip(clippingRectangle);
this.actualBounds = GetTextBounds(
position, textSize, this.Padding, this.TextRotation, this.TextHorizontalAlignment, this.TextVerticalAlignment);
if ((this.TextRotation % 90).Equals(0))
{
var actualRect = new OxyRect(this.actualBounds[0], this.actualBounds[2]);
rc.DrawRectangle(actualRect, this.Background, this.Stroke, this.StrokeThickness);
}
else
{
rc.DrawPolygon(this.actualBounds, this.Background, this.Stroke, this.StrokeThickness);
}
rc.DrawMathText(
position,
this.Text,
this.GetSelectableFillColor(this.ActualTextColor),
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
this.TextRotation,
this.TextHorizontalAlignment,
this.TextVerticalAlignment);
rc.ResetClip();
}