本文整理汇总了C#中OxyRect类的典型用法代码示例。如果您正苦于以下问题:C# OxyRect类的具体用法?C# OxyRect怎么用?C# OxyRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OxyRect类属于命名空间,在下文中一共展示了OxyRect类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ClipPolygon
public void ClipPolygon()
{
var bounds = new OxyRect(0, 0, 1, 1);
var points = CreatePointList();
var result = SutherlandHodgmanClipping.ClipPolygon(bounds, points);
Assert.AreEqual(4, result.Count);
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:7,代码来源:SutherlandHodgmanClippingTests.cs
示例2: Render
/// <summary>
/// Renders the polygon annotation.
/// </summary>
/// <param name="rc">The render context.</param>
public override void Render(IRenderContext rc)
{
base.Render(rc);
this.screenRectangle = new OxyRect(this.Transform(this.X - (this.Width / 2), this.Y - (this.Height / 2)), this.Transform(this.X + (this.Width / 2), this.Y + (this.Height / 2)));
// clip to the area defined by the axes
var clippingRectangle = this.GetClippingRect();
rc.DrawClippedEllipse(
clippingRectangle,
this.screenRectangle,
this.GetSelectableFillColor(this.Fill),
this.GetSelectableColor(this.Stroke),
this.StrokeThickness);
if (!string.IsNullOrEmpty(this.Text))
{
var textPosition = this.GetActualTextPosition(() => this.screenRectangle.Center);
rc.DrawClippedText(
clippingRectangle,
textPosition,
this.Text,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
this.TextRotation,
this.TextHorizontalAlignment,
this.TextVerticalAlignment);
}
}
开发者ID:Keyabob,项目名称:MMG,代码行数:36,代码来源:EllipseAnnotation.cs
示例3: CohenSutherlandClipping
/// <summary>
/// Initializes a new instance of the <see cref="CohenSutherlandClipping" /> class.
/// </summary>
/// <param name="rect">The clipping rectangle.</param>
public CohenSutherlandClipping(OxyRect rect)
{
this.xmin = rect.Left;
this.xmax = rect.Right;
this.ymin = rect.Top;
this.ymax = rect.Bottom;
}
开发者ID:Celderon,项目名称:oxyplot,代码行数:11,代码来源:CohenSutherlandClipping.cs
示例4: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
this.SetAlias(false);
var convertedRectangle = rect.Convert();
if (fill.IsVisible())
{
this.SetFill(fill);
using (var path = new CGPath())
{
path.AddEllipseInRect(convertedRectangle);
this.gctx.AddPath(path);
}
this.gctx.DrawPath(CGPathDrawingMode.Fill);
}
if (stroke.IsVisible() && thickness > 0)
{
this.SetStroke(stroke, thickness);
using (var path = new CGPath())
{
path.AddEllipseInRect(convertedRectangle);
this.gctx.AddPath(path);
}
this.gctx.DrawPath(CGPathDrawingMode.Stroke);
}
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:36,代码来源:CoreGraphicsRenderContext.cs
示例5: SinglePointOutside
public void SinglePointOutside()
{
var points = new[] { new ScreenPoint(0, 0) };
var clippingRectangle = new OxyRect(0.3, -0.5, 0.5, 1);
var rc = Substitute.For<IRenderContext>();
var received = new List<ScreenPoint>();
rc.DrawClippedLine(clippingRectangle, points, 1, OxyColors.Black, 1, null, LineJoin.Miter, false, null, received.AddRange);
Assert.AreEqual(0, received.Count);
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:9,代码来源:RenderingExtensionsTests.cs
示例6: CrossingLine
public void CrossingLine()
{
var points = new[] { new ScreenPoint(0, 0), new ScreenPoint(100, 0) };
var clippingRectangle = new OxyRect(30, -50, 50, 100);
var rc = Substitute.For<IRenderContext>();
var received = new List<ScreenPoint>();
rc.DrawClippedLine(clippingRectangle, points, 1, OxyColors.Black, 1, null, LineJoin.Miter, false, null, received.AddRange);
Assert.AreEqual(2, received.Count);
Assert.AreEqual(new ScreenPoint(30, 0), received[0]);
Assert.AreEqual(new ScreenPoint(80, 0), received[1]);
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:11,代码来源:RenderingExtensionsTests.cs
示例7: Render
/// <summary>
/// Renders the polygon 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);
double x0 = double.IsNaN(this.MinimumX) || this.MinimumX.Equals(double.MinValue)
? this.XAxis.ActualMinimum
: this.MinimumX;
double x1 = double.IsNaN(this.MaximumX) || this.MaximumX.Equals(double.MaxValue)
? this.XAxis.ActualMaximum
: this.MaximumX;
double y0 = double.IsNaN(this.MinimumY) || this.MinimumY.Equals(double.MinValue)
? this.YAxis.ActualMinimum
: this.MinimumY;
double y1 = double.IsNaN(this.MaximumY) || this.MaximumY.Equals(double.MaxValue)
? this.YAxis.ActualMaximum
: this.MaximumY;
this.screenRectangle = new OxyRect(this.Transform(x0, y0), this.Transform(x1, y1));
// clip to the area defined by the axes
var clippingRectangle = this.GetClippingRect();
rc.DrawClippedRectangle(
clippingRectangle,
this.screenRectangle,
this.GetSelectableFillColor(this.Fill),
this.GetSelectableColor(this.Stroke),
this.StrokeThickness);
if (!string.IsNullOrEmpty(this.Text))
{
var textPosition = this.GetActualTextPosition(() => this.screenRectangle.Center);
rc.DrawClippedText(
clippingRectangle,
textPosition,
this.Text,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
this.TextRotation,
HorizontalAlignment.Center,
VerticalAlignment.Middle);
}
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:50,代码来源:RectangleAnnotation.cs
示例8: DrawEllipse
public void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness = 1)
{
using (var paint = new Paint())
{
paint.AntiAlias = true;
paint.StrokeWidth = (float)thickness;
if (fill != null)
{
paint.SetStyle(Paint.Style.Fill);
paint.Color = stroke.ToColor();
canvas.DrawOval(rect.ToRectF(), paint);
}
if (stroke != null)
{
paint.SetStyle(Paint.Style.Stroke);
paint.Color = stroke.ToColor();
canvas.DrawOval(rect.ToRectF(), paint);
}
}
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:20,代码来源:CanvasRenderContext.cs
示例9: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle defining the ellipse.</param>
/// <param name="fill">The fill.</param>
/// <param name="stroke">The stroke.</param>
/// <param name="thickness">The thickness.</param>
public void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
var el = new Ellipse();
if (stroke.IsVisible())
{
el.Stroke = stroke.ToBrush();
el.StrokeThickness = thickness;
}
if (fill.IsVisible())
{
el.Fill = fill.ToBrush();
}
el.Width = rect.Width;
el.Height = rect.Height;
Canvas.SetLeft(el, rect.Left);
Canvas.SetTop(el, rect.Top);
this.Add(el, rect.Left, rect.Top);
}
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:27,代码来源:MetroRenderContext.cs
示例10: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
// center of ellipse
var ex = rect.Left + (rect.Width / 2.0);
var ey = rect.Top + (rect.Height / 2.0);
// ellipse dimensions
var ew = rect.Width;
var eh = rect.Height;
if (fill.IsVisible())
{
this.g.Save();
this.g.Translate(ex, ey); // make (ex, ey) == (0, 0)
this.g.Scale(ew / 2.0, eh / 2.0); // for width: ew / 2.0 == 1.0, eh / 2.0 == 1.0
this.g.Arc(0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI); // 'circle' centered at (0, 0)
this.g.ClosePath();
this.g.SetSourceColor(fill);
this.g.Fill();
this.g.Restore();
}
if (stroke.IsVisible() && thickness > 0)
{
this.g.Save();
// g.SmoothingMode = SmoothingMode.HighQuality; // TODO
this.g.Translate(ex, ey); // make (ex, ey) == (0, 0)
this.g.Scale(ew / 2.0, eh / 2.0); // for width: ew / 2.0 == 1.0
// for height: eh / 2.0 == 1.0
this.g.Arc(0.0, 0.0, 1.0, 0.0, 2.0 * Math.PI); // 'circle' centered at (0, 0)
this.g.SetSourceColor(stroke);
this.g.LineWidth = thickness * 2.0 / ew;
this.g.Stroke();
this.g.Restore();
}
}
开发者ID:Celderon,项目名称:oxyplot,代码行数:47,代码来源:GraphicsRenderContext.cs
示例11: Render
/// <summary>
/// Renders the image 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);
var p = this.GetPoint(this.X, this.Y, rc, model);
var o = this.GetVector(this.OffsetX, this.OffsetY, rc, model);
var position = p + o;
var clippingRect = this.GetClippingRect();
var imageInfo = rc.GetImageInfo(this.ImageSource);
if (imageInfo == null)
{
return;
}
var s = this.GetVector(this.Width, this.Height, rc, model);
var width = s.X;
var height = s.Y;
if (double.IsNaN(width) && double.IsNaN(height))
{
width = imageInfo.Width;
height = imageInfo.Height;
}
if (double.IsNaN(width))
{
width = height / imageInfo.Height * imageInfo.Width;
}
if (double.IsNaN(height))
{
height = width / imageInfo.Width * imageInfo.Height;
}
double x = position.X;
double y = position.Y;
if (this.HorizontalAlignment == HorizontalAlignment.Center)
{
x -= width * 0.5;
}
if (this.HorizontalAlignment == HorizontalAlignment.Right)
{
x -= width;
}
if (this.VerticalAlignment == VerticalAlignment.Middle)
{
y -= height * 0.5;
}
if (this.VerticalAlignment == VerticalAlignment.Bottom)
{
y -= height;
}
this.actualBounds = new OxyRect(x, y, width, height);
if (this.X.Unit == PlotLengthUnit.Data || this.Y.Unit == PlotLengthUnit.Data)
{
rc.DrawClippedImage(clippingRect, this.ImageSource, x, y, width, height, this.Opacity, this.Interpolate);
}
else
{
rc.DrawImage(this.ImageSource, x, y, width, height, this.Opacity, this.Interpolate);
}
}
开发者ID:AndrewTPohlmann,项目名称:open-hardware-monitor,代码行数:80,代码来源:ImageAnnotation.cs
示例12: 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);
}
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:49,代码来源:CandleStickSeries.cs
示例13: DrawEllipse
public override void DrawEllipse (OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
if (fill != null)
{
ToColor(fill).SetFill();
var path = new CGPath ();
path.AddElipseInRect(ToRectangle(rect));
gctx.AddPath (path);
gctx.DrawPath (CGPathDrawingMode.Fill);
}
if (stroke == null || thickness <= 0)
{
return;
}
SetAttributes (null, stroke, thickness);
var path2 = new CGPath ();
path2.AddElipseInRect(ToRectangle(rect));
gctx.AddPath (path2);
gctx.DrawPath (CGPathDrawingMode.Stroke);
}
开发者ID:acremean,项目名称:OxyPlot.2DGraphLib.MonoTouch,代码行数:26,代码来源:MonoTouchRenderContext.cs
示例14: UpdateTransform
/// <summary>
/// Updates the scale and offset properties of the transform from the specified boundary rectangle.
/// </summary>
/// <param name="bounds">The bounds.</param>
internal override void UpdateTransform(OxyRect bounds)
{
var x0 = bounds.Left;
var x1 = bounds.Right;
var y0 = bounds.Bottom;
var y1 = bounds.Top;
this.ScreenMin = new ScreenPoint(x0, y1);
this.ScreenMax = new ScreenPoint(x1, y0);
var newScale = (this.EndAngle - this.StartAngle) / (this.ActualMaximum - this.ActualMinimum);
var newOffset = this.ActualMinimum - (this.StartAngle / newScale);
this.SetTransform(newScale, newOffset);
}
开发者ID:benjaminrupp,项目名称:oxyplot,代码行数:18,代码来源:AngleAxis.cs
示例15: SetClip
/// <summary>
/// Sets the clip rectangle.
/// </summary>
/// <param name="clippingRect">The clipping rectangle.</param>
/// <returns>True if the clip rectangle was set.</returns>
public bool SetClip(OxyRect clippingRect)
{
this.clip = clippingRect.ToRect(false);
return true;
}
开发者ID:aleksanderkobylak,项目名称:oxyplot,代码行数:10,代码来源:MetroRenderContext.cs
示例16: RenderPointLabels
/// <summary>
/// Renders the point labels.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="clippingRect">The clipping rectangle.</param>
protected void RenderPointLabels(IRenderContext rc, OxyRect clippingRect)
{
int index = -1;
foreach (var point in this.ActualPoints)
{
index++;
if (!this.IsValidPoint(point))
{
continue;
}
var pt = this.Transform(point) + new ScreenVector(0, -this.LabelMargin);
if (!clippingRect.Contains(pt))
{
continue;
}
var item = this.GetItem(index);
var s = StringHelper.Format(this.ActualCulture, this.LabelFormatString, item, point.X, point.Y);
#if SUPPORTLABELPLACEMENT
switch (this.LabelPlacement)
{
case LabelPlacement.Inside:
pt = new ScreenPoint(rect.Right - this.LabelMargin, (rect.Top + rect.Bottom) / 2);
ha = HorizontalAlignment.Right;
break;
case LabelPlacement.Middle:
pt = new ScreenPoint((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2);
ha = HorizontalAlignment.Center;
break;
case LabelPlacement.Base:
pt = new ScreenPoint(rect.Left + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
ha = HorizontalAlignment.Left;
break;
default: // Outside
pt = new ScreenPoint(rect.Right + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
ha = HorizontalAlignment.Left;
break;
}
#endif
rc.DrawClippedText(
clippingRect,
pt,
s,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
HorizontalAlignment.Center,
VerticalAlignment.Bottom);
}
}
开发者ID:Keyabob,项目名称:MMG,代码行数:62,代码来源:LineSeries.cs
示例17: 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);
}
开发者ID:Keyabob,项目名称:MMG,代码行数:26,代码来源:LineSeries.cs
示例18: UpdateTransform
/// <summary>
/// Updates the scale and offset properties of the transform from the specified boundary rectangle.
/// </summary>
/// <param name="bounds">The bounds.</param>
internal override void UpdateTransform(OxyRect bounds)
{
double x0 = bounds.Left;
double x1 = bounds.Right;
double y0 = bounds.Bottom;
double y1 = bounds.Top;
this.ScreenMin = new ScreenPoint(x0, y1);
this.ScreenMax = new ScreenPoint(x1, y0);
this.MidPoint = new ScreenPoint((x0 + x1) / 2, (y0 + y1) / 2);
// this.ActualMinimum = 0;
double r = Math.Min(Math.Abs(x1 - x0), Math.Abs(y1 - y0));
this.SetTransform(0.5 * r / (this.ActualMaximum - this.ActualMinimum), this.ActualMinimum);
}
开发者ID:Celderon,项目名称:oxyplot,代码行数:20,代码来源:MagnitudeAxis.cs
示例19: 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,
this.ActualDashArray);
var midpt = new ScreenPoint(xmid, ymid);
rc.DrawMarker(
legendBox,
midpt,
this.MarkerType,
this.MarkerOutline,
this.MarkerSize,
this.ActualMarkerFill,
this.MarkerStroke,
this.MarkerStrokeThickness);
}
开发者ID:Keyabob,项目名称:MMG,代码行数:27,代码来源:LineSeries.cs
示例20: DrawEllipse
/// <summary>
/// Draws an ellipse.
/// </summary>
/// <param name="rect">The rectangle.</param>
/// <param name="fill">The fill color.</param>
/// <param name="stroke">The stroke color.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
this.paint.Reset();
{
if (fill.IsVisible())
{
this.SetFill(fill);
this.canvas.DrawOval(this.Convert(rect), this.paint);
}
if (stroke.IsVisible())
{
this.SetStroke(stroke, thickness);
this.canvas.DrawOval(this.Convert(rect), this.paint);
}
}
}
开发者ID:Cheesebaron,项目名称:oxyplot,代码行数:24,代码来源:CanvasRenderContext.cs
注:本文中的OxyRect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论