private bool IsLinkUniqueBothWays(UseCaseDiagramLinkData linkData, string category) { int count1 = (diagram.LinksSource as ObservableCollection <UseCaseDiagramLinkData>) .Count(x => x.From == linkData.From && x.To == linkData.To && x.Category == category); int count2 = (diagram.LinksSource as ObservableCollection <UseCaseDiagramLinkData>) .Count(x => x.From == linkData.To && x.To == linkData.From && x.Category == category); return(count1 + count2 < 2); }
private bool IsLinkUnique(UseCaseDiagramLinkData linkData, string category) { if ((diagram.LinksSource as ObservableCollection <UseCaseDiagramLinkData>) .Count(x => x.From == linkData.From && x.To == linkData.To && x.Category == category) > 1) { return(false); } else { return(true); } }
private void diagram_LinkRelinked(object sender, Northwoods.GoXam.DiagramEventArgs e) { Link link = (e.Part as Link); UseCaseDiagramLinkData linkData = link.Data as UseCaseDiagramLinkData; UseCaseDiagramNodeData fromData = link.FromData as UseCaseDiagramNodeData; UseCaseDiagramNodeData toData = link.ToData as UseCaseDiagramNodeData; var isValid = CheckLink(fromData, toData, linkData, linkData.Category); if (!isValid) { (diagram.LinksSource as ObservableCollection <UseCaseDiagramLinkData>).Remove(linkData); } }
private bool CheckLink(UseCaseDiagramNodeData fromData, UseCaseDiagramNodeData toData, UseCaseDiagramLinkData linkData, string category) { if ( (category == Constants.UML_UCD_ANCHOR) && (fromData.Category == Constants.UML_UCD_EDITABLE_NOTE || toData.Category == Constants.UML_UCD_EDITABLE_NOTE) && (fromData.Category != toData.Category) && (fromData.Category != Constants.UML_UCD_NOTE) && (toData.Category != Constants.UML_UCD_NOTE) ) { linkData.Category = category; linkData.Color = Constants.VALID_COLOR; return(IsLinkUniqueBothWays(linkData, category)); } else { string relationship = Uml4Upmm.CheckUCDRelationship(fromData.IRI, toData.IRI, UseCaseDiagramPage.IsValidatingWithModel, out string color, category); if (relationship == null) { return(false); } else { linkData.Category = category; linkData.Text = relationship == "" ? relationship : "<<" + relationship + ">>"; linkData.Color = color; } } return(IsLinkUnique(linkData, category)); }