Share via


ActivityDesignerPaint.DrawExpandButton Méthode

Définition

Dessine un bouton utilisé pour développer et réduire les concepteurs composites sur l‘aire du concepteur d‘activité.

public:
 static void DrawExpandButton(System::Drawing::Graphics ^ graphics, System::Drawing::Rectangle boundingRect, bool drawExpanded, System::Workflow::ComponentModel::Design::CompositeDesignerTheme ^ compositeDesignerTheme);
public static void DrawExpandButton (System.Drawing.Graphics graphics, System.Drawing.Rectangle boundingRect, bool drawExpanded, System.Workflow.ComponentModel.Design.CompositeDesignerTheme compositeDesignerTheme);
static member DrawExpandButton : System.Drawing.Graphics * System.Drawing.Rectangle * bool * System.Workflow.ComponentModel.Design.CompositeDesignerTheme -> unit
Public Shared Sub DrawExpandButton (graphics As Graphics, boundingRect As Rectangle, drawExpanded As Boolean, compositeDesignerTheme As CompositeDesignerTheme)

Paramètres

graphics
Graphics

Graphics sur lequel dessiner le bouton.

boundingRect
Rectangle

Rectangle qui définit les limites du bouton.

drawExpanded
Boolean

true pour dessiner un bouton développé ; sinon, false.

compositeDesignerTheme
CompositeDesignerTheme

CompositeDesignerTheme associé au concepteur d'activité utilisé pour afficher le bouton.

Exceptions

graphics ou compositeDesignerTheme contient une référence Null (Nothing en Visual Basic).

Exemples

L'exemple suivant montre une façon d'utiliser la classe ActivityDesignerPaint pour dessiner une activité personnalisée sur l'aire de conception de workflow. Un rectangle arrondi est tout d'abord dessiné à l'aide de la méthode DrawRoundedRectangle. Le texte est ensuite dessiné à l'aide de DrawText et est positionné à l'emplacement de la propriété TextRectangle du ActivityDesigner. En outre, la propriété Image associée au ActivityDesigner est dessinée à l'aide de la méthode DrawImage de la classe ActivityDesignerPaint. Enfin, un bouton de développement utilisé par un CompositeActivity est dessiné à l’aide de la méthode 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

S’applique à