bool CreateFlowSwitchLink(ConnectionPoint sourceConnPoint, ModelItem srcFlowElementMI, ModelItem destFlowElementMI, IFlowSwitchLink caseKey, PointCollection connectorViewState, ref string errorMessage) { IModelTreeItem modelTreeItem = this.ModelItem as IModelTreeItem; if ((caseKey != null && caseKey.IsDefaultCase) || (caseKey == null && srcFlowElementMI.Properties["Default"].Value == null)) { IFlowSwitchLink link = GenericFlowSwitchHelper.CreateFlowSwitchLink(srcFlowElementMI.ItemType, srcFlowElementMI, null, true); ModelItem linkModelItem = new FakeModelItemImpl(modelTreeItem.ModelTreeManager, link.GetType(), link, null); link.ModelItem = linkModelItem; if (connectorViewState != null) { this.StoreConnectorViewState(linkModelItem, connectorViewState, sourceConnPoint); } srcFlowElementMI.Properties["Default"].SetValue(destFlowElementMI); } else { ModelProperty casesProp = srcFlowElementMI.Properties["Cases"]; string uniqueCaseName = null; if (caseKey == null) { Type typeArgument = srcFlowElementMI.ItemType.GetGenericArguments()[0]; if (GenericFlowSwitchHelper.CanBeGeneratedUniquely(typeArgument)) { uniqueCaseName = GenericFlowSwitchHelper.GetCaseName(casesProp, typeArgument, out errorMessage); } else { FlowSwitchCaseEditorDialog editor = new FlowSwitchCaseEditorDialog(srcFlowElementMI, this.Context, this, SR.AddNewCase, typeArgument); editor.WindowSizeToContent = SizeToContent.WidthAndHeight; if (!editor.ShowOkCancel()) { return(false); } uniqueCaseName = editor.CaseName; } } else { uniqueCaseName = caseKey.CaseName; } if (string.IsNullOrEmpty(errorMessage)) { IFlowSwitchLink link = GenericFlowSwitchHelper.CreateFlowSwitchLink(srcFlowElementMI.ItemType, srcFlowElementMI, uniqueCaseName, false); ModelItem linkModelItem = new FakeModelItemImpl(modelTreeItem.ModelTreeManager, link.GetType(), link, null); link.ModelItem = linkModelItem; if (connectorViewState != null) { this.StoreConnectorViewState(linkModelItem, connectorViewState, sourceConnPoint); } GenericFlowSwitchHelper.AddCase(srcFlowElementMI.Properties["Cases"], link.CaseObject, destFlowElementMI.GetCurrentValue()); } } return(true); }
// The method will return the CaseKey if any. // referenceUpdatedModelItems: say A linked to B by linker C, there is a relationship: // A.Properties["Relation"] = B. // When delete the linker C, A will be updated like, A.Properties["Relation"] = null; // In multiple drag/drop, the A.Properties["Relation"] is set correctly before coming // here, which means we should not set the value again, otherwise the correct, // value which is set previously, will be removed. internal IFlowSwitchLink DeleteLink(Connector link, bool isMoveOrAutoSplit = false, HashSet <ModelItem> referenceUpdatedModelItems = null) { IFlowSwitchLink caseKey = null; using (EditingScope deleteLinkEditingScope = ((IModelTreeItem)this.ModelItem).ModelTreeManager.CreateEditingScope(SR.FCDeleteLink)) { caseKey = DeleteLinkImpl(link, isMoveOrAutoSplit, referenceUpdatedModelItems); deleteLinkEditingScope.Complete(); } return(caseKey); }
void RefreshFlowSwitchLinkModelItem(ModelItem flowSwitchModelItem, Connector connector, bool isDefault) { ModelItem oldLinkModelItem = FlowchartDesigner.GetLinkModelItem(connector); IModelTreeItem modelTreeItem = flowSwitchModelItem as IModelTreeItem; IFlowSwitchLink link = GenericFlowSwitchHelper.CreateFlowSwitchLink(flowSwitchModelItem.ItemType, flowSwitchModelItem, ((IFlowSwitchLink)oldLinkModelItem.GetCurrentValue()).CaseObject, isDefault); ModelItem linkModelItem = new FakeModelItemImpl(modelTreeItem.ModelTreeManager, link.GetType(), link, null); link.ModelItem = linkModelItem; FlowchartDesigner.SetLinkModelItem(connector, linkModelItem); connector.SetBinding(Connector.LabelTextProperty, link.CreateConnectorLabelTextBinding()); Selection currentSelection = this.Context.Items.GetValue <Selection>(); if (currentSelection.SelectedObjects.Contains(oldLinkModelItem)) { Selection.Toggle(this.Context, oldLinkModelItem); Selection.Select(this.Context, linkModelItem); } }
internal bool CreateLinkGesture(ConnectionPoint sourceConnectionPoint, UIElement dest, out string errorMessage, bool isLinkValidDueToLinkMove, IFlowSwitchLink caseKey) { bool linkCreated = false; ConnectionPoint destConnectionPoint = ClosestDestConnectionPoint(sourceConnectionPoint, dest, out errorMessage); if (destConnectionPoint != null) { linkCreated = CreateLinkGesture(sourceConnectionPoint, destConnectionPoint, out errorMessage, isLinkValidDueToLinkMove, caseKey); } return linkCreated; }
internal bool CreateLinkGesture(ConnectionPoint sourceConnectionPoint, ConnectionPoint destConnectionPoint, out string errorMessage, bool isLinkValidDueToLinkMove, IFlowSwitchLink caseKey) { Fx.Assert(this.panel != null, "This code should not be hit if panel is null"); Fx.Assert(sourceConnectionPoint != null, "sourceConnectionPoint is null."); Fx.Assert(destConnectionPoint != null, "destConnectionPoint is null."); bool linkCreated = false; errorMessage = string.Empty; if (destConnectionPoint.PointType != ConnectionPointKind.Outgoing && sourceConnectionPoint.PointType != ConnectionPointKind.Incoming) { using (EditingScope es = (EditingScope)this.ModelItem.BeginEdit(SR.FCCreateLink)) { linkCreated = UpdateFlowChartObject(sourceConnectionPoint, destConnectionPoint, out errorMessage, isLinkValidDueToLinkMove, caseKey); try { es.Complete(); } catch (ArgumentException) { errorMessage = SR.InvalidFlowSwitchCaseMessage; linkCreated = false; } } } else { errorMessage = SR.FCInvalidLink; } return linkCreated; }
//Interfaces for users to create links on the flowchart. internal bool CreateLinkGesture(ConnectionPoint sourceConnectionPoint, ConnectionPoint destConnectionPoint, out string errorMessage, IFlowSwitchLink caseKey) { return CreateLinkGesture(sourceConnectionPoint, destConnectionPoint, out errorMessage, false, caseKey); }
bool CreateFlowSwitchLink(ConnectionPoint sourceConnPoint, ModelItem srcFlowElementMI, ModelItem destFlowElementMI, IFlowSwitchLink caseKey, PointCollection connectorViewState, ref string errorMessage) { IModelTreeItem modelTreeItem = this.ModelItem as IModelTreeItem; if ((caseKey != null && caseKey.IsDefaultCase) || (caseKey == null && srcFlowElementMI.Properties["Default"].Value == null)) { IFlowSwitchLink link = GenericFlowSwitchHelper.CreateFlowSwitchLink(srcFlowElementMI.ItemType, srcFlowElementMI, null, true); ModelItem linkModelItem = new FakeModelItemImpl(modelTreeItem.ModelTreeManager, link.GetType(), link, null); link.ModelItem = linkModelItem; if (connectorViewState != null) { this.StoreConnectorViewState(linkModelItem, connectorViewState, sourceConnPoint); } srcFlowElementMI.Properties["Default"].SetValue(destFlowElementMI); } else { ModelProperty casesProp = srcFlowElementMI.Properties["Cases"]; string uniqueCaseName = null; if (caseKey == null) { Type typeArgument = srcFlowElementMI.ItemType.GetGenericArguments()[0]; if (GenericFlowSwitchHelper.CanBeGeneratedUniquely(typeArgument)) { uniqueCaseName = GenericFlowSwitchHelper.GetCaseName(casesProp, typeArgument, out errorMessage); } else { FlowSwitchCaseEditorDialog editor = new FlowSwitchCaseEditorDialog(srcFlowElementMI, this.Context, this, SR.AddNewCase, typeArgument); editor.WindowSizeToContent = SizeToContent.WidthAndHeight; if (!editor.ShowOkCancel()) { return false; } uniqueCaseName = editor.CaseName; } } else { uniqueCaseName = caseKey.CaseName; } if (string.IsNullOrEmpty(errorMessage)) { IFlowSwitchLink link = GenericFlowSwitchHelper.CreateFlowSwitchLink(srcFlowElementMI.ItemType, srcFlowElementMI, uniqueCaseName, false); ModelItem linkModelItem = new FakeModelItemImpl(modelTreeItem.ModelTreeManager, link.GetType(), link, null); link.ModelItem = linkModelItem; if (connectorViewState != null) { this.StoreConnectorViewState(linkModelItem, connectorViewState, sourceConnPoint); } GenericFlowSwitchHelper.AddCase(srcFlowElementMI.Properties["Cases"], link.CaseObject, destFlowElementMI.GetCurrentValue()); } } return true; }
bool UpdateFlowChartObject(ConnectionPoint sourceConnPoint, ConnectionPoint destConnPoint, out string errorMessage, bool isLinkValidDueToLinkMove, IFlowSwitchLink caseKey) { //srcDesigner will be null for the case where source designer is StartSymbol. VirtualizedContainerService.VirtualizingContainer srcDesigner = sourceConnPoint.ParentDesigner as VirtualizedContainerService.VirtualizingContainer; VirtualizedContainerService.VirtualizingContainer destDesigner = destConnPoint.ParentDesigner as VirtualizedContainerService.VirtualizingContainer; ModelItem linkSource; ModelItem linkDest = destDesigner.ModelItem; ModelItem destFlowElementMI = GetFlowElementMI(linkDest); PointCollection connectorViewState = new PointCollection(ConnectorRouter.Route(this.panel, sourceConnPoint, destConnPoint)); errorMessage = string.Empty; if (sourceConnPoint.ParentDesigner is StartSymbol) { linkSource = this.ModelItem; if (linkSource.Properties["StartNode"].Value == null || isLinkValidDueToLinkMove) { this.StoreConnectorViewState(linkSource, connectorViewState, sourceConnPoint); linkSource.Properties["StartNode"].SetValue(destFlowElementMI); } else { errorMessage = SR.FCNextLinkDefined; } } else { linkSource = srcDesigner.ModelItem; ModelItem srcFlowElementMI = GetFlowElementMI(linkSource); if (typeof(FlowStep).IsAssignableFrom(srcFlowElementMI.ItemType)) { if (srcFlowElementMI.Properties["Next"].Value == null || isLinkValidDueToLinkMove) { this.StoreConnectorViewState(srcFlowElementMI, connectorViewState, sourceConnPoint); srcFlowElementMI.Properties["Next"].SetValue(destFlowElementMI); } else { errorMessage = SR.FCNextLinkDefined; } } else if (typeof(FlowDecision).IsAssignableFrom(srcFlowElementMI.ItemType)) { if (sourceConnPoint.Equals(FlowchartDesigner.GetTrueConnectionPoint(this.modelElement[linkSource]))) { if (linkSource.Properties["True"].Value == null || isLinkValidDueToLinkMove) { this.StoreConnectorViewState(srcFlowElementMI, connectorViewState, sourceConnPoint); linkSource.Properties["True"].SetValue(destFlowElementMI); } else { errorMessage = SR.FCTrueBranchExists; } } else if (sourceConnPoint.Equals(FlowchartDesigner.GetFalseConnectionPoint(this.modelElement[linkSource]))) { if (linkSource.Properties["False"].Value == null || isLinkValidDueToLinkMove) { this.StoreConnectorViewState(srcFlowElementMI, connectorViewState, sourceConnPoint); linkSource.Properties["False"].SetValue(destFlowElementMI); } else { errorMessage = SR.FCFalseBranchExists; } } else { errorMessage = SR.FCFlowConditionLinkError; } } else //FlowSwitch { if (!CreateFlowSwitchLink(sourceConnPoint, srcFlowElementMI, destFlowElementMI, caseKey, connectorViewState, ref errorMessage)) { return false; } } } return errorMessage.Equals(string.Empty); }
private IFlowSwitchLink DeleteLinkImpl(Connector link, bool isMoveOrAutoSplit = false, HashSet <ModelItem> referenceUpdatedModelItems = null) { IFlowSwitchLink caseKey = null; ModelItem linkModelItem = FlowchartDesigner.GetLinkModelItem(link); if (referenceUpdatedModelItems != null && referenceUpdatedModelItems.Contains(linkModelItem)) { return(caseKey); } ConnectionPoint srcConnectionPoint = FreeFormPanel.GetSourceConnectionPoint(link); ConnectionPoint destConnectionPoint = FreeFormPanel.GetDestinationConnectionPoint(link); if (typeof(FlowStep).IsAssignableFrom(linkModelItem.ItemType)) { linkModelItem.Properties["Next"].SetValue(null); } else if (typeof(FlowDecision).IsAssignableFrom(linkModelItem.ItemType)) { //Determine if it is True or False branch. if (srcConnectionPoint.Equals(FlowchartDesigner.GetTrueConnectionPoint(srcConnectionPoint.ParentDesigner))) { //True branch linkModelItem.Properties["True"].SetValue(null); } else { linkModelItem.Properties["False"].SetValue(null); } } else if (typeof(IFlowSwitchLink).IsAssignableFrom(linkModelItem.ItemType)) { IFlowSwitchLink flowSwitchLink = (IFlowSwitchLink)linkModelItem.GetCurrentValue(); caseKey = flowSwitchLink; //Transitioning from the fakeModelItem world to the real ModelItem world. FlowNode fs = flowSwitchLink.ParentFlowSwitch; ModelItem realFlowSwitchMI = (this.ModelItem as IModelTreeItem).ModelTreeManager.WrapAsModelItem(fs); if (referenceUpdatedModelItems != null && referenceUpdatedModelItems.Contains(realFlowSwitchMI)) { return(caseKey); } if (flowSwitchLink.IsDefaultCase) { realFlowSwitchMI.Properties["Default"].SetValue(null); if (!isMoveOrAutoSplit) { realFlowSwitchMI.Properties[FlowSwitchLabelFeature.DefaultCaseDisplayNamePropertyName].SetValue(FlowSwitchLabelFeature.DefaultCaseDisplayNameDefaultValue); } } else { GenericFlowSwitchHelper.RemoveCase(realFlowSwitchMI.Properties["Cases"], flowSwitchLink.CaseObject); } } else // StartNode { this.ModelItem.Properties["StartNode"].SetValue(null); } this.StoreConnectorViewState(linkModelItem, null, srcConnectionPoint, true); return(caseKey); }
void AddFlowElementsToDesigner(IList <ModelItem> flowElementMICollection, bool addConnectorAfterLoaded = false) { Queue <ModelItem> flowElementsToProcess = new Queue <ModelItem>(); List <UIElement> viewsAdded = new List <UIElement>(); foreach (ModelItem model in flowElementMICollection) { ModelItem itemOnCanvas = GetCorrespondingElementOnCanvas(model); if (!this.modelElement.ContainsKey(itemOnCanvas)) { flowElementsToProcess.Enqueue(model); viewsAdded.Add(ProcessAndGetModelView(itemOnCanvas)); } else if (!this.panel.Children.Contains(this.modelElement[itemOnCanvas])) { flowElementsToProcess.Enqueue(model); viewsAdded.Add(this.modelElement[itemOnCanvas]); } } ModelItem startNodeModelItem = null; List <Tuple <UIElement, UIElement, ModelItem> > elem2elemConnections = new List <Tuple <UIElement, UIElement, ModelItem> >(); List <Tuple <ConnectionPoint, UIElement, ModelItem> > point2elemConnections = new List <Tuple <ConnectionPoint, UIElement, ModelItem> >(); while (flowElementsToProcess.Count > 0) { ModelItem currentMI = flowElementsToProcess.Dequeue(); //Create links for the current FlowNode. //First of all check if this is connected to the start node. if (this.ModelItem.Properties["StartNode"].Value != null && this.ModelItem.Properties["StartNode"].Value.Equals(currentMI)) { startNodeModelItem = currentMI; } if (typeof(FlowStep).IsAssignableFrom(currentMI.ItemType)) { ModelItem linkDest = currentMI.Properties["Next"].Value; if (linkDest != null) { ModelItem src = GetCorrespondingElementOnCanvas(currentMI); ModelItem dest = GetCorrespondingElementOnCanvas(linkDest); if (!modelElement.ContainsKey(dest)) { viewsAdded.Add(ProcessAndGetModelView(dest)); flowElementsToProcess.Enqueue(linkDest); } elem2elemConnections.Add(Tuple.Create(modelElement[src], modelElement[dest], currentMI)); } } else if (typeof(FlowDecision).IsAssignableFrom(currentMI.ItemType)) { ModelItem trueDest = currentMI.Properties["True"].Value; ModelItem falseDest = currentMI.Properties["False"].Value; if (trueDest != null) { ConnectionPoint srcConnectionPoint = FlowchartDesigner.GetTrueConnectionPoint(modelElement[currentMI]); ModelItem trueDestOnCanvas = GetCorrespondingElementOnCanvas(trueDest); if (!modelElement.ContainsKey(trueDestOnCanvas)) { viewsAdded.Add(ProcessAndGetModelView(trueDestOnCanvas)); flowElementsToProcess.Enqueue(trueDest); } point2elemConnections.Add(Tuple.Create(srcConnectionPoint, modelElement[trueDestOnCanvas], currentMI)); } if (falseDest != null) { ConnectionPoint srcConnectionPoint = FlowchartDesigner.GetFalseConnectionPoint(modelElement[currentMI]); ModelItem falseDestOnCanvas = GetCorrespondingElementOnCanvas(falseDest); if (!modelElement.ContainsKey(falseDestOnCanvas)) { viewsAdded.Add(ProcessAndGetModelView(falseDestOnCanvas)); flowElementsToProcess.Enqueue(falseDest); } point2elemConnections.Add(Tuple.Create(srcConnectionPoint, modelElement[falseDestOnCanvas], currentMI)); } } else if (GenericFlowSwitchHelper.IsGenericFlowSwitch(currentMI.ItemType)) { IModelTreeItem modelTreeItem = this.ModelItem as IModelTreeItem; ModelItem defaultCase = currentMI.Properties["Default"].Value; if (defaultCase != null) { ModelItem defaultCaseOnCanvas = GetCorrespondingElementOnCanvas(defaultCase); if (!modelElement.ContainsKey(defaultCaseOnCanvas)) { viewsAdded.Add(ProcessAndGetModelView(defaultCaseOnCanvas)); flowElementsToProcess.Enqueue(defaultCase); } IFlowSwitchLink link = GenericFlowSwitchHelper.CreateFlowSwitchLink(currentMI.ItemType, currentMI, null, true); ModelItem linkModelItem = new FakeModelItemImpl(modelTreeItem.ModelTreeManager, link.GetType(), link, null); link.ModelItem = linkModelItem; elem2elemConnections.Add(Tuple.Create(modelElement[currentMI], modelElement[defaultCaseOnCanvas], linkModelItem)); } Type genericType = currentMI.ItemType.GetGenericArguments()[0]; foreach (ModelItem key in GenericFlowSwitchHelper.GetCaseKeys(currentMI.Properties["Cases"])) { ModelItem destFlowElementMI = GenericFlowSwitchHelper.GetCaseModelItem(currentMI.Properties["Cases"], (key == null) ? null : key.GetCurrentValue()); IFlowSwitchLink link = GenericFlowSwitchHelper.CreateFlowSwitchLink(currentMI.ItemType, currentMI, (key == null) ? null : key.GetCurrentValue(), false); ModelItem linkModelItem = new FakeModelItemImpl(modelTreeItem.ModelTreeManager, link.GetType(), link, null); link.ModelItem = linkModelItem; ModelItem destModelItem = GetCorrespondingElementOnCanvas(destFlowElementMI); if (!modelElement.ContainsKey(destModelItem)) { viewsAdded.Add(ProcessAndGetModelView(destModelItem)); flowElementsToProcess.Enqueue(destFlowElementMI); } elem2elemConnections.Add(Tuple.Create(modelElement[currentMI], modelElement[destModelItem], linkModelItem)); } } else { Fx.Assert(false, "Unknown type of FlowNode"); } } if (!this.startNodeAdded) { panel.Children.Add(this.StartSymbol); this.startNodeAdded = true; } foreach (UIElement view in viewsAdded) { panel.Children.Add(view); } // connection between flownode should be create only after all flownodes have been loaded on the canvas if (addConnectorAfterLoaded) { this.Dispatcher.BeginInvoke(DispatcherPriority.Loaded, new Action(() => { if (this.isLoaded) { AddConnectorsToPanel(startNodeModelItem, elem2elemConnections, point2elemConnections); } })); } else { AddConnectorsToPanel(startNodeModelItem, elem2elemConnections, point2elemConnections); } }
internal bool CreateLinkGesture(UIElement source, ConnectionPoint destConnectionPoint, Point mouseLocation, out string errorMessage, bool isLinkValidDueToLinkMove, IFlowSwitchLink caseKey) { bool linkCreated = false; double minDist; errorMessage = string.Empty; ConnectionPoint sourceConnectionPoint = FindClosestConnectionPoint( mouseLocation, FlowchartDesigner.GetConnectionPoints(source).Where(p => p.PointType != ConnectionPointKind.Incoming).ToList(), out minDist); if (sourceConnectionPoint != null) { linkCreated = CreateLinkGesture(sourceConnectionPoint, destConnectionPoint, out errorMessage, isLinkValidDueToLinkMove, caseKey); } else { errorMessage = SR.FCInvalidLink; } return(linkCreated); }
internal bool CreateLinkGesture(ConnectionPoint sourceConnectionPoint, UIElement dest, out string errorMessage, bool isLinkValidDueToLinkMove, IFlowSwitchLink caseKey) { bool linkCreated = false; ConnectionPoint destConnectionPoint = ClosestDestConnectionPoint(sourceConnectionPoint, dest, out errorMessage); if (destConnectionPoint != null) { linkCreated = CreateLinkGesture(sourceConnectionPoint, destConnectionPoint, out errorMessage, isLinkValidDueToLinkMove, caseKey); } return(linkCreated); }
internal bool CreateLinkGesture(ConnectionPoint sourceConnectionPoint, ConnectionPoint destConnectionPoint, out string errorMessage, bool isLinkValidDueToLinkMove, IFlowSwitchLink caseKey) { Fx.Assert(this.panel != null, "This code should not be hit if panel is null"); Fx.Assert(sourceConnectionPoint != null, "sourceConnectionPoint is null."); Fx.Assert(destConnectionPoint != null, "destConnectionPoint is null."); bool linkCreated = false; errorMessage = string.Empty; if (destConnectionPoint.PointType != ConnectionPointKind.Outgoing && sourceConnectionPoint.PointType != ConnectionPointKind.Incoming) { using (EditingScope es = (EditingScope)this.ModelItem.BeginEdit(SR.FCCreateLink)) { linkCreated = UpdateFlowChartObject(sourceConnectionPoint, destConnectionPoint, out errorMessage, isLinkValidDueToLinkMove, caseKey); try { es.Complete(); } catch (ArgumentException) { errorMessage = SR.InvalidFlowSwitchCaseMessage; linkCreated = false; } } } else { errorMessage = SR.FCInvalidLink; } return(linkCreated); }
//Interfaces for users to create links on the flowchart. internal bool CreateLinkGesture(ConnectionPoint sourceConnectionPoint, ConnectionPoint destConnectionPoint, out string errorMessage, IFlowSwitchLink caseKey) { return(CreateLinkGesture(sourceConnectionPoint, destConnectionPoint, out errorMessage, false, caseKey)); }
bool UpdateFlowChartObject(ConnectionPoint sourceConnPoint, ConnectionPoint destConnPoint, out string errorMessage, bool isLinkValidDueToLinkMove, IFlowSwitchLink caseKey) { //srcDesigner will be null for the case where source designer is StartSymbol. VirtualizedContainerService.VirtualizingContainer srcDesigner = sourceConnPoint.ParentDesigner as VirtualizedContainerService.VirtualizingContainer; VirtualizedContainerService.VirtualizingContainer destDesigner = destConnPoint.ParentDesigner as VirtualizedContainerService.VirtualizingContainer; ModelItem linkSource; ModelItem linkDest = destDesigner.ModelItem; ModelItem destFlowElementMI = GetFlowElementMI(linkDest); PointCollection connectorViewState = new PointCollection(ConnectorRouter.Route(this.panel, sourceConnPoint, destConnPoint)); errorMessage = string.Empty; if (sourceConnPoint.ParentDesigner is StartSymbol) { linkSource = this.ModelItem; if (linkSource.Properties["StartNode"].Value == null || isLinkValidDueToLinkMove) { this.StoreConnectorViewState(linkSource, connectorViewState, sourceConnPoint); linkSource.Properties["StartNode"].SetValue(destFlowElementMI); } else { errorMessage = SR.FCNextLinkDefined; } } else { linkSource = srcDesigner.ModelItem; ModelItem srcFlowElementMI = GetFlowElementMI(linkSource); if (typeof(FlowStep).IsAssignableFrom(srcFlowElementMI.ItemType)) { if (srcFlowElementMI.Properties["Next"].Value == null || isLinkValidDueToLinkMove) { this.StoreConnectorViewState(srcFlowElementMI, connectorViewState, sourceConnPoint); srcFlowElementMI.Properties["Next"].SetValue(destFlowElementMI); } else { errorMessage = SR.FCNextLinkDefined; } } else if (typeof(FlowDecision).IsAssignableFrom(srcFlowElementMI.ItemType)) { if (sourceConnPoint.Equals(FlowchartDesigner.GetTrueConnectionPoint(this.modelElement[linkSource]))) { if (linkSource.Properties["True"].Value == null || isLinkValidDueToLinkMove) { this.StoreConnectorViewState(srcFlowElementMI, connectorViewState, sourceConnPoint); linkSource.Properties["True"].SetValue(destFlowElementMI); } else { errorMessage = SR.FCTrueBranchExists; } } else if (sourceConnPoint.Equals(FlowchartDesigner.GetFalseConnectionPoint(this.modelElement[linkSource]))) { if (linkSource.Properties["False"].Value == null || isLinkValidDueToLinkMove) { this.StoreConnectorViewState(srcFlowElementMI, connectorViewState, sourceConnPoint); linkSource.Properties["False"].SetValue(destFlowElementMI); } else { errorMessage = SR.FCFalseBranchExists; } } else { errorMessage = SR.FCFlowConditionLinkError; } } else //FlowSwitch { if (!CreateFlowSwitchLink(sourceConnPoint, srcFlowElementMI, destFlowElementMI, caseKey, connectorViewState, ref errorMessage)) { return(false); } } } return(errorMessage.Equals(string.Empty)); }
internal bool CreateLinkGesture(UIElement source, ConnectionPoint destConnectionPoint, Point mouseLocation, out string errorMessage, bool isLinkValidDueToLinkMove, IFlowSwitchLink caseKey) { bool linkCreated = false; double minDist; errorMessage = string.Empty; ConnectionPoint sourceConnectionPoint = FindClosestConnectionPoint( mouseLocation, FlowchartDesigner.GetConnectionPoints(source).Where(p => p.PointType != ConnectionPointKind.Incoming).ToList(), out minDist); if (sourceConnectionPoint != null) { linkCreated = CreateLinkGesture(sourceConnectionPoint, destConnectionPoint, out errorMessage, isLinkValidDueToLinkMove, caseKey); } else { errorMessage = SR.FCInvalidLink; } return linkCreated; }
internal bool CreateLinkGesture(UIElement source, UIElement dest, out string errorMessage, IFlowSwitchLink caseKey) { bool linkCreated = false; ConnectionPoint srcConnPoint, destConnPoint; GetSrcDestConnectionPoints(source, dest, out srcConnPoint, out destConnPoint, out errorMessage); if (srcConnPoint != null && destConnPoint != null) { linkCreated = CreateLinkGesture(srcConnPoint, destConnPoint, out errorMessage, caseKey); } return linkCreated; }
internal bool CreateLinkGesture(UIElement source, UIElement dest, out string errorMessage, IFlowSwitchLink caseKey) { bool linkCreated = false; ConnectionPoint srcConnPoint, destConnPoint; GetSrcDestConnectionPoints(source, dest, out srcConnPoint, out destConnPoint, out errorMessage); if (srcConnPoint != null && destConnPoint != null) { linkCreated = CreateLinkGesture(srcConnPoint, destConnPoint, out errorMessage, caseKey); } return(linkCreated); }