DesignerGlyph.OnPaint 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
当在派生类中重写时,执行在活动设计器图面上呈现标志符号所需的任何任务。
protected:
abstract void OnPaint(System::Drawing::Graphics ^ graphics, bool activated, System::Workflow::ComponentModel::Design::AmbientTheme ^ ambientTheme, System::Workflow::ComponentModel::Design::ActivityDesigner ^ designer);
protected abstract void OnPaint (System.Drawing.Graphics graphics, bool activated, System.Workflow.ComponentModel.Design.AmbientTheme ambientTheme, System.Workflow.ComponentModel.Design.ActivityDesigner designer);
abstract member OnPaint : System.Drawing.Graphics * bool * System.Workflow.ComponentModel.Design.AmbientTheme * System.Workflow.ComponentModel.Design.ActivityDesigner -> unit
Protected MustOverride Sub OnPaint (graphics As Graphics, activated As Boolean, ambientTheme As AmbientTheme, designer As ActivityDesigner)
参数
- activated
- Boolean
为 true
则指示在设计图面上显示标志符号;否则为 false
。
- ambientTheme
- AmbientTheme
要用于访问环境属性设置的 AmbientTheme。
- designer
- ActivityDesigner
从中获取有关用户操作的信息的 ActivityDesigner。
示例
下面的代码示例演示如何重写 OnPaint 方法。 该代码自定义在与标志符号关联的活动设计器上绘制标志符号对象的方式。
此代码示例摘自工作流监视器 SDK 示例中的 DesignerGlyphProvider.cs 文件。 有关详细信息,请参阅 工作流监视器。
protected override void OnPaint(Graphics graphics, bool activated, AmbientTheme ambientTheme, ActivityDesigner designer)
{
Bitmap bitmap = Resources.Executing;
bitmap.MakeTransparent(Color.FromArgb(0, 255, 255));
if (bitmap != null)
graphics.DrawImage(bitmap, GetBounds(designer, activated), new Rectangle(Point.Empty, bitmap.Size), GraphicsUnit.Pixel);
}
Protected Overrides Sub OnPaint(ByVal graphics As System.Drawing.Graphics, ByVal activated As Boolean, ByVal ambientTheme As System.Workflow.ComponentModel.Design.AmbientTheme, ByVal designer As System.Workflow.ComponentModel.Design.ActivityDesigner)
Dim bitmap As Bitmap = AppResources.Executing
bitmap.MakeTransparent(Color.FromArgb(0, 255, 255))
If Not bitmap Is Nothing Then
graphics.DrawImage(bitmap, GetBounds(designer, activated), New Rectangle(Point.Empty, bitmap.Size), GraphicsUnit.Pixel)
End If
End Sub
注解
OnPaint 使用 CommentIndicatorPen 来绘制注释标志符号的边界并使用 CommentIndicatorBrush 进行填充。