本文整理汇总了C#中OxyPlot.OxyRect.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# OxyRect.Contains方法的具体用法?C# OxyRect.Contains怎么用?C# OxyRect.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OxyPlot.OxyRect
的用法示例。
在下文中一共展示了OxyRect.Contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderPointLabels
/// <summary>
/// Renders the point labels.
/// </summary>
/// <param name="rc">The render context.</param>
/// <param name="clippingRect">The clipping rect.</param>
protected void RenderPointLabels(IRenderContext rc, OxyRect clippingRect)
{
int index = -1;
foreach (var point in this.Points)
{
index++;
if (!this.IsValidPoint(point, this.XAxis, this.YAxis))
{
continue;
}
var pt = this.XAxis.Transform(point.X, point.Y, this.YAxis);
pt.Y -= this.LabelMargin;
if (!clippingRect.Contains(pt))
{
continue;
}
var s = StringHelper.Format(
this.ActualCulture, this.LabelFormatString, this.GetItem(index), 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 = HorizontalTextAlign.Right;
break;
case LabelPlacement.Middle:
pt = new ScreenPoint((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2);
ha = HorizontalTextAlign.Center;
break;
case LabelPlacement.Base:
pt = new ScreenPoint(rect.Left + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
ha = HorizontalTextAlign.Left;
break;
default: // Outside
pt = new ScreenPoint(rect.Right + this.LabelMargin, (rect.Top + rect.Bottom) / 2);
ha = HorizontalTextAlign.Left;
break;
}
#endif
rc.DrawClippedText(
clippingRect,
pt,
s,
this.ActualTextColor,
this.ActualFont,
this.ActualFontSize,
this.ActualFontWeight,
0,
HorizontalTextAlign.Center,
VerticalTextAlign.Bottom);
}
}
示例2: 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;
}
示例3: DrawClippedText
/// <summary>
/// Draws the clipped text.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="clippingRectangle">The clipping rectangle.</param>
/// <param name="p">The position.</param>
/// <param name="text">The text.</param>
/// <param name="fill">The fill color.</param>
/// <param name="fontFamily">The font family.</param>
/// <param name="fontSize">Size of the font.</param>
/// <param name="fontWeight">The font weight.</param>
/// <param name="rotate">The rotation angle.</param>
/// <param name="horizontalAlignment">The horizontal align.</param>
/// <param name="verticalAlignment">The vertical align.</param>
/// <param name="maxSize">Size of the max.</param>
public static void DrawClippedText(
this IRenderContext rc,
OxyRect clippingRectangle,
ScreenPoint p,
string text,
OxyColor fill,
string fontFamily = null,
double fontSize = 10,
double fontWeight = 500,
double rotate = 0,
HorizontalAlignment horizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment verticalAlignment = VerticalAlignment.Top,
OxySize? maxSize = null)
{
if (rc.SetClip(clippingRectangle))
{
rc.DrawText(p, text, fill, fontFamily, fontSize, fontWeight, rotate, horizontalAlignment, verticalAlignment, maxSize);
rc.ResetClip();
return;
}
// fall back simply check position
if (clippingRectangle.Contains(p.X, p.Y))
{
rc.DrawText(p, text, fill, fontFamily, fontSize, fontWeight, rotate, horizontalAlignment, verticalAlignment, maxSize);
}
}
示例4: DrawClippedText
/// <summary>
/// Draws the clipped text.
/// </summary>
/// <param name="rc">The rendering context.</param>
/// <param name="clippingRectangle">The clipping rectangle.</param>
/// <param name="p">The position.</param>
/// <param name="text">The text.</param>
/// <param name="fill">The fill color.</param>
/// <param name="fontFamily">The font family.</param>
/// <param name="fontSize">Size of the font.</param>
/// <param name="fontWeight">The font weight.</param>
/// <param name="rotate">The rotation angle.</param>
/// <param name="horizontalAlignment">The horizontal align.</param>
/// <param name="verticalAlignment">The vertical align.</param>
/// <param name="maxSize">Size of the max.</param>
public static void DrawClippedText(
this IRenderContext rc,
OxyRect clippingRectangle,
ScreenPoint p,
string text,
OxyColor fill,
string fontFamily = null,
double fontSize = 10,
double fontWeight = 500,
double rotate = 0,
HorizontalTextAlign horizontalAlignment = HorizontalTextAlign.Left,
VerticalTextAlign verticalAlignment = VerticalTextAlign.Top,
OxySize? maxSize = null)
{
if (clippingRectangle.Contains(p.X, p.Y))
{
rc.DrawText(p, text, fill, fontFamily, fontSize, fontWeight, rotate, horizontalAlignment, verticalAlignment, maxSize);
}
}
示例5: AddContourLabels
/// <summary>
/// The add contour labels.
/// </summary>
/// <param name="contour">
/// The contour.
/// </param>
/// <param name="pts">
/// The pts.
/// </param>
/// <param name="clippingRect">
/// The clipping rect.
/// </param>
/// <param name="contourLabels">
/// The contour labels.
/// </param>
private void AddContourLabels(
Contour contour, ScreenPoint[] pts, OxyRect clippingRect, List<ContourLabel> contourLabels)
{
// todo: support label spacing and label step
if (pts.Length < 2)
{
return;
}
// Calculate position and angle of the label
double i = (pts.Length - 1) * 0.5;
var i0 = (int)i;
int i1 = i0 + 1;
double dx = pts[i1].X - pts[i0].X;
double dy = pts[i1].Y - pts[i0].Y;
double x = pts[i0].X + (dx * (i - i0));
double y = pts[i0].Y + (dy * (i - i0));
if (!clippingRect.Contains(x, y))
{
return;
}
var pos = new ScreenPoint(x, y);
double angle = Math.Atan2(dy, dx) * 180 / Math.PI;
if (angle > 90)
{
angle -= 180;
}
if (angle < -90)
{
angle += 180;
}
string text = contour.ContourLevel.ToString(this.LabelFormatString, this.ActualCulture);
contourLabels.Add(new ContourLabel { Position = pos, Angle = angle, Text = text });
}