FreeformActivityDesigner.AddConnector Yöntem

Tanım

öğesine FreeformActivityDesignerbir bağlayıcı ekler.

public:
 System::Workflow::ComponentModel::Design::Connector ^ AddConnector(System::Workflow::ComponentModel::Design::ConnectionPoint ^ source, System::Workflow::ComponentModel::Design::ConnectionPoint ^ target);
public System.Workflow.ComponentModel.Design.Connector AddConnector (System.Workflow.ComponentModel.Design.ConnectionPoint source, System.Workflow.ComponentModel.Design.ConnectionPoint target);
member this.AddConnector : System.Workflow.ComponentModel.Design.ConnectionPoint * System.Workflow.ComponentModel.Design.ConnectionPoint -> System.Workflow.ComponentModel.Design.Connector
Public Function AddConnector (source As ConnectionPoint, target As ConnectionPoint) As Connector

Parametreler

source
ConnectionPoint

Bağlayıcıyı ConnectionPoint çizmeye başlanacağınız konum.

target
ConnectionPoint

ConnectionPoint Bağlayıcıyı çizmeyi bitirecek konum.

Döndürülenler

Connector

öğesine Connector eklenen FreeformActivityDesigner.

Özel durumlar

sourceveya target bir null başvuru içerir (Nothing Visual Basic).

AssociatedDesigner veya source target özelliği bir null başvuru (Nothing içerir.

Geçerli FreeformActivityDesigner , bağlayıcının ekleneceği kapsayıcı değildir.

Örnekler

Aşağıdaki örnekte, özel etkinlik tasarımcısının AddConnector yönteminde yönteminin nasıl kullanılacağı gösterilmektedir OnLayoutPosition .

class ProcessActvityDesigner : FreeformActivityDesigner
{
    private ConnectionPoint GetConnectionPoint(Activity activity, Int32 connectorIndex, DesignerEdges edge)
    {
        ActivityDesigner designer = null;

        if (activity != null && activity.Site != null)
        {
            IDesignerHost designerHost = activity.Site.GetService(typeof(IDesignerHost)) as IDesignerHost;
            if (designerHost != null)
                designer = designerHost.GetDesigner(activity) as ActivityDesigner;
        }
        return new ConnectionPoint(designer, edge, connectorIndex);
    }

    protected override void OnLayoutPosition(ActivityDesignerLayoutEventArgs e)
    {
        base.OnLayoutPosition(e);

        // Draw a connector between the first and second activities contained in
        // the sequence activity used by this designer
        if (this.IsRootDesigner)
        {
            CompositeActivity parentActivity = (CompositeActivity)this.Activity;
            ConnectionPoint sourcePoint = GetConnectionPoint(parentActivity.Activities[0], 1, DesignerEdges.Bottom);
            ConnectionPoint targetPoint = GetConnectionPoint(parentActivity.Activities[1], 0, DesignerEdges.Top);

            this.AddConnector(sourcePoint, targetPoint);
        }
    }
Class ProcessActvityDesigner
    Inherits System.Workflow.ComponentModel.Design.FreeformActivityDesigner


    Function GetConnectionPoint(ByVal activity As Activity, ByVal connectorIndex As Int32, ByVal edge As DesignerEdges) As ConnectionPoint

        Dim designer As ActivityDesigner = Nothing

        If Activity IsNot Nothing And Activity.Site IsNot Nothing Then

            Dim designerHost As IDesignerHost = activity.Site.GetService(GetType(IDesignerHost))
            If designerHost IsNot Nothing Then
                designer = CType(designerHost.GetDesigner(activity), ActivityDesigner)
            End If
        End If

        Return New ConnectionPoint(designer, edge, connectorIndex)
    End Function


    Protected Overrides Sub OnLayoutPosition(ByVal e As ActivityDesignerLayoutEventArgs)

        MyBase.OnLayoutPosition(e)

        ' Draw a connector between the first and second activities contained in 
        ' the sequence activity used by me designer
        If Me.IsRootDesigner Then

            Dim parentActivity As CompositeActivity = CType(Me.Activity, CompositeActivity)
            Dim sourcePoint As ConnectionPoint = GetConnectionPoint(parentActivity.Activities(0), 1, DesignerEdges.Bottom)
            Dim targetPoint As ConnectionPoint = GetConnectionPoint(parentActivity.Activities(1), 0, DesignerEdges.Top)

            Me.AddConnector(sourcePoint, targetPoint)
        End If
    End Sub

End Class

Açıklamalar

AddConnector , kullanıcı öğesine bir Connector eklediğinde çağrılır FreeformActivityDesigner.

Şunlara uygulanır