/// <summary>
        /// Performs the business logic for changing the deleting the person
        /// </summary>
        public static void DeletePerson(PeopleCollection family, Person 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);
        }
Beispiel #2
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            var people = new PeopleCollection();

            new GedcomImport().Import(people, txtPath.Text);
            new HtmlExporter().Export("index.html", people, txtAncestor.Text); //"I157"
        }
Beispiel #3
0
        /// <summary>
        /// Populate the people collection with information from the GEDCOM file.
        /// </summary>
        public void Import(PeopleCollection peopleCollection, string gedcomFilePath)
        {
            // Clear current content.
            peopleCollection.Clear();

            // First convert the GEDCOM file to an XML file so it's easier to parse, the temp XML
            // file is deleted when importing is complete.
            string xmlFilePath = Path.GetTempFileName();

            try
            {
                this.people = peopleCollection;

                // Convert the GEDCOM file to a temp XML file.
                GedcomConverter.ConvertToXml(gedcomFilePath, xmlFilePath, true);
                doc = new XmlDocument();
                doc.Load(xmlFilePath);

                // Import data from the temp XML file to the people collection.
                ImportPeople();
                ImportFamilies();

                // The collection requires a primary-person, use the first person added to the
                // collection as the primary-person.
                if (peopleCollection.Count > 0)
                {
                    peopleCollection.Current = peopleCollection[0];
                }
            }
            finally
            {
                // Delete the temp XML file.
                File.Delete(xmlFilePath);
            }
        }
Beispiel #4
0
 private Person GetPerson(PeopleCollection ppl, string ancestorId)
 {
     foreach (var p in ppl)
     {
         if (p.Id == ancestorId)
         {
             return(p);
         }
     }
     return(null);
 }
        /// <summary>
        /// Performs the business logic for adding the Spousal relationship between the person and
        /// the spouse.
        /// </summary>
        public static void AddSpouse(PeopleCollection family, Person person, Person spouse, SpouseModifier modifier)
        {
            // Assume the spouse's gender based on the counterpart of the person's gender
            if (person.Gender == Gender.Male)
            {
                spouse.Gender = Gender.Female;
            }
            else
            {
                spouse.Gender = Gender.Male;
            }

            if (person.Spouses != null)
            {
                switch (person.Spouses.Count)
                {
                // No existing spouse
                case 0:
                    family.AddSpouse(person, spouse, modifier);

                    // Add any of the children as the child of the spouse.
                    if (person.Children != null || person.Children.Count > 0)
                    {
                        foreach (Person child in person.Children)
                        {
                            family.AddChild(spouse, child, ParentChildModifier.Natural);
                        }
                    }
                    break;

                // Existing spouse(s)
                default:
                    // If specifying a new married spouse, make existing spouses former.
                    if (modifier == SpouseModifier.Current)
                    {
                        foreach (Relationship relationship in person.Relationships)
                        {
                            if (relationship.RelationshipType == RelationshipType.Spouse)
                            {
                                ((SpouseRelationship)relationship).SpouseModifier = SpouseModifier.Former;
                            }
                        }
                    }

                    family.AddSpouse(person, spouse, modifier);
                    break;
                }

                // Setter for property change notification
                person.HasSpouse = true;
            }
        }
        /// <summary>
        /// Performs the business logic for adding the Parent relationship between the person and the parents.
        /// </summary>
        public static void AddParent(PeopleCollection family, Person person, ParentSet parentSet)
        {
            // First add child to parents.
            family.AddChild(parentSet.FirstParent, person, ParentChildModifier.Natural);
            family.AddChild(parentSet.SecondParent, person, 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 <Person> siblings = GetChildren(parentSet);

            foreach (Person sibling in siblings)
            {
                if (sibling != person)
                {
                    family.AddSibling(person, sibling);
                }
            }
        }
        /// <summary>
        /// Performs the business logic for adding the Sibling relationship between the person and
        /// the sibling.
        /// </summary>
        public static void AddSibling(PeopleCollection family, Person person, Person sibling)
        {
            // Handle siblings
            if (person.Siblings.Count > 0)
            {
                // Make the siblings siblings to each other.
                foreach (Person 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 (Person parent in person.Parents)
                    {
                        family.AddChild(parent, sibling, ParentChildModifier.Natural);
                    }

                    family.AddSibling(person, sibling);
                    break;

                default:
                    family.AddSibling(person, sibling);
                    break;
                }
            }
        }
        /// <summary>
        /// Performs the business logic for adding the Child relationship between the person and the child.
        /// </summary>
        public static void AddChild(PeopleCollection family, Person person, Person child)
        {
            // Add the new child as a sibling to any existing children
            foreach (Person existingSibling in person.Children)
            {
                family.AddSibling(existingSibling, child);
            }

            switch (person.Spouses.Count)
            {
            // Single parent, add the child to the person
            case 0:
                family.AddChild(person, child, ParentChildModifier.Natural);
                break;

            // Has existing spouse, add the child to the person's spouse as well.
            case 1:
                family.AddChild(person, child, ParentChildModifier.Natural);
                family.AddChild(person.Spouses[0], child, ParentChildModifier.Natural);
                break;
            }
        }
        /// <summary>
        /// Performs the business logic for adding the Parent relationship between the person and the parent.
        /// </summary>
        public static void AddParent(PeopleCollection family, Person person, Person parent)
        {
            // A person can only have 2 parents, do nothing
            if (person.Parents.Count == 2)
            {
                return;
            }

            // Add the parent to the main collection of people.
            family.Add(parent);

            switch (person.Parents.Count)
            {
            // No exisitng parents
            case 0:
                family.AddChild(parent, person, ParentChildModifier.Natural);
                break;

            // An existing parent
            case 1:
                family.AddChild(parent, person, ParentChildModifier.Natural);
                family.AddSpouse(parent, person.Parents[0], SpouseModifier.Current);
                break;
            }

            // Handle siblings
            if (person.Siblings.Count > 0)
            {
                // Make siblings the child of the new parent
                foreach (Person sibling in person.Siblings)
                {
                    family.AddChild(parent, sibling, ParentChildModifier.Natural);
                }
            }

            // Setter for property change notification
            person.HasParents = true;
        }
        /// <summary>
        /// Performs the business logic for changing the person parents
        /// </summary>
        public static void ChangeParents(PeopleCollection family, Person person, ParentSet newParentSet)
        {
            // Don't do anything if there is nothing to change or if the parents are the same
            if (person.ParentSet == null || newParentSet == null || person.ParentSet.Equals(newParentSet))
            {
                return;
            }

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

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

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

            // Remove the sibling relationships
            RemoveSiblingRelationships(person);

            // Add the new parents
            AddParent(family, person, newParentSet);
        }
Beispiel #11
0
        public void Export(string path, PeopleCollection ppl, string ancestorId)
        {
            var          firstAncestor = GetPerson(ppl, ancestorId);
            StreamWriter strW          = new StreamWriter(path);

            strW.Write("<html><meta charset='UTF-8'> ");
            strW.Write("<script type='text/javascript' src='https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.5.0.min.js'></script>'");
            strW.Write(@"<style type='text/css'>
.tree * {margin: 0; padding: 0;}

.tree{
	white-space:nowrap;
}

.tree ul
{
	padding-top: 5px; position: relative;
	display: table;
    margin: 0 auto;
	font-size:0;

	transition: all 0.5s;
	-webkit-transition: all 0.5s;
	-moz-transition: all 0.5s;
}

.tree li
{
	display:inline-block;
	text-align: center;
	list-style-type: none;
	position: relative;
	padding: 20px 5px 0 5px;
	font-size: 12px;
	line-height: normal;

	transition: all 0.5s;
	-webkit-transition: all 0.5s;
	-moz-transition: all 0.5s;
}

/*We will use ::before and ::after to draw the connectors*/

.tree li::before, .tree li::after{
	content: '';
	position: absolute; top: 0; right: 50%;
	border-top: 1px solid #2980B9;
	width: 50%; height: 20px;
}
.tree li::after{
	right: auto; left: 50%;
	border-left: 1px solid #2980B9;
}

/*We need to remove left-right connectors from elements without
any siblings*/
.tree li:only-child::after {
	display: none;
}

/*Remove space from the top of single children*/
.tree li:only-child{ padding-top: 0;}

/*Remove left connector from first child and
right connector from last child*/
.tree li:first-child::before, .tree li:last-child::after{
	border: 0 none;
}
/*Adding back the vertical connector to the last nodes*/
.tree li li:last-child::before{
	border-right: 1px solid #2980B9;
	border-radius: 0 5px 0 0;
	-webkit-border-radius: 0 5px 0 0;
	-moz-border-radius: 0 5px 0 0;
}
.tree li:first-child::after{
	border-radius: 5px 0 0 0;
	-webkit-border-radius: 5px 0 0 0;
	-moz-border-radius: 5px 0 0 0;
}

.tree li li:only-child::before
{
	right: auto; left: 50%;
	border-left: 1px solid #2980B9;
	border-right:none;
}

.tree ul.p>li::before
{
	border:none;
	content: '&';
	left:0;
	width:100%;
	display:block;
	}

.tree ul.p>li::after
{
	content: '';
	position: absolute; top: 0; right: 50%;
	border-top: none;
	width: 50%; height: 20px;
}

.tree ul.p>li::after
{
	border-left: none;
}

.p1
{
	display:table;
	margin:0px auto;
}

.p1::before
{
	border:none;
	content: '&';
	left:0;
	width:100%;
	display:block;
	margin:5px 0px;
}

/*Time to add downward connectors from parents*/

.tree ul.c {
	padding-top: 20px;
	}

.tree ul ul.c::before{
	content: '';
	position: absolute; top: 0; left: 50%;
	border-left: 1px solid #2980B9;
	width: 0; height: 20px;
}

.tree li a{
	border: 1px solid #ccc;
	padding: 4px;
	text-decoration: none;
	color: #666;
	background-color:#fff;
	display: inline-block;
	min-width:50px;

	border-radius: 5px;
	-webkit-border-radius: 5px;
	-moz-border-radius: 5px;

	transition: all 0.5s;
	-webkit-transition: all 0.5s;
	-moz-transition: all 0.5s;
  position:relative;

  /* cg - remove focus rectangle */
  outline:none;

box-shadow: 3px 6px 5px 0px rgba(186,186,186,1);
   -webkit-box-shadow: 3px 6px 5px 0px rgba(186,186,186,1);
   -moz-box-shadow: 3px 6px 5px 0px rgba(186,186,186,1);
}

.tree li a#hilight{
	border: 1px solid #999;
	color:#333;
	background-color:#FFFF88;
	}

/* red border on contacts */
.tree li a.o{
	/* background-color: #f90; */
}

.tree li a span{
	display:block;
	font-size: 10px;
	}

/*Time for some hover effects*/
/*We will apply the hover effect the the lineage of the element also*/
.tree li a.m { background: #c8e4f8; color: #000; border: 1px solid #94a0b4; }
.tree li a.f { background: #ffc0cb; color: #000; border: 1px solid #94a0b4; }

.tree li a+ul li a.m { background: #c8e4fb; color: #000; border: 1px solid #94a0b4; }
.tree li a+ul li a.f { background: #ffc0cb; color: #000; border: 1px solid #94a0b4; }

.tree li a+.p1 a.m { background: #c8e4fb; color: #000; border: 1px solid #94a0b4; }
.tree li a+.p1 a.f { background: #ffc0cb; color: #000; border: 1px solid #94a0b4; }


.tree .tree-thumbnail
{
	display:block;
	vertical-align:text-top;
	margin:0px auto 4px auto;
	width:50px;
	height:50px;
}

.tree a.f .tree-thumbnail
{
	background-image:url('./images/f.gif');
}

.tree a.m .tree-thumbnail
{
	background-image:url('./images/m.gif');
}

.tree-detail
{
	display:inline-block;
	vertical-align:text-top;
}

/* ie8 fixes */

.tree-ie8 td.line
{
  line-height:0px;
  height:1px;
  font-size: 1px;
}

.tree-ie8 .li
{
	display:inline-block;
	text-align: center;
	list-style-type: none;
	position: relative;
	padding: 0px 5px 0 5px;
	font-size: 12px;
	line-height: normal;

	transition: all 0.5s;
	-webkit-transition: all 0.5s;
	-moz-transition: all 0.5s;
}


/* cg: make sure the popovers are higher than the hovers */
.popover { z-index: 4444; }


</style>");
            strW.Write("<div class='tree'><ul>");
            ExportUser(firstAncestor, strW);
            strW.Write("</ul></div>");
            strW.Write(@"<script type='text/javascript'>$(document).ready(function(){ document.getElementById('" + ancestorId + "').scrollIntoView({ inline: 'center' });});</script>");
            strW.Write("</html>");
            strW.Flush();
            strW.Close();
        }
Beispiel #12
0
 public People()
 {
     peopleCollection = new PeopleCollection();
 }