public bool GetFromElement(XElement xPerson, out Person person) { try { int ID = Int32.Parse(xPerson.Attribute("id").Value); string name = xPerson.Attribute("name").Value; int layer= Int32.Parse(xPerson.Attribute("layer").Value); Genders gender = (Genders)Enum.Parse(typeof(Genders),xPerson.Attribute("gender").Value); DateTime bornDate; DateTime? BornDate; if (DateTime.TryParse(xPerson.Attribute("bornDate").Value, out bornDate)) BornDate = bornDate; else BornDate = null; DateTime deathDate; DateTime? DeathDate; if (DateTime.TryParse(xPerson.Attribute("deathDate").Value, out deathDate)) DeathDate = deathDate; else DeathDate = null; string note = xPerson.Attribute("note").Value; person = new Person(name, BornDate, DeathDate, gender, note,ID,null,layer); return true; } catch(Exception) { person = null; return false; } }
public bool AddToElement(Person person,out XElement xPerson) { try { xPerson = new XElement("person"); xPerson.SetAttributeValue("id", person.ID); xPerson.SetAttributeValue("name",person.NameOfPerson); xPerson.SetAttributeValue("layer", person.GenLayer); xPerson.SetAttributeValue("gender", person.Gender.ToString()); xPerson.SetAttributeValue("bornDate", person.DateOfBorn.ToString()); xPerson.SetAttributeValue("deathDate", person.DateOfDeath.ToString()); xPerson.SetAttributeValue("note", person.Note); return true; } catch (Exception) { xPerson = null; return false; } }
private void DrawElement(int x, int y,int offsetX,int offsetY,int offsetBetweenLayers,Person person) { if (person.Gender == Genders.Male) { if (offsetBetweenLayers != 0) { curCanvas.Children.Add(new Rectangle() { Width = offsetBetweenLayers * CellWidth, Height = lineThinkness, Fill = new LinearGradientBrush(Colors.Blue, Colors.Red, 30) }); Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight * offsetY + FigureHeight / 2); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth * (offsetX + offsetBetweenLayers) + FigureWidth / 2); curCanvas.Children.Add(new Rectangle() { Width = lineThinkness, Height = 2 * CellHeight - FigureHeight / 2, Fill = new LinearGradientBrush(Colors.Blue, Colors.Red, 30) }); Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight * offsetY + FigureHeight / 2); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth * (offsetX + offsetBetweenLayers) + FigureWidth / 2 - lineThinkness / 2); } curCanvas.Children.Add(new Rectangle() { Width = FigureWidth, Height = FigureHeight, Fill = new LinearGradientBrush(Colors.Blue, Colors.Red, 30) }); Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight*offsetY); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth*offsetX); curCanvas.Children.Add(new TextBlock() { Width = FigureWidth*3, Height = FigureHeight, Text = person.NameOfPerson, TextWrapping = TextWrapping.WrapWithOverflow }); Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight*offsetY + FigureHeight); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth*offsetX - FigureWidth); curCanvas.Children.Add(new TextBlock() { Width = FigureWidth*3, Height = FigureHeight*2, TextWrapping = TextWrapping.WrapWithOverflow }); try { if (person.DateOfBorn != null) { ((TextBlock) curCanvas.Children[curCanvas.Children.Count - 1]).Text = person.DateOfBorn.Value.ToShortDateString(); } if (person.DateOfDeath != null) { ((TextBlock) curCanvas.Children[curCanvas.Children.Count - 1]).Text = ((TextBlock) curCanvas.Children[curCanvas.Children.Count - 1]).Text + "-\n" + person.DateOfDeath.Value.ToShortDateString(); } Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight*offsetY + FigureHeight + FigureHeight/2); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth*offsetX - FigureWidth); } catch (Exception) { } } else { if (offsetBetweenLayers != 0) { curCanvas.Children.Add(new Rectangle() { Width = offsetBetweenLayers*CellWidth, Height = lineThinkness, Fill = new LinearGradientBrush(Colors.Blue, Colors.Red, 30) }); Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight*offsetY+FigureHeight/2); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth*offsetX+FigureWidth/2); curCanvas.Children.Add(new Rectangle() { Width = lineThinkness, Height = 2*CellHeight-FigureHeight/2, Fill = new LinearGradientBrush(Colors.Blue, Colors.Red, 30) }); Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight * offsetY+FigureHeight/2); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth * (offsetX-offsetBetweenLayers)+FigureWidth/2-lineThinkness/2); } curCanvas.Children.Add(new Ellipse() { Width = FigureWidth, Height = FigureHeight, Fill = new LinearGradientBrush(Colors.Blue, Colors.Red, 30) }); Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight * offsetY); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth * offsetX); curCanvas.Children.Add(new TextBlock() { Width = FigureWidth * 3, Height = FigureHeight, Text = person.NameOfPerson, TextWrapping = TextWrapping.WrapWithOverflow }); Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight * offsetY + FigureHeight); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth * offsetX - FigureWidth); curCanvas.Children.Add(new TextBlock() { Width = FigureWidth * 4, Height = FigureHeight, TextWrapping = TextWrapping.WrapWithOverflow }); try { if (person.DateOfBorn != null) { ((TextBlock)curCanvas.Children[curCanvas.Children.Count - 1]).Text = person.DateOfBorn.Value.ToShortDateString(); } if (person.DateOfDeath != null) { ((TextBlock)curCanvas.Children[curCanvas.Children.Count - 1]).Text = ((TextBlock)curCanvas.Children[curCanvas.Children.Count - 1]).Text + "-\n" + person.DateOfDeath.Value.ToShortDateString(); } Canvas.SetTop(curCanvas.Children[curCanvas.Children.Count - 1], Y - CellHeight * offsetY + FigureHeight + FigureHeight / 2); Canvas.SetLeft(curCanvas.Children[curCanvas.Children.Count - 1], X - CellWidth * offsetX - FigureWidth); } catch(Exception) { } } }
public RelationBetweenTwoPerson(Person firstPerson, Person secondPerson, Relatives relations) { FirstPerson = firstPerson; SecondPerson = secondPerson; Relations = relations; }
/* private void listView1_SelectionChanged(object sender, SelectionChangedEventArgs e) { int selectPersonIndex = PeopleListView.SelectedIndex; if (selectPersonIndex != -1) { isDeleteButtonActive = true; NewPersonButton.Content = "Delete person"; TreeProcessor.TreeProcessorSingletone.CurrentPerson = TreeProcessor.TreeProcessorSingletone.CurrentTree.Persons.GetPersonList()[selectPersonIndex]; RefreshPersonEditor(TreeProcessor.TreeProcessorSingletone.CurrentPerson); } }*/ private void RefreshPersonEditor(Person person) { NameTextBox.Text = person.NameOfPerson; if(person.DateOfBorn != null) BornDatePicker.Text = person.DateOfBorn.ToString(); if (person.DateOfDeath != null) DeathDatePicker.Text = person.DateOfDeath.ToString(); if (person.Gender == Genders.Male) GenderComboBox.SelectedIndex = 1; else GenderComboBox.SelectedIndex = 0; NoteTextBox.Text = person.Note; }
public PersonAsGraphElement(Person person, int layer, int familyCell) { PersonLink = person; Layer = layer; FamilyCell = familyCell; }
public void DeletePerson(Person person) { Persons.DeletePersonFromList(person); Relations.DeleteRelationOfPerson(person); }
public RelationBetweenTwoPerson GetRelationsBetweenPersons(Person firstPerson, Person secondPerson) { try { RelationBetweenTwoPerson answ = _relationsList.Where <RelationBetweenTwoPerson>(x => (x.FirstPerson == firstPerson) && (x.SecondPerson == secondPerson)).Single <RelationBetweenTwoPerson>(); return(answ); } catch (Exception) { return(null); } }
public List <RelationBetweenTwoPerson> GetPersonRelation(Person person, bool onlyWherePersonIsFirst = true) { return((_relationsList.Where(x => x.FirstPerson.ID == person.ID)).ToList()); }
public void DeleteRelationOfPerson(Person person) { _relationsList.RemoveAll(x => (x.FirstPerson == person) || (x.SecondPerson == person)); }
public Relatives GetOpositeRelative(Relatives relatives, Person secondPerson) { switch (relatives) { case Relatives.aunt: return((secondPerson.Gender == Genders.Male) ? Relatives.nephew : Relatives.niece); break; case Relatives.uncle: return((secondPerson.Gender == Genders.Male) ? Relatives.nephew : Relatives.niece); break; case Relatives.grandfather: return((secondPerson.Gender == Genders.Male) ? Relatives.grandson : Relatives.granddaughter); break; case Relatives.grandmother: return((secondPerson.Gender == Genders.Male) ? Relatives.grandson : Relatives.granddaughter); break; case Relatives.brother: return((secondPerson.Gender == Genders.Male) ? Relatives.brother : Relatives.sister); break; case Relatives.sister: return((secondPerson.Gender == Genders.Male) ? Relatives.brother : Relatives.sister); break; case Relatives.daughter: return((secondPerson.Gender == Genders.Male) ? Relatives.father : Relatives.mother); break; case Relatives.son: return((secondPerson.Gender == Genders.Male) ? Relatives.father : Relatives.mother); break; case Relatives.father: return((secondPerson.Gender == Genders.Male) ? Relatives.son : Relatives.daughter); break; case Relatives.mother: return((secondPerson.Gender == Genders.Male) ? Relatives.son : Relatives.daughter); break; case Relatives.granddaughter: return((secondPerson.Gender == Genders.Male) ? Relatives.grandfather : Relatives.grandmother); break; case Relatives.grandson: return((secondPerson.Gender == Genders.Male) ? Relatives.grandfather : Relatives.grandmother); break; case Relatives.husband: return((secondPerson.Gender == Genders.Male) ? Relatives.husband : Relatives.wife); break; case Relatives.wife: return((secondPerson.Gender == Genders.Male) ? Relatives.husband : Relatives.wife); break; case Relatives.nephew: return((secondPerson.Gender == Genders.Male) ? Relatives.uncle : Relatives.aunt); break; case Relatives.niece: return((secondPerson.Gender == Genders.Male) ? Relatives.uncle : Relatives.aunt); break; case Relatives.NoRelative: return((secondPerson.Gender == Genders.Male) ? Relatives.NoRelative : Relatives.NoRelative); break; default: return(Relatives.NoRelative); } }
public bool AddNewPersonToTree(Person newPerson) { try { if (_currentTree.Persons.AddNewPerson(newPerson)) { foreach(Person person in _currentTree.Persons) { // if (newPerson != person) // { // RelationsTable.GetTable().SetRelationBetweenPersons(newPerson, person, Relatives.NoRelative); // RelationsTable.GetTable().SetRelationBetweenPersons(person, newPerson, Relatives.NoRelative); // } } return true; } else return false; } catch { return false; } }
public void DeletePerson(Person person) { CurrentTree.DeletePerson(person); new TreeDB().DeletePerson(person.ID,_builder); }