ActivityDesignerPaint Class
Provides static methods used to draw user interface elements on activity designer surfaces. This class cannot be inherited.
Assembly: System.Workflow.ComponentModel (in System.Workflow.ComponentModel.dll)
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 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); }
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.