本文整理汇总了C#中IRenderContext.DrawClippedRectangleAsPolygon方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawClippedRectangleAsPolygon方法的具体用法?C# IRenderContext.DrawClippedRectangleAsPolygon怎么用?C# IRenderContext.DrawClippedRectangleAsPolygon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.DrawClippedRectangleAsPolygon方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
/// <summary>
/// Renders the Series on the specified rendering context.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="model">The model.</param>
public override void Render(IRenderContext rc, PlotModel model)
{
this.ActualBarRectangles = new List<OxyRect>();
if (this.ValidItems.Count == 0)
{
return;
}
var clippingRect = this.GetClippingRect();
var categoryAxis = this.GetCategoryAxis();
var actualBarWidth = this.GetActualBarWidth();
var stackIndex = categoryAxis.GetStackIndex(this.StackGroup);
for (var i = 0; i < this.ValidItems.Count; i++)
{
var item = this.ValidItems[i];
var categoryIndex = item.GetCategoryIndex(i);
double categoryValue = categoryAxis.GetCategoryValue(categoryIndex, stackIndex, actualBarWidth);
var p0 = this.Transform(item.Start, categoryValue);
var p1 = this.Transform(item.End, categoryValue + actualBarWidth);
var rectangle = OxyRect.Create(p0.X, p0.Y, p1.X, p1.Y);
this.ActualBarRectangles.Add(rectangle);
rc.DrawClippedRectangleAsPolygon(
clippingRect,
rectangle,
this.GetSelectableFillColor(item.Color.GetActualColor(this.ActualFillColor)),
this.StrokeColor,
this.StrokeThickness);
if (this.LabelFormatString != null)
{
var s = this.Format(this.LabelFormatString, this.GetItem(i), item.Start, item.End, item.Title);
var pt = new ScreenPoint(
(rectangle.Left + rectangle.Right) / 2, (rectangle.Top + rectangle.Bottom) / 2);
rc.DrawClippedText(
clippingRect,
pt,
s,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
HorizontalAlignment.Center,
VerticalAlignment.Middle);
}
}
}
示例2: Render
//.........这里部分代码省略.........
this.VerifyAxes();
var clippingRect = this.GetClippingRect();
var dashArray = this.LineStyle.GetDashArray();
var actualColor = this.GetSelectableColor(this.ActualColor);
var shadowEndColor = this.GetSelectableColor(this.ShadowEndColor);
foreach (var v in this.Items)
{
if (!this.IsValidItem(v, this.XAxis, this.YAxis))
{
continue;
}
if (this.StrokeThickness > 0 && this.LineStyle != LineStyle.None)
{
var high = this.Transform(v.X, v.High);
var low = this.Transform(v.X, v.Low);
if (double.IsNaN(v.Open) || double.IsNaN(v.Close))
{
rc.DrawClippedLine(
clippingRect,
new[] { low, high },
0,
actualColor,
this.StrokeThickness,
dashArray,
this.LineJoin,
false);
}
else
{
var open = this.Transform(v.X, v.Open);
var close = this.Transform(v.X, v.Close);
var max = new ScreenPoint(open.X, Math.Max(open.Y, close.Y));
var min = new ScreenPoint(open.X, Math.Min(open.Y, close.Y));
// Upper shadow
rc.DrawClippedLine(
clippingRect,
new[] { high, min },
0,
actualColor,
this.StrokeThickness,
dashArray,
this.LineJoin,
true);
// Lower shadow
rc.DrawClippedLine(
clippingRect,
new[] { max, low },
0,
actualColor,
this.StrokeThickness,
dashArray,
this.LineJoin,
true);
// Shadow ends
if (this.ShadowEndColor.IsVisible() && this.ShadowEndLength > 0)
{
var highLeft = new ScreenPoint(high.X - (this.CandleWidth * 0.5 * this.ShadowEndLength) - 1, high.Y);
var highRight = new ScreenPoint(high.X + (this.CandleWidth * 0.5 * this.ShadowEndLength), high.Y);
rc.DrawClippedLine(
clippingRect,
new[] { highLeft, highRight },
0,
shadowEndColor,
this.StrokeThickness,
dashArray,
this.LineJoin,
true);
var lowLeft = new ScreenPoint(low.X - (this.CandleWidth * 0.5 * this.ShadowEndLength) - 1, low.Y);
var lowRight = new ScreenPoint(low.X + (this.CandleWidth * 0.5 * this.ShadowEndLength), low.Y);
rc.DrawClippedLine(
clippingRect,
new[] { lowLeft, lowRight },
0,
shadowEndColor,
this.StrokeThickness,
dashArray,
this.LineJoin,
true);
}
// Body
var openLeft = open + new ScreenVector(-this.CandleWidth * 0.5, 0);
var rect = new OxyRect(openLeft.X, min.Y, this.CandleWidth, max.Y - min.Y);
var fillColor = v.Close > v.Open
? this.GetSelectableFillColor(this.ActualIncreasingFill)
: this.GetSelectableFillColor(this.DecreasingFill);
rc.DrawClippedRectangleAsPolygon(clippingRect, rect, fillColor, actualColor, this.StrokeThickness);
}
}
}
}
示例3: Render
/// <summary>
/// Renders the Series on the specified rendering context.
/// </summary>
/// <param name="rc">
/// The rendering context.
/// </param>
/// <param name="model">
/// The model.
/// </param>
public override void Render(IRenderContext rc, PlotModel model)
{
this.ActualMinimumBarRectangles = new List<OxyRect>();
this.ActualMaximumBarRectangles = new List<OxyRect>();
if (this.ValidItems.Count == 0)
{
return;
}
var clippingRect = this.GetClippingRect();
var categoryAxis = this.GetCategoryAxis();
var actualBarWidth = this.GetActualBarWidth();
for (var i = 0; i < this.ValidItems.Count; i++)
{
var item = this.ValidItems[i];
var categoryIndex = item.GetCategoryIndex(i);
var baseValue = double.IsNaN(item.BaseValue) ? this.BaseValue : item.BaseValue;
var p0 = this.Transform(item.Minimum, categoryIndex - 0.5 + categoryAxis.BarOffset[categoryIndex]);
var p1 = this.Transform(
item.Maximum, categoryIndex - 0.5 + categoryAxis.BarOffset[categoryIndex] + actualBarWidth);
var p2 = this.Transform(baseValue, categoryIndex - 0.5 + categoryAxis.BarOffset[categoryIndex]);
p2.X = (int)p2.X;
var minimumRectangle = OxyRect.Create(p0.X, p0.Y, p2.X, p1.Y);
var maximumRectangle = OxyRect.Create(p2.X, p0.Y, p1.X, p1.Y);
this.ActualMinimumBarRectangles.Add(minimumRectangle);
this.ActualMaximumBarRectangles.Add(maximumRectangle);
rc.DrawClippedRectangleAsPolygon(
minimumRectangle,
clippingRect,
item.MinimumColor ?? this.ActualMinimumFillColor,
this.StrokeColor,
this.StrokeThickness);
rc.DrawClippedRectangleAsPolygon(
maximumRectangle,
clippingRect,
item.MaximumColor ?? this.ActualMaximumFillColor,
this.StrokeColor,
this.StrokeThickness);
if (this.MinimumLabelFormatString != null)
{
var s = StringHelper.Format(
this.ActualCulture,
this.MinimumLabelFormatString,
this.GetItem(this.ValidItemsIndexInversion[i]),
item.Minimum);
var pt = new ScreenPoint(
minimumRectangle.Left - this.LabelMargin, (minimumRectangle.Top + minimumRectangle.Bottom) / 2);
rc.DrawClippedText(
clippingRect,
pt,
s,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
HorizontalAlignment.Right,
VerticalAlignment.Middle);
}
if (this.MaximumLabelFormatString != null)
{
var s = StringHelper.Format(
this.ActualCulture,
this.MaximumLabelFormatString,
this.GetItem(this.ValidItemsIndexInversion[i]),
item.Maximum);
var pt = new ScreenPoint(
maximumRectangle.Right + this.LabelMargin, (maximumRectangle.Top + maximumRectangle.Bottom) / 2);
rc.DrawClippedText(
clippingRect,
pt,
s,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
HorizontalAlignment.Left,
VerticalAlignment.Middle);
//.........这里部分代码省略.........
示例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.Items.Count == 0)
{
return;
}
var clippingRect = this.GetClippingRect();
var outlierScreenPoints = new List<ScreenPoint>();
var halfBoxWidth = this.BoxWidth * 0.5;
var halfWhiskerWidth = halfBoxWidth * this.WhiskerWidth;
var strokeColor = this.GetSelectableColor(this.Stroke);
var fillColor = this.GetSelectableFillColor(this.Fill);
var dashArray = this.LineStyle.GetDashArray();
foreach (var item in this.Items)
{
// Add the outlier points
outlierScreenPoints.AddRange(item.Outliers.Select(outlier => this.Transform(item.X, outlier)));
var topWhiskerTop = this.Transform(item.X, item.UpperWhisker);
var topWhiskerBottom = this.Transform(item.X, item.BoxTop);
var bottomWhiskerTop = this.Transform(item.X, item.BoxBottom);
var bottomWhiskerBottom = this.Transform(item.X, item.LowerWhisker);
rc.DrawClippedLine(
clippingRect,
new[] { topWhiskerTop, topWhiskerBottom },
0,
strokeColor,
this.StrokeThickness,
dashArray,
OxyPenLineJoin.Miter,
true);
rc.DrawClippedLine(
clippingRect,
new[] { bottomWhiskerTop, bottomWhiskerBottom },
0,
strokeColor,
this.StrokeThickness,
dashArray,
OxyPenLineJoin.Miter,
true);
// Draw the whiskers
if (this.WhiskerWidth > 0)
{
var topWhiskerLine1 = this.Transform(item.X - halfWhiskerWidth, item.UpperWhisker);
var topWhiskerLine2 = this.Transform(item.X + halfWhiskerWidth, item.UpperWhisker);
var bottomWhiskerLine1 = this.Transform(item.X - halfWhiskerWidth, item.LowerWhisker);
var bottomWhiskerLine2 = this.Transform(item.X + halfWhiskerWidth, item.LowerWhisker);
rc.DrawClippedLine(
clippingRect,
new[] { topWhiskerLine1, topWhiskerLine2 },
0,
strokeColor,
this.StrokeThickness,
null,
OxyPenLineJoin.Miter,
true);
rc.DrawClippedLine(
clippingRect,
new[] { bottomWhiskerLine1, bottomWhiskerLine2 },
0,
strokeColor,
this.StrokeThickness,
null,
OxyPenLineJoin.Miter,
true);
}
if (this.ShowBox)
{
// Draw the box
var rect = this.GetBoxRect(item);
rc.DrawClippedRectangleAsPolygon(clippingRect, rect, fillColor, strokeColor, this.StrokeThickness);
}
if (!this.ShowMedianAsDot)
{
// Draw the median line
var medianLeft = this.Transform(item.X - halfBoxWidth, item.Median);
var medianRight = this.Transform(item.X + halfBoxWidth, item.Median);
rc.DrawClippedLine(
clippingRect,
new[] { medianLeft, medianRight },
0,
strokeColor,
this.StrokeThickness * this.MedianThickness,
null,
OxyPenLineJoin.Miter,
true);
}
//.........这里部分代码省略.........
示例5: Render
/// <summary>
/// Renders the series on the specified rendering context.
/// </summary>
/// <param name="rc">The rendering context.</param>
public override void Render(IRenderContext rc)
{
if (this.Items.Count == 0)
{
return;
}
var clippingRect = this.GetClippingRect();
int i = 0;
this.ActualBarRectangles = new List<OxyRect>();
foreach (var item in this.Items)
{
if (!this.IsValid(item.X0) || !this.IsValid(item.X1)
|| !this.IsValid(item.Y0) || !this.IsValid(item.Y1))
{
continue;
}
var p0 = this.Transform(item.X0, item.Y0);
var p1 = this.Transform(item.X1, item.Y1);
var rectangle = OxyRect.Create(p0.X, p0.Y, p1.X, p1.Y);
this.ActualBarRectangles.Add(rectangle);
rc.DrawClippedRectangleAsPolygon(
clippingRect,
rectangle,
this.GetSelectableFillColor(item.Color.GetActualColor(this.ActualFillColor)),
this.StrokeColor,
this.StrokeThickness);
if (this.LabelFormatString != null)
{
var s = StringHelper.Format(
this.ActualCulture,
this.LabelFormatString,
this.GetItem(i),
item.X0,
item.X1,
item.Y0,
item.Y1,
item.Title);
var pt = new ScreenPoint(
(rectangle.Left + rectangle.Right) / 2, (rectangle.Top + rectangle.Bottom) / 2);
rc.DrawClippedText(
clippingRect,
pt,
s,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
HorizontalAlignment.Center,
VerticalAlignment.Middle);
}
i++;
}
}
示例6: Render
/// <summary>
/// Renders the series on the specified rendering context.
/// </summary>
/// <param name="rc">The rendering context.</param>
// ReSharper disable once FunctionComplexityOverflow
public override void Render(IRenderContext rc)
{
if (this.data == null || this.data.Count == 0)
{
return;
}
var items = this.data;
var nitems = this.data.Count;
this.VerifyAxes();
var clippingBar = this.GetClippingRect(this.BarAxis);
var clippingSep = this.GetSeparationClippingRect();
var clippingVol = this.GetClippingRect(this.VolumeAxis);
var datacandlewidth = (this.CandleWidth > 0) ? this.CandleWidth : this.minDx * 0.80;
var candlewidth =
this.XAxis.Transform(items[0].X + datacandlewidth) -
this.XAxis.Transform(items[0].X) - this.StrokeThickness;
// colors
var fillUp = this.GetSelectableFillColor(this.PositiveColor);
var fillDown = this.GetSelectableFillColor(this.NegativeColor);
var barfillUp = this.PositiveHollow ? OxyColors.Transparent : fillUp;
var barfillDown = this.NegativeHollow ? OxyColors.Transparent : fillDown;
var lineUp = this.GetSelectableColor(this.PositiveColor.ChangeIntensity(this.StrokeIntensity));
var lineDown = this.GetSelectableColor(this.NegativeColor.ChangeIntensity(this.StrokeIntensity));
// determine render range
var xmin = this.XAxis.ActualMinimum;
var xmax = this.XAxis.ActualMaximum;
this.winIndex = OhlcvItem.FindIndex(items, xmin, this.winIndex);
for (int i = this.winIndex; i < nitems; i++)
{
var bar = items[i];
// if item beyond visible range, done
if (bar.X > xmax)
{
break;
}
// check to see whether is valid
if (!bar.IsValid())
{
continue;
}
var fillColor = bar.Close > bar.Open ? barfillUp : barfillDown;
var lineColor = bar.Close > bar.Open ? lineUp : lineDown;
var high = this.Transform(bar.X, bar.High);
var low = this.Transform(bar.X, bar.Low);
var open = this.Transform(bar.X, bar.Open);
var close = this.Transform(bar.X, bar.Close);
var max = new ScreenPoint(open.X, Math.Max(open.Y, close.Y));
var min = new ScreenPoint(open.X, Math.Min(open.Y, close.Y));
// Bar part
rc.DrawClippedLine(
clippingBar,
new[] { high, min },
0,
lineColor,
this.StrokeThickness,
null,
LineJoin.Miter,
true);
// Lower extent
rc.DrawClippedLine(
clippingBar,
new[] { max, low },
0,
lineColor,
this.StrokeThickness,
null,
LineJoin.Miter,
true);
// Body
var openLeft = open + new ScreenVector(-candlewidth * 0.5, 0);
var rect = new OxyRect(openLeft.X, min.Y, candlewidth, max.Y - min.Y);
rc.DrawClippedRectangleAsPolygon(
clippingBar,
rect,
fillColor,
lineColor,
this.StrokeThickness);
//.........这里部分代码省略.........
示例7: RenderItem
/// <summary>
/// Renders the bar/column item.
/// </summary>
/// <param name="rc">
/// The render context.
/// </param>
/// <param name="clippingRect">
/// The clipping rectangle.
/// </param>
/// <param name="topValue">
/// The end value of the bar.
/// </param>
/// <param name="categoryValue">
/// The category value.
/// </param>
/// <param name="actualBarWidth">
/// The actual width of the bar.
/// </param>
/// <param name="item">
/// The item.
/// </param>
/// <param name="rect">
/// The rectangle of the bar.
/// </param>
protected virtual void RenderItem(
IRenderContext rc,
OxyRect clippingRect,
double topValue,
double categoryValue,
double actualBarWidth,
BarItemBase item,
OxyRect rect)
{
// Get the color of the item
var actualFillColor = item.Color;
if (actualFillColor == null)
{
actualFillColor = this.ActualFillColor;
if (item.Value < 0 && this.NegativeFillColor != null)
{
actualFillColor = this.NegativeFillColor;
}
}
rc.DrawClippedRectangleAsPolygon(
rect, clippingRect, this.GetSelectableFillColor(actualFillColor), this.StrokeColor, this.StrokeThickness);
}
示例8: Render
/// <summary>
/// Renders the series on the specified rendering context.
/// </summary>
/// <param name="rc">The rendering context.</param>
public override void Render(IRenderContext rc)
{
if (this.data == null || this.data.Count == 0)
{
return;
}
var items = this.data;
var nitems = this.data.Count;
this.VerifyAxes();
var clipping = this.GetClippingRect();
var datacandlewidth = (this.BarWidth > 0) ? this.BarWidth : this.minDx * 0.80;
var candlewidth =
this.XAxis.Transform(items[0].X + datacandlewidth) -
this.XAxis.Transform(items[0].X) - this.StrokeThickness;
// colors
var fillUp = this.GetSelectableFillColor(this.PositiveColor);
var fillDown = this.GetSelectableFillColor(this.NegativeColor);
var barfillUp = this.PositiveHollow ? OxyColors.Transparent : fillUp;
var barfillDown = this.NegativeHollow ? OxyColors.Transparent : fillDown;
var lineUp = this.GetSelectableColor(this.PositiveColor.ChangeIntensity(this.StrokeIntensity));
var lineDown = this.GetSelectableColor(this.NegativeColor.ChangeIntensity(this.StrokeIntensity));
// determine render range
var xmin = this.XAxis.ActualMinimum;
var xmax = this.XAxis.ActualMaximum;
this.winIndex = OhlcvItem.FindIndex(items, xmin, this.winIndex);
for (int i = this.winIndex; i < nitems; i++)
{
var bar = items[i];
// if item beyond visible range, done
if (bar.X > xmax)
{
break;
}
// check to see whether is valid
if (!bar.IsValid())
{
continue;
}
var leftX = this.XAxis.Transform(bar.X) - (this.BarWidth / 2.0);
var y0 = this.YAxis.Transform(0);
switch (this.VolumeStyle)
{
case VolumeStyle.Combined:
{
var adj = this.YAxis.Transform(Math.Abs(bar.BuyVolume - bar.SellVolume));
var fillcolor = (bar.BuyVolume > bar.SellVolume) ? barfillUp : barfillDown;
var linecolor = (bar.BuyVolume > bar.SellVolume) ? lineUp : lineDown;
var rect1 = new OxyRect(leftX, adj, candlewidth, Math.Abs(adj - y0));
rc.DrawClippedRectangleAsPolygon(clipping, rect1, fillcolor, linecolor, this.StrokeThickness);
}
break;
case VolumeStyle.PositiveNegative:
{
var buyY = this.YAxis.Transform(bar.BuyVolume);
var sellY = this.YAxis.Transform(-bar.SellVolume);
var rect1 = new OxyRect(leftX, buyY, candlewidth, Math.Abs(buyY - y0));
rc.DrawClippedRectangleAsPolygon(clipping, rect1, fillUp, lineUp, this.StrokeThickness);
var rect2 = new OxyRect(leftX, y0, candlewidth, Math.Abs(sellY - y0));
rc.DrawClippedRectangleAsPolygon(clipping, rect2, fillDown, lineDown, this.StrokeThickness);
}
break;
case VolumeStyle.Stacked:
if (bar.BuyVolume > bar.SellVolume)
{
var buyY = this.YAxis.Transform(bar.BuyVolume);
var sellY = this.YAxis.Transform(bar.SellVolume);
var dyoffset = sellY - y0;
var rect2 = new OxyRect(leftX, sellY, candlewidth, Math.Abs(sellY - y0));
rc.DrawClippedRectangleAsPolygon(clipping, rect2, fillDown, lineDown, this.StrokeThickness);
var rect1 = new OxyRect(leftX, buyY + dyoffset, candlewidth, Math.Abs(buyY - y0));
rc.DrawClippedRectangleAsPolygon(clipping, rect1, fillUp, lineUp, this.StrokeThickness);
}
else
{
var buyY = this.YAxis.Transform(bar.BuyVolume);
var sellY = this.YAxis.Transform(bar.SellVolume);
var dyoffset = buyY - y0;
var rect1 = new OxyRect(leftX, buyY, candlewidth, Math.Abs(buyY - y0));
rc.DrawClippedRectangleAsPolygon(clipping, rect1, fillUp, lineUp, this.StrokeThickness);
//.........这里部分代码省略.........
示例9: Render
/// <summary>
/// Renders the series on the specified rendering context.
/// </summary>
/// <param name="rc">
/// The rendering context.
/// </param>
/// <param name="model">
/// The owner plot model.
/// </param>
public override void Render(IRenderContext rc, PlotModel model)
{
if (this.Items.Count == 0)
{
return;
}
this.VerifyAxes();
var clippingRect = this.GetClippingRect();
foreach (var v in this.Items)
{
if (!this.IsValidItem(v, this.XAxis, this.YAxis))
{
continue;
}
if (this.StrokeThickness > 0 && this.LineStyle != LineStyle.None)
{
var high = this.Transform(v.X, v.High);
var low = this.Transform(v.X, v.Low);
if (double.IsNaN(v.Open) || double.IsNaN(v.Close))
{
rc.DrawClippedLine(
new[] { low, high },
clippingRect,
0,
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
this.LineStyle,
this.LineJoin,
false);
}
else
{
var open = this.Transform(v.X, v.Open);
var close = this.Transform(v.X, v.Close);
var max = new ScreenPoint(open.X, Math.Max(open.Y, close.Y));
var min = new ScreenPoint(open.X, Math.Min(open.Y, close.Y));
rc.DrawClippedLine(
new[] { high, min },
clippingRect,
0,
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
this.LineStyle,
this.LineJoin,
true);
rc.DrawClippedLine(
new[] { max, low },
clippingRect,
0,
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
this.LineStyle,
this.LineJoin,
true);
var openLeft = open;
openLeft.X -= this.CandleWidth * 0.5;
var closeRight = close;
closeRight.X += this.CandleWidth * 0.5;
var rect = new OxyRect(openLeft.X, min.Y, this.CandleWidth, max.Y - min.Y);
rc.DrawClippedRectangleAsPolygon(
rect, clippingRect, v.Open > v.Close ? this.GetSelectableFillColor(this.ActualColor) : null, this.GetSelectableColor(this.ActualColor), this.StrokeThickness);
}
}
}
}
示例10: RenderBars
/// <summary>
/// Renders the series bars.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="clippingRect">The clipping rectangle.</param>
/// <param name="actualPoints">The list of points that should be rendered.</param>
private void RenderBars(IRenderContext rc, OxyRect clippingRect, List<DataPoint> actualPoints)
{
var widthOffset = this.GetBarWidth(actualPoints) / 2;
for (var pointIndex = 0; pointIndex < actualPoints.Count; pointIndex++)
{
var actualPoint = actualPoints[pointIndex];
if (!this.IsValidPoint(actualPoint))
{
continue;
}
var screenPoint = Translate(this.Transform(actualPoint), -widthOffset);
var basePoint = Translate(this.Transform(new DataPoint(actualPoint.X, 0)), widthOffset);
var rectangle = new OxyRect(basePoint, screenPoint);
this.rectangles.Add(rectangle);
this.rectanglesPointIndexes.Add(pointIndex);
var barColors = this.GetBarColors(actualPoint.Y);
rc.DrawClippedRectangleAsPolygon(clippingRect, rectangle, barColors.FillColor, barColors.StrokeColor, this.StrokeThickness);
}
}
示例11: Render
/// <summary>
/// Renders the series on the specified rendering context.
/// </summary>
/// <param name="rc">The rendering context.</param>
public override void Render(IRenderContext rc)
{
var nitems = this.Items.Count;
var items = this.Items;
if (nitems == 0 || this.StrokeThickness <= 0 || this.LineStyle == LineStyle.None)
{
return;
}
this.VerifyAxes();
var clippingRect = this.GetClippingRect();
var dashArray = this.LineStyle.GetDashArray();
var datacandlewidth = (this.CandleWidth > 0) ? this.CandleWidth : this.minDx * 0.80;
var candlewidth =
this.XAxis.Transform(items[0].X + datacandlewidth) -
this.XAxis.Transform(items[0].X);
// colors
var fillUp = this.GetSelectableFillColor(this.IncreasingColor);
var fillDown = this.GetSelectableFillColor(this.DecreasingColor);
var lineUp = this.GetSelectableColor(this.IncreasingColor.ChangeIntensity(0.70));
var lineDown = this.GetSelectableColor(this.DecreasingColor.ChangeIntensity(0.70));
// determine render range
var xmin = this.XAxis.ActualMinimum;
var xmax = this.XAxis.ActualMaximum;
this.winIndex = HighLowItem.FindIndex(items, xmin, this.winIndex);
for (int i = this.winIndex; i < nitems; i++)
{
var bar = items[i];
// if item beyond visible range, done
if (bar.X > xmax)
{
return;
}
// check to see whether is valid
if (!this.IsValidItem(bar, this.XAxis, this.YAxis))
{
continue;
}
var fillColor = bar.Close > bar.Open ? fillUp : fillDown;
var lineColor = bar.Close > bar.Open ? lineUp : lineDown;
var high = this.Transform(bar.X, bar.High);
var low = this.Transform(bar.X, bar.Low);
var open = this.Transform(bar.X, bar.Open);
var close = this.Transform(bar.X, bar.Close);
var max = new ScreenPoint(open.X, Math.Max(open.Y, close.Y));
var min = new ScreenPoint(open.X, Math.Min(open.Y, close.Y));
// Upper extent
rc.DrawClippedLine(
clippingRect,
new[] { high, min },
0,
lineColor,
this.StrokeThickness,
dashArray,
this.LineJoin,
true);
// Lower extent
rc.DrawClippedLine(
clippingRect,
new[] { max, low },
0,
lineColor,
this.StrokeThickness,
dashArray,
this.LineJoin,
true);
// Body
var openLeft = open + new ScreenVector(-candlewidth * 0.5, 0);
var rect = new OxyRect(openLeft.X, min.Y, candlewidth, max.Y - min.Y);
rc.DrawClippedRectangleAsPolygon(clippingRect, rect, fillColor, lineColor, this.StrokeThickness);
}
}
示例12: Render
/// <summary>
/// Renders the series on the specified rendering context.
/// </summary>
/// <param name="rc">The rendering context.</param>
public override void Render(IRenderContext rc)
{
if (this.Items.Count == 0)
{
return;
}
var clippingRect = this.GetClippingRect();
int startIdx = 0;
double xmax = double.MaxValue;
this.ActualBarRectangles = new List<OxyRect>();
if (this.IsXMonotonic)
{
var xmin = this.XAxis.ActualMinimum;
xmax = this.XAxis.ActualMaximum;
this.WindowStartIndex = this.UpdateWindowStartIndex(this.Items, rect => rect.X0, xmin, this.WindowStartIndex);
startIdx = this.WindowStartIndex;
}
int clipCount = 0;
for (int i = startIdx; i < this.Items.Count; i++)
{
var item = this.Items[i];
if (!this.IsValid(item.X0) || !this.IsValid(item.X1)
|| !this.IsValid(item.Y0) || !this.IsValid(item.Y1))
{
continue;
}
var p0 = this.Transform(item.X0, item.Y0);
var p1 = this.Transform(item.X1, item.Y1);
var rectangle = OxyRect.Create(p0.X, p0.Y, p1.X, p1.Y);
this.ActualBarRectangles.Add(rectangle);
rc.DrawClippedRectangleAsPolygon(
clippingRect,
rectangle,
this.GetSelectableFillColor(item.Color.GetActualColor(this.ActualFillColor)),
this.StrokeColor,
this.StrokeThickness);
if (this.LabelFormatString != null)
{
var s = StringHelper.Format(
this.ActualCulture,
this.LabelFormatString,
this.GetItem(i),
item.X0,
item.X1,
item.Y0,
item.Y1,
item.Title);
var pt = new ScreenPoint(
(rectangle.Left + rectangle.Right) / 2, (rectangle.Top + rectangle.Bottom) / 2);
rc.DrawClippedText(
clippingRect,
pt,
s,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
HorizontalAlignment.Center,
VerticalAlignment.Middle);
}
clipCount += item.X0 > xmax ? 1 : 0;
if (clipCount > 1)
{
break;
}
}
}