Example #1
0
        public bool GetFromElement(XElement xTable, out RelationsTable table)
        {
            table = RelationsTable.GetTable();
            table.Clear();
            try
            {
                foreach (XElement xRelation in xTable.Elements("relation"))
                {
                    int       firstID  = Int32.Parse(xRelation.Attribute("firstPerson").Value);
                    int       secondID = Int32.Parse(xRelation.Attribute("secondPerson").Value);
                    Relatives relation = (Relatives)Enum.Parse(typeof(Relatives), xRelation.Attribute("relation").Value);

                    PersonList personList = PersonList.GetPersonList(null);
                    Person     fPerson;
                    Person     sPerson;
                    if ((personList.GetPersonFromID(firstID, out fPerson)) &&
                        (personList.GetPersonFromID(secondID, out sPerson)))
                    {
                        table.SetRelationBetweenPersons(fPerson, sPerson, relation);
                    }
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Example #2
0
        public bool GetFromElement(XElement xTable, out RelationsTable table)
        {
            table = RelationsTable.GetTable();
            table.Clear();
            try
            {
                foreach (XElement xRelation in xTable.Elements("relation"))
                {
                    int firstID = Int32.Parse(xRelation.Attribute("firstPerson").Value);
                    int secondID = Int32.Parse(xRelation.Attribute("secondPerson").Value);
                    Relatives relation = (Relatives)Enum.Parse(typeof(Relatives), xRelation.Attribute("relation").Value);

                    PersonList personList = PersonList.GetPersonList(null);
                    Person fPerson;
                    Person sPerson;
                    if((personList.GetPersonFromID(firstID,out fPerson))
                        &&(personList.GetPersonFromID(secondID,out sPerson)))
                    {
                        table.SetRelationBetweenPersons(fPerson, sPerson, relation);
                    }
                }
                return true;
            }
            catch
            {

                return false;
            }
        }
Example #3
0
 private void button1_Click_2(object sender, RoutedEventArgs e)
 {
     if (PeopleDataGrid.SelectedIndex != -1)
     {
         Person       person = PersonList.GetPersonList().GetPersonsList()[PeopleDataGrid.SelectedIndex];
         PersonsGraph graph  = new PersonsGraph(PersonList.GetPersonList(), RelationsTable.GetTable(), person);
         var          wind   = new GraphWindow(graph);
         wind.ShowDialog();
     }
 }
Example #4
0
 private void SaveRelationButton_Click(object sender, RoutedEventArgs e)
 {
     if (RelationTableDataGrid.SelectedIndex != -1)
     {
         Relatives relative;
         if (Relatives.TryParse(RelationComboBox.SelectedValue.ToString(), out relative))
         {
             RelationsTable.GetTable().SetRelationBetweenPersons(_currentRelation.FirstPerson,
                                                                 _currentRelation.SecondPerson, relative);
             RefreshTable();
         }
     }
 }
Example #5
0
 public GenTree(DateTime dateOfCreate, DateTime dateOfLastEdit,
   String name,string information,int id = -1, List<Person> personList = null,
   List<RelationBetweenTwoPerson> relationList=null)
 {
     _dateOfCreate = dateOfCreate;
       _dateOfLastEdit = dateOfLastEdit;
       _name = name;
       _information = information;
       _persons = PersonList.GetPersonList(personList);
       _relationTable = RelationsTable.GetTable(relationList);
       if (id == -1)
       _id = (name + dateOfCreate.ToString() + information).GetHashCode();
       else
       _id = id;
 }
Example #6
0
 public bool AddToElement(RelationsTable table, out XElement xTable)
 {
     try
     {
         xTable = new XElement("relations");
         foreach (RelationBetweenTwoPerson relation in table)
         {
             XElement xRelation = new XElement("relation");
             xRelation.SetAttributeValue("firstPerson", relation.FirstPerson.ID);
             xRelation.SetAttributeValue("secondPerson", relation.SecondPerson.ID);
             xRelation.SetAttributeValue("relation", relation.Relations.ToString());
             xTable.Add(xRelation);
         }
         return(true);
     }
     catch
     {
         xTable = null;
         return(false);
     }
 }
Example #7
0
 public bool AddToElement(RelationsTable table, out XElement xTable)
 {
     try
     {
         xTable = new XElement("relations");
         foreach (RelationBetweenTwoPerson relation in table)
         {
             XElement xRelation = new XElement("relation");
             xRelation.SetAttributeValue("firstPerson", relation.FirstPerson.ID);
             xRelation.SetAttributeValue("secondPerson", relation.SecondPerson.ID);
             xRelation.SetAttributeValue("relation", relation.Relations.ToString());
             xTable.Add(xRelation);
          }
         return true;
     }
     catch
     {
         xTable = null;
         return false;
     }
 }