コード例 #1
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            // Create a new person with the specified inputs
            Person newPerson = new Person(FirstNameInputTextBox.Text, LastNameInputTextBox.Text);

            // Setup the properties based on the input
            newPerson.Gender     = ((bool)MaleRadioButton.IsChecked) ? Gender.Male : Gender.Female;
            newPerson.BirthPlace = BirthPlaceInputTextBox.Text;
            newPerson.IsLiving   = true;

            DateTime birthdate = App.StringToDate(BirthDateInputTextBox.Text);

            if (birthdate != DateTime.MinValue)
            {
                newPerson.BirthDate = birthdate;
            }

            // Setup the avatar photo
            if (!string.IsNullOrEmpty(avatarPhotoPath))
            {
                Photo photo = new Photo(avatarPhotoPath);
                photo.IsAvatar = true;

                // Add the avatar photo to the person photos
                newPerson.Photos.Add(photo);
            }

            family.Current = newPerson;
            family.Add(newPerson);

            family.OnContentChanged();

            RaiseEvent(new RoutedEventArgs(AddButtonClickEvent));
        }
コード例 #2
0
        private void WelcomeUserControl_OpenRecentFileButtonClick(object sender, RoutedEventArgs e)
        {
            Button item = (Button)e.OriginalSource;
            string file = item.CommandParameter as string;

            if (!string.IsNullOrEmpty(file))
            {
                // Load the selected family file
                LoadFamily(file);

                ShowDetailsPane();

                // This will tell the diagram to redraw and the details panel to update.
                family.OnContentChanged();

                // Remove the file from its current position and add it back to the top/most recent position.
                App.RecentFiles.Remove(file);
                App.RecentFiles.Insert(0, file);
                BuildOpenMenu();
                family.IsDirty = false;
            }
        }
コード例 #3
0
        private void AddButton_Click(object sender, RoutedEventArgs e)
        {
            // Create a new person with the specified inputs
            Person newPerson = new Person(NamesInputTextBox.Text, SurnameInputTextBox.Text);

            // Setup the properties based on the input
            newPerson.Gender     = ((bool)MaleRadioButton.IsChecked) ? Gender.Male : Gender.Female;
            newPerson.BirthPlace = BirthPlaceInputTextBox.Text;
            newPerson.IsLiving   = true;

            DateTime birthdate = App.StringToDate(BirthDateInputTextBox.Text);

            if (birthdate != DateTime.MinValue)
            {
                newPerson.BirthDate = birthdate;
            }

            family.Current = newPerson;
            family.Add(newPerson);
            family.OnContentChanged();

            RaiseEvent(new RoutedEventArgs(AddButtonClickEvent));
        }
コード例 #4
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);
        }