コード例 #1
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);
     }
 }
コード例 #2
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;
                }
            }
        }
コード例 #3
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);
                }
            }
        }