本文整理汇总了C#中RectangleD.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleD.Contains方法的具体用法?C# RectangleD.Contains怎么用?C# RectangleD.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RectangleD
的用法示例。
在下文中一共展示了RectangleD.Contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsPotentialHit
/// <summary>
/// Gets a value indicating whether the specified point is potentially a hit for the specified element.
/// </summary>
/// <param name="element">The element to evaluate.</param>
/// <param name="point">The point to evaluate.</param>
/// <returns><see langword="true"/> if the specified point is a potential hit; otherwise, <see langword="false"/>.</returns>
public static Boolean IsPotentialHit(UIElement element, Point2D point)
{
if (element.Visibility != Visibility.Visible)
return false;
if (!element.IsHitTestVisible)
return false;
if (!element.VisualBounds.Contains(point))
return false;
var clip = element.ClipRectangle;
if (clip.HasValue)
{
var absoluteClip = clip.Value;
var relativeClip = new RectangleD(
absoluteClip.X - element.UntransformedAbsolutePosition.X,
absoluteClip.Y - element.UntransformedAbsolutePosition.Y,
absoluteClip.Width,
absoluteClip.Height);
if (!relativeClip.Contains(point))
return false;
}
return true;
}
示例2: LineContainsPoint
public static bool LineContainsPoint (double x1, double y1, double x2, double y2, double px, double py) {
RectangleD r = new RectangleD (new PointD (x1, y1));
r.Add (x2, y2);
r.Inflate (2.0, 2.0);
if (!r.Contains (px, py)) {
return false;
}
double a, b, x, y;
if (x1 == x2) {
return (Math.Abs (px - x1) < 3.0);
}
if (y1 == y2) {
return (Math.Abs (py - y1) < 3.0);
}
a = (y1 - y2) / (x1 - x2);
b = y1 - a * x1;
x = (py - b) / a;
y = a * px + b;
return (Math.Min (Math.Abs (x - px), Math.Abs (y - py)) < 4.0);
}
示例3: ScrollToLine
/// <summary>
/// Scrolls the text editor so that the specified line is in full view.
/// </summary>
/// <param name="lineIndex">The index of the line to scroll into view.</param>
public void ScrollToLine(Int32 lineIndex)
{
Contract.EnsureRange(lineIndex >= 0 && lineIndex < textLayoutStream.LineCount, nameof(lineIndex));
var scrollViewer = Parent as ScrollViewer;
if (scrollViewer == null)
return;
var lineInfo = textLayoutStream.GetLineInfo(lineIndex);
var boundsViewport = new RectangleD(scrollViewer.HorizontalOffset, scrollViewer.VerticalOffset,
scrollViewer.ViewportWidth, scrollViewer.ViewportHeight);
var boundsLine = Display.PixelsToDips(new RectangleD(lineInfo.X, lineInfo.Y, lineInfo.Width, lineInfo.Height));
if (boundsViewport.Contains(boundsLine))
return;
scrollViewer.ScrollToHorizontalOffset(lineInfo.X);
scrollViewer.ScrollToVerticalOffset(lineInfo.Y);
}
示例4: TestHitAnchor
/// <summary>
/// Pulled directly from Reflector disassembly
/// </summary>
private static AnchorPoint TestHitAnchor(BinaryLinkShape linkShape, LineSegment segment, SizeD tolerance, PointD hitPoint)
{
RectangleD ed1 = new RectangleD(0, 0, tolerance.Width * 2, tolerance.Height * 2);
NodeShape shape1 = null;
bool flag1 = false;
if (linkShape != null)
{
PointD td1;
if (segment.IsStartSegment && segment.IsEndSegment)
{
if (ClosestEnd(segment, hitPoint))
{
td1 = segment.StartPoint;
shape1 = linkShape.FromShape;
flag1 = true;
}
else
{
td1 = segment.EndPoint;
shape1 = linkShape.ToShape;
}
}
else if (segment.IsStartSegment)
{
td1 = segment.StartPoint;
shape1 = linkShape.FromShape;
flag1 = true;
}
else if (segment.IsEndSegment)
{
td1 = segment.EndPoint;
shape1 = linkShape.ToShape;
}
else
{
return null;
}
if ((shape1 != null) && !shape1.IsPort)
{
ed1.Offset(td1.X - tolerance.Width, td1.Y - tolerance.Height);
if (ed1.Contains(hitPoint))
{
return new AnchorPoint(linkShape, segment, shape1, tolerance, flag1);
}
}
}
return null;
}
示例5: ContainsPoint
public bool ContainsPoint (double x, double y) {
RectangleD displayBox = new RectangleD(Locate());
displayBox.Inflate(Width/2, Height/2);
return displayBox.Contains(x, y);
}