/// <summary> /// Reroute a connector when the role players of its underlying relationship change /// </summary> public override void RolePlayerChanged(DslModeling::RolePlayerChangedEventArgs e) { if (e == null) { throw new global::System.ArgumentNullException("e"); } global::System.Collections.ObjectModel.ReadOnlyCollection <DslDiagrams::PresentationViewsSubject> connectorLinks = DslDiagrams::PresentationViewsSubject.GetLinksToPresentation(e.ElementLink); foreach (DslDiagrams::PresentationViewsSubject connectorLink in connectorLinks) { // Fix up any binary link shapes attached to the element link. DslDiagrams::BinaryLinkShape linkShape = connectorLink.Presentation as DslDiagrams::BinaryLinkShape; if (linkShape != null) { global::Company.SlideShowDesigner.SlideShowDesignerDiagram diagram = linkShape.Diagram as global::Company.SlideShowDesigner.SlideShowDesignerDiagram; if (diagram != null) { if (e.NewRolePlayer != null) { DslDiagrams::NodeShape fromShape; DslDiagrams::NodeShape toShape; diagram.GetSourceAndTargetForConnector(linkShape, out fromShape, out toShape); if (fromShape != null && toShape != null) { if (!object.Equals(fromShape, linkShape.FromShape)) { linkShape.FromShape = fromShape; } if (!object.Equals(linkShape.ToShape, toShape)) { linkShape.ToShape = toShape; } } else { // delete the connector if we cannot find an appropriate target shape. linkShape.Delete(); } } else { // delete the connector if the new role player is null. linkShape.Delete(); } } } } }