ActivityDesignerPaint 类

定义

注意

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

提供用于在活动设计器图面上绘制用户界面元素的静态方法。 此类不能被继承。

public ref class ActivityDesignerPaint abstract sealed
public static class ActivityDesignerPaint
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public static class ActivityDesignerPaint
type ActivityDesignerPaint = class
[<System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")>]
type ActivityDesignerPaint = class
Public Class ActivityDesignerPaint
继承
ActivityDesignerPaint
属性

示例

下面的示例演示一种使用 ActivityDesignerPaint 类在工作流设计图面上绘制自定义活动的方式。 首先使用 DrawRoundedRectangle 方法绘制一个圆角矩形。 然后使用 DrawText 绘制文本并将其放在 TextRectangleActivityDesigner 位置。 此外,再使用 Image 类的 ActivityDesigner 方法绘制与 DrawImage 关联的 ActivityDesignerPaint。 最后,使用 CompositeActivity 绘制由 DrawExpandButton 使用的展开按钮。

private bool expanded = true;
private bool useBasePaint = false;

public bool UseBasePaint
{
    get { return this.useBasePaint; }
    set { this.useBasePaint = value; }
}

public bool Expanded
{
    get { return this.expanded; }
    set { this.expanded = value; }
}

protected override void OnPaint(ActivityDesignerPaintEventArgs e)
{
    if (this.UseBasePaint)
    {
        base.OnPaint(e);
        return;
    }

    DrawCustomActivity(e);
}

private void DrawCustomActivity(ActivityDesignerPaintEventArgs e)
{
    Graphics graphics = e.Graphics;

    CompositeDesignerTheme compositeDesignerTheme = (CompositeDesignerTheme)e.DesignerTheme;

    ActivityDesignerPaint.DrawRoundedRectangle(graphics, compositeDesignerTheme.BorderPen, this.Bounds, compositeDesignerTheme.BorderWidth);

    string text = this.Text;
    Rectangle textRectangle = this.TextRectangle;
    if (!string.IsNullOrEmpty(text) && !textRectangle.IsEmpty)
    {
        ActivityDesignerPaint.DrawText(graphics, compositeDesignerTheme.Font, text, textRectangle, StringAlignment.Center, e.AmbientTheme.TextQuality, compositeDesignerTheme.ForegroundBrush);
    }

    System.Drawing.Image image = this.Image;
    Rectangle imageRectangle = this.ImageRectangle;
    if (image != null && !imageRectangle.IsEmpty)
    {
        ActivityDesignerPaint.DrawImage(graphics, image, imageRectangle, DesignerContentAlignment.Fill);
    }

    ActivityDesignerPaint.DrawExpandButton(graphics,
        new Rectangle(this.Location.X, this.Location.Y, 10, 10),
        this.Expanded,
        compositeDesignerTheme);
}
Private expandedValue As Boolean = True
Private useBasePaintValue As Boolean = False

Public Property UseBasePaint() As Boolean
    Get
        Return Me.useBasePaintValue
    End Get

    Set(ByVal value As Boolean)
        Me.useBasePaintValue = value
    End Set
End Property

Public Property Expanded() As Boolean
    Get
        Return Me.expandedValue
    End Get
    Set(ByVal value As Boolean)
        Me.expandedValue = value
    End Set
End Property


Protected Overrides Sub OnPaint(ByVal e As ActivityDesignerPaintEventArgs)
    If Me.UseBasePaint = True Then
        MyBase.OnPaint(e)
        Return
    End If

    DrawCustomActivity(e)
End Sub

Private Sub DrawCustomActivity(ByVal e As ActivityDesignerPaintEventArgs)
    Dim graphics As Graphics = e.Graphics

    Dim compositeDesignerTheme As CompositeDesignerTheme = CType(e.DesignerTheme, CompositeDesignerTheme)

    ActivityDesignerPaint.DrawRoundedRectangle(graphics, compositeDesignerTheme.BorderPen, Me.Bounds, compositeDesignerTheme.BorderWidth)

    Dim text As String = Me.Text
    Dim TextRectangle As Rectangle = Me.TextRectangle
    If Not String.IsNullOrEmpty(text) And Not TextRectangle.IsEmpty Then
        ActivityDesignerPaint.DrawText(graphics, compositeDesignerTheme.Font, text, TextRectangle, StringAlignment.Center, e.AmbientTheme.TextQuality, compositeDesignerTheme.ForegroundBrush)
    End If

    Dim Image As System.Drawing.Image = Me.Image
    Dim ImageRectangle As Rectangle = Me.ImageRectangle
    If Image IsNot Nothing And Not ImageRectangle.IsEmpty Then
        ActivityDesignerPaint.DrawImage(graphics, Image, ImageRectangle, DesignerContentAlignment.Fill)
    End If

    ActivityDesignerPaint.DrawExpandButton(graphics, _
        New Rectangle(Me.Location.X, Me.Location.Y, 10, 10), _
        Me.Expanded, _
        compositeDesignerTheme)
End Sub

注解

注意

本材料讨论的类型和命名空间已废弃不用。 有关详细信息,请参阅 Windows Workflow Foundation 4.5 中弃用的类型

方法

Draw3DButton(Graphics, Image, Rectangle, Single, ButtonState)
已过时.

在活动设计器图面上绘制三维按钮。

DrawExpandButton(Graphics, Rectangle, Boolean, CompositeDesignerTheme)
已过时.

绘制一个用于在活动设计器图面上展开和折叠复合设计器的按钮。

DrawImage(Graphics, Image, Rectangle, DesignerContentAlignment)
已过时.

使用 GraphicsImageRectangleDesignerContentAlignment 在活动设计器图面上绘制图像。

DrawImage(Graphics, Image, Rectangle, Rectangle, DesignerContentAlignment, Single, Boolean)
已过时.

使用 GraphicsImage、源和目标 RectangleDesignerContentAlignment、单精度浮点型数字和布尔值在活动设计器图面上绘制图像。

DrawRoundedRectangle(Graphics, Pen, Rectangle, Int32)
已过时.

在活动设计器图面上绘制圆角矩形。

DrawText(Graphics, Font, String, Rectangle, StringAlignment, TextQuality, Brush)
已过时.

在活动设计器图面上绘制文本。

GetRoundedRectanglePath(Rectangle, Int32)
已过时.

返回用于绘制指定圆角矩形的图形路径。

适用于