FreeformActivityDesigner.AddConnector メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
FreeformActivityDesigner にコネクタを追加します。
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
パラメーター
- source
- ConnectionPoint
コネクタの描画の始点となる ConnectionPoint の場所。
- target
- ConnectionPoint
コネクタの描画の終点となる ConnectionPoint の場所。
戻り値
Connector に追加された FreeformActivityDesigner。
例外
source
または target
に null
参照 (Visual Basic の場合は Nothing
) が含まれています。
AssociatedDesigner または source
の target
プロパティに null
参照 (Nothing
) が含まれています。
現在の FreeformActivityDesigner は、追加するコネクタのコンテナーではありません。
例
カスタム アクティビティ デザイナーの AddConnector
メソッドで 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
注釈
AddConnector は、ユーザーが Connector に FreeformActivityDesigner を追加するときに呼び出されます。