public DiagramConnector(ConnectorType type,
                         DiagramNode startNode, DiagramGroup startGroup, DiagramRow startRow,
                         DiagramNode endNode, DiagramGroup endGroup, DiagramRow endRow)
 {
     this.type  = type;
     this.start = new DiagramConnectorNode(startNode, startGroup, startRow);
     this.end   = new DiagramConnectorNode(endNode, endGroup, endRow);
 }
Exemple #2
0
        /// <summary>
        /// Creates the primary row. The row contains groups: 1) The primary-group
        /// that only contains the primary node, and 2) The optional left-group
        /// that contains spouses and siblings.
        /// </summary>
        public DiagramRow CreatePrimaryRow(Person person, double scale, double scaleRelated, bool hideSiblings, bool hideSpouses, bool hidePreviousSpouses)
        {
            // The primary node contains two groups,
            DiagramGroup primaryGroup = new DiagramGroup();
            DiagramGroup leftGroup    = new DiagramGroup();

            // Set up the row.
            DiagramRow row = new DiagramRow();

            // Add primary node.
            DiagramNode node = CreateNode(person, NodeType.Primary, false, scale);

            primaryGroup.Add(node);
            personLookup.Add(node.Person, new DiagramConnectorNode(node, primaryGroup, row));

            if (hideSpouses == false)
            {
                // Current spouses.
                Collection <Person> currentSpouses = person.CurrentSpouses;
                AddSpouseNodes(person, row, leftGroup, currentSpouses,
                               NodeType.Spouse, scaleRelated, true);
            }


            if (hidePreviousSpouses == false)
            {
                // Previous spouses.
                Collection <Person> previousSpouses = person.PreviousSpouses;
                AddSpouseNodes(person, row, leftGroup, previousSpouses,
                               NodeType.Spouse, scaleRelated, false);
            }

            if (hideSiblings == false)
            {
                // Siblings.
                Collection <Person> siblings = person.Siblings;
                AddSiblingNodes(row, leftGroup, siblings, NodeType.Sibling, scaleRelated);

                // Half siblings.
                Collection <Person> halfSiblings = person.HalfSiblings;
                AddSiblingNodes(row, leftGroup, halfSiblings, NodeType.SiblingLeft, scaleRelated);
            }

            if (leftGroup.Nodes.Count > 0)
            {
                leftGroup.Reverse();
                row.Add(leftGroup);
            }

            row.Add(primaryGroup);

            return(row);
        }
 /// <summary>
 /// Add the siblings to the specified row and group.
 /// </summary>
 private void AddSiblingNodes(DiagramRow row, DiagramGroup group,
                              Collection <Person> siblings, NodeType nodeType, double scale)
 {
     foreach (Person sibling in siblings)
     {
         if (!personLookup.ContainsKey(sibling))
         {
             // Siblings node.
             DiagramNode node = CreateNode(sibling, nodeType, true, scale);
             group.Add(node);
             personLookup.Add(node.Person, new DiagramConnectorNode(node, group, row));
         }
     }
 }
        /// <summary>
        /// Add the spouses to the specified row and group.
        /// </summary>
        private void AddSpouseNodes(Person person, DiagramRow row,
                                    DiagramGroup group, Collection <Person> spouses,
                                    NodeType nodeType, double scale, bool married)
        {
            foreach (Person spouse in spouses)
            {
                if (!personLookup.ContainsKey(spouse))
                {
                    // Spouse node.
                    DiagramNode node = CreateNode(spouse, nodeType, true, scale);
                    group.Add(node);

                    // Add connection.
                    DiagramConnectorNode connectorNode = new DiagramConnectorNode(node, group, row);
                    personLookup.Add(node.Person, connectorNode);
                    connections.Add(new MarriedDiagramConnector(married, personLookup[person], connectorNode));
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// Create the child row. The row contains a group for each child.
        /// Each group contains the child and spouses.
        /// </summary>
        public DiagramRow CreateChildrenRow(List <Person> children, double scale, double scaleRelated, bool hideInLaws)
        {
            // Setup the row.
            DiagramRow row = new DiagramRow();

            foreach (Person child in children)
            {
                // Each child is in their group, the group contains the child
                // and any spouses. The groups does not contain siblings.
                DiagramGroup group = new DiagramGroup();
                row.Add(group);

                // Child.
                if (!personLookup.ContainsKey(child))
                {
                    DiagramNode node = CreateNode(child, NodeType.Related, true, scale);
                    group.Add(node);
                    personLookup.Add(node.Person, new DiagramConnectorNode(node, group, row));
                }


                if (hideInLaws == false)
                {
                    // Current spouses.
                    Collection <Person> currentSpouses = child.CurrentSpouses;
                    AddSpouseNodes(child, row, group, currentSpouses,
                                   NodeType.Spouse, scaleRelated, true);

                    // Previous spouses.
                    Collection <Person> previousSpouses = child.PreviousSpouses;
                    AddSpouseNodes(child, row, group, previousSpouses,
                                   NodeType.Spouse, scaleRelated, false);
                }

                // Connections.
                AddParentConnections(child);

                group.Reverse();
            }

            return(row);
        }
        /// <summary>
        /// Add the spouses to the specified row and group.
        /// </summary>
        private void AddSpouseNodes(Person person, DiagramRow row,
            DiagramGroup group, Collection<Person> spouses,
            NodeType nodeType, double scale, bool married)
        {
            foreach (Person spouse in spouses)
            {
                if (!personLookup.ContainsKey(spouse))
                {
                    // Spouse node.
                    DiagramNode node = CreateNode(spouse, nodeType, true, scale);
                    group.Add(node);

                    // Add connection.
                    DiagramConnectorNode connectorNode = new DiagramConnectorNode(node, group, row);
                    personLookup.Add(node.Person, connectorNode);
                    connections.Add(new MarriedDiagramConnector(married, personLookup[person], connectorNode));
                }
            }
        }
 /// <summary>
 /// Add the siblings to the specified row and group.
 /// </summary>
 private void AddSiblingNodes(DiagramRow row, DiagramGroup group,
     Collection<Person> siblings, NodeType nodeType, double scale)
 {
     foreach (Person sibling in siblings)
     {
         if (!personLookup.ContainsKey(sibling))
         {
             // Siblings node.
             DiagramNode node = CreateNode(sibling, nodeType, true, scale);
             group.Add(node);
             personLookup.Add(node.Person, new DiagramConnectorNode(node, group, row));
         }
     }
 }
        /// <summary>
        /// Creates the primary row. The row contains groups: 1) The primary-group 
        /// that only contains the primary node, and 2) The optional left-group 
        /// that contains spouses and siblings.
        /// </summary>
        public DiagramRow CreatePrimaryRow(Person person, double scale, double scaleRelated)
        {
            // The primary node contains two groups,
            DiagramGroup primaryGroup = new DiagramGroup();
            DiagramGroup leftGroup = new DiagramGroup();

            // Set up the row.
            DiagramRow row = new DiagramRow();

            // Add primary node.
            DiagramNode node = CreateNode(person, NodeType.Primary, false, scale);
            primaryGroup.Add(node);
            personLookup.Add(node.Person, new DiagramConnectorNode(node, primaryGroup, row));

            // Current spouses.
            Collection<Person> currentSpouses = person.CurrentSpouses;
            AddSpouseNodes(person, row, leftGroup, currentSpouses,
                NodeType.Spouse, scaleRelated, true);

            // Previous spouses.
            Collection<Person> previousSpouses = person.PreviousSpouses;
            AddSpouseNodes(person, row, leftGroup, previousSpouses,
                NodeType.Spouse, scaleRelated, false);

            // Siblings.
            Collection<Person> siblings = person.Siblings;
            AddSiblingNodes(row, leftGroup, siblings, NodeType.Sibling, scaleRelated);

            // Half siblings.
            Collection<Person> halfSiblings = person.HalfSiblings;
            AddSiblingNodes(row, leftGroup, halfSiblings, NodeType.SiblingLeft, scaleRelated);

            if (leftGroup.Nodes.Count > 0)
            {
                leftGroup.Reverse();
                row.Add(leftGroup);
            }

            row.Add(primaryGroup);

            return row;
        }
        /// <summary>
        /// Create the parent row. The row contains a group for each parent. 
        /// Each groups contains the parent, spouses and siblings.
        /// </summary>
        public DiagramRow CreateParentRow(Collection<Person> parents, double scale, double scaleRelated)
        {
            // Set up the row.
            DiagramRow row = new DiagramRow();

            int groupCount = 0;

            foreach (Person person in parents)
            {
                // Each parent is in their group, the group contains the parent,
                // spouses and siblings.
                DiagramGroup group = new DiagramGroup();
                row.Add(group);

                // Determine if this is a left or right oriented group.
                bool left = (groupCount++ % 2 == 0) ? true : false;

                // Parent.
                if (!personLookup.ContainsKey(person))
                {
                    DiagramNode node = CreateNode(person, NodeType.Related, true, scale);
                    group.Add(node);
                    personLookup.Add(node.Person, new DiagramConnectorNode(node, group, row));
                }

                // Current spouses.
                Collection<Person> currentSpouses = person.CurrentSpouses;
                RemoveDuplicates(currentSpouses, parents);
                AddSpouseNodes(person, row, group, currentSpouses,
                    NodeType.Spouse, scaleRelated, true);

                // Previous spouses.
                Collection<Person> previousSpouses = person.PreviousSpouses;
                RemoveDuplicates(previousSpouses, parents);
                AddSpouseNodes(person, row, group, previousSpouses,
                    NodeType.Spouse, scaleRelated, false);

                // Siblings.
                Collection<Person> siblings = person.Siblings;
                AddSiblingNodes(row, group, siblings, NodeType.Sibling, scaleRelated);

                // Half siblings.
                Collection<Person> halfSiblings = person.HalfSiblings;
                AddSiblingNodes(row, group, halfSiblings, left ?
                    NodeType.SiblingLeft : NodeType.SiblingRight, scaleRelated);

                // Connections.
                AddChildConnections(person);
                AddChildConnections(currentSpouses);
                AddChildConnections(previousSpouses);

                if (left)
                    group.Reverse();
            }

            // Add connections that span across groups.
            AddSpouseConnections(parents);

            return row;
        }
        /// <summary>
        /// Create the child row. The row contains a group for each child. 
        /// Each group contains the child and spouses.
        /// </summary>
        public DiagramRow CreateChildrenRow(List<Person> children, double scale, double scaleRelated)
        {
            // Setup the row.
            DiagramRow row = new DiagramRow();

            foreach (Person child in children)
            {
                // Each child is in their group, the group contains the child
                // and any spouses. The groups does not contain siblings.
                DiagramGroup group = new DiagramGroup();
                row.Add(group);

                // Child.
                if (!personLookup.ContainsKey(child))
                {
                    DiagramNode node = CreateNode(child, NodeType.Related, true, scale);
                    group.Add(node);
                    personLookup.Add(node.Person, new DiagramConnectorNode(node, group, row));
                }

                // Current spouses.
                Collection<Person> currentSpouses = child.CurrentSpouses;
                AddSpouseNodes(child, row, group, currentSpouses,
                    NodeType.Spouse, scaleRelated, true);

                // Previous spouses.
                Collection<Person> previousSpouses = child.PreviousSpouses;
                AddSpouseNodes(child, row, group, previousSpouses,
                    NodeType.Spouse, scaleRelated, false);

                // Connections.
                AddParentConnections(child);

                group.Reverse();
            }

            return row;
        }
 public DiagramConnectorNode(DiagramNode node, DiagramGroup group, DiagramRow row)
 {
     this.node = node;
     this.group = group;
     this.row = row;
 }
        /// <summary>
        /// Create the parent row. The row contains a group for each parent.
        /// Each groups contains the parent, spouses and siblings.
        /// </summary>
        public DiagramRow CreateParentRow(Collection <Person> parents, double scale, double scaleRelated)
        {
            // Set up the row.
            DiagramRow row = new DiagramRow();

            int groupCount = 0;

            foreach (Person person in parents)
            {
                // Each parent is in their group, the group contains the parent,
                // spouses and siblings.
                DiagramGroup group = new DiagramGroup();
                row.Add(group);

                // Determine if this is a left or right oriented group.
                bool left = (groupCount++ % 2 == 0) ? true : false;

                // Parent.
                if (!personLookup.ContainsKey(person))
                {
                    DiagramNode node = CreateNode(person, NodeType.Related, true, scale);
                    group.Add(node);
                    personLookup.Add(node.Person, new DiagramConnectorNode(node, group, row));
                }

                // Current spouses.
                Collection <Person> currentSpouses = person.CurrentSpouses;
                RemoveDuplicates(currentSpouses, parents);
                AddSpouseNodes(person, row, group, currentSpouses,
                               NodeType.Spouse, scaleRelated, true);

                // Previous spouses.
                Collection <Person> previousSpouses = person.PreviousSpouses;
                RemoveDuplicates(previousSpouses, parents);
                AddSpouseNodes(person, row, group, previousSpouses,
                               NodeType.Spouse, scaleRelated, false);

                // Siblings.
                Collection <Person> siblings = person.Siblings;
                AddSiblingNodes(row, group, siblings, NodeType.Sibling, scaleRelated);

                // Half siblings.
                Collection <Person> halfSiblings = person.HalfSiblings;
                AddSiblingNodes(row, group, halfSiblings, left ?
                                NodeType.SiblingLeft : NodeType.SiblingRight, scaleRelated);

                // Connections.
                AddChildConnections(person);
                AddChildConnections(currentSpouses);
                AddChildConnections(previousSpouses);

                if (left)
                {
                    group.Reverse();
                }
            }

            // Add connections that span across groups.
            AddSpouseConnections(parents);

            return(row);
        }
Exemple #13
0
 public DiagramConnectorNode(DiagramNode node, DiagramGroup group, DiagramRow row)
 {
     this.node  = node;
     this.group = group;
     this.row   = row;
 }
Exemple #14
0
 /// <summary>
 /// Add the group to the row.
 /// </summary>
 public void Add(DiagramGroup group)
 {
     groups.Add(group);
     this.AddVisualChild(group);
 }
Exemple #15
0
 public DiagramConnector(ConnectorType type,
     DiagramNode startNode, DiagramGroup startGroup, DiagramRow startRow,
     DiagramNode endNode, DiagramGroup endGroup, DiagramRow endRow)
 {
     this.type = type;
     this.start = new DiagramConnectorNode(startNode, startGroup, startRow);
     this.end = new DiagramConnectorNode(endNode, endGroup, endRow);
 }
Exemple #16
0
 /// <summary>
 /// Add the group to the row.
 /// </summary>
 public void Add(DiagramGroup group)
 {
     groups.Add(group);
     this.AddVisualChild(group);
 }