Freigeben über


ActivityDesignerPaint.DrawImage Methode

Definition

Zeichnet ein Bild auf der Aktivitätsdesigneroberfläche.

Überlädt

DrawImage(Graphics, Image, Rectangle, DesignerContentAlignment)

Zeichnet unter Verwendung von Graphics, Image, Rectangle und DesignerContentAlignment ein Bild auf der Aktivitätsdesigneroberfläche.

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

Zeichnet unter Verwendung von Graphics, Image, eines Quell- und Ziel-Rectangle, DesignerContentAlignment, einer Gleitkommazahl mit einfacher Genauigkeit und eines booleschen Werts ein Bild auf der Aktivitätsdesigneroberfläche.

DrawImage(Graphics, Image, Rectangle, DesignerContentAlignment)

Zeichnet unter Verwendung von Graphics, Image, Rectangle und DesignerContentAlignment ein Bild auf der Aktivitätsdesigneroberfläche.

public:
 static void DrawImage(System::Drawing::Graphics ^ graphics, System::Drawing::Image ^ image, System::Drawing::Rectangle destination, System::Workflow::ComponentModel::Design::DesignerContentAlignment alignment);
public static void DrawImage (System.Drawing.Graphics graphics, System.Drawing.Image image, System.Drawing.Rectangle destination, System.Workflow.ComponentModel.Design.DesignerContentAlignment alignment);
static member DrawImage : System.Drawing.Graphics * System.Drawing.Image * System.Drawing.Rectangle * System.Workflow.ComponentModel.Design.DesignerContentAlignment -> unit
Public Shared Sub DrawImage (graphics As Graphics, image As Image, destination As Rectangle, alignment As DesignerContentAlignment)

Parameter

graphics
Graphics

Die Graphics, auf der das Bild gezeichnet werden soll.

image
Image

Das zu zeichnende Image.

destination
Rectangle

Das Rectangle, das die Begrenzungen des zu zeichnenden Bilds definiert.

alignment
DesignerContentAlignment

Die DesignerContentAlignment, die angibt, wie das Bild im umschließenden Rechteck ausgerichtet wird.

Ausnahmen

graphics, image oder destination enthält einen NULL-Verweis (Nothing in Visual Basic).

Beispiele

Das folgende Beispiel zeigt, wie die ActivityDesignerPaint-Klasse verwendet werden kann, um eine benutzerdefinierte Aktivität auf der Workflowentwurfsoberfläche zu zeichnen. Zunächst wird mit der DrawRoundedRectangle-Methode ein abgerundetes Rechteck gezeichnet. Anschließend wird Text anhand von DrawText gezeichnet und an der TextRectangle-Position von ActivityDesigner platziert. Darüber hinaus wird das Image zugeordnete ActivityDesigner mithilfe der DrawImage-Methode der ActivityDesignerPaint-Klasse gezeichnet. Zum Schluss wird eine von CompositeActivity verwendete Erweiterungsschaltfläche mit DrawExpandButton gezeichnet.

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

Hinweise

Wenn Sie diese Version von DrawImage verwenden, wird das Quellrechteck auf die Größe des Bilds (in Pixeln) festgelegt, die Transparenz wird auf 1.0f eingestellt, und das Zeichnen von Graustufen ist nicht zulässig.

Gilt für

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

Zeichnet unter Verwendung von Graphics, Image, eines Quell- und Ziel-Rectangle, DesignerContentAlignment, einer Gleitkommazahl mit einfacher Genauigkeit und eines booleschen Werts ein Bild auf der Aktivitätsdesigneroberfläche.

public:
 static void DrawImage(System::Drawing::Graphics ^ graphics, System::Drawing::Image ^ image, System::Drawing::Rectangle destination, System::Drawing::Rectangle source, System::Workflow::ComponentModel::Design::DesignerContentAlignment alignment, float transparency, bool grayscale);
public static void DrawImage (System.Drawing.Graphics graphics, System.Drawing.Image image, System.Drawing.Rectangle destination, System.Drawing.Rectangle source, System.Workflow.ComponentModel.Design.DesignerContentAlignment alignment, float transparency, bool grayscale);
static member DrawImage : System.Drawing.Graphics * System.Drawing.Image * System.Drawing.Rectangle * System.Drawing.Rectangle * System.Workflow.ComponentModel.Design.DesignerContentAlignment * single * bool -> unit
Public Shared Sub DrawImage (graphics As Graphics, image As Image, destination As Rectangle, source As Rectangle, alignment As DesignerContentAlignment, transparency As Single, grayscale As Boolean)

Parameter

graphics
Graphics

Die Graphics, auf der das Bild gezeichnet werden soll.

image
Image

Das zu zeichnende Image.

destination
Rectangle

Das Rectangle, das die Begrenzungen des Bilds definiert.

source
Rectangle

Das Rectangle, das die Quelle des Bilds definiert.

alignment
DesignerContentAlignment

Die DesignerContentAlignment, die angibt, wie das Bild im umschließenden Rechteck ausgerichtet wird.

transparency
Single

Eine Gleitkommazahl mit einfacher Genauigkeit, die die Transparenzeinstellungen für das Bild definiert.

grayscale
Boolean

true, um das Bild in Graustufen zu zeichnen, andernfalls false.

Ausnahmen

graphics, image, destination oder source enthält einen NULL-Verweis (Nothing in Visual Basic).

- oder - transparency ist kleiner als 0 oder größer als1.0f.

Gilt für