ActivityDesignerPaint Class

Definition

Caution

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

Provides static methods used to draw user interface elements on activity designer surfaces. This class cannot be inherited.

C#
public static class ActivityDesignerPaint
C#
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public static class ActivityDesignerPaint
Inheritance
ActivityDesignerPaint
Attributes

Examples

The following example demonstrates a way to use the ActivityDesignerPaint class to draw a custom activity on the workflow design surface. A rounded rectangle is first drawn using the DrawRoundedRectangle method. Text is then drawn using DrawText and is placed at the location of the TextRectangle of the ActivityDesigner. Additionally, the Image associated with the ActivityDesigner is drawn using the DrawImage method of the ActivityDesignerPaint class. Finally, an expand button used by a CompositeActivity is drawn using the DrawExpandButton.

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

Remarks

Poznámka

This material discusses types and namespaces that are obsolete. For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

Methods

Draw3DButton(Graphics, Image, Rectangle, Single, ButtonState)

Draws a 3-dimensional button on the activity designer surface.

DrawExpandButton(Graphics, Rectangle, Boolean, CompositeDesignerTheme)

Draws a button that is used to expand and collapse composite designers on the activity designer surface.

DrawImage(Graphics, Image, Rectangle, DesignerContentAlignment)

Draws an image on the activity designer surface by using a Graphics, an Image, a Rectangle, and a DesignerContentAlignment.

DrawImage(Graphics, Image, Rectangle, Rectangle, DesignerContentAlignment, Single, Boolean)

Draws an image on the activity designer surface by using a Graphics, an Image, a source and destination Rectangle, an DesignerContentAlignment, a single-precision floating-point number, and a Boolean value.

DrawRoundedRectangle(Graphics, Pen, Rectangle, Int32)

Draws a rounded rectangle on the activity designer surface.

DrawText(Graphics, Font, String, Rectangle, StringAlignment, TextQuality, Brush)

Draws text on the activity designer surface.

GetRoundedRectanglePath(Rectangle, Int32)

Returns the graphics path used to draw the specified rounded rectangle.

Applies to

Produkt Verzie (Zastarané)
.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)