Metodo InkOverlay.Draw
Aggiornamento: novembre 2007
Imposta un rettangolo nel quale ridisegnare l' input penna all'interno dell'oggetto InkOverlay.
Spazio dei nomi: Microsoft.Ink
Assembly: Microsoft.Ink (in Microsoft.Ink.dll)
Sintassi
'Dichiarazione
Public Sub Draw ( _
rDrawRect As Rectangle _
)
'Utilizzo
Dim instance As InkOverlay
Dim rDrawRect As Rectangle
instance.Draw(rDrawRect)
public void Draw(
Rectangle rDrawRect
)
public:
void Draw(
Rectangle rDrawRect
)
public void Draw(
Rectangle rDrawRect
)
public function Draw(
rDrawRect : Rectangle
)
Parametri
- rDrawRect
Tipo: System.Drawing.Rectangle
Rettangolo nel quale ridisegnare l'input penna, in coordinate pixel.
Note
Se il parametro rDrawRect è nullriferimento null (Nothing in Visual Basic) (Nothing in Microsoft Visual Basic .NET), viene ridisegnata l'intera finestra.
Questo metodo può essere utilizzato efficacemente per ridisegnare i tratti che sono stati modificati a livello di codice. È possibile chiamare anche il metodo Control.Invalidate, ma questo comporta il ridisegno di tutti i tratti dell'oggetto InkOverlay. A tale scopo, è possibile chiamare anche il metodo Renderer.Draw, tuttavia l'oggetto Renderer non è in grado di disegnare nessun tratto selezionato, poiché non riconosce quali tratti si trovino nell'insieme Selection.
Nota
Per poter eseguire il disegno, la proprietà AutoRedraw deve essere impostata su true.
Esempi
In questo esempio di C# viene illustrato un metodo che modifica il colore di tutti i tratti di un insieme Strokes che appartengono all'oggetto Ink associato a un oggetto InkOverlay, theInkOverlay. La modifica della proprietà DrawingAttributes di un oggetto Stroke non è automaticamente e immediatamente visibile. È possibile chiamare il metodo Invalidate o Refresh sul controllo associato all'oggetto theInkOverlay, ma questo comporta il ridisegno di tutti gli oggetti Stroke nell'oggetto theInkOverlay. Per ottenere prestazioni migliori, utilizzare il metodo Draw nel riquadro dell'insieme Strokes. Questa operazione comporta la conversione del riquadro dalle coordinate dello spazio di input penna alle coordinate pixel.
private void ChangeColor(Strokes theStrokes, Color newColor)
{
// Change the color of theStrokes
foreach (Stroke stroke in theStrokes)
{
stroke.DrawingAttributes.Color = newColor;
}
// Convert bounding box to pixel coordinates
Graphics g = CreateGraphics();
Rectangle strokesBounds = theStrokes.GetBoundingBox();
Point topLeft = strokesBounds.Location;
Point bottomRight = strokesBounds.Location + strokesBounds.Size;
theInkOverlay.Renderer.InkSpaceToPixel(g, ref topLeft);
theInkOverlay.Renderer.InkSpaceToPixel(g, ref bottomRight);
g.Dispose()
strokesBounds = new Rectangle(topLeft,
new Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y));
// Redraw the strokes
theInkOverlay.Draw(strokesBounds);
}
In questo esempio di Visual Basic .NET viene illustrato un metodo che modifica il colore di tutti i tratti di un insieme Strokes che appartengono all'oggetto Ink associato a un oggetto InkOverlay, theInkOverlay. La modifica della proprietà DrawingAttributes di un oggetto Stroke non è automaticamente e immediatamente visibile. È possibile chiamare il metodo Invalidate o Refresh sul controllo associato all'oggetto theInkOverlay, ma questo comporta il ridisegno di tutti gli oggetti Stroke nell'oggetto theInkOverlay. Per ottenere prestazioni migliori, utilizzare il metodo Draw nel riquadro dell'insieme Strokes. Questa operazione comporta la conversione del riquadro dalle coordinate dello spazio di input penna alle coordinate pixel.
Private Sub ChangeColor(ByVal theStrokes As Strokes, ByVal newColor As Color)
' Change the color of theStrokes
Dim theStroke As Stroke
For Each theStroke In theStrokes
theStroke.DrawingAttributes.Color = newColor
Next
'Convert bounding box to pixel coordinates
Dim g As Graphics = CreateGraphics()
Dim strokesBounds As Rectangle = theStrokes.GetBoundingBox()
Dim topLeft As Point = strokesBounds.Location
Dim bottomRight As Point = New Point(strokesBounds.Right, strokesBounds.Bottom)
theInkOverlay.Renderer.InkSpaceToPixel(g, topLeft)
theInkOverlay.Renderer.InkSpaceToPixel(g, bottomRight)
g.Dispose()
strokesBounds = New Rectangle(topLeft, _
New Size(bottomRight.X - topLeft.X, bottomRight.Y - topLeft.Y))
'Redraw the strokes
theInkOverlay.Draw(strokesBounds)
End Sub
Piattaforme
Windows Vista
.NET Framework e .NET Compact Framework non supportano tutte le versioni di ciascuna piattaforma. Per un elenco delle versioni supportate, vedere Requisiti di sistema di .NET Framework.
Informazioni sulla versione
.NET Framework
Supportato in: 3.0