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