Pen.Width Proprietà
Definizione
Importante
Alcune informazioni sono relative alla release non definitiva del prodotto, che potrebbe subire modifiche significative prima della release definitiva. Microsoft non riconosce alcuna garanzia, espressa o implicita, in merito alle informazioni qui fornite.
public:
property float Width { float get(); void set(float value); };
public float Width { get; set; }
member this.Width : single with get, set
Public Property Width As Single
Valore della proprietà
Larghezza dell'oggetto Pen.
Eccezioni
La Width proprietà viene impostata su un oggetto non modificabile Pen, ad esempio quelli restituiti dalla Pens classe .
Esempio
Nell'esempio di codice seguente vengono illustrati gli effetti dell'impostazione delle Width proprietà e LineJoin in un oggetto Pen.
Questo esempio è progettato per essere usato con Windows Form. Incollare il codice in una maschera e chiamare il ShowLineJoin metodo quando si gestisce l'evento del Paint modulo, passando e come PaintEventArgs.
private:
void ShowLineJoin( PaintEventArgs^ e )
{
// Create a new pen.
Pen^ skyBluePen = gcnew Pen( Brushes::DeepSkyBlue );
// Set the pen's width.
skyBluePen->Width = 8.0F;
// Set the LineJoin property.
skyBluePen->LineJoin = System::Drawing::Drawing2D::LineJoin::Bevel;
// Draw a rectangle.
e->Graphics->DrawRectangle( skyBluePen, Rectangle(40,40,150,200) );
//Dispose of the pen.
delete skyBluePen;
}
private void ShowLineJoin(PaintEventArgs e)
{
// Create a new pen.
Pen skyBluePen = new Pen(Brushes.DeepSkyBlue);
// Set the pen's width.
skyBluePen.Width = 8.0F;
// Set the LineJoin property.
skyBluePen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;
// Draw a rectangle.
e.Graphics.DrawRectangle(skyBluePen,
new Rectangle(40, 40, 150, 200));
//Dispose of the pen.
skyBluePen.Dispose();
}
Private Sub ShowLineJoin(ByVal e As PaintEventArgs)
' Create a new pen.
Dim skyBluePen As New Pen(Brushes.DeepSkyBlue)
' Set the pen's width.
skyBluePen.Width = 8.0F
' Set the LineJoin property.
skyBluePen.LineJoin = Drawing2D.LineJoin.Bevel
' Draw a rectangle.
e.Graphics.DrawRectangle(skyBluePen, _
New Rectangle(40, 40, 150, 200))
'Dispose of the pen.
skyBluePen.Dispose()
End Sub
Commenti
È possibile accedere all'unità di misura dell'oggetto Graphics usando la relativa PageUnit proprietà . L'unità di misura è in genere pixel. Un Width valore pari a 0 comporterà il Pen disegno come se fosse Width 1.