예제 #1
0
파일: Form1.cs 프로젝트: ptorpman/torpgen
        /// <summary>
        /// Shows the person page
        /// </summary>
        /// <param name="mode"></param>
        /// <param name="person"></param>
        private void ShowPersonPage(PersonPageMode mode, Person person)
        {
            mPageMode = mode;

            if (mMen != null)
            {
                mMen.Clear();
            }

            if (mWomen != null)
            {
                mWomen.Clear();
            }

            mMen = mDB.GetPersonsWithGender(Gender.Male);
            mWomen = mDB.GetPersonsWithGender(Gender.Female);

            // Make sure all fields are empty.
            tbFirstName.Text = "";
            tbLastName.Text = "";
            rbMale.Checked = true;
            rbFemale.Checked = false;
            tbBirthDate.Text = "";
            tbBirthLocation.Text = "";
            tbBirthNote.Text = "";
            tbDeathDate.Text = "";
            tbDeathLocation.Text = "";
            tbDeathNotes.Text = "";

            tbMarriageDate.Text = "";
            tbMarriageLocation.Text = "";
            tbMarriageNotes.Text = "";

            tbNotes.Text = "";
            lbSpouses.Items.Clear();

            if (mMen != null)
            {
                cmbFather.Items.Clear();
                cmbFather.Items.Add(String.Empty);
                cmbFather.Items.AddRange(mMen.ToArray());
            }

            if (mWomen != null)
            {
                cmbMother.Items.Clear();
                cmbMother.Items.Add(String.Empty);
                cmbMother.Items.AddRange(mWomen.ToArray());
            }

            cmbFather.DisplayMember = "listBoxString";
            cmbFather.ValueMember = "id";
            cmbMother.DisplayMember = "listBoxString";
            cmbMother.ValueMember = "id";

            if (mode == PersonPageMode.Add)
            {
                lbPanelTopLabel.Text = "Add Person";
                mTempFather = Guid.Empty;
                mTempFather = Guid.Empty;
                mTempMarriages = new List<Marriage>();

                person = mCurrentPerson;
            }
            else if (mode == PersonPageMode.Edit)
            {
                lbPanelTopLabel.Text = "Edit Person";

                tbFirstName.Text = person.firstName;
                tbLastName.Text = person.lastName;

                if (person.birth != null)
                {
                    tbBirthDate.Text = person.birth.date;
                    tbBirthLocation.Text = person.birth.place;
                    tbBirthNote.Text = person.birth.note;
                }

                if (person.death != null)
                {
                    tbDeathDate.Text = person.death.date;
                    tbDeathLocation.Text = person.death.place;
                    tbDeathNotes.Text = person.death.note;
                }

                mTempFather = person.father;
                mTempFather = person.mother;

                if (person.father != Guid.Empty)
                {
                    cmbFather.SelectedItem = mDB.GetPerson(person.father);
                }

                if (person.mother != Guid.Empty)
                {
                    cmbMother.SelectedItem = mDB.GetPerson(person.mother);
                }

                // Create a temporary list of marriages to be able to handle changes upon saving the person
                mTempMarriages = new List<Marriage>();

                if (person.marriages.Count > 0)
                {
                    for (int i = 0; i < person.marriages.Count; i++)
                    {
                        mTempMarriages.Add(mDB.GetMarriage(person.marriages[i]));
                    }
                }
            }

            if (person.gender == Gender.Male)
            {
                rbMale.Checked = true;
            }
            else
            {
                rbFemale.Checked = true;
            }

            UpdateMarriageSpouseCombo();
            UpdateMarriageControls();

            // Make sure the first tag is open
            tabPerson.SelectedIndex = 0;

            panelPerson.Visible = true;
        }
예제 #2
0
파일: Form1.cs 프로젝트: ptorpman/torpgen
 /// <summary>
 /// Hides the person page.
 /// </summary>
 private void HidePersonPage()
 {
     this.panelPerson.Visible = false;
     this.lbAdd.ForeColor = SystemColors.ControlText;
     this.lbEdit.ForeColor = SystemColors.ControlText;
     this.lbRemove.ForeColor = SystemColors.ControlText;
     this.lbSpouseAdd.ForeColor = SystemColors.ControlText;
     this.mCurrentPerson = null;
     this.mPageMode = PersonPageMode.None;
 }
예제 #3
0
파일: Form1.cs 프로젝트: ptorpman/torpgen
        /// <summary>
        /// Constructor
        /// </summary>
        public Form1()
        {
            InitializeComponent();

            mCurrentPerson = null;
            mPageMode = PersonPageMode.None;
            mFileName = "";

            LoadPersonsFromFile();
            toolStripStatusLabel1.Text = "";
        }