CustomLineCap CustomLineCap CustomLineCap CustomLineCap Class

Definición

Encapsula un extremo de línea personalizado definido por el usuario.Encapsulates a custom user-defined line cap.

public ref class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
public class CustomLineCap : MarshalByRefObject, ICloneable, IDisposable
type CustomLineCap = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
Public Class CustomLineCap
Inherits MarshalByRefObject
Implements ICloneable, IDisposable
Herencia
Derivado
Implementaciones

Ejemplos

En el siguiente ejemplo se muestra cómo utilizar la clase CustomLineCap.The following example demonstrates how to use the CustomLineCap class. Para ejecutar este ejemplo, pegue, el código en un Windows Form.To run this example paste, the code into a Windows Form. Controle el evento Paint del formulario y DrawCaps llame a desde el Paint método de control de eventos del e formulario PaintEventArgs, pasando como.Handle the form's Paint event and call DrawCaps from the form's Paint event-handling method, passing e as PaintEventArgs.


protected void DrawCaps(PaintEventArgs e)
{
    GraphicsPath hPath = new GraphicsPath();

    // Create the outline for our custom end cap.
    hPath.AddLine(new Point(0, 0), new Point(0, 5));
    hPath.AddLine(new Point(0, 5), new Point(5, 1));
    hPath.AddLine(new Point(5, 1), new Point(3, 1));

    // Construct the hook-shaped end cap.
    CustomLineCap HookCap = new CustomLineCap(null, hPath);

    // Set the start cap and end cap of the HookCap to be rounded.
    HookCap.SetStrokeCaps(LineCap.Round, LineCap.Round);

    // Create a pen and set end custom start and end
    // caps to the hook cap.
    Pen customCapPen = new Pen(Color.Black, 5);
    customCapPen.CustomStartCap = HookCap;
    customCapPen.CustomEndCap = HookCap;

    // Create a second pen using the start and end caps from
    // the hook cap.
    Pen capPen = new Pen(Color.Red, 10);
    LineCap startCap;
    LineCap endCap;
    HookCap.GetStrokeCaps(out startCap, out endCap);
    capPen.StartCap = startCap;
    capPen.EndCap = endCap;

    // Create a line to draw.
    Point[] points = { new Point(100, 100), new Point(200, 50), 
        new Point(250, 300) };

    // Draw the lines.
    e.Graphics.DrawLines(capPen, points);
    e.Graphics.DrawLines(customCapPen, points);

}
Protected Sub DrawCaps(ByVal e As PaintEventArgs)
    Dim hPath As New GraphicsPath()

    ' Create the outline for our custom end cap.
    hPath.AddLine(New Point(0, 0), New Point(0, 5))
    hPath.AddLine(New Point(0, 5), New Point(5, 1))
    hPath.AddLine(New Point(5, 1), New Point(3, 1))

    ' Construct the hook-shaped end cap.
    Dim HookCap As New CustomLineCap(Nothing, hPath)

    ' Set the start cap and end cap of the HookCap to be rounded.
    HookCap.SetStrokeCaps(LineCap.Round, LineCap.Round)

    ' Create a pen and set end custom start and end
    ' caps to the hook cap.
    Dim customCapPen As New Pen(Color.Black, 5)
    customCapPen.CustomStartCap = HookCap
    customCapPen.CustomEndCap = HookCap

    ' Create a second pen using the start and end caps from
    ' the hook cap.
    Dim capPen As New Pen(Color.Red, 10)
    Dim startCap As LineCap
    Dim endCap As LineCap
    HookCap.GetStrokeCaps(startCap, endCap)
    capPen.StartCap = startCap
    capPen.EndCap = endCap

    ' Create a line to draw.
    Dim points As Point() = {New Point(100, 100), New Point(200, 50), _
        New Point(250, 300)}

    ' Draw the lines.
    e.Graphics.DrawLines(capPen, points)
    e.Graphics.DrawLines(customCapPen, points)

End Sub

Comentarios

Los extremos de línea se utilizan al principio y al final de las líneas o curvas Pen dibujadas por objetos GDI+.Line caps are used at the beginnings and ends of lines or curves drawn by GDI+ Pen objects. GDI+ admite varios estilos de extremo predefinidos y también permite a los usuarios definir sus propios estilos de extremo.GDI+ supports several predefined cap styles, and also allows users to define their own cap styles. Esta clase se usa para crear estilos de extremo personalizados.This class is used to create custom cap styles.

Constructores

CustomLineCap(GraphicsPath, GraphicsPath) CustomLineCap(GraphicsPath, GraphicsPath) CustomLineCap(GraphicsPath, GraphicsPath) CustomLineCap(GraphicsPath, GraphicsPath)

Inicializa una nueva instancia de la clase CustomLineCap con el contorno y el relleno especificados.Initializes a new instance of the CustomLineCap class with the specified outline and fill.

CustomLineCap(GraphicsPath, GraphicsPath, LineCap) CustomLineCap(GraphicsPath, GraphicsPath, LineCap) CustomLineCap(GraphicsPath, GraphicsPath, LineCap) CustomLineCap(GraphicsPath, GraphicsPath, LineCap)

Inicializa una nueva instancia de la clase CustomLineCap de la enumeración LineCap existente especificada, con el contorno y el relleno especificados.Initializes a new instance of the CustomLineCap class from the specified existing LineCap enumeration with the specified outline and fill.

CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single) CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single) CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single) CustomLineCap(GraphicsPath, GraphicsPath, LineCap, Single)

Inicializa una nueva instancia de la clase CustomLineCap de la enumeración LineCap existente especificada, con el contorno, el relleno y el insertado especificados.Initializes a new instance of the CustomLineCap class from the specified existing LineCap enumeration with the specified outline, fill, and inset.

Propiedades

BaseCap BaseCap BaseCap BaseCap

Obtiene o establece la enumeración LineCap en que se basa este CustomLineCap.Gets or sets the LineCap enumeration on which this CustomLineCap is based.

BaseInset BaseInset BaseInset BaseInset

Obtiene o establece la distancia entre el extremo y la línea.Gets or sets the distance between the cap and the line.

StrokeJoin StrokeJoin StrokeJoin StrokeJoin

Obtiene o establece la enumeración LineJoin que determina cómo se unen las líneas que forman este objeto CustomLineCap.Gets or sets the LineJoin enumeration that determines how lines that compose this CustomLineCap object are joined.

WidthScale WidthScale WidthScale WidthScale

Obtiene o establece la cantidad por la que se debe ajustar este objeto de la clase CustomLineCap en relación con el ancho del objeto Pen.Gets or sets the amount by which to scale this CustomLineCap Class object with respect to the width of the Pen object.

Métodos

Clone() Clone() Clone() Clone()

Crea una copia exacta de este objeto CustomLineCap.Creates an exact copy of this CustomLineCap.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Crea un objeto que contiene toda la información relevante necesaria para generar un proxy utilizado para comunicarse con un objeto remoto.Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Libera todos los recursos utilizados por este objeto CustomLineCap.Releases all resources used by this CustomLineCap object.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Libera los recursos no administrados que usa CustomLineCap y, de forma opcional, libera los recursos administrados.Releases the unmanaged resources used by the CustomLineCap and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina si el objeto especificado es igual al objeto actual.Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

Permite que un objeto CustomLineCap intente liberar recursos y realizar otras operaciones de limpieza antes de que el objeto CustomLineCap sea reclamado por la recolección de elementos no utilizados.Allows an CustomLineCap to attempt to free resources and perform other cleanup operations before the CustomLineCap is reclaimed by garbage collection.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Sirve como la función hash predeterminada.Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Recupera el objeto de servicio de duración actual que controla la directiva de duración de esta instancia.Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetStrokeCaps(LineCap, LineCap) GetStrokeCaps(LineCap, LineCap) GetStrokeCaps(LineCap, LineCap) GetStrokeCaps(LineCap, LineCap)

Obtiene los extremos utilizados para iniciar y finalizar las líneas que forman este extremo personalizado.Gets the caps used to start and end lines that make up this custom cap.

GetType() GetType() GetType() GetType()

Obtiene el Type de la instancia actual.Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtiene un objeto de servicio de duración para controlar la directiva de duración de esta instancia.Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficial del objeto Object actual.Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Crea una copia superficial del objeto MarshalByRefObject actual.Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
SetStrokeCaps(LineCap, LineCap) SetStrokeCaps(LineCap, LineCap) SetStrokeCaps(LineCap, LineCap) SetStrokeCaps(LineCap, LineCap)

Establece los extremos utilizados para iniciar y finalizar las líneas que forman este extremo personalizado.Sets the caps used to start and end lines that make up this custom cap.

ToString() ToString() ToString() ToString()

Devuelve una cadena que representa el objeto actual.Returns a string that represents the current object.

(Inherited from Object)

Se aplica a