LineShape.EndPoint 属性

获取或设置 LineShape 控件绘制的线结束坐标。

命名空间:  Microsoft.VisualBasic.PowerPacks
程序集:  Microsoft.VisualBasic.PowerPacks.Vs(在 Microsoft.VisualBasic.PowerPacks.Vs.dll 中)

语法

声明
<BrowsableAttribute(False)> _
Public Property EndPoint As Point
[BrowsableAttribute(false)]
public Point EndPoint { get; set; }
[BrowsableAttribute(false)]
public:
property Point EndPoint {
    Point get ();
    void set (Point value);
}
[<BrowsableAttribute(false)>]
member EndPoint : Point with get, set
function get EndPoint () : Point
function set EndPoint (value : Point)

属性值

类型:System.Drawing.Point
该行的结尾坐标的 Point 结构。

备注

坐标系是相对于 LineShape 控件的容器和使用像素表示。

可以通过设置 X2Y2 属性来更改关闭坐标。

示例

下面的示例切换从水平方向的 LineShape 到一个对角线方向,再到一个垂直方向,使用 StartPoint 作为轴。

Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim line1 As New Microsoft.VisualBasic.PowerPacks.LineShape(10, 10, 200, 10)
Private Sub Form1_Load() Handles MyBase.Load
    ' Set the form as the parent of the ShapeContainer.
    canvas.Parent = Me
    ' Set the ShapeContainer as the parent of the LineShape.
    line1.Parent = canvas
End Sub
Private Sub Form1_Click() Handles Me.Click
    ChangeOrientation()
End Sub
Private Sub ChangeOrientation()
    Static direction As String = "horizontal"
    If direction = "horizontal" Then
        ' Change the orientation to diagonal.
        line1.EndPoint = New System.Drawing.Point(200, 200)
        direction = "diagonal"
    ElseIf direction = "diagonal" Then
        ' Change the orientation to vertical.
        line1.EndPoint = New System.Drawing.Point(line1.X1, 200)
        direction = "vertical"
    Else
        ' Change the orientation to horizontal.
        line1.EndPoint = New System.Drawing.Point(200, line1.Y1)
        direction = "horizontal"
    End If
End Sub
        Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas = 
            new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
        Microsoft.VisualBasic.PowerPacks.LineShape line1 = 
            new Microsoft.VisualBasic.PowerPacks.LineShape(10, 10, 200, 10);
        string direction;
        private void Form1_Load(System.Object sender, System.EventArgs e)
        {
            // Set the form as the parent of the ShapeContainer.
            canvas.Parent = this;
            // Set the ShapeContainer as the parent of the LineShape.
            line1.Parent = canvas;
            direction = "horizontal";
        }
        private void Form1_Click(object sender, System.EventArgs e)
        {
            ChangeOrientation();
        }

        private void ChangeOrientation()
        {

            if (direction == "horizontal")
            // Change the orientation to diagonal.
            {
                line1.EndPoint = new System.Drawing.Point(200, 200);
                direction = "diagonal";
            }
            else if (direction == "diagonal")
            {
                line1.EndPoint = new System.Drawing.Point(line1.X1, 200);
                direction = "vertical";
            }
            else
            {
                // Change the orientation to horizontal.
                line1.EndPoint = new System.Drawing.Point(200, line1.Y1);
                direction = "horizontal";
            }
        }

.NET Framework 安全性

请参见

参考

LineShape 类

Microsoft.VisualBasic.PowerPacks 命名空间

ShapeContainer

Shape

其他资源

如何:使用 OvalShape 和 RectangleShape 控件绘制形状 (Visual Studio)

如何:使用 LineShape 控件绘制直线 (Visual Studio)

Line 和 Shape 控件简介 (Visual Studio)