Exemplo n.º 1
0
        private void AddChildren(ref List <IWriteTo> statements, IUIPerson person, IUIPerson partner, NodeStatement point, IEnumerable <IUIPerson> childrenOfCouple)
        {
            childrenOfCouple = childrenOfCouple.Where(x => !x.IsHidden);
            var childrenSubgraphStatements = new List <IWriteTo>();

            foreach (var child in childrenOfCouple)
            {
                var childNodeDict = new Dictionary <Id, Id> {
                    { "label", child.Label }, { "shape", "box" }, { "color", child.IsFemale ? "pink" : "blue" }, { "fillcolor", "white" }, { "style", "filled" }
                }.ToImmutableDictionary();
                var childNode = new NodeStatement(child.Id.ToString(), childNodeDict);

                var childToDotDict = new Dictionary <Id, Id> {
                    { "dir", "none" }
                }.ToImmutableDictionary();
                var childToDotStatement = new EdgeStatement(point.Id.Value, child.Id.ToString(), childToDotDict);

                childrenSubgraphStatements.Add(childNode);

                statements.Add(childToDotStatement);
            }

            var childrenSubgraphStatement = new SubgraphStatement("children" + (person.Id + "z" + partner.Id), childrenSubgraphStatements.ToImmutableList());

            statements.Add(childrenSubgraphStatement);
        }
Exemplo n.º 2
0
        private void AddPartner(ref List <IWriteTo> statements, IUIPerson person, NodeStatement personNode, IUIPerson partner)
        {
            if (partner.IsHidden)
            {
                return;
            }

            var edgeDictPoint = new Dictionary <Id, Id> {
                { "shape", "point" }, { "label", "" }
            }.ToImmutableDictionary();
            var point = new NodeStatement("partners" + (partner.Id + "z" + person.Id), edgeDictPoint);

            var partnerNodeDict = new Dictionary <Id, Id> {
                { "label", partner.Label }, { "shape", "box" }, { "color", partner.IsFemale ? "pink" : "blue" }, { "fillcolor", "white" }, { "style", "filled" }
            }.ToImmutableDictionary();
            var partnerNode = new NodeStatement(partner.Id.ToString(), partnerNodeDict);

            var edgeDictLinePersonToPoint = new Dictionary <Id, Id> {
                { "dir", "none" }
            }.ToImmutableDictionary();
            var linePersonToPoint = new EdgeStatement(person.Id.ToString(), point.Id.ToString(), edgeDictLinePersonToPoint);

            var linePartnerToPointDict = new Dictionary <Id, Id> {
                { "dir", "none" }
            }.ToImmutableDictionary();
            var linePartnerToPoint = new EdgeStatement(partner.Id.ToString(), point.Id.ToString(), linePartnerToPointDict);

            var parentSubgraphExists = statements.Where(x => x is SubgraphStatement).Select(y => ((SubgraphStatement)y).Name).Any(z => z.Value == "partners" + (partner.Id + "z" + person.Id) || z.Value == "partners" + (person.Id + "z" + partner.Id));

            if (!parentSubgraphExists)
            {
                var parentSubgraphStatements = new List <IWriteTo>();

                parentSubgraphStatements.Add(point);

                parentSubgraphStatements.Add(partnerNode);

                parentSubgraphStatements.Add(personNode);

                parentSubgraphStatements.Add(linePersonToPoint);

                parentSubgraphStatements.Add(linePartnerToPoint);

                var parentSubgraphStatement = new SubgraphStatement(point.Id.ToString(), parentSubgraphStatements.ToImmutableList());
                statements.Add(parentSubgraphStatement);

                var childrenSubgraphExists = statements.Where(x => x is SubgraphStatement).Select(y => ((SubgraphStatement)y).Name).Any(z => z.Value == "children" + (partner.Id + "z" + person.Id) || z.Value == "children" + (person.Id + "z" + partner.Id));
                if (!childrenSubgraphExists)
                {
                    var childrenOfCouple = person.Children.Where(x => x.Parents.Contains(partner) && x.Parents.Contains(person)).Where(x => !x.IsHidden);
                    childrenOfCouple = childrenOfCouple.OrderByDescending(x => x.GetAllDescendants().Count);
                    this.AddChildren(ref statements, person, partner, point, childrenOfCouple);
                }
            }
        }