다음을 통해 공유


ActivityDesignerPaint.DrawText 메서드

정의

Activity Designer 화면에 이미지를 그립니다.

public:
 static void DrawText(System::Drawing::Graphics ^ graphics, System::Drawing::Font ^ font, System::String ^ text, System::Drawing::Rectangle boundingRect, System::Drawing::StringAlignment alignment, System::Workflow::ComponentModel::Design::TextQuality textQuality, System::Drawing::Brush ^ textBrush);
public static void DrawText (System.Drawing.Graphics graphics, System.Drawing.Font font, string text, System.Drawing.Rectangle boundingRect, System.Drawing.StringAlignment alignment, System.Workflow.ComponentModel.Design.TextQuality textQuality, System.Drawing.Brush textBrush);
static member DrawText : System.Drawing.Graphics * System.Drawing.Font * string * System.Drawing.Rectangle * System.Drawing.StringAlignment * System.Workflow.ComponentModel.Design.TextQuality * System.Drawing.Brush -> unit
Public Shared Sub DrawText (graphics As Graphics, font As Font, text As String, boundingRect As Rectangle, alignment As StringAlignment, textQuality As TextQuality, textBrush As Brush)

매개 변수

graphics
Graphics

텍스트를 그릴 Graphics입니다.

font
Font

텍스트를 그릴 때 사용되는 Font입니다.

text
String

그릴 텍스트입니다.

boundingRect
Rectangle

텍스트를 그려야 하는 경계 Rectangle입니다.

alignment
StringAlignment

텍스트가 경계 사각형에 정렬되는 위치를 지정하는 StringAlignment입니다.

textQuality
TextQuality

텍스트를 그리기 위한 품질 설정을 지정하는 TextQuality입니다.

textBrush
Brush

텍스트를 그릴 Brush입니다.

예외

graphics, font, text 또는 textBrush에 null 참조(Visual Basic의 경우 Nothing)가 포함된 경우

예제

다음 예제에서는 ActivityDesignerPaint 클래스를 사용하여 워크플로 디자인 화면에 사용자 지정 활동을 그리는 방법을 보여 줍니다. 먼저 DrawRoundedRectangle 메서드를 사용하여 모퉁이가 둥근 사각형을 그립니다. 그런 다음 DrawText를 사용하여 텍스트를 그리고 TextRectangleActivityDesigner 위치에 배치합니다. 또한 Image 클래스의 ActivityDesigner 메서드를 사용하여 DrawImage와 연결된 ActivityDesignerPaint를 그립니다. 마지막으로 CompositeActivity에서 사용하는 확장명 단추를 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

적용 대상