Connector CreateLink(UIElement source, UIElement dest, ModelItem linkModelItem) { Connector newConnector = null; ConnectionPoint srcConnPoint = null, destConnPoint = null; if (this.srcConnectionPointForAutoConnect != null) { srcConnPoint = this.srcConnectionPointForAutoConnect; destConnPoint = FlowchartDesigner.GetDestinationConnectionPointForAutoConnect(dest, srcConnPoint); this.srcConnectionPointForAutoConnect = null; } else if (this.srcConnectionPointForAutoSplit != null && this.srcConnectionPointForAutoSplit.ParentDesigner == source) { srcConnPoint = this.srcConnectionPointForAutoSplit; destConnPoint = this.GetDestinationConnectionPointForAutoSplit(srcConnPoint, dest); this.srcConnectionPointForAutoSplit = null; } else if (this.destConnectionPointForAutoSplit != null && this.destConnectionPointForAutoSplit.ParentDesigner == dest) { destConnPoint = this.destConnectionPointForAutoSplit; srcConnPoint = this.GetSourceConnectionPointForAutoSplit(destConnPoint, source); this.destConnectionPointForAutoSplit = null; } else { string errorMessage; GetSrcDestConnectionPoints(source, dest, out srcConnPoint, out destConnPoint, out errorMessage); } if (srcConnPoint != null && destConnPoint != null) { newConnector = CreateLink(srcConnPoint, destConnPoint, linkModelItem); } return(newConnector); }
Connector CreateLink(ConnectionPoint sourceConnectionPoint, UIElement dest, ModelItem linkModelItem) { Connector newConnector = null; ConnectionPoint destConnectionPoint = null; if (this.srcConnectionPointForAutoConnect != null) { Fx.Assert(this.srcConnectionPointForAutoConnect == sourceConnectionPoint, "sourceConnectionPoint should equal to this.srcConnectionPointForAutoConnect"); destConnectionPoint = FlowchartDesigner.GetDestinationConnectionPointForAutoConnect(dest, sourceConnectionPoint); this.srcConnectionPointForAutoConnect = null; } else if (this.srcConnectionPointForAutoSplit == sourceConnectionPoint) { destConnectionPoint = this.GetDestinationConnectionPointForAutoSplit(this.srcConnectionPointForAutoSplit, dest); this.srcConnectionPointForAutoSplit = null; } else { string errorMessage; destConnectionPoint = FindBestMatchDestConnectionPoint(sourceConnectionPoint, dest, out errorMessage); } if (destConnectionPoint != null) { newConnector = CreateLink(sourceConnectionPoint, destConnectionPoint, linkModelItem); } return(newConnector); }