public void AddUnion(CPerson p)
 {
     foreach (CUnion u in p.GetUnions())
     {
         this.Add(u.GetTheOther(p), p.X + p.Label.Width + 1, p.Y);
     }
 }
        public void ShowParentRelation(System.Drawing.Graphics g)
        {
            Pen ParentPen = new Pen(Color.Green, 1);

            foreach (CPerson Man in this.Persons)
            {
                if (Man.Displayed)
                {
                    CPerson Father = Man.Father;

                    if (Father != null)
                    {
                        if (Father.Displayed)
                        {
                            g.DrawLine(ParentPen, Man.X + (Man.Label.Width / 2), Man.Y, Father.X + (Father.Label.Width / 2), Father.Label.Top + Father.Label.Height);
                        }
                    }


                    CPerson Mother = Man.Mother;

                    if (Mother != null)
                    {
                        if (Mother.Displayed)
                        {
                            g.DrawLine(ParentPen, Man.X + (Man.Label.Width / 2), Man.Y, Mother.X + (Mother.Label.Width / 2), Mother.Label.Top + Mother.Label.Height);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public void SetRelation(CPerson P, ERelation Relation)
        {
            switch (Relation)
            {
            case ERelation.ChildOfMother:
                this.MotherGuid = P.Guid;
                this.SaveXML();
                break;

            case ERelation.ChildOfFather:
                this.FatherGuid = P.Guid;
                this.SaveXML();
                break;

            case ERelation.FatherOf:
                P.FatherGuid = this.Guid;
                P.SaveXML();
                break;

            case ERelation.MotherOf:
                P.MotherGuid = this.Guid;
                P.SaveXML();
                break;
            }
        }
Beispiel #4
0
        private void GraphicObject_Click(object sender, System.EventArgs e)
        {
            if (SelectedPerson != null)
            {
                SelectedPerson.Selected = false;
            }
            if (SelectedUnion != null)
            {
                SelectedUnion.Selected = false;
            }

            System.Windows.Forms.Label l = (System.Windows.Forms.Label)sender;
            SelectedPerson = GeneaManager.Persons[l.Tag.ToString()];
            if (SelectedPerson != null)
            {
                SelectedGraphicObject   = SelectedPerson;
                SelectedPerson.Selected = true;
                ShowPersonDetail(SelectedPerson);
            }
            SelectedUnion = GeneaManager.Unions[l.Tag.ToString()];
            if (SelectedUnion != null)
            {
                SelectedGraphicObject  = SelectedUnion;
                SelectedUnion.Selected = true;
                ShowUnionDetail(SelectedUnion);
            }
        }
 public CPerson GetTheOther(CPerson p)
 {
     if (p.Guid == this.ManGuid)
     {
         return(Persons[this.WomanGuid]);
     }
     else
     {
         return(Persons[this.ManGuid]);
     }
 }
 public CPerson Add(string strFolderName)
 {
     try{
         CPerson p = new CPerson(strFolderName);
         return(this.Add(p));
     }
     catch (System.Exception e) {
         GeneaTools.ShowError(e.Message);
         return(null);
     }
 }
        public void AddChildren(CPerson p)
        {
            int x = p.X;

            foreach (CPerson c in p.GetChildren())
            {
                this.Add(c, x, p.Y + CGraphicObjectCommon.CellHeight);
                Show();
                x += c.Label.Width + 1;
            }
        }
Beispiel #8
0
        private void ShowPersonDetail(CPerson SelectedPerson)
        {
            this.Status(SelectedPerson.Text);

            if (SelectedPerson.ImageExist)
            {
                this.pictureBox1.Image = System.Drawing.Image.FromFile(SelectedPerson.ImageFullPath);
            }
            else
            {
                this.pictureBox1.Image = null;
            }
        }
 public void Add(CPerson FirstPerson, int x, int y)
 {
     if (this.Persons.Exist(FirstPerson.Guid))
     {
         GeneaTools.ShowError(GeneaTools.ERR_1003, FirstPerson.Text);
     }
     else
     {
         this.Persons.Add(FirstPerson);
         FirstPerson.X = x;
         FirstPerson.Y = y;
     }
 }
Beispiel #10
0
        public CGeneaManager(string RootDir)
        {
            DisplayOptions = new CDisplayOptions();
            this.RootDir   = RootDir;


            LoadPersons();
            LoadUnions();



            RootPerson = new CPerson(this.DisplayOptions.Person1);
        }
Beispiel #11
0
        private void mnuViewNew_Click(object sender, System.EventArgs e)
        {
            PersonSelectorForm f = new PersonSelectorForm();
            CPerson            p = f.OpenDialog(this.GeneaManager);

            if (p != null)
            {
                View          = new CView(this, this.MainToolTip, new System.EventHandler(GraphicObject_Click), new System.EventHandler(GraphicObject_DoubleClick), this.PersonContextMenu, GeneaManager.Persons);
                View.FileName = @"C:\DVT\MyGenalogie.db\CurrentView.View";
                View.Add(p, 0, 0);
                mnuViewRefresh_Click(null, null);
            }
        }
        public CPerson OpenDialog(CGeneaManager GeneaManager)
        {
            GeneaManager.Persons.FillComboBox(cboMAN, "");

            if (this.ShowDialog() == DialogResult.OK)
            {
                CPerson Man = (CPerson)((CSLib.CObjectBoxItem)cboMAN.SelectedItem).Value;
                return(Man);
            }
            else
            {
                return(null);
            }
        }
        public bool OpenDialog(CPerson p, CGeneaManager GeneaManager)
        {
            this.BirthDate.Text    = p.BirthDate;
            this.BirthCountry.Text = p.BirthCountry;
            this.BirthCity.Text    = p.BirthCity;
            this.DeathDate.Text    = p.DeathDate;
            this.DeathCountry.Text = p.DeathCountry;
            this.DeathCity.Text    = p.DeathCity;
            this.Comment.Text      = p.Comment;
            this.Text = p.FolderName;

            GeneaManager.Persons.FillComboBox(this.cboFather, p.FatherGuid, "M");
            GeneaManager.Persons.FillComboBox(this.cboMother, p.MotherGuid, "F");

            GeneaManager.FillComboBoxSexe(this.cboSexe, p.Sexe);

            if (this.ShowDialog() == DialogResult.OK)
            {
                p.BirthDate    = this.BirthDate.Text;
                p.BirthCountry = this.BirthCountry.Text;
                p.BirthCity    = this.BirthCity.Text;
                p.DeathDate    = this.DeathDate.Text;
                p.DeathCountry = this.DeathCountry.Text;
                p.DeathCity    = this.DeathCity.Text;
                p.Comment      = this.Comment.Text;
                p.Sexe         = ((CSLib.CObjectBoxItem)cboSexe.SelectedItem).Value == "M" ? "M" : "F";

                if (cboFather.SelectedItem != null)
                {
                    CPerson Father = (CPerson)((CSLib.CObjectBoxItem)cboFather.SelectedItem).Value;
                    p.FatherGuid = Father.Guid;
                }

                if (cboMother.SelectedItem != null)
                {
                    CPerson Mother = (CPerson)((CSLib.CObjectBoxItem)cboMother.SelectedItem).Value;
                    p.MotherGuid = Mother.Guid;
                }



                p.Save();

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void AddParent(CPerson p)
        {
            CPerson Father = p.Father;

            if (Father != null)
            {
                this.Add(Father, p.X, p.Y - CGraphicObjectCommon.CellHeight);
            }
            CPerson Mother = p.Mother;

            if (Mother != null)
            {
                this.Add(Mother, p.X + p.Label.Width + 1, p.Y - CGraphicObjectCommon.CellHeight);
            }
        }
        public bool CreateUnion(CPerson UnionMember1, CGeneaManager GeneaManager)
        {
            GeneaManager.Persons.FillComboBox(cboMAN, UnionMember1.IsMan() ? UnionMember1.Guid : null);
            GeneaManager.Persons.FillComboBox(cboWoman, UnionMember1.IsMan() ? null : UnionMember1.Guid);

            if (this.ShowDialog() == DialogResult.OK)
            {
                CPerson Man   = (CPerson)((CSLib.CObjectBoxItem)cboMAN.SelectedItem).Value;
                CPerson Woman = (CPerson)((CSLib.CObjectBoxItem)cboWoman.SelectedItem).Value;

                CUnion u = new CUnion();
                u.Create(Man.Guid, Woman.Guid, this.StartDate.Text, this.EndDate.Text);
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool OpenDialog(CPerson P1, CGeneaManager GeneaManager)
        {
            GeneaManager.Persons.FillComboBox(this.cboPerson1, P1.Guid);
            GeneaManager.Persons.FillComboBox(this.cboPerson2, null);
            GeneaManager.FillComboBoxWithRelation(this.cboRelation);

            if (this.ShowDialog() == DialogResult.OK)
            {
                CPerson   p1       = (CPerson)((CSLib.CObjectBoxItem)cboPerson1.SelectedItem).Value;
                CPerson   p2       = (CPerson)((CSLib.CObjectBoxItem)cboPerson2.SelectedItem).Value;
                ERelation Relation = (ERelation)((CSLib.CObjectBoxItem) this.cboRelation.SelectedItem).Value;

                p1.SetRelation(p2, Relation);

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public void Load()
        {
            CSLib.File.CTextFile f = new CSLib.File.CTextFile();

            if (CSLib.File.CTextFile.Exist(FileName))
            {
                string [] PersonsInfo = f.LoadFile(this.FileName).Split(CSLib.CSLibGlobal.CR[0]);

                foreach (string s in PersonsInfo)
                {
                    string [] item = s.Split(',');
                    CPerson   p    = this.GlobalPersons[item[0]];
                    if (p == null)
                    {
                    }
                    else
                    {
                        this.Add(p, CSLib.CSLibGlobal.CInt(item[1]), CSLib.CSLibGlobal.CInt(item[2]));
                    }
                }
            }
        }
        public void FillComboBox(System.Windows.Forms.ComboBox cbo, string strGuid, string strSexe)
        {
            foreach (CPerson p in this)
            {
                bool booAdd = false;

                switch (strSexe)
                {
                case "":
                    booAdd = true;
                    break;

                case "M":
                    booAdd = p.Sexe == "M";
                    break;

                case "F":
                    booAdd = p.Sexe == "F";
                    break;
                }
                if (booAdd)
                {
                    CSLib.CObjectBoxItem i = new CSLib.CObjectBoxItem(p, p.Text);
                    int index = cbo.Items.Add(i);
                }
            }
            for (int i = 0; i < cbo.Items.Count; i++)
            {
                CSLib.CObjectBoxItem it = (CSLib.CObjectBoxItem)cbo.Items[i];
                CPerson p = (CPerson)it.Value;

                if (p.Guid == strGuid)
                {
                    cbo.SelectedIndex = i;
                    return;
                }
            }
        }
        public void ShowUnionRelation(System.Drawing.Graphics g)
        {
            Pen UnionPen = new Pen(Color.Blue, 1);

            foreach (CPerson Man in this.Persons)
            {
                if (Man.IsMan())
                {
                    if (Man.Displayed)
                    {
                        foreach (CUnion u in Man.GetUnions())
                        {
                            CPerson Woman = u.GetTheOther(Man);

                            if (Woman.Displayed)
                            {
                                g.DrawLine(UnionPen, Man.X + Man.Label.Width, Man.Y + (Man.Label.Height / 2), Woman.X, Woman.Y + (Woman.Label.Height / 2));
                            }
                        }
                    }
                }
            }
        }
 public CPerson Add(CPerson p)
 {
     return((CPerson)this.Add(p.Guid.ToUpper(), p));
 }