This documentation is archived and is not being maintained.

ActivityDesignerPaint Class

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

Namespace:  System.Workflow.ComponentModel.Design
Assembly:  System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)

'Declaration
Public NotInheritable Class ActivityDesignerPaint
'Usage
You do not need to declare an instance of a static class in order to access its members.

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.

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

System.Object
  System.Workflow.ComponentModel.Design.ActivityDesignerPaint

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0
Show: