示例#1
0
        public ITreeData Create(Person p, string s, Color clr, int depth, bool isSpouse = false)
        {
            int w, h;

            w = h = 0;
            if (s != null)
            {
                // MeasureString and DrawText will behave as desired for multiline text
                // if the Environment.NewLine is used for line separation.
                var   s2    = s.Replace("\n", Environment.NewLine);
                SizeF txtSz = _graphics.MeasureString(s2,
                                                      isSpouse ? _spouseFont : _mainFont,
                                                      1000, StringFormat.GenericDefault);

                w = (int)(txtSz.Width + 1);
                h = (int)(txtSz.Height);
            }
            var node = new PersonNode(p, s, w, h, _vertOrient);

            node.BackColor = clr;
            node.DrawVert  = !isSpouse; // TODO brother/sister incest: both spouses are children
            node.Depth     = depth;

            return(node);
        }
示例#2
0
 public UnionNode(PersonNode p1, PersonNode p2, string unionId, bool vertical)
 {
     IsReal   = true;
     P1       = p1;
     P2       = p2;
     UnionId  = unionId;
     Vertical = vertical;
 }
示例#3
0
        private static void MultiMarriage(ITreeData parent, Person who, int depth)
        {
            // A person has multiple marriages.
            // 1. Make the person a child of the parent.
            // 2. For each marriage:
            // 2a. Add the spouse as a not-real child of the parent.
            // 2b. Connect each spouse to the person for drawing.
            // 2c. call GrowTree(spouse, marriage)

            PersonNode nodeP = (PersonNode)_nf.Create(who, StringForNode(who), ColorForNode(who), depth);

            _tree.addChild(parent, nodeP);

            foreach (var marr in who.SpouseIn)
            {
                // Add each spouse as a pseudo-child of the 'parent'
                Person     spouseP = marr.Spouse(who);
                PersonNode node    = (PersonNode)_nf.Create(spouseP, StringForNode(spouseP), ColorForNode(spouseP), depth, true);
                node.IsReal = false;
                nodeP.AddSpouse(node);
                _tree.addChild(parent, node);

                // This union might have already been added to the
                // tree. If so, provide a link to the previous node,
                // and do NOT add children.
                ITreeData dup;
                if (_unionSet.TryGetValue(marr.Id, out dup))
                {
                    nodeP.DupNode = dup;
                    node.DupNode  = dup;
                }
                else
                {
                    _unionSet.Add(marr.Id, nodeP);

                    // here we're about to start the next level, punt if limit reached
                    if (_genDepth < _config.MaxDepth)
                    {
                        GrowTree(node, marr);
                    }
                }
            }
        }