Ejemplo n.º 1
0
        /// <summary>
        /// Display the Details Add Intermediate section
        /// </summary>
        private void ShowDetailsAddIntermediate(ParentSetCollection possibleParents)
        {
            // Display the Details Add Intermediate section
            ((Storyboard)Resources["ExpandDetailsAddIntermediate"]).Begin(this);

            // Bind the possible parents
            ParentsListBox.ItemsSource = possibleParents;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the combination of parent sets for this person and his/her spouses
        /// </summary>
        /// <returns></returns>
        public ParentSetCollection MakeParentSets()
        {
            ParentSetCollection parentSets = new ParentSetCollection();

            foreach (Person spouse in Spouses)
            {
                ParentSet ps = new ParentSet(this, spouse);

                // Don't add the same parent set twice.
                if (!parentSets.Contains(ps))
                {
                    parentSets.Add(ps);
                }
            }

            return(parentSets);
        }
Ejemplo n.º 3
0
        private void UserControl_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
        {
            if (DataContext != null)
            {
                if (family != null && family.Current != null && family.Current.HasParents)
                {
                    // Programmatically set the possible parents that can be selected.
                    ParentSetCollection psc = family.Current.PossibleParentSets;
                    ParentsEditListBox.ItemsSource = psc;

                    // Cannot simply set the selected parent like so: ParentsEditListBox.SelectedItem = family.Current.ParentSet;
                    // Need to use .Equals and set the index
                    for (int i = 0; i <= psc.Count - 1; i++)
                    {
                        if (psc[i].Equals(family.Current.ParentSet))
                        {
                            ParentsEditListBox.SelectedIndex = i;
                        }
                    }
                }

                SetFamilyMemberAddButton();
            }
        }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 5
0
        /// <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);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Display the Details Add Intermediate section
        /// </summary>
        private void ShowDetailsAddIntermediate(ParentSetCollection possibleParents)
        {
            // Display the Details Add Intermediate section
            ((Storyboard)this.Resources["ExpandDetailsAddIntermediate"]).Begin(this);

            // Bind the possible parents
            ParentsListBox.ItemsSource = possibleParents;
        }