ActivityDesigner 类 
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
注意
The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*
为所有活动设计器组件提供强制的基类。
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
		- 继承
 - 
				ActivityDesigner
 
- 派生
 
- 属性
 
- 实现
 
示例
下面的示例演示了自定义活动的 ActivityDesigner 的完整实现。 该设计器有一个可切换的标志,该标志允许基类 ActivityDesigner 控制绘制操作或使用 ActivityDesignerPaint 类的各种方法来绘制活动。
[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
	注解
注意
本材料讨论的类型和命名空间已废弃不用。 有关详细信息,请参阅 Windows Workflow Foundation 4.5 中弃用的类型。
所有活动设计器组件都是从 ActivityDesigner 派生的。 ActivityDesigner 提供了一个简单设计器,使用户可以在设计模式下直观地设计活动。
ActivityDesigner 为活动提供了一个简单机制,使它们可以参与在设计图面上呈现工作流的操作。
ActivityDesigner 使用户可以自定义与活动关联的布局和绘制。
ActivityDesigner 使用户可以扩展与活动关联的元数据。
构造函数
| ActivityDesigner() | 
			 
				已过时.
			 
		初始化 ActivityDesigner 类的新实例。  | 
        	
属性
| AccessibilityObject | 
			 
				已过时.
			 
		获取一个 AccessibleObject,辅助功能应用程序使用该对象为残障用户调整应用程序 UI。  | 
        	
| Activity | 
			 
				已过时.
			 
		获取与设计器关联的 Activity。  | 
        	
| Bounds | 
			 
				已过时.
			 
		获取一个 Rectangle,其中包含环绕设计器的矩形的值(以逻辑坐标表示)。  | 
        	
| DesignerActions | 
			 
				已过时.
			 
		获取与配置错误关联的操作的数组。  | 
        	
| DesignerTheme | 
			 
				已过时.
			 
		获取活动设计器的当前设计器主题。  | 
        	
| EnableVisualResizing | 
			 
				已过时.
			 
		获取一个值,该值指示能否在任意形式的设计器中调整活动设计器的大小。  | 
        	
| Glyphs | 
			 
				已过时.
			 
		获取用于修饰设计器的标志符号的集合。  | 
        	
| Image | 
			 
				已过时.
			 
		获取或设置与设计器关联的 Image。  | 
        	
| ImageRectangle | 
			 
				已过时.
			 
		获取与设计器关联的图像的环绕边界值(以逻辑坐标表示)。  | 
        	
| InvokingDesigner | 
			 
				已过时.
			 
		获取或设置调用与当前活动设计器关联的活动的活动设计器。  | 
        	
| IsLocked | 
			 
				已过时.
			 
		获取一个值,该值指示能否修改与设计器关联的活动。  | 
        	
| IsPrimarySelection | 
			 
				已过时.
			 
		获取一个值,该值指示与设计器关联的活动是否为主选择。  | 
        	
| IsRootDesigner | 
			 
				已过时.
			 
		获取一个值,该值指示设计器是否为根设计器。  | 
        	
| IsSelected | 
			 
				已过时.
			 
		获取一个值,该值指示是否选择了与设计器关联的活动。  | 
        	
| IsVisible | 
			 
				已过时.
			 
		获取一个值,该值指示与设计器关联的活动在工作流上是否可见。  | 
        	
| Location | 
			 
				已过时.
			 
		获取或设置设计器的位置(以逻辑坐标表示)。  | 
        	
| MessageFilters | 
			 
				已过时.
			 
		获取与活动设计器关联的消息筛选器的只读集合。  | 
        	
| MinimumSize | 
			 
				已过时.
			 
		获取活动设计器的最小大小。  | 
        	
| ParentDesigner | 
			 
				已过时.
			 
		获取现有设计器的父设计器。  | 
        	
| ParentView | 
			 
				已过时.
			 
		获取包含当前活动设计器的工作流视图。  | 
        	
| ShowSmartTag | 
			 
				已过时.
			 
		获取一个值,该值指示活动是否应显示智能标记。  | 
        	
| Size | 
			 
				已过时.
			 
		获取或设置 ActivityDesigner 的大小。  | 
        	
| SmartTagRectangle | 
			 
				已过时.
			 
		获取应在其中显示智能标记的矩形。  | 
        	
| SmartTagVerbs | 
			 
				已过时.
			 
		获取要与活动设计器上的智能标记关联的设计器操作的只读集合。  | 
        	
| Text | 
			 
				已过时.
			 
		获取或设置与设计器关联的文本。  | 
        	
| TextRectangle | 
			 
				已过时.
			 
		获取文本矩形的值(以逻辑坐标表示)。  | 
        	
| Verbs | 
			 
				已过时.
			 
		获取与设计器关联的谓词的集合。  |