本文整理匯總了C#中System.Windows.Rect.Offset方法的典型用法代碼示例。如果您正苦於以下問題:C# Rect.Offset方法的具體用法?C# Rect.Offset怎麽用?C# Rect.Offset使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Rect
的用法示例。
在下文中一共展示了Rect.Offset方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: offsetExample1
private Point offsetExample1()
{
// 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);
// Create a vector to use to offset the position of the rectangle.
Vector vector1 = new Vector(20, 30);
// The Offset method translates this rectangle by the specified vector.
// myRectangle location changed from 10,5 to 30,35.
myRectangle.Offset(vector1);
// This rectangle's location changed from 10,5 to 30,35.
return myRectangle.Location;
}
示例2: offsetExample2
private Point offsetExample2()
{
// 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);
// The Offset method translates this rectangle by the specified horizontal and
// vertical amounts.
// myRectangle location changed from 10,5 to 30,35.
myRectangle.Offset(20,30);
// This rectangle's location changed from 10,5 to 30,35.
return myRectangle.Location;
}
示例3: offsetExample3
private Point offsetExample3()
{
// 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);
// Create a vector to use to offset the position of the rectangle.
Vector vector1 = new Vector(20, 30);
// The Offset method translates the specified rectangle by the specified amount
// and returns the resulting Rect.
// resultRect location changed from 10,5 to 30,35.
Rect resultRect = Rect.Offset(myRectangle, vector1);
// This rectangle's location changed from 10,5 to 30,35.
return resultRect.Location;
}
示例4: offsetExample4
private Point offsetExample4()
{
// 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);
// Create a vector to use to offset the position of the rectangle.
Vector vector1 = new Vector(20, 30);
// The Offset method translates the specified rectangle by the specified horizontal
// and vertical amounts and returns the resulting Rect.
// resultRect location changed from 10,5 to 30,35.
Rect resultRect = Rect.Offset(myRectangle, 20, 30);
// This rectangle's location changed from 10,5 to 30,35.
return resultRect.Location;
}