Beispiel #1
0
        // TODO: call this method whenever one of the relations is changing its visibility
        private void UpdateBendingOffsets(UmlDiagramClass endUmlDiagramClass, UmlDiagramClass startUmlDiagramClass)
        {
            var tmprelations =
                Relations.Where(v => v.IsVisible).Where(
                    r => r.StartClass == startUmlDiagramClass && r.EndClass == endUmlDiagramClass ||
                    r.StartClass == endUmlDiagramClass && r.EndClass == startUmlDiagramClass).ToList();

            int          numberOfRelationsBetweenStartAndEndClass = tmprelations.Count;
            const double range      = 300.0;
            double       deltaRange = range / (numberOfRelationsBetweenStartAndEndClass + 1);

            if (numberOfRelationsBetweenStartAndEndClass == 1)
            {
                tmprelations[0].BendingOffset = 0;
            }
            else
            {
                for (int i = 0; i < tmprelations.Count; i++)
                {
                    var currentRelation = tmprelations[i];
                    currentRelation.BendingOffset = (i + 1) * deltaRange - range / 2;
                    if (currentRelation.StartClass == endUmlDiagramClass)
                    {
                        //
                        // If the start and end class are reversed, the bendingoffset has to be reversed too, otherwise it will coincide with a previous relation curve.
                        //
                        currentRelation.BendingOffset = -currentRelation.BendingOffset;
                    }
                }
            }
        }
Beispiel #2
0
 public UmlDiagramDependenceRelation(
     UmlRelation umlRelation,
     UmlDiagramClass startUmlDiagramClass,
     UmlDiagramClass endUmlDiagramClass
     ) : base(umlRelation, startUmlDiagramClass, endUmlDiagramClass)
 {
 }
 public UmlDiagramImplementsInterfaceRelation(
     UmlRelation umlRelation,
     UmlDiagramClass startUmlDiagramClass,
     UmlDiagramClass endUmlDiagramClass
     ) : base(umlRelation, startUmlDiagramClass, endUmlDiagramClass)
 {
 }
        public UmlDiagramRelation(UmlRelation umlRelation, UmlDiagramClass startUmlDiagramClass, UmlDiagramClass endUmlDiagramClass)
            : base(startUmlDiagramClass, endUmlDiagramClass)
        {
            Relation = umlRelation;

            IsVisible = true;
        }
Beispiel #5
0
 public UmlDiagramMethodLink(UmlMethodLink umlMethodLink, UmlDiagramClass umlDiagramClass, UmlDiagramMethodNode umlDiagramMethodNode)
     : base(umlDiagramClass, umlDiagramMethodNode)
 {
     MethodLink    = umlMethodLink;
     IsVisible     = true;
     pen           = new Pen(new SolidColorBrush(Colors.Gray), 2);
     pen.DashStyle = new DashStyle(new[] { 4.0, 4.0 }, 0.0);
 }
Beispiel #6
0
 public UmlDiagramInheritanceRelation(
     UmlRelation umlRelation,
     UmlDiagramClass startUmlDiagramClass,
     UmlDiagramClass endUmlDiagramClass
     ) : base(umlRelation, startUmlDiagramClass, endUmlDiagramClass)
 {
     PreferredAngles = new double[] { 90 };
 }
Beispiel #7
0
 private void RemoveClass(UmlDiagramClass umlDiagramClass)
 {
     if (classes.Contains(umlDiagramClass))
     {
         RemoveNode(umlDiagramClass);
         classes.Remove(umlDiagramClass);
     }
 }
 public UmlDiagramNoteLink(UmlNoteLink umlNoteLink, UmlDiagramClass umlDiagramClass, UmlDiagramNote umlDiagramNote)
     : base(umlDiagramClass, umlDiagramNote)
 {
     NoteLink      = umlNoteLink;
     IsVisible     = true;
     pen           = new Pen(new SolidColorBrush(Colors.Black), 1);
     pen.DashStyle = new DashStyle(new[] { 4.0, 4.0 }, 0.0);
 }
 public UmlDiagramAssociationRelation(
     UmlRelation umlRelation,
     UmlDiagramClass startUmlDiagramClass,
     UmlDiagramClass endUmlDiagramClass
     ) : base(umlRelation, startUmlDiagramClass, endUmlDiagramClass)
 {
     PreferredAngles = new double[] {  };
 }
Beispiel #10
0
        public void AddNoteFromModel(UmlClass umlClass, UmlNote umlNote, UmlNoteLink umlNoteLink)
        {
            UmlDiagramClass umlDiagramClass    = GetDiagramClass(umlClass);
            var             umlDiagramNote     = new UmlDiagramNote(umlNote);
            var             umlDiagramNoteLink = new UmlDiagramNoteLink(umlNoteLink, umlDiagramClass, umlDiagramNote);

            AddNote(umlDiagramNote);
            AddNoteLink(umlDiagramNoteLink);
        }
Beispiel #11
0
        public void AddMethodNodeFromModel(UmlClass umlClass, UmlMethodNode umlMethodNode, UmlMethodLink umlMethodLink)
        {
            UmlDiagramClass umlDiagramClass      = GetDiagramClass(umlClass);
            var             umlDiagramMethodNode = new UmlDiagramMethodNode(umlMethodNode);
            var             umlDiagramMethodLink = new UmlDiagramMethodLink(umlMethodLink, umlDiagramClass, umlDiagramMethodNode);

            AddMethodNode(umlDiagramMethodNode);
            AddMethodLink(umlDiagramMethodLink);
        }
Beispiel #12
0
 public void RemoveClassesFromDiagram(List <UmlClass> classes)
 {
     foreach (var umlClass in classes)
     {
         UmlDiagramClass umlDiagramClass = GetDiagramClass(umlClass);
         if (umlDiagramClass != null)
         {
             RemoveDiagramClass(umlDiagramClass);
         }
     }
 }
Beispiel #13
0
 public void Show(List <UmlClass> classes)
 {
     foreach (var umlClass in classes)
     {
         UmlDiagramClass umlDiagramClass = GetDiagramClass(umlClass);
         if (umlDiagramClass == null)
         {
             AddClassFromModel(umlClass);
         }
     }
 }
Beispiel #14
0
 private void AddClass(UmlDiagramClass umlDiagramClass)
 {
     if (!classes.Contains(umlDiagramClass))
     {
         AddNode(umlDiagramClass);
         classes.Add(umlDiagramClass);
         if (!ClassNames.Contains(umlDiagramClass.Name))
         {
             ClassNames.Add(umlDiagramClass.Name);
         }
     }
 }
Beispiel #15
0
        public void RemoveDiagramClass(UmlDiagramClass umlDiagramClass)
        {
            if (Classes.Contains(umlDiagramClass))
            {
                RemoveClass(umlDiagramClass);
                modelToDiagramClasses.Remove(umlDiagramClass.Class);

                //List<UmlDiagramRelation> umlDiagramRelations =
                //    Relations.Where(
                //        r =>
                //        r.StartClass == umlDiagramClass || r.EndClass == umlDiagramClass
                //    ).ToList();

                //foreach (var umlDiagramRelation in umlDiagramRelations) {
                //    RemoveDiagramRelation(umlDiagramRelation);
                //}
            }
        }
Beispiel #16
0
        /// <summary>
        /// Add a class that already exists in the Model to the diagram.
        /// </summary>
        private void AddClassFromModel(UmlClass umlClass)
        {
            var umlDiagramClass = new UmlDiagramClass(umlClass, this)
            {
                ShowsMembers = ShowsMembers
            };

            CheckForTags(umlDiagramClass);
            Model.FillMethodsFromClass(umlClass);
            umlDiagramClass.SyncAttributesAndOperationsFromModel();
            modelToDiagramClasses[umlClass] = umlDiagramClass;
            umlDiagramClass.Pos             = new Point(rand.NextDouble() * 300, rand.NextDouble() * 300);
            AddClass(umlDiagramClass);

            //
            // Add any relation that should be visible in the diagram now.
            //
            //
            // Don't just add all umlClass.Relations, only the ones that are connected to an
            // already shown class.
            //
            foreach (var umlDiagramClass2 in Classes)
            {
                List <UmlRelation> umlRelations =
                    Model.Relations.Where(
                        r =>
                        r.StartClass == umlClass && r.EndClass == umlDiagramClass2.Class ||
                        r.StartClass == umlDiagramClass2.Class && r.EndClass == umlClass
                        ).ToList();
                foreach (var umlRelation in umlRelations)
                {
                    UmlDiagramRelation umlDiagramRelation = GetDiagramRelation(umlRelation);
                    if (umlDiagramRelation == null)
                    {
                        AddRelationFromModel(umlRelation);
                    }
                }
            }

            NotifyPropertyChanged(() => ClassNames);
        }
Beispiel #17
0
        private void CheckForTags(UmlDiagramClass umlDiagramClass)
        {
            UmlClass umlClass = umlDiagramClass.Class;

            foreach (var tag in Tags)
            {
                if (umlDiagramClass.Name.ToLower().Contains(tag.ToLower()))
                {
                    if (tag == "PresentationState" || tag == "Presentation")
                    {
                        umlDiagramClass.AddTag("DataModel");
                    }
                    else
                    {
                        umlDiagramClass.AddTag(tag);
                    }
                    break;
                }

                if (umlClass.AssemblyDefinition != null)
                {
                    if (umlClass.AssemblyDefinition.FullName.Contains("Controllers"))
                    {
                        umlDiagramClass.AddTag("Controller");
                    }
                    if (umlClass.AssemblyDefinition.FullName.Contains("ViewModels"))
                    {
                        umlDiagramClass.AddTag("ViewModel");
                    }
                    if (umlClass.AssemblyDefinition.FullName.Contains("UI"))
                    {
                        umlDiagramClass.AddTag("UI");
                    }
                    if (umlClass.AssemblyDefinition.FullName.Contains("DataModel"))
                    {
                        umlDiagramClass.AddTag("DataModel");
                    }
                }
            }
        }
Beispiel #18
0
        internal void UpdateMemberVisibility(UmlDiagramClass umlDiagramClass)
        {
            foreach (var umlAttribute in umlDiagramClass.Attributes)
            {
                umlAttribute.IsVisibleInList =
                    umlAttribute.AccessModifier == AccessModifier.Private && umlDiagramClass.ShowsPrivateMembers ||
                    umlAttribute.AccessModifier == AccessModifier.Protected && umlDiagramClass.ShowsProtectedMembers ||
                    umlAttribute.AccessModifier == AccessModifier.Internal && umlDiagramClass.ShowsInternalMembers ||
                    umlAttribute.AccessModifier == AccessModifier.Public && umlDiagramClass.ShowsPublicMembers;
            }
            foreach (var umlProperty in umlDiagramClass.Properties)
            {
                umlProperty.IsVisibleInList =
                    (
                        umlProperty.GetterAccessModifier == AccessModifier.Private ||
                        umlProperty.SetterAccessModifier == AccessModifier.Private
                    ) && umlDiagramClass.ShowsPrivateMembers ||
                    (
                        umlProperty.GetterAccessModifier == AccessModifier.Protected ||
                        umlProperty.SetterAccessModifier == AccessModifier.Protected
                    ) && umlDiagramClass.ShowsProtectedMembers ||
                    (
                        umlProperty.GetterAccessModifier == AccessModifier.Internal ||
                        umlProperty.SetterAccessModifier == AccessModifier.Internal
                    ) && umlDiagramClass.ShowsInternalMembers ||
                    (
                        umlProperty.GetterAccessModifier == AccessModifier.Public ||
                        umlProperty.SetterAccessModifier == AccessModifier.Public
                    ) && umlDiagramClass.ShowsPublicMembers;
            }
            foreach (var umlOperation in umlDiagramClass.Operations)
            {
                umlOperation.IsVisibleInList =
                    umlOperation.AccessModifier == AccessModifier.Private && umlDiagramClass.ShowsPrivateMembers ||
                    umlOperation.AccessModifier == AccessModifier.Protected && umlDiagramClass.ShowsProtectedMembers ||
                    umlOperation.AccessModifier == AccessModifier.Internal && umlDiagramClass.ShowsInternalMembers ||
                    umlOperation.AccessModifier == AccessModifier.Public && umlDiagramClass.ShowsPublicMembers;
            }

            foreach (var umlDiagramAssociationRelation in umlDiagramClass.Relations.OfType <UmlDiagramAssociationRelation>().Where(w => w.StartClass == umlDiagramClass))
            {
                //
                // Search for 'Double dispatch': resolving a virtual method happens dynamically, resolving the type of a method
                // parameter happens statically. So, at this point, the type of the method argument of 'GetAccessmodifier' has to
                // be resolved. Which means we have to explicitly cast MemberReference.
                //
                bool isVisible = umlDiagramAssociationRelation.IsVisible;

                if (umlDiagramAssociationRelation.MemberReference is FieldReference)
                {
                    var accessModifier =
                        UmlModel.GetAccessmodifier(((FieldReference)umlDiagramAssociationRelation.MemberReference).Resolve());
                    umlDiagramAssociationRelation.IsVisible =
                        accessModifier == AccessModifier.Private && umlDiagramClass.ShowsPrivateMembers ||
                        accessModifier == AccessModifier.Protected && umlDiagramClass.ShowsProtectedMembers ||
                        accessModifier == AccessModifier.Internal && umlDiagramClass.ShowsInternalMembers ||
                        accessModifier == AccessModifier.Public && umlDiagramClass.ShowsPublicMembers;
                }
                else if (umlDiagramAssociationRelation.MemberReference is MethodReference)
                {
                    var accessModifier =
                        UmlModel.GetAccessmodifier(((MethodReference)umlDiagramAssociationRelation.MemberReference).Resolve());
                    umlDiagramAssociationRelation.IsVisible =
                        accessModifier == AccessModifier.Private && umlDiagramClass.ShowsPrivateMembers ||
                        accessModifier == AccessModifier.Protected && umlDiagramClass.ShowsProtectedMembers ||
                        accessModifier == AccessModifier.Internal && umlDiagramClass.ShowsInternalMembers ||
                        accessModifier == AccessModifier.Public && umlDiagramClass.ShowsPublicMembers;
                }
                else if (umlDiagramAssociationRelation.MemberReference is PropertyReference)
                {
                    var getterAccessModifier =
                        UmlModel.GetAccessmodifier(((PropertyReference)umlDiagramAssociationRelation.MemberReference).Resolve().GetMethod);
                    var setterAccessModifier =
                        UmlModel.GetAccessmodifier(((PropertyReference)umlDiagramAssociationRelation.MemberReference).Resolve().SetMethod);
                    umlDiagramAssociationRelation.IsVisible =
                        (
                            getterAccessModifier == AccessModifier.Private ||
                            setterAccessModifier == AccessModifier.Private
                        ) && umlDiagramClass.ShowsPrivateMembers ||
                        (
                            getterAccessModifier == AccessModifier.Protected ||
                            setterAccessModifier == AccessModifier.Protected
                        ) && umlDiagramClass.ShowsProtectedMembers ||
                        (
                            getterAccessModifier == AccessModifier.Internal ||
                            setterAccessModifier == AccessModifier.Internal
                        ) && umlDiagramClass.ShowsInternalMembers ||
                        (
                            getterAccessModifier == AccessModifier.Public ||
                            setterAccessModifier == AccessModifier.Public
                        ) && umlDiagramClass.ShowsPublicMembers;
                }

                if (umlDiagramAssociationRelation.IsVisible != isVisible)
                {
                    UpdateBendingOffsets(umlDiagramAssociationRelation.EndClass, umlDiagramClass);
                }
            }
        }