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); } }
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; } }
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(); } }
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(); } } }
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; }
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); } }
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; } }