Exemplo n.º 1
0
        public DiagramLogic()
        {
            // The list of people, this is a global list shared by the application.
            family = GlobalData.Family;

            Clear();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Performs the business logic for changing the deleting the person
        /// </summary>
        public static void DeletePerson(UMLCollection family, Shape personToDelete)
        {
            if (!personToDelete.IsDeletable)
            {
                return;
            }

            // Remove the personToDelete from the relationships that contains the personToDelete.
            foreach (Relationship relationship in personToDelete.Relationships)
            {
                foreach (Relationship rel in relationship.RelationTo.Relationships)
                {
                    if (rel.RelationTo.Equals(personToDelete))
                    {
                        relationship.RelationTo.Relationships.Remove(rel);
                        break;
                    }
                }
            }

            // Delete the person's photos and story
            personToDelete.DeletePhotos();
            personToDelete.DeleteStory();

            family.Remove(personToDelete);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Performs the business logic for adding the Parent relationship between the person and the parent.
        /// </summary>
        public static void AddParent(UMLCollection family, Shape shape, Shape parent)
        {
            // Add the parent to the main collection of people.
            family.Add(parent);

            // Setter for property change notification
            shape.HasParents = true;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Performs the business logic for adding the Child relationship between the person and the child.
 /// </summary>
 public static void AddChild(UMLCollection family, Shape shape, Shape child)
 {
     // Add the new child as a sibling to any existing children
     foreach (Shape existingSibling in shape.Children)
     {
         family.AddSibling(existingSibling, child);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Performs the business logic for adding the Parent relationship between the person and the parents.
        /// </summary>
        public static void AddParent(UMLCollection family, Shape shape, ParentSet parentSet)
        {
            // First add child to parents.
            family.AddChild(parentSet.FirstParent, shape, ParentChildModifier.Natural);
            family.AddChild(parentSet.SecondParent, shape, ParentChildModifier.Natural);

            // Next update the siblings. Get the list of full siblings for the person.
            // A full sibling is a sibling that has both parents in common.
            List <Shape> siblings = GetChildren(parentSet);

            foreach (Shape sibling in siblings)
            {
                if (sibling != shape)
                {
                    family.AddSibling(shape, sibling);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Performs the business logic for adding the Sibling relationship between the person and the sibling.
        /// </summary>
        public static void AddSibling(UMLCollection family, Shape person, Shape sibling)
        {
            // Handle siblings
            if (person.Siblings.Count > 0)
            {
                // Make the siblings siblings to each other.
                foreach (Shape existingSibling in person.Siblings)
                {
                    family.AddSibling(existingSibling, sibling);
                }
            }

            if (person.Parents != null)
            {
                switch (person.Parents.Count)
                {
                // No parents
                case 0:
                    family.AddSibling(person, sibling);
                    break;

                // Single parent
                case 1:
                    family.AddSibling(person, sibling);
                    family.AddChild(person.Parents[0], sibling, ParentChildModifier.Natural);
                    break;

                // 2 parents
                case 2:
                    // Add the sibling as a child of the same parents
                    foreach (Shape parent in person.Parents)
                    {
                        family.AddChild(parent, sibling, ParentChildModifier.Natural);
                    }

                    family.AddSibling(person, sibling);
                    break;

                default:
                    family.AddSibling(person, sibling);
                    break;
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Performs the business logic for changing the person parents
        /// </summary>
        public static void ChangeParents(UMLCollection family, Shape shape, ParentSet newParentSet)
        {
            // Don't do anything if there is nothing to change or if the parents are the same
            if (shape.ParentSet == null || newParentSet == null || shape.ParentSet.Equals(newParentSet))
            {
                return;
            }

            // store the current parent set which will be removed
            ParentSet formerParentSet = shape.ParentSet;

            // Remove the first parent
            RemoveParentChildRelationship(shape, formerParentSet.FirstParent);

            // Remove the person as a child of the second parent
            RemoveParentChildRelationship(shape, formerParentSet.SecondParent);

            // Remove the sibling relationships
            RemoveSiblingRelationships(shape);

            // Add the new parents
            AddParent(family, shape, newParentSet);
        }
Exemplo n.º 8
0
 public UML()
 {
     umlCollection = new UMLCollection();
 }
Exemplo n.º 9
0
 /// <summary>
 /// Performs the business logic for adding the Spousal relationship between the person and the spouse.
 /// </summary>
 public static void AddSpouse(UMLCollection family, Shape person, Shape spouse, SpouseModifier modifier)
 {
 }