InkOverlay.Draw - метод
Обновлен: Ноябрь 2007
Sets a rectangle in which to redraw the ink within the InkOverlay object.
Пространство имен: Microsoft.Ink
Сборка: Microsoft.Ink (в Microsoft.Ink.dll)
Синтаксис
'Декларация
Public Sub Draw ( _
rDrawRect As Rectangle _
)
'Применение
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
)
Параметры
- rDrawRect
Тип: System.Drawing.Rectangle
The rectangle in which to redraw the ink, in pixel coordinates.
Заметки
When the rDrawRect parameter is nullссылка null (Nothing в Visual Basic) (Nothing in Microsoft Visual Basic .NET), the entire window is redrawn.
A good use of this method is to redraw strokes that have been programmically changed. You can also call the Control.Invalidate method, but this causes a redrawing off all of the InkOverlay object's strokes. You can also call the Renderer.Draw method for this purpose, but the Renderer object is not able to draw any strokes as selected because it has no knowledge of which strokes are in the Selection collection.
Примечание. |
---|
The AutoRedraw property must be set to true for the drawing to occur. |
Примеры
This C# example is a method that changes the color of all the strokes in a Strokes collection that belong to the Ink object associated with an InkOverlay object, theInkOverlay. Changing the DrawingAttributes property of a Stroke object is not automatically and immediately visible. You can call the Invalidate or Refresh method on the control associated with theInkOverlay, but this causes a redrawing of all the Stroke objects in theInkOverlay. To achieve better performance, use the Draw method on the bounding box of the Strokes collection. Note that this means converting the bounding box from ink space coordinates to pixel coordinates.
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);
}
This Visual Basic .NET example is a method that changes the color of all the strokes in a Strokes collection belonging to the Ink object associated with an InkOverlay object, theInkOverlay. Changing the DrawingAttributes property of a Stroke object is not automatically and immediately visible. You can call the Invalidate or Refresh method on the control associated with theInkOverlay, but this causes a redrawing of all the Stroke objects in theInkOverlay. To achieve better performance, use the Draw method on the bounding box of the Strokes collection. Note that this means converting the bounding box from ink space coordinates to pixel coordinates.
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
Платформы
Windows Vista
Среды .NET Framework и .NET Compact Framework поддерживают не все версии каждой платформы. Поддерживаемые версии перечислены в разделе Требования к системе для .NET Framework.
Сведения о версии
.NET Framework
Поддерживается в версии: 3.0