本文整理汇总了C#中OxyRect类的典型用法代码示例。如果您正苦于以下问题:C# OxyRect类的具体用法?C# OxyRect怎么用?C# OxyRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OxyRect类属于命名空间,在下文中一共展示了OxyRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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]);
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
示例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();
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}