本文整理汇总了C#中System.Windows.Rect.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.Contains方法的具体用法?C# Rect.Contains怎么用?C# Rect.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Rect
的用法示例。
在下文中一共展示了Rect.Contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: rectContainsExample1
private bool rectContainsExample1()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
// Using the Contains method, see if the rectangle contains the specified
// point. doesContain is true because the point is inside of myRectangle.
bool doesContain = myRectangle.Contains(new Point(13, 30));
return doesContain;
}
示例2: rectContainsExample2
private bool rectContainsExample2()
{
// Create a rectangle.
Rect myRectangle1 = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle1.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle1.Size = new Size(200, 50);
// Create second rectangle.
Rect myRectangle2 = new Rect();
myRectangle2.Location = new Point(12, 12);
myRectangle2.Size = new Size(10, 60);
// Using the Contains method, see if the second rectangle is
// contained within the first rectangle. doesContain is false
// because only part of myRectangle2 is contained in myRectangle1
// (myRectangle2 is too wide).
bool doesContain = myRectangle1.Contains(myRectangle2);
return doesContain;
}
示例3: rectContainsExample3
private bool rectContainsExample3()
{
// Initialize new rectangle.
Rect myRectangle = new Rect();
// The Location property specifies the coordinates of the upper left-hand
// corner of the rectangle.
myRectangle.Location = new Point(10, 5);
// Set the Size property of the rectangle with a width of 200
// and a height of 50.
myRectangle.Size = new Size(200, 50);
// Using the Contains method, see if the rectangle contains the specified
// point specified by the given X and Y coordinates. doesContain is false
// because the X and Y coordinates specify a point outside of myRectangle.
bool doesContain = myRectangle.Contains(4, 13);
return doesContain;
}