// event handler pro validaci myší vytvořených linků jakožto povolených vztahů z UPMM
        private void diagram_LinkDrawn(object sender, Northwoods.GoXam.DiagramEventArgs e)
        {
            Link link = (e.Part as Link);
            ClassDiagramLinkData linkData = link.Data as ClassDiagramLinkData;
            ClassDiagramNodeData fromData = link.FromData as ClassDiagramNodeData;
            ClassDiagramNodeData toData   = link.ToData as ClassDiagramNodeData;

            var isValid = CheckLink(fromData, toData, linkData, category: SelectedLinkType);

            if (!isValid)
            {
                (diagram.LinksSource as ObservableCollection <ClassDiagramLinkData>).Remove(linkData);
            }
        }
        private void diagram_LinkRelinked(object sender, DiagramEventArgs e)
        {
            Link link = (e.Part as Link);
            ClassDiagramLinkData linkData = link.Data as ClassDiagramLinkData;
            ClassDiagramNodeData fromData = link.FromData as ClassDiagramNodeData;
            ClassDiagramNodeData toData   = link.ToData as ClassDiagramNodeData;

            var isValid = CheckLink(fromData, toData, linkData, linkData.Category);

            if (!isValid)
            {
                (diagram.LinksSource as ObservableCollection <ClassDiagramLinkData>).Remove(linkData);
            }
        }
        // event handler pro vkládání uzlu
        private void diagram_ExternalObjectsDropped(object sender, Northwoods.GoXam.DiagramEventArgs e)
        {
            ClassDiagramNodeData data = (sender as Diagram).SelectedNode.Data as ClassDiagramNodeData;

            string[] categories = { "Class" };

            if (categories.Contains(data.Category) && !AllowDuplicateNodes)
            {
                if ((sender as Diagram).Nodes.Count(x => (x.Data as ClassDiagramNodeData).IRI == data.IRI && (x.Data as ClassDiagramNodeData).Category == data.Category) > 1)
                {
                    diagram.Model.RemoveNode(data);
                }
            }
        }
        private bool CheckLink(ClassDiagramNodeData fromData, ClassDiagramNodeData toData, ClassDiagramLinkData linkData, string category)
        {
            if (category == Constants.UML_CD_ANCHOR)
            {
                if ((fromData.Category == Constants.UML_CD_NOTE || toData.Category == Constants.UML_CD_NOTE) && fromData.Category != toData.Category)
                {
                    linkData.Category = category;
                    linkData.Color    = Constants.VALID_COLOR;

                    return(IsLinkUniqueBothWays(linkData, category));
                }
                else
                {
                    return(false);
                }
            }
            else if (fromData.Category == Constants.UML_CD_NOTE || toData.Category == Constants.UML_CD_NOTE)
            {
                return(false);
            }
            else
            {
                string relationship = Uml4Upmm.CheckCDRelationship(fromData.IRI, toData.IRI, ClassDiagramPage.IsValidatingWithModel, out string color, category);

                if (relationship == null)
                {
                    return(false);
                }
                else
                {
                    linkData.Category = category;
                    linkData.FromText = "";
                    linkData.ToText   = "";
                    linkData.Text     = relationship == "" ? relationship : "<<" + relationship + ">>";
                    linkData.Color    = color;
                }
            }
            return(IsLinkUnique(linkData, category));
        }