DesignerGlyph.OnPaint 方法

定義

在衍生類別中覆寫時,請執行任何轉譯活動設計工具介面上圖像時所需的工作。

C#
protected abstract void OnPaint(System.Drawing.Graphics graphics, bool activated, System.Workflow.ComponentModel.Design.AmbientTheme ambientTheme, System.Workflow.ComponentModel.Design.ActivityDesigner designer);

參數

graphics
Graphics

Graphics,可執行填滿與繪製工作。

activated
Boolean

true,表示圖像顯示在設計介面上,否則為 false

ambientTheme
AmbientTheme

用於存取環境屬性 (Ambient Property) 設定的 AmbientTheme

designer
ActivityDesigner

要從中取得關於使用者動作之資訊的 ActivityDesigner

範例

下列程式碼範例示範如何覆寫 OnPaint 方法。 程式碼可自訂在與圖像關聯之活動設計工具上繪製圖像物件的方式。

這個程式碼範例是 DesignerGlyphProvider.cs 檔案中<工作流程監視器 SDK>範例的一部分。 如需詳細資訊,請參閱 工作流程監視器

C#
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);
}

備註

OnPaint 會使用 CommentIndicatorPen 繪製註解圖像界限和要填滿的 CommentIndicatorBrush

適用於

產品 版本
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

另請參閱