ActivityDesigner 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
警告
The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*
為所有的活動設計工具元件提供強制基底類別 (Base Class)。
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 |
已淘汰.
取得協助工具應用程式用來為殘障使用者調整應用程式 UI 的 AccessibleObject。 |
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 |
已淘汰.
取得要與設計工具產生關聯的動詞集合。 |