DynamicRenderer.OnDraw 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
即時繪製筆墨,使筆墨看起來像是「順著」Tablet 畫筆或其他指向裝置出現一樣。
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)
參數
- drawingContext
- DrawingContext
要在其中呈現筆劃的 DrawingContext 物件。
- stylusPoints
- StylusPointCollection
表示要繪製之筆劃區段的 StylusPointCollection。
- fillBrush
- Brush
指定目前筆劃外觀的筆刷。
範例
下列範例示範如何使用 覆寫 OnDraw 方法來動態轉譯數位筆跡 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
給繼承者的注意事項
在 OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) 衍生類別中覆寫時,請務必呼叫基類的 OnDraw(DrawingContext, StylusPointCollection, Geometry, Brush) 方法。