ActivityDesignerPaint Class
Assembly: System.Workflow.ComponentModel (in system.workflow.componentmodel.dll)
The following example demonstrates a way of using 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 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.