Point 建構函式
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
初始化一個結構體的新實例 Point ,並使用指定的座標。
多載
| 名稱 | Description |
|---|---|
| Point(Size) | |
| Point(Int32) |
初始化一個結構體的新實例 Point ,使用由整數值指定的座標。 |
| Point(Int32, Int32) |
初始化一個結構體的新實例 Point ,並使用指定的座標。 |
Point(Size)
- 來源:
- Point.cs
- 來源:
- Point.cs
- 來源:
- Point.cs
- 來源:
- Point.cs
- 來源:
- Point.cs
public:
Point(System::Drawing::Size sz);
public Point(System.Drawing.Size sz);
new System.Drawing.Point : System.Drawing.Size -> System.Drawing.Point
Public Sub New (sz As Size)
參數
範例
以下程式碼範例示範如何使用Equality運算子,以及如何從一Point兩個整數構造 aSize。 同時也示範如何使用 X 和 Y 屬性。 此範例設計用於 Windows 表單。 將程式碼貼到包含一個名為 Button1的按鈕的表單中,並將該方法與按鈕事件Button1_Click關聯Click起來。
private:
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// Construct a new Point with integers.
Point Point1 = Point(100,100);
// Create a Graphics object.
Graphics^ formGraphics = this->CreateGraphics();
// Construct another Point, this time using a Size.
Point Point2 = Point(System::Drawing::Size( 100, 100 ));
// Call the equality operator to see if the points are equal,
// and if so print out their x and y values.
if ( Point1 == Point2 )
{
array<Object^>^temp0 = {Point1.X,Point2.X,Point1.Y,Point2.Y};
formGraphics->DrawString( String::Format( "Point1.X: "
"{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}", temp0 ), this->Font, Brushes::Black, PointF(10,70) );
}
}
private void Button1_Click(System.Object sender, System.EventArgs e)
{
// Construct a new Point with integers.
Point Point1 = new Point(100, 100);
// Create a Graphics object.
Graphics formGraphics = this.CreateGraphics();
// Construct another Point, this time using a Size.
Point Point2 = new Point(new Size(100, 100));
// Call the equality operator to see if the points are equal,
// and if so print out their x and y values.
if (Point1 == Point2)
{
formGraphics.DrawString(String.Format("Point1.X: " +
"{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}",
new object[]{Point1.X, Point2.X, Point1.Y, Point2.Y}),
this.Font, Brushes.Black, new PointF(10, 70));
}
}
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Construct a new Point with integers.
Dim Point1 As New Point(100, 100)
' Create a Graphics object.
Dim formGraphics As Graphics = Me.CreateGraphics()
' Construct another Point, this time using a Size.
Dim Point2 As New Point(New Size(100, 100))
' Call the equality operator to see if the points are equal,
' and if so print out their x and y values.
If (Point.op_Equality(Point1, Point2)) Then
formGraphics.DrawString(String.Format("Point1.X: " & _
"{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}", _
New Object() {Point1.X, Point2.X, Point1.Y, Point2.Y}), _
Me.Font, Brushes.Black, New PointF(10, 70))
End If
End Sub
適用於
Point(Int32)
- 來源:
- Point.cs
- 來源:
- Point.cs
- 來源:
- Point.cs
- 來源:
- Point.cs
- 來源:
- Point.cs
初始化一個結構體的新實例 Point ,使用由整數值指定的座標。
public:
Point(int dw);
public Point(int dw);
new System.Drawing.Point : int -> System.Drawing.Point
Public Sub New (dw As Integer)
參數
範例
以下程式碼範例示範如何使用 Point and Size.Size 構造子與 System.Drawing.ContentAlignment 列舉。 要執行此範例,將此程式碼貼入包含標籤為 Label1 的 Windows 表單,並在表單建構子中呼叫 InitializeLabel1 方法。
void InitializeLabel1()
{
// Set a border.
Label1->BorderStyle = BorderStyle::FixedSingle;
// Set the size, constructing a size from two integers.
Label1->Size = System::Drawing::Size( 100, 50 );
// Set the location, constructing a point from a 32-bit integer
// (using hexadecimal).
Label1->Location = Point(0x280028);
// Set and align the text on the lower-right side of the label.
Label1->TextAlign = ContentAlignment::BottomRight;
Label1->Text = "Bottom Right Alignment";
}
private void InitializeLabel1()
{
// Set a border.
Label1.BorderStyle = BorderStyle.FixedSingle;
// Set the size, constructing a size from two integers.
Label1.Size = new Size(100, 50);
// Set the location, constructing a point from a 32-bit integer
// (using hexadecimal).
Label1.Location = new Point(0x280028);
// Set and align the text on the lower-right side of the label.
Label1.TextAlign = ContentAlignment.BottomRight;
Label1.Text = "Bottom Right Alignment";
}
Private Sub InitializeLabel1()
' Set a border.
Label1.BorderStyle = BorderStyle.FixedSingle
' Set the size, constructing a size from two integers.
Label1.Size = New Size(100, 50)
' Set the location, constructing a point from a 32-bit integer
' (using hexadecimal).
Label1.Location = New Point(&H280028)
' Set and align the text on the lower-right side of the label.
Label1.TextAlign = ContentAlignment.BottomRight
Label1.Text = "Bottom Right Alignment"
End Sub
備註
參數的 dw 低階 16 位元指定水平 x 座標,較高的 16 位元指定新的 Point垂直 y 座標。
適用於
Point(Int32, Int32)
- 來源:
- Point.cs
- 來源:
- Point.cs
- 來源:
- Point.cs
- 來源:
- Point.cs
- 來源:
- Point.cs
初始化一個結構體的新實例 Point ,並使用指定的座標。
public:
Point(int x, int y);
public Point(int x, int y);
new System.Drawing.Point : int * int -> System.Drawing.Point
Public Sub New (x As Integer, y As Integer)
參數
- x
- Int32
該點的水平位置。
- y
- Int32
該點的垂直位置。
範例
以下程式碼範例示範如何使用Equality運算子,以及如何從一Point兩個整數構造 aSize。 同時也示範如何使用 X 和 Y 屬性。 此範例設計用於 Windows 表單。 將程式碼貼到包含一個名為 Button1的按鈕的表單中,並將該方法與按鈕事件Button1_Click關聯Click起來。
private:
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
// Construct a new Point with integers.
Point Point1 = Point(100,100);
// Create a Graphics object.
Graphics^ formGraphics = this->CreateGraphics();
// Construct another Point, this time using a Size.
Point Point2 = Point(System::Drawing::Size( 100, 100 ));
// Call the equality operator to see if the points are equal,
// and if so print out their x and y values.
if ( Point1 == Point2 )
{
array<Object^>^temp0 = {Point1.X,Point2.X,Point1.Y,Point2.Y};
formGraphics->DrawString( String::Format( "Point1.X: "
"{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}", temp0 ), this->Font, Brushes::Black, PointF(10,70) );
}
}
private void Button1_Click(System.Object sender, System.EventArgs e)
{
// Construct a new Point with integers.
Point Point1 = new Point(100, 100);
// Create a Graphics object.
Graphics formGraphics = this.CreateGraphics();
// Construct another Point, this time using a Size.
Point Point2 = new Point(new Size(100, 100));
// Call the equality operator to see if the points are equal,
// and if so print out their x and y values.
if (Point1 == Point2)
{
formGraphics.DrawString(String.Format("Point1.X: " +
"{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}",
new object[]{Point1.X, Point2.X, Point1.Y, Point2.Y}),
this.Font, Brushes.Black, new PointF(10, 70));
}
}
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
' Construct a new Point with integers.
Dim Point1 As New Point(100, 100)
' Create a Graphics object.
Dim formGraphics As Graphics = Me.CreateGraphics()
' Construct another Point, this time using a Size.
Dim Point2 As New Point(New Size(100, 100))
' Call the equality operator to see if the points are equal,
' and if so print out their x and y values.
If (Point.op_Equality(Point1, Point2)) Then
formGraphics.DrawString(String.Format("Point1.X: " & _
"{0},Point2.X: {1}, Point1.Y: {2}, Point2.Y {3}", _
New Object() {Point1.X, Point2.X, Point1.Y, Point2.Y}), _
Me.Font, Brushes.Black, New PointF(10, 70))
End If
End Sub