StructuredCompositeActivityDesigner.ContainedDesigners 屬性

定義

取得泛型唯讀集合,其中包含 StructuredCompositeActivityDesigner 子系的所有活動設計工具。Gets a generic read-only collection that contains all activity designers that are children of the StructuredCompositeActivityDesigner.

public:
 virtual property System::Collections::ObjectModel::ReadOnlyCollection<System::Workflow::ComponentModel::Design::ActivityDesigner ^> ^ ContainedDesigners { System::Collections::ObjectModel::ReadOnlyCollection<System::Workflow::ComponentModel::Design::ActivityDesigner ^> ^ get(); };
public override System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.ComponentModel.Design.ActivityDesigner> ContainedDesigners { get; }
member this.ContainedDesigners : System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.ComponentModel.Design.ActivityDesigner>
Public Overrides ReadOnly Property ContainedDesigners As ReadOnlyCollection(Of ActivityDesigner)

屬性值

ActivityDesigner 唯讀集合,包含子設計工具。An ActivityDesigner read-only collection that contains the child designers.

範例

下列範例將示範如何使用 CompositeActivityDesigner 類別以外的設計工具,加入新的分支。The following example demonstrates the addition of a new branch using a designer based off of the CompositeActivityDesigner class. 如果 CanInsertActivities 傳回 true,就會使用 InsertActivities 方法來建立新的分支。If CanInsertActivities returns true, a new branch is created using the InsertActivities method. 建立 ConnectorHitTestInfo 物件並做為參數傳到 InsertActivities 方法。A ConnectorHitTestInfo object is created as a parameter to the InsertActivities method. 當結束時,EnsureVisibleContainedDesigner 方法會藉由存取 ContainedDesigners 集合中的單一物件,用來確保新加入的分支將顯示在工作流程設計工具上。When this is finished, the EnsureVisibleContainedDesigner method is used to ensure that the newly added branch is displayed in the workflow designer by accessing a single object in the ContainedDesigners collection.

protected override CompositeActivity OnCreateNewBranch()
{
    return new ParallelIfBranch();
}

private void OnAddBranch(object sender, EventArgs e)
{
    CompositeActivity activity1 = this.OnCreateNewBranch();
    CompositeActivity activity2 = base.Activity as CompositeActivity;

    if ((activity2 != null) && (activity1 != null))
    {
        int num1 = this.ContainedDesigners.Count;
        Activity[] activityArray1 = new Activity[] { activity1 };

        if (CanInsertActivities(new ConnectorHitTestInfo(this, HitTestLocations.Designer, activity2.Activities.Count),
            new List<Activity>(activityArray1).AsReadOnly()))
        {
            CompositeActivityDesigner.InsertActivities(this,
                new ConnectorHitTestInfo(this, HitTestLocations.Designer, activity2.Activities.Count),
                new List<Activity>(activityArray1).AsReadOnly(),
                string.Format("Adding branch {0}", activity1.GetType().Name));

            if ((this.ContainedDesigners.Count > num1) && (this.ContainedDesigners.Count > 0))
            {
                this.ContainedDesigners[this.ContainedDesigners.Count - 1].EnsureVisible();
            }
        }
    }
}
Protected Overrides Function OnCreateNewBranch() As CompositeActivity
    Return New ParallelIfBranch()
End Function

Private Sub OnAddBranch(ByVal sender As Object, ByVal e As EventArgs)
    Dim activity1 As CompositeActivity = Me.OnCreateNewBranch()
    Dim activity2 As CompositeActivity = CType(MyBase.Activity, CompositeActivity)

    If (activity2 IsNot Nothing) And (activity1 IsNot Nothing) Then

        Dim num1 As Integer = Me.ContainedDesigners.Count
        Dim activityArray1() As Activity = {activity1}

        If (CanInsertActivities(New ConnectorHitTestInfo(Me, HitTestLocations.Designer, activity2.Activities.Count), _
            New List(Of Activity)(activityArray1).AsReadOnly())) Then

            CompositeActivityDesigner.InsertActivities(Me, _
                New ConnectorHitTestInfo(Me, HitTestLocations.Designer, activity2.Activities.Count), _
                New List(Of Activity)(activityArray1).AsReadOnly(), _
                String.Format("Adding branch 0}", activity1.GetType().Name))

            If (Me.ContainedDesigners.Count > num1) And (Me.ContainedDesigners.Count > 0) Then
                Me.ContainedDesigners(Me.ContainedDesigners.Count - 1).EnsureVisible()
            End If
        End If
    End If
End Sub

適用於