DynamicRenderer.OnDraw 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
墨迹的绘制是实时的,因此墨迹看起来就像从触笔或其他指针设备中“流”出来一样。
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 方法以使用 a 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) 的方法。