共用方式為


CompositeActivityDesigner.InsertActivities 方法

定義

插入活動到設計工具中。

多載

InsertActivities(HitTestInfo, ReadOnlyCollection<Activity>)

在設計工具中的指定位置插入指定活動。

InsertActivities(CompositeActivityDesigner, HitTestInfo, ReadOnlyCollection<Activity>, String)

使用交易在設計工具的指定位置插入活動。

InsertActivities(HitTestInfo, ReadOnlyCollection<Activity>)

在設計工具中的指定位置插入指定活動。

public:
 virtual void InsertActivities(System::Workflow::ComponentModel::Design::HitTestInfo ^ insertLocation, System::Collections::ObjectModel::ReadOnlyCollection<System::Workflow::ComponentModel::Activity ^> ^ activitiesToInsert);
public virtual void InsertActivities (System.Workflow.ComponentModel.Design.HitTestInfo insertLocation, System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.ComponentModel.Activity> activitiesToInsert);
abstract member InsertActivities : System.Workflow.ComponentModel.Design.HitTestInfo * System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.ComponentModel.Activity> -> unit
override this.InsertActivities : System.Workflow.ComponentModel.Design.HitTestInfo * System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.ComponentModel.Activity> -> unit
Public Overridable Sub InsertActivities (insertLocation As HitTestInfo, activitiesToInsert As ReadOnlyCollection(Of Activity))

參數

insertLocation
HitTestInfo

要插入活動的設計工具位置。

activitiesToInsert
ReadOnlyCollection<Activity>

要插入之活動的清單。

備註

您可以使用 InsertActivities 將活動清單插入到指定的位置。

在呼叫 前,可以使用 來確定指定的活動可以插入。

適用於

InsertActivities(CompositeActivityDesigner, HitTestInfo, ReadOnlyCollection<Activity>, String)

使用交易在設計工具的指定位置插入活動。

public:
 static void InsertActivities(System::Workflow::ComponentModel::Design::CompositeActivityDesigner ^ compositeActivityDesigner, System::Workflow::ComponentModel::Design::HitTestInfo ^ insertLocation, System::Collections::ObjectModel::ReadOnlyCollection<System::Workflow::ComponentModel::Activity ^> ^ activitiesToInsert, System::String ^ undoTransactionDescription);
public static void InsertActivities (System.Workflow.ComponentModel.Design.CompositeActivityDesigner compositeActivityDesigner, System.Workflow.ComponentModel.Design.HitTestInfo insertLocation, System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.ComponentModel.Activity> activitiesToInsert, string undoTransactionDescription);
static member InsertActivities : System.Workflow.ComponentModel.Design.CompositeActivityDesigner * System.Workflow.ComponentModel.Design.HitTestInfo * System.Collections.ObjectModel.ReadOnlyCollection<System.Workflow.ComponentModel.Activity> * string -> unit
Public Shared Sub InsertActivities (compositeActivityDesigner As CompositeActivityDesigner, insertLocation As HitTestInfo, activitiesToInsert As ReadOnlyCollection(Of Activity), undoTransactionDescription As String)

參數

compositeActivityDesigner
CompositeActivityDesigner

將插入活動的設計工具。

insertLocation
HitTestInfo

將插入活動的設計工具位置。

activitiesToInsert
ReadOnlyCollection<Activity>

要插入之活動的清單。

undoTransactionDescription
String

藉由插入而建立的設計工具異動描述。

範例

下列範例將示範如何使用 CompositeActivityDesigner 類別以外的設計工具,加入新的分支。 如果 CanInsertActivities 傳回 true,就會使用 InsertActivities 方法來建立新的分支。

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

備註

您可以使用 InsertActivities 將活動清單插入到複合活動中。

在呼叫 InsertActivities 前,可以使用 CanInsertActivities 來確定指定的活動清單可以插入。

適用於