Share via


ActivityDesignerPaint Classe

Definição

Cuidado

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

Fornece métodos estáticos usados para desenhar os elementos da interface do usuário nas superfícies de designer de atividade. Essa classe não pode ser herdada.

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
Herança
ActivityDesignerPaint
Atributos

Exemplos

O exemplo a seguir demonstra uma maneira de usar a ActivityDesignerPaint classe para desenhar uma atividade personalizada na superfície de design do fluxo de trabalho. Um retângulo arredondado é desenhado pela primeira vez usando o DrawRoundedRectangle método. Em seguida, o texto é desenhado usando DrawText e é colocado no local do TextRectangle ActivityDesigner. Além disso, o Image associado ao ActivityDesigner é desenhado usando o DrawImage método da ActivityDesignerPaint classe. Por fim, um botão expandir usado por um CompositeActivity é desenhado usando o 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 == true)
    {
        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

Comentários

Observação

Este material discute tipos e namespaces obsoletos. Para obter mais informações, consulte Deprecated Types in Windows Workflow Foundation 4.5 (Tipos preteridos no Windows Workflow Foundation 4.5).

Métodos

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

Desenha um botão tridimensional na superfície do designer de atividade.

DrawExpandButton(Graphics, Rectangle, Boolean, CompositeDesignerTheme)

Desenha um botão que é usado para expandir e recolher os designers de composição na superfície do designer de atividade.

DrawImage(Graphics, Image, Rectangle, DesignerContentAlignment)

Desenha uma imagem na superfície do designer de atividade usando um Graphics, uma Image, um Rectangle e um DesignerContentAlignment.

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

Desenha uma imagem na superfície do designer de atividade usando um Graphics, uma Image, um Rectangle de origem e de destino, um DesignerContentAlignment, um número de ponto flutuante de precisão simples e um valor booliano.

DrawRoundedRectangle(Graphics, Pen, Rectangle, Int32)

Desenha um retângulo arredondado na superfície do designer de atividade.

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

Desenha texto na superfície do designer de atividade.

GetRoundedRectanglePath(Rectangle, Int32)

Retorna o caminho de gráficos usado para desenhar o retângulo arredondado especificado.

Aplica-se a