本文整理汇总了C#中OxyPlot.OxyRect类的典型用法代码示例。如果您正苦于以下问题:C# OxyRect类的具体用法?C# OxyRect怎么用?C# OxyRect使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OxyRect类属于OxyPlot命名空间,在下文中一共展示了OxyRect类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderRect
public void RenderRect(OxyRect bounds, OxyColor fill, OxyColor borderColor, double borderThickness)
{
var border = new[]
{
new ScreenPoint(bounds.Left, bounds.Top), new ScreenPoint(bounds.Right, bounds.Top),
new ScreenPoint(bounds.Right, bounds.Bottom), new ScreenPoint(bounds.Left, bounds.Bottom),
new ScreenPoint(bounds.Left, bounds.Top)
};
rc.DrawPolygon(border, fill, borderColor, borderThickness, null, true);
}
示例2: ClipPolygon
/// <summary>
/// The Sutherland-Hodgman polygon clipping algorithm.
/// </summary>
/// <remarks>
/// See http://ezekiel.vancouver.wsu.edu/~cs442/lectures/clip/clip/index.html
/// </remarks>
/// <param name="bounds">
/// The bounds.
/// </param>
/// <param name="v">
/// The polygon points.
/// </param>
/// <returns>
/// The clipped points.
/// </returns>
public static List<ScreenPoint> ClipPolygon(OxyRect bounds, IList<ScreenPoint> v)
{
List<ScreenPoint> p1 = ClipOneAxis(bounds, RectangleEdge.Left, v);
List<ScreenPoint> p2 = ClipOneAxis(bounds, RectangleEdge.Right, p1);
List<ScreenPoint> p3 = ClipOneAxis(bounds, RectangleEdge.Top, p2);
return ClipOneAxis(bounds, RectangleEdge.Bottom, p3);
}
示例3: 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)
{
var isStroked = stroke.IsVisible() && thickness > 0;
var isFilled = fill.IsVisible();
if (!isStroked && !isFilled)
{
return;
}
double y = this.doc.PageHeight - rect.Bottom;
if (isStroked)
{
this.SetLineWidth(thickness);
this.doc.SetColor(stroke);
if (isFilled)
{
this.doc.SetFillColor(fill);
this.doc.DrawEllipse(rect.Left, y, rect.Width, rect.Height, true);
}
else
{
this.doc.DrawEllipse(rect.Left, y, rect.Width, rect.Height);
}
}
else
{
this.doc.SetFillColor(fill);
this.doc.FillEllipse(rect.Left, y, rect.Width, rect.Height);
}
}
示例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)
{
var isStroked = stroke.IsVisible() && thickness > 0;
if (fill.IsVisible())
{
if (!isStroked)
{
this.g.SmoothingMode = SmoothingMode.HighQuality;
}
this.g.FillEllipse(this.GetCachedBrush(fill), (float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height);
}
if (!isStroked)
{
return;
}
using (var pen = this.GetCachedPen(stroke, thickness))
{
this.g.SmoothingMode = SmoothingMode.HighQuality;
this.g.DrawEllipse(pen, (float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height);
}
}
示例5: ClipOneAxis
/// <summary>
/// Clips to one axis.
/// </summary>
/// <param name="bounds">The bounds.</param>
/// <param name="edge">The edge.</param>
/// <param name="v">The points of the polygon.</param>
/// <returns>The clipped points.</returns>
private static List<ScreenPoint> ClipOneAxis(OxyRect bounds, RectangleEdge edge, IList<ScreenPoint> v)
{
if (v.Count == 0)
{
return new List<ScreenPoint>();
}
var polygon = new List<ScreenPoint>(v.Count);
var s = v[v.Count - 1];
for (int i = 0; i < v.Count; ++i)
{
var p = v[i];
bool pin = IsInside(bounds, edge, p);
bool sin = IsInside(bounds, edge, s);
if (sin && pin)
{
// case 1: inside -> inside
polygon.Add(p);
}
else if (sin)
{
// case 2: inside -> outside
polygon.Add(LineIntercept(bounds, edge, s, p));
}
else if (!pin)
{
// case 3: outside -> outside
// emit nothing
}
else
{
// case 4: outside -> inside
polygon.Add(LineIntercept(bounds, edge, s, p));
polygon.Add(p);
}
s = p;
}
return polygon;
}
示例6: DrawEllipse
/// <summary>
/// Draws the ellipse.
/// </summary>
/// <param name="rect">The rect.</param>
/// <param name="fill">The fill.</param>
/// <param name="stroke">The stroke.</param>
/// <param name="thickness">The thickness.</param>
public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
if (fill != null)
{
this.g.FillEllipse(
this.ToBrush(fill), (float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height);
}
if (stroke == null || thickness <= 0)
{
return;
}
using (var pen = new Pen(this.ToColor(stroke), (float)thickness))
{
this.g.SmoothingMode = SmoothingMode.HighQuality;
this.g.DrawEllipse(pen, (float)rect.Left, (float)rect.Top, (float)rect.Width, (float)rect.Height);
}
}
示例7: SetClip
/// <summary>
/// Sets the clip rectangle.
/// </summary>
/// <param name="rect">The clip rectangle.</param>
/// <returns>
/// True if the clip rectangle was set.
/// </returns>
public bool SetClip(OxyRect rect)
{
return true;
}
示例8: 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);
}
示例9: RenderLegendOnLine
/// <summary>
/// Renders a legend on the line.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="clippingRect">The clipping rectangle.</param>
protected void RenderLegendOnLine(IRenderContext rc, OxyRect clippingRect)
{
// Find the position
IDataPoint point;
var ha = HorizontalTextAlign.Left;
double dx;
switch (this.LineLegendPosition)
{
case LineLegendPosition.Start:
// start position
point = this.Points[0];
ha = HorizontalTextAlign.Right;
dx = -4;
break;
default:
// end position
point = this.Points[this.Points.Count - 1];
dx = 4;
break;
}
var pt = this.XAxis.Transform(point.X, point.Y, this.YAxis);
pt.X += dx;
// Render the legend
rc.DrawClippedText(
clippingRect,
pt,
this.Title,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
ha,
VerticalTextAlign.Middle);
}
示例10: 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, LineStyleHelper.GetDashArray(this.ActualLineStyle));
var midpt = new ScreenPoint(xmid, ymid);
rc.DrawMarker(
midpt,
legendBox,
this.MarkerType,
this.MarkerOutline,
this.MarkerSize,
this.MarkerFill,
this.MarkerStroke,
this.MarkerStrokeThickness);
}
示例11: RenderLegends
/// <summary>
/// Renders or measures the legends.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="rect">The rectangle.</param>
private void RenderLegends(IRenderContext rc, OxyRect rect)
{
this.RenderOrMeasureLegends(rc, rect);
}
示例12: GetNearestPoint
/// <summary>
/// Gets the point on the series that is nearest the specified point.
/// </summary>
/// <param name="point">The point.</param>
/// <param name="interpolate">
/// Interpolate the series if this flag is set to <c>true</c>.
/// </param>
/// <returns>A TrackerHitResult for the current hit.</returns>
public override TrackerHitResult GetNearestPoint(ScreenPoint point, bool interpolate)
{
foreach (var v in this.Values)
{
if (double.IsNaN(v) || v < this.XAxis.ActualMinimum || v > this.XAxis.ActualMaximum)
{
continue;
}
double x = this.XAxis.Transform(v);
var r = new OxyRect(
x - this.symbolSize.Width / 2,
this.symbolPosition - this.symbolSize.Height,
this.symbolSize.Width,
this.symbolSize.Height);
if (r.Contains(point))
{
var text = StringHelper.Format(this.ActualCulture, this.TrackerFormatString, null, this.Title, v);
return new TrackerHitResult(
this,
new DataPoint(v, double.NaN),
new ScreenPoint(x, this.symbolPosition - this.symbolSize.Height)) { Text = text };
}
}
return null;
}
示例13: DrawRectangleAsPolygon
/// <summary>
/// Draws the rectangle as an aliased polygon.
/// (makes sure pixel alignment is the same as for lines)
/// </summary>
/// <param name="rc">
/// The render context.
/// </param>
/// <param name="rect">
/// The rectangle.
/// </param>
/// <param name="fill">
/// The fill.
/// </param>
/// <param name="stroke">
/// The stroke.
/// </param>
/// <param name="thickness">
/// The thickness.
/// </param>
public static void DrawRectangleAsPolygon(
this IRenderContext rc, OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
{
var sp0 = new ScreenPoint(rect.Left, rect.Top);
var sp1 = new ScreenPoint(rect.Right, rect.Top);
var sp2 = new ScreenPoint(rect.Right, rect.Bottom);
var sp3 = new ScreenPoint(rect.Left, rect.Bottom);
rc.DrawPolygon(new[] { sp0, sp1, sp2, sp3 }, fill, stroke, thickness, null, OxyPenLineJoin.Miter, true);
}
示例14: DrawMarkers
/// <summary>
/// Draws a list of markers.
/// </summary>
/// <param name="rc">
/// The render context.
/// </param>
/// <param name="markerPoints">
/// The marker points.
/// </param>
/// <param name="clippingRect">
/// The clipping rectangle.
/// </param>
/// <param name="markerType">
/// Type of the marker.
/// </param>
/// <param name="markerOutline">
/// The marker outline.
/// </param>
/// <param name="markerSize">
/// Size of the markers.
/// </param>
/// <param name="markerFill">
/// The marker fill.
/// </param>
/// <param name="markerStroke">
/// The marker stroke.
/// </param>
/// <param name="markerStrokeThickness">
/// The marker stroke thickness.
/// </param>
/// <param name="resolution">
/// The resolution.
/// </param>
/// <param name="binOffset">
/// The bin Offset.
/// </param>
public static void DrawMarkers(
this IRenderContext rc,
IList<ScreenPoint> markerPoints,
OxyRect clippingRect,
MarkerType markerType,
IList<ScreenPoint> markerOutline,
IList<double> markerSize,
OxyColor markerFill,
OxyColor markerStroke,
double markerStrokeThickness,
int resolution = 0,
ScreenPoint binOffset = new ScreenPoint())
{
if (markerType == MarkerType.None)
{
return;
}
int n = markerPoints.Count;
var ellipses = new List<OxyRect>(n);
var rects = new List<OxyRect>(n);
var polygons = new List<IList<ScreenPoint>>(n);
var lines = new List<ScreenPoint>(n);
var hashset = new HashSet<uint>();
int i = 0;
double minx = clippingRect.Left;
double maxx = clippingRect.Right;
double miny = clippingRect.Top;
double maxy = clippingRect.Bottom;
foreach (var p in markerPoints)
{
if (resolution > 1)
{
var x = (int)((p.X - binOffset.X) / resolution);
var y = (int)((p.Y - binOffset.Y) / resolution);
uint hash = (uint)(x << 16) + (uint)y;
if (hashset.Contains(hash))
{
i++;
continue;
}
hashset.Add(hash);
}
bool outside = p.x < minx || p.x > maxx || p.y < miny || p.y > maxy;
if (!outside)
{
int j = i < markerSize.Count ? i : 0;
AddMarkerGeometry(p, markerType, markerOutline, markerSize[j], ellipses, rects, polygons, lines);
}
i++;
}
if (ellipses.Count > 0)
{
rc.DrawEllipses(ellipses, markerFill, markerStroke, markerStrokeThickness);
}
//.........这里部分代码省略.........
示例15: ShowZoomRectangle
public void ShowZoomRectangle(OxyRect r)
{
zoomRectangle = new Rectangle((int)r.Left, (int)r.Top, (int)r.Width, (int)r.Height);
Invalidate();
}