次の方法で共有


LineShape Class

Represents a control displayed as a horizontal, vertical, or diagonal line.

Inheritance Hierarchy

System.Object
  System.MarshalByRefObject
    System.ComponentModel.Component
      Microsoft.VisualBasic.PowerPacks.Shape
        Microsoft.VisualBasic.PowerPacks.LineShape

Namespace:  Microsoft.VisualBasic.PowerPacks
Assembly:  Microsoft.VisualBasic.PowerPacks.Vs (in Microsoft.VisualBasic.PowerPacks.Vs.dll)

Syntax

'宣言
<ToolboxBitmapAttribute(GetType(LineShape), "Microsoft.VisualBasic.PowerPacks.LineShape.bmp")> _
Public Class LineShape _
    Inherits Shape
[ToolboxBitmapAttribute(typeof(LineShape), "Microsoft.VisualBasic.PowerPacks.LineShape.bmp")]
public class LineShape : Shape
[ToolboxBitmapAttribute(typeof(LineShape), L"Microsoft.VisualBasic.PowerPacks.LineShape.bmp")]
public ref class LineShape : public Shape
[<ToolboxBitmapAttribute(typeof(LineShape), "Microsoft.VisualBasic.PowerPacks.LineShape.bmp")>]
type LineShape =  
    class
        inherit Shape
    end
public class LineShape extends Shape

The LineShape type exposes the following members.

Constructors

  Name Description
Public method LineShape() Initializes a new instance of the LineShape class.
Public method LineShape(ShapeContainer) Initializes a new instance of the LineShape class, specifying the ShapeContainer where it will be parented.
Public method LineShape(Int32, Int32, Int32, Int32) Initializes a new instance of the LineShape class, specifying the coordinates for the line.

Top

Properties

  Name Description
Public property AccessibilityObject Gets the AccessibleObject that is assigned to the control. (Inherited from Shape.)
Public property AccessibleDefaultActionDescription Gets or sets the default action description of the control for use by accessibility client applications. (Inherited from Shape.)
Public property AccessibleDescription Gets or sets the description of the control that is used by accessibility client applications. (Inherited from Shape.)
Public property AccessibleName Gets or sets the name of the control that is used by accessibility client applications. (Inherited from Shape.)
Public property AccessibleRole Gets or sets the accessible role of the control. (Inherited from Shape.)
Public property Anchor Gets or sets the edges of the container to which a shape is bound, and determines how a shape is resized when its parent is resized. (Inherited from Shape.)
Public property BorderColor Gets or sets the color of the border of a shape or line control. (Inherited from Shape.)
Public property BorderStyle Gets or sets the border style for a shape or line control. (Inherited from Shape.)
Public property BorderWidth Gets or sets the width of a line or shape control's border. (Inherited from Shape.)
Public property CanFocus Gets a value indicating whether a line or shape control can receive focus. (Inherited from Shape.)
Protected property CanRaiseEvents Gets a value indicating whether the component can raise an event. (Inherited from Component.)
Public property CanSelect Gets a value indicating whether a line or shape control can be selected. (Inherited from Shape.)
Public property Container Gets the IContainer that contains the Component. (Inherited from Shape.)
Public property ContainsFocus Gets a value indicating whether a line or shape control currently has the input focus. (Inherited from Shape.)
Public property ContextMenu Gets or sets the shortcut menu associated with a line or shape control. (Inherited from Shape.)
Public property ContextMenuStrip Gets or sets the ContextMenuStrip associated with a line or shape control. (Inherited from Shape.)
Public property Created Gets a value indicating whether a line or shape control has been created. (Inherited from Shape.)
Public property Cursor Gets or sets the cursor that is displayed when the mouse pointer is resting on a line or shape control. (Inherited from Shape.)
Protected property DesignMode Gets a value that indicates whether the Component is currently in design mode. (Inherited from Component.)
Public property Disposing Gets a value indicating whether the base Shape class is disposing. (Inherited from Shape.)
Public property Enabled Gets or sets a value indicating whether a line or shape control can respond to user interaction. (Inherited from Shape.)
Public property EndPoint Gets or sets the ending coordinates of a line drawn by a LineShape control.
Protected property Events Gets the list of event handlers that are attached to this Component. (Inherited from Component.)
Public property Focused Gets a value indicating whether a line or shape control currently has the input focus. (Inherited from Shape.)
Public property IsAccessible Gets or sets a value indicating whether a line or shape control is available to accessibility applications. (Inherited from Shape.)
Public property IsDisposed Gets a value indicating whether a line or shape control has been disposed of. (Inherited from Shape.)
Public property Name Gets or sets the name of a line or shape control. (Inherited from Shape.)
Public property Parent Gets or sets the parent container of a line or shape control. (Inherited from Shape.)
Public property Region Gets or sets the window region associated with a line or shape control. (Inherited from Shape.)
Public property SelectionColor Gets or sets the selection color of a shape. (Inherited from Shape.)
Public property Site Gets or sets the ISite of the Component. (Inherited from Component.)
Public property StartPoint Gets or sets the starting coordinates of a line drawn by a LineShape control.
Public property Tag Gets or sets the object that contains data about a line or shape control. (Inherited from Shape.)
Public property UseWaitCursor Gets or sets a value indicating whether to use the wait cursor for the current line or shape control. (Inherited from Shape.)
Public property Visible Gets or sets a value indicating whether a line or shape control is displayed. (Inherited from Shape.)
Public property X1 Gets or sets the X coordinate of the starting point of a line drawn by a LineShape control.
Public property X2 Gets or sets the X coordinate of the ending point of a line drawn by a LineShape control.
Public property Y1 Gets or sets the Y coordinate of the starting point of a line drawn by a LineShape control.
Public property Y2 Gets or sets the Y coordinate of the ending point of a line drawn by a LineShape control.

Top

Methods

  Name Description
Public method BringToFront Brings a line or shape control to the front of the z-order. (Inherited from Shape.)
Protected method CreateAccessibilityInstance Creates an object to provide information that accessibility applications use to adjust an application's user interface (UI) for users who have disabilities. (Overrides Shape.CreateAccessibilityInstance().)
Public method CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public method Dispose() Releases all resources used by the Component. (Inherited from Component.)
Protected method Dispose(Boolean) Releases the unmanaged resources used by a line or shape control and optionally releases the managed resources. (Inherited from Shape.)
Public method DrawToBitmap Supports drawing to the specified bitmap. (Overrides Shape.DrawToBitmap(Bitmap, Rectangle).)
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Releases unmanaged resources and performs other cleanup operations before the Component is reclaimed by garbage collection. (Inherited from Component.)
Public method FindForm Retrieves the form that a line or shape control is on. (Inherited from Shape.)
Public method Focus Sets input focus to a line or shape control. (Inherited from Shape.)
Public method GetContainerControl Returns the next ContainerControl up in a line or shape control's chain of parent controls. (Inherited from Shape.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Protected method GetService Returns an object that represents a service provided by the Component or by its Container. (Inherited from Component.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method Hide Conceals a line or shape control from the user. (Inherited from Shape.)
Public method HitTest Gets information about the LineShape control at the specified point on the screen. (Overrides Shape.HitTest(Int32, Int32).)
Public method InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public method Invalidate Invalidates a specific region of a line or shape control and causes a paint message to be sent to the control. (Inherited from Shape.)
Protected method MemberwiseClone() Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method MemberwiseClone(Boolean) Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Protected method OnClick Raises the Click event. (Inherited from Shape.)
Protected method OnContextMenuChanged Raises the ContextMenuChanged event. (Inherited from Shape.)
Protected method OnContextMenuStripChanged Raises the ContextMenuStripChanged event. (Inherited from Shape.)
Protected method OnCursorChanged Raises the CursorChanged event. (Inherited from Shape.)
Protected method OnDoubleClick Raises the DoubleClick event. (Inherited from Shape.)
Protected method OnEnabledChanged Raises the EnabledChanged event. (Inherited from Shape.)
Protected method OnEndPointChanged Raises the EndPointChanged event.
Protected method OnEnter Raises the Enter event. (Inherited from Shape.)
Protected method OnGotFocus Raises the GotFocus event. (Inherited from Shape.)
Protected method OnInvalidated Raises the Invalidated event. (Inherited from Shape.)
Protected method OnKeyDown Raises the KeyDown event. (Inherited from Shape.)
Protected method OnKeyPress Raises the KeyPress event. (Inherited from Shape.)
Protected method OnKeyUp Raises the KeyUp event. (Inherited from Shape.)
Protected method OnLeave Raises the Leave event. (Inherited from Shape.)
Protected method OnLostFocus Raises the LostFocus event. (Inherited from Shape.)
Protected method OnMouseClick Raises the MouseClick event. (Inherited from Shape.)
Protected method OnMouseDoubleClick Raises the MouseDoubleClick event. (Inherited from Shape.)
Protected method OnMouseDown Raises the MouseDown event. (Inherited from Shape.)
Protected method OnMouseEnter Raises the MouseEnter event. (Inherited from Shape.)
Protected method OnMouseHover Raises the MouseHover event. (Inherited from Shape.)
Protected method OnMouseLeave Raises the MouseLeave event. (Inherited from Shape.)
Protected method OnMouseMove Raises the MouseMove event. (Inherited from Shape.)
Protected method OnMouseUp Raises the MouseUp event. (Inherited from Shape.)
Protected method OnMouseWheel Raises the MouseWheel event. (Inherited from Shape.)
Protected method OnMove Raises the Move event. (Inherited from Shape.)
Protected method OnPaint Raises the Paint event. (Overrides Shape.OnPaint(PaintEventArgs).)
Protected method OnParentChanged Raises the ParentChanged event. (Inherited from Shape.)
Protected method OnPreviewKeyDown Raises the PreviewKeyDown event. (Inherited from Shape.)
Protected method OnQueryAccessibilityHelp Raises the QueryAccessibilityHelp event. (Inherited from Shape.)
Protected method OnRegionChanged Raises the RegionChanged event. (Inherited from Shape.)
Protected method OnStartPointChanged Raises the StartPointChanged event.
Protected method OnVisibleChanged Raises the VisibleChanged event. (Inherited from Shape.)
Public method PointToClient Computes the location of the specified screen point into client coordinates. (Inherited from Shape.)
Public method PointToScreen Computes the location of the specified client point into screen coordinates. (Inherited from Shape.)
Public method RectangleToClient Computes the size and location of the specified screen rectangle in client coordinates. (Inherited from Shape.)
Public method RectangleToScreen Computes the size and location of the specified client rectangle in screen coordinates. (Inherited from Shape.)
Public method Refresh Forces a control to invalidate its client area and immediately redraw itself and any child controls. (Inherited from Shape.)
Public method ResumePaint Resumes usual painting logic, optionally forcing an immediate layout of pending paint requests. (Inherited from Shape.)
Public method Scale Resizes the LineShape control by the specified scaling factor. (Overrides Shape.Scale(SizeF).)
Public method Select Enables a control. (Inherited from Shape.)
Public method SendToBack Sends a line or shape control to the back of the z-order. (Inherited from Shape.)
Public method Show Displays a shape to the user. (Inherited from Shape.)
Public method SuspendPaint Suspends the painting logic for a shape. (Inherited from Shape.)
Public method ToString Returns a String containing the name of the Component, if any. This method should not be overridden. (Inherited from Component.)
Public method Update Causes the control to redraw the invalidated regions within its client area. (Inherited from Shape.)

Top

Events

  Name Description
Public event ChangeUICues Occurs when the focus or keyboard user interface (UI) cues change. (Inherited from Shape.)
Public event Click Occurs when the shape is clicked. (Inherited from Shape.)
Public event ContextMenuChanged Occurs when the value of the ContextMenu property changes. (Inherited from Shape.)
Public event ContextMenuStripChanged Occurs when the value of the ContextMenuStrip property changes. (Inherited from Shape.)
Public event CursorChanged Occurs when the value of the Cursor property changes. (Inherited from Shape.)
Public event Disposed Occurs when the component is disposed by a call to the Dispose method. (Inherited from Component.)
Public event DoubleClick Occurs when the shape is double-clicked. (Inherited from Shape.)
Public event EnabledChanged Occurs when the Enabled property value has changed. (Inherited from Shape.)
Public event EndPointChanged Occurs when the EndPoint property value changes.
Public event Enter Occurs when the shape is entered. (Inherited from Shape.)
Public event GotFocus Occurs when the shape receives focus. (Inherited from Shape.)
Public event Invalidated Occurs when a shape's display requires redrawing. (Inherited from Shape.)
Public event KeyDown Occurs when a key is pressed and the shape has focus. (Inherited from Shape.)
Public event KeyPress Occurs when a key is pressed and the shape has focus. (Inherited from Shape.)
Public event KeyUp Occurs when a key is released and the shape has focus. (Inherited from Shape.)
Public event Leave Occurs when the input focus leaves the shape. (Inherited from Shape.)
Public event LostFocus Occurs when the shape loses focus. (Inherited from Shape.)
Public event MouseClick Occurs when the shape is clicked by the mouse. (Inherited from Shape.)
Public event MouseDoubleClick Occurs when the shape is double-clicked by the mouse. (Inherited from Shape.)
Public event MouseDown Occurs when the mouse pointer is over the shape and a mouse button is pressed. (Inherited from Shape.)
Public event MouseEnter Occurs when the mouse pointer enters the shape. (Inherited from Shape.)
Public event MouseHover Occurs when the mouse pointer rests on the shape. (Inherited from Shape.)
Public event MouseLeave Occurs when the mouse pointer leaves the shape. (Inherited from Shape.)
Public event MouseMove Occurs when the mouse pointer is moved over the shape. (Inherited from Shape.)
Public event MouseUp Occurs when the mouse pointer is over the shape and a mouse button is released. (Inherited from Shape.)
Public event MouseWheel Occurs when the mouse wheel moves and the shape has focus. (Inherited from Shape.)
Public event Move Occurs when the shape is moved. (Inherited from Shape.)
Public event Paint Occurs when the shape is redrawn. (Inherited from Shape.)
Public event ParentChanged Occurs when the Parent property value changes. (Inherited from Shape.)
Public event PreviewKeyDown Occurs before the KeyDown event when a key is pressed and focus is on the shape. (Inherited from Shape.)
Public event QueryAccessibilityHelp Occurs when an AccessibleObject is providing Help to accessibility applications. (Inherited from Shape.)
Public event RegionChanged Occurs when the value of the Region property changes. (Inherited from Shape.)
Public event StartPointChanged Occurs when the StartPoint property value changes.
Public event VisibleChanged Occurs when the Visible property value changes. (Inherited from Shape.)

Top

Remarks

The LineShape control enables you to draw lines on a form or container at design time or run time.

When you add a Line or Shape control to a form or container, an invisible ShapeContainer object is created. The ShapeContainer acts as a drawing surface for the shapes within each container control; each ShapeContainer has a corresponding ShapeCollection that enables you to iterate through the Line and Shape controls.

When you create a LineShape control at run time, you must also create a ShapeContainer and set the Parent property of the LineShape to the ShapeContainer.

Examples

The following example creates a ShapeContainer and a LineShape, adds them to a form, and displays a vertical line from the top to the bottom of the form.

Dim canvas As New Microsoft.VisualBasic.PowerPacks.ShapeContainer
Dim line1 As New Microsoft.VisualBasic.PowerPacks.LineShape
' Set the form as the parent of the ShapeContainer.
canvas.Parent = Me
' Set the ShapeContainer as the parent of the LineShape.
line1.Parent = canvas
' Set the starting and ending coordinates for the line.
line1.StartPoint = New System.Drawing.Point(Me.Width / 2, 0)
line1.EndPoint = New System.Drawing.Point(Me.Width / 2, Me.Height)
Microsoft.VisualBasic.PowerPacks.ShapeContainer canvas = 
    new Microsoft.VisualBasic.PowerPacks.ShapeContainer();
Microsoft.VisualBasic.PowerPacks.LineShape line1 = 
    new Microsoft.VisualBasic.PowerPacks.LineShape();
// Set the form as the parent of the ShapeContainer.
canvas.Parent = this;
// Set the ShapeContainer as the parent of the LineShape.
line1.Parent = canvas;
// Set the starting and ending coordinates for the line.
line1.StartPoint = new System.Drawing.Point(this.Width / 2, 0);
line1.EndPoint = new System.Drawing.Point(this.Width / 2, this.Height);

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualBasic.PowerPacks Namespace

ShapeContainer

Shape

Other Resources

How to: Draw Shapes with the OvalShape and RectangleShape Controls (Visual Studio)

How to: Draw Lines with the LineShape Control (Visual Studio)

Introduction to the Line and Shape Controls (Visual Studio)