本文整理汇总了C#中IRenderContext.DrawClippedLine方法的典型用法代码示例。如果您正苦于以下问题:C# IRenderContext.DrawClippedLine方法的具体用法?C# IRenderContext.DrawClippedLine怎么用?C# IRenderContext.DrawClippedLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRenderContext
的用法示例。
在下文中一共展示了IRenderContext.DrawClippedLine方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: RenderLine
/// <summary>
/// Renders a continuous line.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="clippingRect">The clipping rectangle.</param>
/// <param name="pointsToRender">The points to render.</param>
protected virtual void RenderLine(IRenderContext rc, OxyRect clippingRect, IList<ScreenPoint> pointsToRender)
{
var dashArray = this.ActualDashArray;
if (this.outputBuffer == null)
{
this.outputBuffer = new List<ScreenPoint>(pointsToRender.Count);
}
rc.DrawClippedLine(
clippingRect,
pointsToRender,
this.MinimumSegmentLength * this.MinimumSegmentLength,
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
dashArray,
this.LineJoin,
false,
this.outputBuffer);
}
示例3: RenderSmoothedLine
/// <summary>
/// Renders the (smoothed) line.
/// </summary>
/// <param name="rc">
/// The render context.
/// </param>
/// <param name="clippingRect">
/// The clipping rect.
/// </param>
/// <param name="pointsToRender">
/// The points to render.
/// </param>
protected virtual void RenderSmoothedLine(IRenderContext rc, OxyRect clippingRect, IList<ScreenPoint> pointsToRender)
{
rc.DrawClippedLine(
pointsToRender,
clippingRect,
this.MinimumSegmentLength * this.MinimumSegmentLength,
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
this.ActualLineStyle,
this.LineJoin,
false);
}
示例4: Render
/// <summary>
/// Renders the LineSeries 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.Points.Count == 0)
{
return;
}
this.VerifyAxes();
var clippingRect = this.GetClippingRect();
Action<IList<ScreenPoint>, IList<ScreenPoint>> renderPoints = (lpts, mpts) =>
{
var lineStyle = this.ActualLineStyle;
// clip the line segments with the clipping rectangle
if (this.StrokeThickness > 0 && lineStyle != LineStyle.None)
{
var verticalStrokeThickness = double.IsNaN(this.VerticalStrokeThickness)
? this.StrokeThickness
: this.VerticalStrokeThickness;
if (!verticalStrokeThickness.Equals(this.StrokeThickness) || this.VerticalLineStyle != lineStyle)
{
var hlpts = new List<ScreenPoint>();
var vlpts = new List<ScreenPoint>();
for (int i = 0; i + 2 < lpts.Count; i += 2)
{
hlpts.Add(lpts[i]);
hlpts.Add(lpts[i + 1]);
vlpts.Add(lpts[i + 1]);
vlpts.Add(lpts[i + 2]);
}
rc.DrawClippedLineSegments(
hlpts,
clippingRect,
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
lineStyle,
this.LineJoin,
false);
rc.DrawClippedLineSegments(
vlpts,
clippingRect,
this.GetSelectableColor(this.ActualColor),
verticalStrokeThickness,
this.VerticalLineStyle,
this.LineJoin,
false);
}
else
{
rc.DrawClippedLine(
lpts,
clippingRect,
0,
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
lineStyle,
this.LineJoin,
false);
}
}
if (this.MarkerType != MarkerType.None)
{
rc.DrawMarkers(
mpts,
clippingRect,
this.MarkerType,
this.MarkerOutline,
new[] { this.MarkerSize },
this.MarkerFill,
this.MarkerStroke,
this.MarkerStrokeThickness);
}
};
// Transform all points to screen coordinates
// Render the line when invalid points occur
var linePoints = new List<ScreenPoint>();
var markerPoints = new List<ScreenPoint>();
double previousY = double.NaN;
foreach (var point in this.Points)
{
if (!this.IsValidPoint(point, this.XAxis, this.YAxis))
{
renderPoints(linePoints, markerPoints);
linePoints.Clear();
markerPoints.Clear();
previousY = double.NaN;
//.........这里部分代码省略.........
示例5: 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();
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);
}
//.........这里部分代码省略.........
示例6: RenderLine
/// <summary>
/// Renders the smoothed line.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="clippingRect">The clipping rectangle.</param>
/// <param name="pointsToRender">The points.</param>
protected override void RenderLine(IRenderContext rc, OxyRect clippingRect, IList<ScreenPoint> pointsToRender)
{
double bottom = clippingRect.Bottom;
// todo: this does not work when y axis is reversed
double y = this.YAxis.Transform(this.Limit);
if (y < clippingRect.Top)
{
y = clippingRect.Top;
}
if (y > clippingRect.Bottom)
{
y = clippingRect.Bottom;
}
var dashArray = this.ActualDashArray;
var dashArray2 = this.ActualDashArray2;
clippingRect = new OxyRect(clippingRect.Left, clippingRect.Top, clippingRect.Width, y - clippingRect.Top);
rc.DrawClippedLine(
clippingRect,
pointsToRender,
this.MinimumSegmentLength * this.MinimumSegmentLength,
this.GetSelectableColor(this.ActualColor),
this.StrokeThickness,
dashArray,
this.LineJoin,
false);
clippingRect = new OxyRect(clippingRect.Left, y, clippingRect.Width, bottom - y);
rc.DrawClippedLine(
clippingRect,
pointsToRender,
this.MinimumSegmentLength * this.MinimumSegmentLength,
this.GetSelectableColor(this.ActualColor2),
this.StrokeThickness,
dashArray2,
this.LineJoin,
false);
}
示例7: Render
/// <summary>
/// Renders the arrow annotation.
/// </summary>
/// <param name="rc">
/// The render context.
/// </param>
/// <param name="model">
/// The plot model.
/// </param>
public override void Render(IRenderContext rc, PlotModel model)
{
base.Render(rc, model);
this.screenEndPoint = this.Transform(this.EndPoint);
if (!this.ArrowDirection.x.IsZero() || !this.ArrowDirection.y.IsZero())
{
this.screenStartPoint = this.screenEndPoint - this.ArrowDirection;
}
else
{
this.screenStartPoint = this.Transform(this.StartPoint);
}
var d = this.screenEndPoint - this.screenStartPoint;
d.Normalize();
var n = new ScreenVector(d.Y, -d.X);
var p1 = this.screenEndPoint - (d * this.HeadLength * this.StrokeThickness);
var p2 = p1 + (n * this.HeadWidth * this.StrokeThickness);
var p3 = p1 - (n * this.HeadWidth * this.StrokeThickness);
var p4 = p1 + (d * this.Veeness * this.StrokeThickness);
OxyRect clippingRect = this.GetClippingRect();
const double MinimumSegmentLength = 4;
rc.DrawClippedLine(
new[] { this.screenStartPoint, p4 },
clippingRect,
MinimumSegmentLength * MinimumSegmentLength,
this.GetSelectableColor(this.Color),
this.StrokeThickness,
this.LineStyle,
this.LineJoin,
false);
rc.DrawClippedPolygon(
new[] { p3, this.screenEndPoint, p2, p4 },
clippingRect,
MinimumSegmentLength * MinimumSegmentLength,
this.GetSelectableColor(this.Color),
null);
if (!string.IsNullOrEmpty(this.Text))
{
var ha = d.X < 0 ? HorizontalAlignment.Left : HorizontalAlignment.Right;
var va = d.Y < 0 ? VerticalAlignment.Top : VerticalAlignment.Bottom;
var textPoint = this.screenStartPoint;
rc.DrawClippedText(
clippingRect,
textPoint,
this.Text,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
ha,
va);
}
}
示例8: Render
//.........这里部分代码省略.........
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);
var rect2 = new OxyRect(leftX, sellY + dyoffset, candlewidth, Math.Abs(sellY - y0));
rc.DrawClippedRectangleAsPolygon(clipping, rect2, fillDown, lineDown, this.StrokeThickness);
}
break;
}
}
// draw volume y=0 line
var intercept = this.YAxis.Transform(0);
rc.DrawClippedLine(
clipping,
new[] { new ScreenPoint(clipping.Left, intercept), new ScreenPoint(clipping.Right, intercept) },
0,
this.InterceptColor,
this.InterceptStrokeThickness,
this.InterceptLineStyle.GetDashArray(),
LineJoin.Miter,
true);
}
示例9: Render
/// <summary>
/// Renders the series on the specified rendering context.
/// </summary>
/// <param name="rc"></param>
/// <param name="model"></param>
public override void Render(IRenderContext rc, PlotModel model)
{
// Check if number of error points is equal to number of data points
if (Points.Count != ErrorValues.Count)
{
throw new InvalidOperationException();
}
// Render data line
base.Render(rc, model);
// Render error points
for (int i = 0; i < Points.Count; i++)
{
var x = Points[i].X;
var y = Points[i].Y;
var error = ErrorValues[i];
var low = y - error;
var high = y + error;
var leftValue = x - 0.5 * ErrorWidth;
var middleValue = x;
var rightValue = x + 0.5 * ErrorWidth;
var lowerErrorPoint = this.Transform(middleValue, low);
var upperErrorPoint = this.Transform(middleValue, high);
// Draw vertical bar
rc.DrawClippedLine
(
new List<ScreenPoint> { lowerErrorPoint, upperErrorPoint },
GetClippingRect(),
0.0,
ActualColor,
1.0,
null, // LineStyle.Solid,
OxyPenLineJoin.Miter,
true
);
// Draw bottom horizontal bar
var lowerLeftErrorPoint = this.Transform(leftValue, low);
var lowerRightErrorPoint = this.Transform(rightValue, low);
rc.DrawClippedLine
(
new List<ScreenPoint> { lowerLeftErrorPoint, lowerRightErrorPoint },
GetClippingRect(),
0,
ActualColor,
1.0,
null, // LineStyle.Solid,
OxyPenLineJoin.Miter,
true
);
// Draw top horizonal bar
var upperLeftErrorPoint = this.Transform(leftValue, high);
var upperRightErrorPoint = this.Transform(rightValue, high);
rc.DrawClippedLine
(
new List<ScreenPoint> { upperLeftErrorPoint, upperRightErrorPoint },
GetClippingRect(),
0,
ActualColor,
1.0,
null, // LineStyle.Solid,
OxyPenLineJoin.Miter,
true
);
}
}
示例10: 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);
}
}
}
}
示例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 actualPoints = this.ActualPoints;
var actualPoints2 = this.points2;
int n0 = actualPoints.Count;
if (n0 == 0)
{
return;
}
this.VerifyAxes();
double minDistSquared = this.MinimumSegmentLength * this.MinimumSegmentLength;
var clippingRect = this.GetClippingRect();
rc.SetClip(clippingRect);
// Transform all points to screen coordinates
IList<ScreenPoint> pts0 = new List<ScreenPoint>();
for (int i = 0; i < n0; i++)
{
pts0.Add(this.XAxis.Transform(actualPoints[i].X, actualPoints[i].Y, this.YAxis));
}
int n1 = actualPoints2.Count;
IList<ScreenPoint> pts1 = new ScreenPoint[n1];
for (int i = 0; i < n1; i++)
{
int j = n1 - 1 - i;
pts1[j] = this.XAxis.Transform(actualPoints2[i].X, actualPoints2[i].Y, this.YAxis);
}
if (this.Smooth)
{
var rpts0 = ScreenPointHelper.ResamplePoints(pts0, this.MinimumSegmentLength);
// var rpts1 = ScreenPointHelper.ResamplePoints(pts1, this.MinimumSegmentLength);
pts0 = CanonicalSplineHelper.CreateSpline(rpts0, 0.5, null, false, 0.25);
// pts1 = CanonicalSplineHelper.CreateSpline(rpts1, 0.5, null, false, 0.25);
}
var dashArray = this.ActualDashArray;
var dashArray2 = this.ActualDashArray2;
var limit = this.YAxis.Transform(this.Limit);
if (limit < clippingRect.Top)
{
limit = clippingRect.Top;
}
if (limit > clippingRect.Bottom)
{
limit = clippingRect.Bottom;
}
var markerSizes = new[] { this.MarkerSize };
var bottom = clippingRect.Bottom;
var top = clippingRect.Top;
clippingRect.Top = limit;
clippingRect.Height = bottom - limit;
// draw the clipped lines belove the limit line
rc.DrawClippedLine(
clippingRect,
pts0,
minDistSquared,
this.GetSelectableColor(this.ActualColor2),
this.StrokeThickness,
dashArray2,
this.LineJoin,
false);
// combine the two lines and draw the clipped area
var pts = new List<ScreenPoint>();
pts.AddRange(pts1);
pts.AddRange(pts0);
// fill the area belove the limit line
rc.DrawClippedPolygon(clippingRect, pts, minDistSquared, this.GetSelectableFillColor(this.ActuallFill2), OxyColors.Undefined);
// draw the markers on line belove the limit line
rc.DrawMarkers(
clippingRect,
pts0,
this.MarkerType,
null,
markerSizes,
this.MarkerFill2,
//.........这里部分代码省略.........
示例12: 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)
{
base.Render(rc, model);
if (this.contours == null)
{
this.CalculateContours();
}
if (this.contours.Count == 0)
{
return;
}
if (this.XAxis == null || this.YAxis == null)
{
this.Trace("Axis not defined.");
return;
}
OxyRect clippingRect = this.GetClippingRect();
var contourLabels = new List<ContourLabel>();
foreach (var contour in this.contours)
{
if (this.StrokeThickness > 0 && this.LineStyle != LineStyle.None)
{
var pts = new ScreenPoint[contour.Points.Count];
{
int i = 0;
foreach (var pt in contour.Points)
{
pts[i++] = this.Transform(pt.X, pt.Y);
}
}
rc.DrawClippedLine(
pts,
clippingRect,
4,
this.GetSelectableColor(contour.Color ?? this.ActualColor),
this.StrokeThickness,
this.LineStyle,
OxyPenLineJoin.Miter,
false);
// rc.DrawClippedPolygon(pts, clippingRect, 4, model.GetDefaultColor(), OxyColors.Black);
if (pts.Length > 10)
{
this.AddContourLabels(contour, pts, clippingRect, contourLabels);
}
}
}
foreach (var cl in contourLabels)
{
this.RenderLabelBackground(rc, cl);
}
foreach (var cl in contourLabels)
{
this.RenderLabel(rc, cl);
}
}
示例13: 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)
{
base.Render(rc, model);
var points = this.Points;
if (points.Count == 0)
{
return;
}
if (this.XAxis == null || this.YAxis == null)
{
Trace("Axis not defined.");
return;
}
var clippingRect = GetClippingRect();
int n = points.Count;
// Transform all points to screen coordinates
var segments = new List<ScreenPoint>(n * 6);
for (int i = 0; i < n; i++)
{
var sp = XAxis.Transform(points[i].X, points[i].Y, YAxis);
var ei = points[i] as ErrorItem;
double errorx = ei != null ? ei.XError * XAxis.Scale : 0;
double errory = ei != null ? ei.YError * Math.Abs(YAxis.Scale) : 0;
double d = 4;
if (errorx > 0)
{
var p0 = new ScreenPoint(sp.X - (errorx * 0.5), sp.Y);
var p1 = new ScreenPoint(sp.X + (errorx * 0.5), sp.Y);
segments.Add(p0);
segments.Add(p1);
segments.Add(new ScreenPoint(p0.X, p0.Y - d));
segments.Add(new ScreenPoint(p0.X, p0.Y + d));
segments.Add(new ScreenPoint(p1.X, p1.Y - d));
segments.Add(new ScreenPoint(p1.X, p1.Y + d));
}
if (errory > 0)
{
var p0 = new ScreenPoint(sp.X, sp.Y - (errory * 0.5));
var p1 = new ScreenPoint(sp.X, sp.Y + (errory * 0.5));
segments.Add(p0);
segments.Add(p1);
segments.Add(new ScreenPoint(p0.X - d, p0.Y));
segments.Add(new ScreenPoint(p0.X + d, p0.Y));
segments.Add(new ScreenPoint(p1.X - d, p1.Y));
segments.Add(new ScreenPoint(p1.X + d, p1.Y));
}
}
// clip the line segments with the clipping rectangle
for (int i = 0; i + 1 < segments.Count; i += 2)
{
rc.DrawClippedLine(
new[] { segments[i], segments[i + 1] },
clippingRect,
2,
this.GetSelectableColor(this.Color),
this.StrokeThickness,
LineStyle.Solid,
OxyPenLineJoin.Bevel,
true);
}
}
示例14: Render
/// <summary>
/// Renders the annotation on the specified context.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="model">The model.</param>
public override void Render(IRenderContext rc, PlotModel model)
{
base.Render(rc, model);
this.CalculateActualMinimumsMaximums();
this.screenPoints = this.GetScreenPoints();
// clip to the area defined by the axes
var clippingRectangle = OxyRect.Create(
this.ClipByXAxis ? this.XAxis.ScreenMin.X : PlotModel.PlotArea.Left,
this.ClipByYAxis ? this.YAxis.ScreenMin.Y : PlotModel.PlotArea.Top,
this.ClipByXAxis ? this.XAxis.ScreenMax.X : PlotModel.PlotArea.Right,
this.ClipByYAxis ? this.YAxis.ScreenMax.Y : PlotModel.PlotArea.Bottom);
const double MinimumSegmentLength = 4;
var clippedPoints = new List<ScreenPoint>();
var dashArray = this.LineStyle.GetDashArray();
rc.DrawClippedLine(
clippingRectangle,
this.screenPoints,
MinimumSegmentLength * MinimumSegmentLength,
this.GetSelectableColor(this.Color),
this.StrokeThickness,
dashArray,
this.LineJoin,
this.aliased,
null,
clippedPoints.AddRange);
ScreenPoint position;
double angle;
double margin = this.TextMargin;
if (this.TextHorizontalAlignment == HorizontalAlignment.Center)
{
margin = 0;
}
else
{
margin *= this.TextLinePosition < 0.5 ? 1 : -1;
}
if (GetPointAtRelativeDistance(clippedPoints, this.TextLinePosition, margin, out position, out angle))
{
if (angle < -90)
{
angle += 180;
}
if (angle > 90)
{
angle -= 180;
}
switch (this.TextOrientation)
{
case AnnotationTextOrientation.Horizontal:
angle = 0;
break;
case AnnotationTextOrientation.Vertical:
angle = -90;
break;
}
// Apply 'padding' to the position
var angleInRadians = angle / 180 * Math.PI;
var f = 1;
if (this.TextHorizontalAlignment == HorizontalAlignment.Right)
{
f = -1;
}
if (this.TextHorizontalAlignment == HorizontalAlignment.Center)
{
f = 0;
}
position += new ScreenVector(f * this.TextPadding * Math.Cos(angleInRadians), f * this.TextPadding * Math.Sin(angleInRadians));
if (!string.IsNullOrEmpty(this.Text))
{
var textPosition = this.GetActualTextPosition(() => position);
if (this.TextPosition.IsDefined())
{
angle = this.TextRotation;
}
if (this.ClipText)
{
var cs = new CohenSutherlandClipping(clippingRectangle);
//.........这里部分代码省略.........
示例15: Render
//.........这里部分代码省略.........
else if (fy != null)
{
double y = actualMinimumY;
// todo: the step size should be adaptive
double dy = (actualMaximumY - actualMinimumY) / 100;
while (true)
{
points.Add(new DataPoint(fy(y), y));
if (y > actualMaximumY)
{
break;
}
y += dy;
}
}
}
// transform to screen coordinates
this.screenPoints = points.Select(p => this.Transform(p)).ToList();
// clip to the area defined by the axes
var clippingRectangle = OxyRect.Create(
this.ClipByXAxis ? this.XAxis.ScreenMin.X : PlotModel.PlotArea.Left,
this.ClipByYAxis ? this.YAxis.ScreenMin.Y : PlotModel.PlotArea.Top,
this.ClipByXAxis ? this.XAxis.ScreenMax.X : PlotModel.PlotArea.Right,
this.ClipByYAxis ? this.YAxis.ScreenMax.Y : PlotModel.PlotArea.Bottom);
const double MinimumSegmentLength = 4;
IList<ScreenPoint> clippedPoints = null;
rc.DrawClippedLine(
this.screenPoints,
clippingRectangle,
MinimumSegmentLength * MinimumSegmentLength,
this.GetSelectableColor(this.Color),
this.StrokeThickness,
this.LineStyle,
this.LineJoin,
aliased,
pts => clippedPoints = pts);
ScreenPoint position;
double angle;
double margin = this.TextMargin;
if (this.TextHorizontalAlignment == HorizontalAlignment.Center)
{
margin = 0;
}
else
{
margin *= this.TextPosition < 0.5 ? 1 : -1;
}
if (clippedPoints != null && GetPointAtRelativeDistance(clippedPoints, this.TextPosition, margin, out position, out angle))
{
if (angle < -90)
{
angle += 180;
}
if (angle > 90)
{