ActivityDesigner Class

Definition

Caution

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

Provides a mandatory base class for all activity designer components.

[System.Workflow.ComponentModel.Design.ActivityDesignerTheme(typeof(System.Workflow.ComponentModel.Design.ActivityDesignerTheme))]
public class ActivityDesigner : IDisposable, System.ComponentModel.Design.IDesignerFilter, System.ComponentModel.Design.IRootDesigner, System.Drawing.Design.IToolboxUser, System.Workflow.ComponentModel.Design.IPersistUIState, System.Workflow.ComponentModel.Design.IWorkflowRootDesigner
[System.Workflow.ComponentModel.Design.ActivityDesignerTheme(typeof(System.Workflow.ComponentModel.Design.ActivityDesignerTheme))]
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public class ActivityDesigner : IDisposable, System.ComponentModel.Design.IDesignerFilter, System.ComponentModel.Design.IRootDesigner, System.Drawing.Design.IToolboxUser, System.Workflow.ComponentModel.Design.IPersistUIState, System.Workflow.ComponentModel.Design.IWorkflowRootDesigner
Inheritance
ActivityDesigner
Derived
Attributes
Implements

Examples

The following example shows a complete implementation of an ActivityDesigner for a custom activity. The designer has a flag that can be toggled to allow the base class ActivityDesigner to control the painting or to utilize the various methods the ActivityDesignerPaint class to draw the activity.

[ActivityDesignerTheme(typeof(CustomCompositeActivityDesignerTheme))]
public class CustomActivityDesigner : ActivityDesigner
{
    public override bool CanBeParentedTo(CompositeActivityDesigner parentActivityDesigner)
    {
        if (parentActivityDesigner.GetType().ToString() == "System.Workflow.Activities.IfElseBranchDesigner")
            return false;

        return true;
    }

    private ActivityDesignerVerbCollection verbs = null;

    protected override ActivityDesignerVerbCollection Verbs
    {
        get
        {
            if (this.verbs == null)
                CreateActivityVerbs();

            return this.verbs;
        }
    }

    private void CreateActivityVerbs()
    {
        this.verbs = new ActivityDesignerVerbCollection();

        ActivityDesignerVerb addBranchVerb = new ActivityDesignerVerb(this,
            DesignerVerbGroup.View, "Add New Parallel Branch", new EventHandler(OnAddParallelBranch));
        this.verbs.Clear();

        this.verbs.Add(addBranchVerb);
    }

    protected void OnAddParallelBranch(object sender, EventArgs e)
    {
        // Code for adding a new branch to the parallel activity goes here
    }

    protected override Rectangle ImageRectangle
    {
        get
        {
            Rectangle bounds = this.Bounds;
            Size sz = new Size(24, 24);

            Rectangle imageRect = new Rectangle();
            imageRect.X = bounds.Left + ((bounds.Width - sz.Width) / 2);
            imageRect.Y = bounds.Top + 4;
            imageRect.Size = sz;

            return imageRect;
        }
    }

    protected override Rectangle TextRectangle
    {
        get
        {
            return new Rectangle(
                this.Bounds.Left + 2,
                this.ImageRectangle.Bottom,
                this.Bounds.Width - 4,
                this.Bounds.Height - this.ImageRectangle.Height - 1);
        }
    }

    protected override void Initialize(Activity activity)
    {
        base.Initialize(activity);
        Bitmap bmp = Resources.ToolboxImage;
        bmp.MakeTransparent();
        this.Image = bmp;
    }

    readonly static Size BaseSize = new Size(64, 64);
    protected override Size OnLayoutSize(ActivityDesignerLayoutEventArgs e)
    {
        return BaseSize;
    }

    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);
    }
}

Remarks

Nota

This material discusses types and namespaces that are obsolete. For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

All activity designer components derive from ActivityDesigner. The ActivityDesigner provides a simple designer which lets the user visually design activities in the design mode.

ActivityDesigner provides a simple mechanism for the activities so they can participate in rendering the workflow on the design surface.

ActivityDesigner lets the user customize layout and drawing associated with the activity.

ActivityDesigner lets the user extend the metadata associated with the activity.

Constructors

ActivityDesigner()

Initializes a new instance of the ActivityDesigner class.

Properties

AccessibilityObject

Gets an AccessibleObject that accessibility applications use to adjust the application UI for users who have impairments.

Activity

Gets the Activity associated with the designer.

Bounds

Gets a Rectangle which contains the value for the enclosing rectangle of the designer in logical coordinates.

DesignerActions

Gets the array of actions associated with configuration errors.

DesignerTheme

Gets the current designer theme for the activity designer.

EnableVisualResizing

Gets a value that indicates whether the activity designer can be resized in a free form designer.

Glyphs

Gets a collection of glyphs with which to adorn the designer.

Image

Gets or sets the Image associated with the designer.

ImageRectangle

Gets the value for the enclosing bounds of the image associated with the designer in logical coordinates.

InvokingDesigner

Gets or sets the designer of the activity that invokes the activity associated with the current activity designer.

IsLocked

Gets a value that indicates whether the activity associated with the designer can be modified.

IsPrimarySelection

Gets a value that indicates whether the activity associated with the designer is the primary selection.

IsRootDesigner

Gets a value that indicates whether the designer is a root designer.

IsSelected

Gets a value that indicates whether the activity associated with the designer is selected.

IsVisible

Gets a value that indicates whether the activity associated with the designer is visible on the workflow.

Location

Gets or sets the location of the designer in logical coordinates.

MessageFilters

Gets a read-only collection of message filters that are associated with the activity designer.

MinimumSize

Gets the minimum size for the activity designer.

ParentDesigner

Gets the parent designer of the existing designer.

ParentView

Gets the workflow view that contains the current activity designer.

ShowSmartTag

Gets a value that indicates whether the activity should show a smart tag.

Size

Gets or sets the size of the ActivityDesigner.

SmartTagRectangle

Gets the rectangle where the smart tag should be displayed.

SmartTagVerbs

Gets a read-only collection of designer actions to associate with a smart tag on the activity designer.

Text

Gets or sets the text to associate with the designer.

TextRectangle

Gets the value of the text rectangle in logical coordinates.

Verbs

Gets the collection of verbs to be associated with the designer.

Methods

CanBeParentedTo(CompositeActivityDesigner)

Returns a value that indicates if a CompositeActivity can be set as the parent of the activity associated with the designer.

CanConnect(ConnectionPoint, ConnectionPoint)

Returns a value that indicates whether a connection can be created between the specified connection point on the current activity designer and the specified connection point on a target activity designer.

CreateView(ViewTechnology)

Creates a workflow view for the current activity designer using the specified ViewTechnology.

Dispose()

Releases the unmanaged resources used by the ActivityDesigner and optionally releases the managed resources.

Dispose(Boolean)

Releases the resources used by the ActivityDesigner class.

DoDefaultAction()

Performs the default UI action associated with the designer.

EnsureVisible()

Shifts the visible area of the screen to guarantee that the specified designer is visible.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize()

When overridden in a derived class, allows an object to clean up any resources deterministically.

GetConnectionPoints(DesignerEdges)

Returns a read-only collection of connection points for the activity designer along the specified DesignerEdges.

GetConnections(DesignerEdges)

Returns a read-only collection of points that the designer uses for connections.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetPreviewImage(Graphics)

Gets the image of the activity designer on the specified Graphics.

GetRootDesigner(IServiceProvider)

Returns the designer associated with the design surface of the workflow.

GetService(Type)

Tries to retrieve the specified type of service from the design mode site for the activity associated with the designer.

GetType()

Gets the Type of the current instance.

(Inherited from Object)
HitTest(Point)

Gets information about the ActivityDesigner at a specified point on the screen.

Initialize(Activity)

Initializes the designer with the associated Activity.

Invalidate()

Invalidates the designer.

Invalidate(Rectangle)

Invalidates the specified rectangle on the designer.

IsCommentedActivity(Activity)

Returns a value that indicates whether the current designer's activity is commented or is inside a commented activity.

IsSupportedActivityType(Type)

Returns a value that indicates whether the specified activity type is supported if the activity designer is a root designer.

LoadViewState(BinaryReader)

Loads the view state of the designer from a binary stream.

MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnActivityChanged(ActivityChangedEventArgs)

Notifies the ActivityDesigner when the activity it is associated with changes.

OnBeginResizing(ActivityDesignerResizeEventArgs)

Notifies the ActivityDesigner when a user starts to visually resize the activity designer when the designer is in a FreeformActivityDesigner.

OnConnected(ConnectionPoint, ConnectionPoint)

Notifies the ActivityDesigner when a connection is established between two connection points.

OnDragDrop(ActivityDragEventArgs)

Occurs when the drag-drop operation is completed inside designer bounds.

OnDragEnter(ActivityDragEventArgs)

Occurs when the drag-drop operation is in progress and the pointer enters the designer bounds.

OnDragLeave()

Occurs when the drag-drop operation is in progress and the pointer leaves the designer bounds.

OnDragOver(ActivityDragEventArgs)

Occurs when the drag-drop operation is in progress and the pointer is within the designer bounds.

OnEndResizing()

Notifies the ActivityDesigner when a user is finished visually resizing the activity designer when the designer is in a FreeformActivityDesigner.

OnExecuteDesignerAction(DesignerAction)

Notifies the ActivityDesigner when the user clicks on the configuration errors associated with the designer.

OnGiveFeedback(GiveFeedbackEventArgs)

Updates the visual cues for feedback supplied to the user when performing a drag operation.

OnKeyDown(KeyEventArgs)

Occurs when a key is pressed when the designer has the keyboard focus.

OnKeyUp(KeyEventArgs)

Occurs when a key is released when the designer has keyboard focus.

OnLayoutPosition(ActivityDesignerLayoutEventArgs)

Notifies the ActivityDesigner when a user repositions its visual cues or child activity designers.

OnLayoutSize(ActivityDesignerLayoutEventArgs)

Returns the size of the visual cues or child activity designers on the ActivityDesigner.

OnMouseCaptureChanged()

Occurs when the mouse capture changes.

OnMouseDoubleClick(MouseEventArgs)

Occurs when the mouse button is clicked multiple times on the designer.

OnMouseDown(MouseEventArgs)

Occurs when the mouse button is pressed when the pointer is in designer bounds.

OnMouseDragBegin(Point, MouseEventArgs)

Occurs when the user starts to drag the mouse on the designer.

OnMouseDragEnd()

Occurs when the user stops dragging the mouse on the designer.

OnMouseDragMove(MouseEventArgs)

Occurs on each movement of the mouse as the user drags the pointer over the designer.

OnMouseEnter(MouseEventArgs)

Occurs when the mouse first enters the designer bounds.

OnMouseHover(MouseEventArgs)

Occurs when the pointer is in designer bounds.

OnMouseLeave()

Occurs when the pointer leaves designer bounds.

OnMouseMove(MouseEventArgs)

Occurs when the pointer is moving in designer bounds.

OnMouseUp(MouseEventArgs)

Occurs when the mouse button is released when the pointer is in designer bounds.

OnPaint(ActivityDesignerPaintEventArgs)

Draws the visual representation of the activity at design time.

OnProcessMessage(Message)

Allows the designer to process raw Win32 messages.

OnQueryContinueDrag(QueryContinueDragEventArgs)

Controls whether the drag operation should continue.

OnResizing(ActivityDesignerResizeEventArgs)

Notifies the ActivityDesigner when a user is visually resizing it at design time. The method is only called if the activity designer is a child of a FreeformActivityDesigner.

OnScroll(ScrollBar, Int32)

Notifies the ActivityDesigner when a user changes the scroll position.

OnShowSmartTagVerbs(Point)

Displays the designer verbs associated with a smart tag at the specified point.

OnSmartTagVisibilityChanged(Boolean)

Notifies the ActivityDesigner whether a smart tag should be displayed or hidden.

OnThemeChange(ActivityDesignerTheme)

Notifies the designer that the associated theme has changed.

PerformLayout()

Updates the layout of the designer.

PointToLogical(Point)

Transforms a point from screen coordinate system to the activity designer coordinate system.

PointToScreen(Point)

Transforms a point from the activity designer coordinate system to the screen coordinate system.

PostFilterAttributes(IDictionary)

When overridden in a derived class, allows a designer to change or remove items from the set of attributes that it exposes through a TypeDescriptor.

PostFilterEvents(IDictionary)

When overridden in a derived class, allows the designer to change or remove items from the set of events that it exposes through a TypeDescriptor.

PostFilterProperties(IDictionary)

When overridden in a derived class, allows a designer to change or remove items from the set of properties that it exposes through a TypeDescriptor.

PreFilterAttributes(IDictionary)

When overridden in a derived class, allows a designer to add items to the set of attributes that it exposes through a TypeDescriptor.

PreFilterEvents(IDictionary)

When overridden in a derived class, allows a designer to add items to the set of events that it exposes through a TypeDescriptor.

PreFilterProperties(IDictionary)

When overridden in a derived class, allows a designer to add items to the set of properties that it exposes through a TypeDescriptor.

RectangleToLogical(Rectangle)

Transforms a rectangle from the screen coordinate system to the activity designer coordinate system.

RectangleToScreen(Rectangle)

Transforms a rectangle from the activity designer coordinate system to the screen coordinate system.

RefreshDesignerActions()

Refreshes the configuration errors associated with the designer.

RefreshDesignerVerbs()

Refreshes the activity designer verbs associated with the designer by calling the status handler.

SaveViewState(BinaryWriter)

Stores the view state of the designer into a binary stream.

ShowInfoTip(String, String)

Displays the info tip for the ActivityDesigner with the specified title and text.

ShowInfoTip(String)

Shows the specified info tip.

ShowInPlaceTip(String, Rectangle)

Displays the specified tool tip in the specified rectangle location.

ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

IDesigner.Component

Gets the base component with which the activity designer is associated.

IDesigner.DoDefaultAction()

Performs the default action associated with the designer.

IDesigner.Initialize(IComponent)

Initializes the designer with the associated activity.

IDesigner.Verbs

Gets the design-time verbs associated with the activity designer.

IDesignerFilter.PostFilterAttributes(IDictionary)

When overridden in a derived class, allows a designer to change or remove items from the set of attributes that it exposes through a TypeDescriptor.

IDesignerFilter.PostFilterEvents(IDictionary)

When overridden in a derived class, allows a designer to change or remove items from the set of events that it exposes through a TypeDescriptor.

IDesignerFilter.PostFilterProperties(IDictionary)

When overridden in a derived class, allows a designer to change or remove items from the set of properties that it exposes through a TypeDescriptor.

IDesignerFilter.PreFilterAttributes(IDictionary)

When overridden in a derived class, allows a designer to add items to the set of attributes that it exposes through a TypeDescriptor.

IDesignerFilter.PreFilterEvents(IDictionary)

When overridden in a derived class, allows a designer to add items to the set of events that it exposes through a TypeDescriptor.

IDesignerFilter.PreFilterProperties(IDictionary)

When overridden in a derived class, allows a designer to add items to the set of properties that it exposes through a TypeDescriptor.

IPersistUIState.LoadViewState(BinaryReader)

Restores the view state from a binary stream.

IPersistUIState.SaveViewState(BinaryWriter)

Saves the view state to a binary stream.

IRootDesigner.GetView(ViewTechnology)

Returns a view object for the specified view technology.

IRootDesigner.SupportedTechnologies

Gets the array of technologies that the activity designer can support for its display.

IToolboxUser.GetToolSupported(ToolboxItem)

Determines whether the specified Toolbox item is supported by the current activity designer.

IToolboxUser.ToolPicked(ToolboxItem)

Selects the specified toolbox item.

IWorkflowRootDesigner.InvokingDesigner

Gets or sets the CompositeActivityDesigner that requested the activity designer be initialized.

IWorkflowRootDesigner.IsSupportedActivityType(Type)

Returns a value that indicates whether the specified type is supported on the current ActivityDesigner.

IWorkflowRootDesigner.MessageFilters

Gets any message filters associated with the activity designer.

IWorkflowRootDesigner.SupportsLayoutPersistence

Gets the value that indicates whether the actual workflow root designer supports the layout persistence.

Applies to

Prodotto Versioni (Obsoleto)
.NET Framework 3.0, 3.5, 4.0 (4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1)