本文整理汇总了C#中OxyRect.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# OxyRect.Contains方法的具体用法?C# OxyRect.Contains怎么用?C# OxyRect.Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OxyRect
的用法示例。
在下文中一共展示了OxyRect.Contains方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
}
示例2: AddContourLabels
/// <summary>
/// The add contour labels.
/// </summary>
/// <param name="contour">The contour.</param>
/// <param name="pts">The points of the contour.</param>
/// <param name="clippingRect">The clipping rectangle.</param>
/// <param name="contourLabels">The contour labels.</param>
private void AddContourLabels(Contour contour, ScreenPoint[] pts, OxyRect clippingRect, ICollection<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;
}
var formatString = string.Concat("{0:", this.LabelFormatString, "}");
string text = string.Format(this.ActualCulture, formatString, contour.ContourLevel);
contourLabels.Add(new ContourLabel { Position = pos, Angle = angle, Text = text });
}