ActivityDesigner Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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.
public ref 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))]
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
[<System.Workflow.ComponentModel.Design.ActivityDesignerTheme(typeof(System.Workflow.ComponentModel.Design.ActivityDesignerTheme))>]
type ActivityDesigner = class
interface IDesignerFilter
interface IToolboxUser
interface IPersistUIState
interface IWorkflowRootDesigner
interface IRootDesigner
interface IDesigner
interface IDisposable
[<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.*")>]
type ActivityDesigner = class
interface IDesignerFilter
interface IToolboxUser
interface IPersistUIState
interface IWorkflowRootDesigner
interface IRootDesigner
interface IDesigner
interface IDisposable
[<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.*")>]
type ActivityDesigner = class
interface IDisposable
interface IDesignerFilter
interface IDesigner
interface IToolboxUser
interface IPersistUIState
interface IWorkflowRootDesigner
interface IRootDesigner
Public Class ActivityDesigner
Implements IDesignerFilter, IDisposable, IPersistUIState, IRootDesigner, IToolboxUser, IWorkflowRootDesigner
- Inheritance
-
ActivityDesigner
- Derived
- Attributes
- Implements
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);
}
}
<ActivityDesignerTheme(GetType(CustomCompositeActivityDesignerTheme))> _
Public Class CustomActivityDesigner
Inherits ActivityDesigner
Public Overrides Function CanBeParentedTo(ByVal parentActivityDesigner As CompositeActivityDesigner) As Boolean
If parentActivityDesigner.GetType().ToString() = "System.Workflow.Activities.IfElseBranchDesigner" Then
Return False
End If
Return True
End Function
Private verbsValue As ActivityDesignerVerbCollection = Nothing
Protected Overrides ReadOnly Property Verbs() As ActivityDesignerVerbCollection
Get
If verbsValue Is Nothing Then
CreateActivityVerbs()
End If
Return Me.verbsValue
End Get
End Property
Private Sub CreateActivityVerbs()
Me.verbsValue = New ActivityDesignerVerbCollection()
Dim addBranchVerb As New ActivityDesignerVerb(Me, DesignerVerbGroup.View, "Add New Parallel Branch", AddressOf OnAddParallelBranch)
Me.verbsValue.Clear()
Me.verbsValue.Add(addBranchVerb)
End Sub
Protected Sub OnAddParallelBranch(ByVal sender As Object, ByVal e As EventArgs)
' Code for adding a new branch to the parallel activity goes here
End Sub
Protected Overrides ReadOnly Property ImageRectangle() As Rectangle
Get
Dim Bounds As Rectangle = Me.Bounds
Dim sz As New Size(24, 24)
Dim imageRect As New Rectangle()
imageRect.X = Bounds.Left + ((Bounds.Width - sz.Width) / 2)
imageRect.Y = Bounds.Top + 4
imageRect.Size = sz
Return imageRect
End Get
End Property
Protected Overrides ReadOnly Property TextRectangle() As Rectangle
Get
Return New Rectangle( _
Me.Bounds.Left + 2, _
Me.ImageRectangle.Bottom, _
Me.Bounds.Width - 4, _
Me.Bounds.Height - Me.ImageRectangle.Height - 1)
End Get
End Property
Protected Overrides Sub Initialize(ByVal activity As Activity)
MyBase.Initialize(activity)
Dim bmp As Bitmap = Resources.ToolboxImage
bmp.MakeTransparent()
Me.Image = bmp
End Sub
Shared ReadOnly BaseSize As New Size(64, 64)
Protected Overrides Function OnLayoutSize(ByVal e As ActivityDesignerLayoutEventArgs) As Size
Return BaseSize
End Function
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
End Class
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.
Activity |
Initializes a new instance of the ActivityDesigner class. |
Accessibility |
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. |
Designer |
Gets the array of actions associated with configuration errors. |
Designer |
Gets the current designer theme for the activity designer. |
Enable |
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. |
Image |
Gets the value for the enclosing bounds of the image associated with the designer in logical coordinates. |
Invoking |
Gets or sets the designer of the activity that invokes the activity associated with the current activity designer. |
Is |
Gets a value that indicates whether the activity associated with the designer can be modified. |
Is |
Gets a value that indicates whether the activity associated with the designer is the primary selection. |
Is |
Gets a value that indicates whether the designer is a root designer. |
Is |
Gets a value that indicates whether the activity associated with the designer is selected. |
Is |
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. |
Message |
Gets a read-only collection of message filters that are associated with the activity designer. |
Minimum |
Gets the minimum size for the activity designer. |
Parent |
Gets the parent designer of the existing designer. |
Parent |
Gets the workflow view that contains the current activity designer. |
Show |
Gets a value that indicates whether the activity should show a smart tag. |
Size |
Gets or sets the size of the ActivityDesigner. |
Smart |
Gets the rectangle where the smart tag should be displayed. |
Smart |
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. |
Text |
Gets the value of the text rectangle in logical coordinates. |
Verbs |
Gets the collection of verbs to be associated with the designer. |
Can |
Returns a value that indicates if a CompositeActivity can be set as the parent of the activity associated with the designer. |
Can |
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. |
Create |
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. |
Do |
Performs the default UI action associated with the designer. |
Ensure |
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. |
Get |
Returns a read-only collection of connection points for the activity designer along the specified DesignerEdges. |
Get |
Returns a read-only collection of points that the designer uses for connections. |
Get |
Serves as the default hash function. (Inherited from Object) |
Get |
Gets the image of the activity designer on the specified Graphics. |
Get |
Returns the designer associated with the design surface of the workflow. |
Get |
Tries to retrieve the specified type of service from the design mode site for the activity associated with the designer. |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Hit |
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. |
Is |
Returns a value that indicates whether the current designer's activity is commented or is inside a commented activity. |
Is |
Returns a value that indicates whether the specified activity type is supported if the activity designer is a root designer. |
Load |
Loads the view state of the designer from a binary stream. |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
On |
Notifies the ActivityDesigner when the activity it is associated with changes. |
On |
Notifies the ActivityDesigner when a user starts to visually resize the activity designer when the designer is in a FreeformActivityDesigner. |
On |
Notifies the ActivityDesigner when a connection is established between two connection points. |
On |
Occurs when the drag-drop operation is completed inside designer bounds. |
On |
Occurs when the drag-drop operation is in progress and the pointer enters the designer bounds. |
On |
Occurs when the drag-drop operation is in progress and the pointer leaves the designer bounds. |
On |
Occurs when the drag-drop operation is in progress and the pointer is within the designer bounds. |
On |
Notifies the ActivityDesigner when a user is finished visually resizing the activity designer when the designer is in a FreeformActivityDesigner. |
On |
Notifies the ActivityDesigner when the user clicks on the configuration errors associated with the designer. |
On |
Updates the visual cues for feedback supplied to the user when performing a drag operation. |
On |
Occurs when a key is pressed when the designer has the keyboard focus. |
On |
Occurs when a key is released when the designer has keyboard focus. |
On |
Notifies the ActivityDesigner when a user repositions its visual cues or child activity designers. |
On |
Returns the size of the visual cues or child activity designers on the ActivityDesigner. |
On |
Occurs when the mouse capture changes. |
On |
Occurs when the mouse button is clicked multiple times on the designer. |
On |
Occurs when the mouse button is pressed when the pointer is in designer bounds. |
On |
Occurs when the user starts to drag the mouse on the designer. |
On |
Occurs when the user stops dragging the mouse on the designer. |
On |
Occurs on each movement of the mouse as the user drags the pointer over the designer. |
On |
Occurs when the mouse first enters the designer bounds. |
On |
Occurs when the pointer is in designer bounds. |
On |
Occurs when the pointer leaves designer bounds. |
On |
Occurs when the pointer is moving in designer bounds. |
On |
Occurs when the mouse button is released when the pointer is in designer bounds. |
On |
Draws the visual representation of the activity at design time. |
On |
Allows the designer to process raw Win32 messages. |
On |
Controls whether the drag operation should continue. |
On |
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. |
On |
Notifies the ActivityDesigner when a user changes the scroll position. |
On |
Displays the designer verbs associated with a smart tag at the specified point. |
On |
Notifies the ActivityDesigner whether a smart tag should be displayed or hidden. |
On |
Notifies the designer that the associated theme has changed. |
Perform |
Updates the layout of the designer. |
Point |
Transforms a point from screen coordinate system to the activity designer coordinate system. |
Point |
Transforms a point from the activity designer coordinate system to the screen coordinate system. |
Post |
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. |
Post |
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. |
Post |
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. |
Pre |
When overridden in a derived class, allows a designer to add items to the set of attributes that it exposes through a TypeDescriptor. |
Pre |
When overridden in a derived class, allows a designer to add items to the set of events that it exposes through a TypeDescriptor. |
Pre |
When overridden in a derived class, allows a designer to add items to the set of properties that it exposes through a TypeDescriptor. |
Rectangle |
Transforms a rectangle from the screen coordinate system to the activity designer coordinate system. |
Rectangle |
Transforms a rectangle from the activity designer coordinate system to the screen coordinate system. |
Refresh |
Refreshes the configuration errors associated with the designer. |
Refresh |
Refreshes the activity designer verbs associated with the designer by calling the status handler. |
Save |
Stores the view state of the designer into a binary stream. |
Show |
Displays the info tip for the ActivityDesigner with the specified title and text. |
Show |
Shows the specified info tip. |
Show |
Displays the specified tool tip in the specified rectangle location. |
To |
Returns a string that represents the current object. (Inherited from Object) |
IDesigner. |
Gets the base component with which the activity designer is associated. |
IDesigner. |
Performs the default action associated with the designer. |
IDesigner. |
Initializes the designer with the associated activity. |
IDesigner. |
Gets the design-time verbs associated with the activity designer. |
IDesigner |
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. |
IDesigner |
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. |
IDesigner |
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. |
IDesigner |
When overridden in a derived class, allows a designer to add items to the set of attributes that it exposes through a TypeDescriptor. |
IDesigner |
When overridden in a derived class, allows a designer to add items to the set of events that it exposes through a TypeDescriptor. |
IDesigner |
When overridden in a derived class, allows a designer to add items to the set of properties that it exposes through a TypeDescriptor. |
IPersist |
Restores the view state from a binary stream. |
IPersist |
Saves the view state to a binary stream. |
IRoot |
Returns a view object for the specified view technology. |
IRoot |
Gets the array of technologies that the activity designer can support for its display. |
IToolbox |
Determines whether the specified Toolbox item is supported by the current activity designer. |
IToolbox |
Selects the specified toolbox item. |
IWorkflow |
Gets or sets the CompositeActivityDesigner that requested the activity designer be initialized. |
IWorkflow |
Returns a value that indicates whether the specified type is supported on the current ActivityDesigner. |
IWorkflow |
Gets any message filters associated with the activity designer. |
IWorkflow |
Gets the value that indicates whether the actual workflow root designer supports the layout persistence. |
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) |
Feedback su .NET
.NET è un progetto di open source. Selezionare un collegamento per fornire feedback: