public bool GetFromElement(XElement xRelation, out RelationBetweenTwoPerson relation) { try { int firstID = Int32.Parse(xRelation.Attribute("firstPerson").Value); int secondID = Int32.Parse(xRelation.Attribute("secondPerson").Value); Relatives relative = (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))) { relation = new RelationBetweenTwoPerson(fPerson, sPerson, relative); return(true); } else { relation = null; return(false); } } catch { relation = null; return(false); } }
private void RefreshTable() { RelationTableDataGrid.Items.Clear(); var person = TreeProcessor.TreeProcessorSingletone.CurrentTree.Persons.GetPersonsList()[personIndex]; foreach (var somePerson in TreeProcessor.TreeProcessorSingletone.CurrentTree.Persons.GetPersonsList()) { if (somePerson.ID != person.ID) { RelationBetweenTwoPerson relation = TreeProcessor.TreeProcessorSingletone.CurrentTree.Relations.GetRelationsBetweenPersons(person, somePerson); if (relation == null) { relation = new RelationBetweenTwoPerson(person, somePerson, Relatives.NoRelative); } RelationTableDataGrid.Items.Add(relation); relations.Add(relation); } } /* * relations = RelationsTable.GetTable().Where( * x => PersonList.GetPersonList().GetPersonIndexInTable(x.FirstPerson) == personIndex).ToList(); * foreach(RelationBetweenTwoPerson relation in relations) * { * RelationTableDataGrid.Items.Add(relation); * } */ }
private void RelationTableDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (RelationTableDataGrid.SelectedIndex != -1) { _currentRelation = relations[RelationTableDataGrid.SelectedIndex]; } else { _currentRelation = null; } }
public bool AddToElement(RelationBetweenTwoPerson relation, out XElement xRelation) { try { xRelation = new XElement("relation"); xRelation.SetAttributeValue("firstPerson", relation.FirstPerson.ID); xRelation.SetAttributeValue("secondPerson", relation.SecondPerson.ID); xRelation.SetAttributeValue("relation", relation.Relations.ToString()); return(true); } catch { xRelation = null; return(false); } }