本文整理汇总了C#中IRenderContext.DrawRectangleAsPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawRectangleAsPolygon方法的具体用法?C# IRenderContext.DrawRectangleAsPolygon怎么用?C# IRenderContext.DrawRectangleAsPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.DrawRectangleAsPolygon方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderOrMeasureLegends
/// <summary>
/// Renders or measures the legends.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="rect">Provides the available size if measuring, otherwise it provides the position and size of the legend.</param>
/// <param name="measureOnly">Specify if the size of the legend box should be measured only (not rendered).</param>
/// <returns>The size of the legend box.</returns>
private OxySize RenderOrMeasureLegends(IRenderContext rc, OxyRect rect, bool measureOnly = false)
{
// Render background and border around legend
if (!measureOnly && rect.Width > 0 && rect.Height > 0)
{
rc.DrawRectangleAsPolygon(rect, this.LegendBackground, this.LegendBorder, this.LegendBorderThickness);
}
double availableWidth = rect.Width;
double availableHeight = rect.Height;
double x = this.LegendPadding;
double top = this.LegendPadding;
var size = new OxySize();
// Render/measure the legend title
if (!string.IsNullOrEmpty(this.LegendTitle))
{
OxySize titleSize;
if (measureOnly)
{
titleSize = rc.MeasureMathText(
this.LegendTitle,
this.LegendTitleFont ?? this.DefaultFont,
this.LegendTitleFontSize,
this.LegendTitleFontWeight);
}
else
{
titleSize = rc.DrawMathText(
new ScreenPoint(rect.Left + x, rect.Top + top),
this.LegendTitle,
this.LegendTitleColor.GetActualColor(this.TextColor),
this.LegendTitleFont ?? this.DefaultFont,
this.LegendTitleFontSize,
this.LegendTitleFontWeight,
0,
HorizontalAlignment.Left,
VerticalAlignment.Top,
null,
true);
}
top += titleSize.Height;
size.Width = x + titleSize.Width + this.LegendPadding;
size.Height = top + titleSize.Height;
}
double y = top;
double lineHeight = 0;
// tolerance for floating-point number comparisons
const double Epsilon = 1e-3;
// the maximum item with in the column being rendered (only used for vertical orientation)
double maxItemWidth = 0;
var items = this.LegendItemOrder == LegendItemOrder.Reverse
? this.Series.Reverse().Where(s => s.IsVisible)
: this.Series.Where(s => s.IsVisible);
// When orientation is vertical and alignment is center or right, the items cannot be rendered before
// the max item width has been calculated. Render the items for each column, and at the end.
var seriesToRender = new Dictionary<Series.Series, OxyRect>();
Action renderItems = () =>
{
foreach (var sr in seriesToRender)
{
var itemRect = sr.Value;
var itemSeries = sr.Key;
double rwidth = availableWidth;
if (itemRect.Left + rwidth + this.LegendPadding > rect.Left + availableWidth)
{
rwidth = rect.Left + availableWidth - itemRect.Left - this.LegendPadding;
}
double rheight = itemRect.Height;
if (rect.Top + rheight + this.LegendPadding > rect.Top + availableHeight)
{
rheight = rect.Top + availableHeight - rect.Top - this.LegendPadding;
}
var r = new OxyRect(itemRect.Left, itemRect.Top, Math.Max(rwidth, 0), Math.Max(rheight, 0));
this.RenderLegend(rc, itemSeries, r);
}
seriesToRender.Clear();
};
foreach (var s in items)
//.........这里部分代码省略.........
示例2: 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 ymid = (legendBox.Top + legendBox.Bottom) / 2;
double height = (legendBox.Bottom - legendBox.Top) * 0.8;
double width = height;
rc.DrawRectangleAsPolygon(
new OxyRect(xmid - (0.5 * width), ymid - (0.5 * height), width, height),
this.GetSelectableFillColor(this.ActualFillColor),
this.StrokeColor,
this.StrokeThickness);
}
示例3: 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);
}
}
示例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: RenderBox
/// <summary>
/// Renders the border around the plot area.
/// </summary>
/// <param name="rc">The render context.</param>
/// <remarks>The border will only by rendered if there are axes in the plot.</remarks>
private void RenderBox(IRenderContext rc)
{
// The border is rendered by DrawRectangleAsPolygon to ensure that it is pixel aligned with the tick marks (cannot use DrawRectangle here).
if (this.Axes.Count > 0)
{
rc.DrawRectangleAsPolygon(this.PlotArea, OxyColors.Undefined, this.PlotAreaBorderColor, this.PlotAreaBorderThickness);
}
}
示例6: 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);
}
示例7: RenderBackgrounds
/// <summary>
/// Renders the series backgrounds.
/// </summary>
/// <param name="rc">The render context.</param>
private void RenderBackgrounds(IRenderContext rc)
{
// Render the main background of the plot area (only if there are axes)
// The border is rendered by DrawRectangleAsPolygon to ensure that it is pixel aligned with the tick marks.
if (this.Axes.Count > 0 && this.PlotAreaBackground.IsVisible())
{
rc.DrawRectangleAsPolygon(this.PlotArea, this.PlotAreaBackground, OxyColors.Undefined, 0);
}
foreach (var s in this.Series.Where(s => s.IsVisible && s is XYAxisSeries && s.Background.IsVisible()).Cast<XYAxisSeries>())
{
rc.DrawRectangle(s.GetScreenRectangle(), s.Background, OxyColors.Undefined, 0);
}
}
示例8: RenderBackgrounds
/// <summary>
/// Renders the series backgrounds.
/// </summary>
/// <param name="rc">
/// The render context.
/// </param>
private void RenderBackgrounds(IRenderContext rc)
{
// Render the main background of the plot area (only if there are axes)
// The border is rendered by DrawRectangleAsPolygon to ensure that it is pixel aligned with the tick marks.
if (this.Axes.Count > 0 && this.PlotAreaBackground != null)
{
rc.DrawRectangleAsPolygon(this.PlotArea, this.PlotAreaBackground, null, 0);
}
foreach (var s in this.VisibleSeries)
{
var s2 = s as XYAxisSeries;
if (s2 == null || s2.Background == null)
{
continue;
}
rc.DrawRectangle(s2.GetScreenRectangle(), s2.Background, null, 0);
}
}
示例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);
}