/// <summary> /// Handles adding new people and choosing the parents within the Intermediate Add section. /// </summary> private void IntermediateAddButton_Click(object sender, RoutedEventArgs e) { Person newPerson = new Person(FirstNameInputTextBox.Text, LastNameInputTextBox.Text); newPerson.IsLiving = (IsLivingInputCheckbox.IsChecked == null) ? true : (bool)IsLivingInputCheckbox.IsChecked; DateTime birthdate = App.StringToDate(BirthDateInputTextBox.Text); if (birthdate != DateTime.MinValue) { newPerson.BirthDate = birthdate; } newPerson.BirthPlace = BirthPlaceInputTextBox.Text; switch ((FamilyMemberComboBoxValue)FamilyMemberComboBox.SelectedValue) { case FamilyMemberComboBoxValue.Brother: newPerson.Gender = Gender.Male; RelationshipHelper.AddParent(family, newPerson, (ParentSet)ParentsListBox.SelectedValue); break; case FamilyMemberComboBoxValue.Sister: newPerson.Gender = Gender.Female; RelationshipHelper.AddParent(family, newPerson, (ParentSet)ParentsListBox.SelectedValue); break; case FamilyMemberComboBoxValue.Son: newPerson.Gender = Gender.Male; RelationshipHelper.AddParent(family, newPerson, (ParentSet)ParentsListBox.SelectedValue); break; case FamilyMemberComboBoxValue.Daughter: newPerson.Gender = Gender.Female; RelationshipHelper.AddParent(family, newPerson, (ParentSet)ParentsListBox.SelectedValue); break; } FamilyMemberComboBox.SelectedIndex = -1; FamilyMemberAddButton.Focus(); // Use animation to hide the Details Add Intermediate section ((Storyboard)Resources["CollapseDetailsAddIntermediate"]).Begin(this); family.OnContentChanged(newPerson); }
private void AddExistingButton_Click(object sender, RoutedEventArgs e) { Person existingPerson = (Person)ExistingPeopleListBox.SelectedItem; bool SelectParent = false; ParentSetCollection possibleParents = family.Current.PossibleParentSets; // Perform the action based on the selected relationship switch ((FamilyMemberComboBoxValue)ExistingFamilyMemberComboBox.SelectedValue) { case FamilyMemberComboBoxValue.Father: existingPerson.Gender = Gender.Male; RelationshipHelper.AddParent(family, family.Current, existingPerson); SetNextFamilyMemberAction(FamilyMemberComboBoxValue.Mother); break; case FamilyMemberComboBoxValue.Mother: existingPerson.Gender = Gender.Female; RelationshipHelper.AddParent(family, family.Current, existingPerson); SetNextFamilyMemberAction(FamilyMemberComboBoxValue.Brother); break; case FamilyMemberComboBoxValue.Brother: existingPerson.Gender = Gender.Male; // Check to see if there are multiple parents if (possibleParents.Count > 1) { SelectParent = true; } else { RelationshipHelper.AddSibling(family, family.Current, existingPerson); } break; case FamilyMemberComboBoxValue.Sister: existingPerson.Gender = Gender.Female; // Check to see if there are multiple parents if (possibleParents.Count > 1) { SelectParent = true; } else { RelationshipHelper.AddSibling(family, family.Current, existingPerson); } break; case FamilyMemberComboBoxValue.Spouse: RelationshipHelper.AddSpouse(family, family.Current, existingPerson, SpouseModifier.Current); SetNextFamilyMemberAction(FamilyMemberComboBoxValue.Son); break; case FamilyMemberComboBoxValue.Son: existingPerson.Gender = Gender.Male; if (family.Current.Spouses.Count > 1) { possibleParents = family.Current.MakeParentSets(); SelectParent = true; } else { RelationshipHelper.AddChild(family, family.Current, existingPerson); } break; case FamilyMemberComboBoxValue.Daughter: existingPerson.Gender = Gender.Female; if (family.Current.Spouses.Count > 1) { possibleParents = family.Current.MakeParentSets(); SelectParent = true; } else { RelationshipHelper.AddChild(family, family.Current, existingPerson); } break; } if (SelectParent) { ShowDetailsAddIntermediate(possibleParents); } else { // Use animation to hide the Details Add section ((Storyboard)Resources["CollapseAddExisting"]).Begin(this); FamilyMemberComboBox.SelectedIndex = -1; FamilyMemberAddButton.Focus(); } }
/// <summary> /// Handles adding new people /// </summary> private void AddButton_Click(object sender, RoutedEventArgs e) { // To make it a little more user friendly, set the next action for the family member button to be the same as the current relationship being added. SetNextFamilyMemberAction((FamilyMemberComboBoxValue)FamilyMemberComboBox.SelectedValue); // The new person to be added Person newPerson = new Person(FirstNameInputTextBox.Text, LastNameInputTextBox.Text) { IsLiving = (IsLivingInputCheckbox.IsChecked == null) ? true : (bool)IsLivingInputCheckbox.IsChecked }; DateTime birthdate = App.StringToDate(BirthDateInputTextBox.Text); if (birthdate != DateTime.MinValue) { newPerson.BirthDate = birthdate; } newPerson.BirthPlace = BirthPlaceInputTextBox.Text; bool SelectParent = false; ParentSetCollection possibleParents = family.Current.PossibleParentSets; // Perform the action based on the selected relationship switch ((FamilyMemberComboBoxValue)FamilyMemberComboBox.SelectedValue) { case FamilyMemberComboBoxValue.Father: newPerson.Gender = Gender.Male; RelationshipHelper.AddParent(family, family.Current, newPerson); SetNextFamilyMemberAction(FamilyMemberComboBoxValue.Mother); break; case FamilyMemberComboBoxValue.Mother: newPerson.Gender = Gender.Female; RelationshipHelper.AddParent(family, family.Current, newPerson); SetNextFamilyMemberAction(FamilyMemberComboBoxValue.Brother); break; case FamilyMemberComboBoxValue.Brother: newPerson.Gender = Gender.Male; // Check to see if there are multiple parents if (possibleParents.Count > 1) { SelectParent = true; } else { RelationshipHelper.AddSibling(family, family.Current, newPerson); } break; case FamilyMemberComboBoxValue.Sister: newPerson.Gender = Gender.Female; // Check to see if there are multiple parents if (possibleParents.Count > 1) { SelectParent = true; } else { RelationshipHelper.AddSibling(family, family.Current, newPerson); } break; case FamilyMemberComboBoxValue.Spouse: RelationshipHelper.AddSpouse(family, family.Current, newPerson, SpouseModifier.Current); SetNextFamilyMemberAction(FamilyMemberComboBoxValue.Son); break; case FamilyMemberComboBoxValue.Son: newPerson.Gender = Gender.Male; if (family.Current.Spouses.Count > 1) { possibleParents = family.Current.MakeParentSets(); SelectParent = true; } else { RelationshipHelper.AddChild(family, family.Current, newPerson); } break; case FamilyMemberComboBoxValue.Daughter: newPerson.Gender = Gender.Female; if (family.Current.Spouses.Count > 1) { possibleParents = family.Current.MakeParentSets(); SelectParent = true; } else { RelationshipHelper.AddChild(family, family.Current, newPerson); } break; } if (SelectParent) { ShowDetailsAddIntermediate(possibleParents); } else { // Use animation to hide the Details Add section ((Storyboard)Resources["CollapseDetailsAdd"]).Begin(this); FamilyMemberComboBox.SelectedIndex = -1; FamilyMemberAddButton.Focus(); } family.OnContentChanged(newPerson); }