LineShape.StartPoint 属性

获取或设置 LineShape 控件绘制的行的开头的坐标。

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

语法

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

属性值

类型:System.Drawing.Point
表示行的开头坐标的 Point 结构。

备注

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

可以通过设置 X1Y1 属性来更改启动的坐标。

示例

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

Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim line1 As New Microsoft.VisualBasic.PowerPacks.LineShape(10, 10, 200, 10)

Private Sub RotateLine2_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 RotateLine2_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.StartPoint = New System.Drawing.Point(line1.X1, 200)
        direction = "diagonal"
    ElseIf direction = "diagonal" Then
        ' Change the orientation to vertical.
        line1.StartPoint = New System.Drawing.Point(line1.Y1, 200)
        direction = "vertical"
    Else
        ' Change the orientation to horizontal.
        line1.StartPoint = New System.Drawing.Point(10, line1.Y2)
        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 RotateLine2_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 RotateLine2_Click(object sender, System.EventArgs e)
        {
            ChangeOrientation();
        }

        private void ChangeOrientation()
        {

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

.NET Framework 安全性

请参见

参考

LineShape 类

Microsoft.VisualBasic.PowerPacks 命名空间

ShapeContainer

Shape

其他资源

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

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

Line 和 Shape 控件简介 (Visual Studio)