DynamicRenderer.OnDraw Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
Zeichnet die Freihandfarbe in Echtzeit, sodass sie vom Tablet-Stift oder einem anderen Zeigegerät "fließen" scheint.
protected:
virtual void OnDraw(System::Windows::Media::DrawingContext ^ drawingContext, System::Windows::Input::StylusPointCollection ^ stylusPoints, System::Windows::Media::Geometry ^ geometry, System::Windows::Media::Brush ^ fillBrush);
protected virtual void OnDraw(System.Windows.Media.DrawingContext drawingContext, System.Windows.Input.StylusPointCollection stylusPoints, System.Windows.Media.Geometry geometry, System.Windows.Media.Brush fillBrush);
abstract member OnDraw : System.Windows.Media.DrawingContext * System.Windows.Input.StylusPointCollection * System.Windows.Media.Geometry * System.Windows.Media.Brush -> unit
override this.OnDraw : System.Windows.Media.DrawingContext * System.Windows.Input.StylusPointCollection * System.Windows.Media.Geometry * System.Windows.Media.Brush -> unit
Protected Overridable Sub OnDraw (drawingContext As DrawingContext, stylusPoints As StylusPointCollection, geometry As Geometry, fillBrush As Brush)
Parameter
- drawingContext
- DrawingContext
Das DrawingContext Objekt, auf dem der Strich gerendert wird.
- stylusPoints
- StylusPointCollection
Dies StylusPointCollection stellt das Segment des zu zeichnenden Strichs dar.
- fillBrush
- Brush
Ein Pinsel, der die Darstellung des aktuellen Strichs angibt.
Beispiele
Im folgenden Beispiel wird veranschaulicht, wie die OnDraw Methode zum dynamischen Rendern digitaler Freihandeingaben mit einem LinearGradientBrush.
protected override void OnDraw(DrawingContext drawingContext,
StylusPointCollection stylusPoints,
Geometry geometry, Brush fillBrush)
{
// Create a new Brush, if necessary
if (brush == null)
{
Color primaryColor;
if (fillBrush is SolidColorBrush)
{
primaryColor = ((SolidColorBrush)fillBrush).Color;
}
else
{
primaryColor = Colors.Red;
}
brush = new LinearGradientBrush(Colors.Blue, primaryColor, 20d);
}
drawingContext.DrawGeometry(brush, null, geometry);
}
Protected Overrides Sub OnDraw(ByVal drawingContext As DrawingContext, _
ByVal stylusPoints As StylusPointCollection, _
ByVal geometry As Geometry, _
ByVal fillBrush As Brush)
' Create a new Brush, if necessary
If brush Is Nothing Then
Dim primaryColor As Color
If TypeOf fillBrush Is SolidColorBrush Then
primaryColor = CType(fillBrush, SolidColorBrush).Color
Else
primaryColor = Colors.Red
End If
brush = New LinearGradientBrush(Colors.Blue, primaryColor, 20.0)
End If
drawingContext.DrawGeometry(brush, Nothing, geometry)
End Sub
Hinweise für Vererber
Achten Sie beim Überschreiben OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) in einer abgeleiteten Klasse darauf, die Methode der Basisklasse OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) aufzurufen.