Пример #1
0
        void UpdateData()
        {
            string newText;

            if (individual != null)
            {
                newText = individual.GetName() + "\n" + individual.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + individual.GetDate(IndividualEventClass.EventType.Death).ToString();
                IndividualClass.IndividualSexType sex = individual.GetSex();

                if (sex == IndividualClass.IndividualSexType.Female)
                {
                    this.BackColor = Color.LightPink;
                }
                else if (sex == IndividualClass.IndividualSexType.Male)
                {
                    this.BackColor = Color.LightBlue;
                }
                else if (sex == IndividualClass.IndividualSexType.Unknown)
                {
                    this.BackColor = Color.LightGray;
                }
            }
            else
            {
                newText = xref + " ...";
            }

            this.Text = newText;
            details.SetToolTip(this, CreateToolString());
        }
        void AddItemToListView(AncestorLineInfo ancestor, SanityCheckLimits limits)
        {
            IndividualClass person = familyTree.GetIndividual(ancestor.rootAncestor);

            if (person != null)
            {
                trace.TraceInformation("  " + ancestor.depth + " generations: " + person.GetName() + " " + person.GetDate(IndividualEventClass.EventType.Birth) + " - " + person.GetDate(IndividualEventClass.EventType.Death));

                ListViewItem oldItem = resultList.FindItemWithText(person.GetName());

                if (oldItem != null)
                {
                    if (oldItem.Tag.ToString() == ancestor.rootAncestor)
                    {
                        resultList.Items.Remove(oldItem);
                    }
                }
                string detailString = ancestor.GetDetailString(limits);

                if (detailString.Length > 0)
                {
                    ListViewItem item = new ListViewItem(person.GetName());
                    item.SubItems.AddRange(new string[] { ancestor.depth.ToString(), ancestor.relationPath.GetDistance(), person.GetDate(IndividualEventClass.EventType.Birth).ToString(), person.GetDate(IndividualEventClass.EventType.Death).ToString(), detailString });
                    item.ToolTipText = ancestor.relationPath.ToString(familyTree, false);
                    item.Tag         = person.GetXrefName();

                    resultList.Items.Add(item);
                }
                //list.Items.
            }
            else
            {
                trace.TraceEvent(TraceEventType.Error, 0, " Error could not fetch " + ancestor.rootAncestor + " from tree " + ancestor.depth + " generations " + ancestor.GetDetailString(limits));
            }
        }
Пример #3
0
 void FormatPerson(IndividualClass person, bool html, StreamWriter exportFile)
 {
     if (!html)
     {
         exportFile.Write(UrlsToString(person));
         exportFile.Write("\t");
         exportFile.Write(person.GetName());
         exportFile.Write("\t");
         exportFile.Write(GetEventDateString(person, IndividualEventClass.EventType.Birth));
         exportFile.Write("\t");
         exportFile.Write(GetEventDateString(person, IndividualEventClass.EventType.Death));
         exportFile.Write("\t");
     }
     else
     {
         exportFile.Write("\n<td><a href=\"");
         exportFile.Write(UrlsToString(person));
         exportFile.Write("\">");
         exportFile.Write(person.GetName());
         exportFile.Write(" (");
         exportFile.Write(GetEventDateString(person, IndividualEventClass.EventType.Birth));
         exportFile.Write(" - ");
         exportFile.Write(GetEventDateString(person, IndividualEventClass.EventType.Death));
         exportFile.Write(")</a></td>\n");
     }
 }
Пример #4
0
        public IndividualButton(TreeViewPanel5 parent, IndividualClass individual, Point size, Font font)
        {
            this.parent     = parent;
            this.individual = individual;

            this.Text = individual.GetName();

            this.Font = font;
            if (size.Y > 15)
            {
                this.Text += "\n" + individual.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + individual.GetDate(IndividualEventClass.EventType.Death).ToString();
            }
            TextAlign    = ContentAlignment.MiddleLeft;
            AutoEllipsis = true;
            details      = new ToolTip();
            //details.IsBalloon = true;
            FlatStyle = FlatStyle.Flat;
            //AutoSize = true;
            Anchor = AnchorStyles.Left | AnchorStyles.Top;
            Click += new System.EventHandler(Clicked);
            //BackColor = Color.Beige;
            //Margin = new Padding(-3,-3,-3,-3);

            //details.AutomaticDelay = 10000;
            details.AutoPopDelay = 600000;
            //string toolTip = ;
            details.SetToolTip(this, CreateToolString());
            //details.ToolTipTitle = individual.GetName();
            //details.ToolTipIcon = ToolTipIcon.Info;

            AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
            AutoSize     = false;
            Height       = size.Y;
            Width        = size.X;
        }
Пример #5
0
        void AddPersonToListView(IndividualClass person)
        {
            string birthAddress          = "";
            string deathAddress          = "";
            IndividualEventClass birthEv = person.GetEvent(IndividualEventClass.EventType.Birth);

            if (birthEv != null)
            {
                AddressClass address = birthEv.GetAddress();
                if (address != null)
                {
                    birthAddress = address.ToString();
                }
            }
            IndividualEventClass deathEv = person.GetEvent(IndividualEventClass.EventType.Death);

            if (deathEv != null)
            {
                AddressClass address = deathEv.GetAddress();
                if (address != null)
                {
                    deathAddress = address.ToString();
                }
            }

            ListViewItem item = new ListViewItem(person.GetName());

            item.SubItems.AddRange(new string[] { person.GetDate(IndividualEventClass.EventType.Birth).ToString(), birthAddress, person.GetDate(IndividualEventClass.EventType.Death).ToString(), deathAddress });
            item.Tag = person.GetXrefName();

            resultList.Items.Add(item);
        }
Пример #6
0
        public static void CompareTrees(FamilyTreeStoreBaseClass familyTree1, FamilyTreeStoreBaseClass familyTree2, ReportCompareResult reportDuplicate, ProgressReporterInterface reporter = null)
        {
            IEnumerator <IndividualClass> iterator1;
            int cnt1 = 0;

            iterator1 = familyTree1.SearchPerson(null, reporter);

            trace.TraceInformation("CompareTrees() started");

            if (iterator1 != null)
            {
                do
                {
                    IndividualClass person1 = iterator1.Current;

                    cnt1++;
                    if (person1 != null)
                    {
                        trace.TraceInformation(" 1:" + person1.GetName());
                        SearchDuplicates(person1, familyTree1, familyTree2, reportDuplicate, reporter);
                    }
                } while (iterator1.MoveNext());
                iterator1.Dispose();
            }
            else
            {
                trace.TraceInformation("iter=null");
            }
            trace.TraceInformation("CompareTrees() done");
        }
        public static bool ComparePerson(IndividualClass person1, IndividualClass person2, NameEquivalenceDb nameEqDb)
        {
            if (IsNamesEqual(person1.GetName(), person2.GetName(), nameEqDb))
            {
                IndividualEventClass birth1 = person1.GetEvent(IndividualEventClass.EventType.Birth);
                IndividualEventClass birth2 = person2.GetEvent(IndividualEventClass.EventType.Birth);
                IndividualEventClass death1 = person1.GetEvent(IndividualEventClass.EventType.Death);
                IndividualEventClass death2 = person2.GetEvent(IndividualEventClass.EventType.Death);

                DateMatch birthMatch = DateMatch.Unknown, deathMatch = DateMatch.Unknown;

                if ((birth1 != null) && (birth2 != null))
                {
                    birthMatch = MatchDates(birth1.GetDate(), birth2.GetDate());
                }
                if ((death1 != null) && (death2 != null))
                {
                    deathMatch = MatchDates(death1.GetDate(), death2.GetDate());
                }
                if ((birthMatch == DateMatch.Unknown) && (deathMatch == DateMatch.Unknown))
                {
                    return(false);
                }
                if ((birthMatch == DateMatch.Bad) || (deathMatch == DateMatch.Bad))
                {
                    return(false);
                }
                return((birthMatch == DateMatch.Good) || (deathMatch == DateMatch.Good));
            }
            return(false);
        }
Пример #8
0
 public void SetIndividual(IndividualClass individual)
 {
     m_Individual = individual;
     Text         = m_Individual.GetName();
     trace.TraceInformation("indictrl4: set " + Text);
     this.Width  = 100;
     this.Height = 100;
 }
Пример #9
0
        public IndividualControl4(IndividualClass individual)
        {
            //::InitializeComponent();
            m_Individual = individual;
            Text         = m_Individual.GetName();

            trace.TraceInformation("indictrl: " + Text);
        }
Пример #10
0
        private void IndividualControl3_MouseLeftButtonDown(object sender, MouseEventArgs e)
        {
            if (trace.Switch.Level.HasFlag(SourceLevels.Information))
            {
                if (m_Individual != null)
                {
                    trace.TraceInformation("IndividualControl3_MouseLeftButtonDown():" + m_Individual.GetName());
                }
                else
                {
                    trace.TraceInformation("IndividualControl3_MouseLeftButtonDown():null");
                }
                trace.TraceInformation("IndividualControl3_MouseLeftButtonDown():" + this.ToString() + " " + this.Height);
                trace.TraceInformation("IndividualControl3_MouseLeftButtonDown():this.Parent.ToString:" + this.Parent.ToString());
            }

            if (this.Parent.GetType() == typeof(FamilyForm2))
            {
                FamilyForm2 fForm = (FamilyForm2)this.Parent;
                fForm.SetSelectedIndividual(m_Individual.GetXrefName());
            }
        }
Пример #11
0
        public void SetIndividual(IndividualClass individual)
        {
            m_Individual = individual;

            if (m_Individual != null)
            {
                Text = m_Individual.GetName();
            }
            else
            {
                Text        = "";
                this.Width  = 10;
                this.Height = 10;
            }
            //trace.TraceInformation("indictrl3: set " + Text);
            label1.Text = Text;
        }
Пример #12
0
        public IndividualControl3(IndividualClass individual)
        {
            InitializeComponent();
            m_Individual = individual;
            if (m_Individual != null)
            {
                this.Text = m_Individual.GetName();
            }
            else
            {
                this.Text = "-";
            }

            //trace.TraceInformation("indictrl3: " + Text);
            label1.Text = Text;
            m_Selected  = false;
        }
Пример #13
0
        void StartSearch()
        {
            trace.TraceInformation("ComparePanel1::StartSearch()" + DateTime.Now);
            if (familyTree == null)
            {
                return;
            }

            //parentForm.
            //startButton.Enabled = false;
            //dateButton.Enabled = false;
            resultList.Items.Clear();

            trace.TraceInformation("search:" + searchTextBox.Text + " " + DateTime.Now);

            if (searchTextBox.Text.Length > 0)
            {
                IEnumerator <IndividualClass> iterator;
                searchTextBox.Items.Add(searchTextBox.Text);

                iterator = familyTree.SearchPerson(searchTextBox.Text);

                if (iterator != null)
                {
                    while (iterator.MoveNext())
                    {
                        IndividualClass person = (IndividualClass)iterator.Current;

                        if (person != null)
                        {
                            ListViewItem item = new ListViewItem(person.GetName());
                            item.SubItems.AddRange(new string[] { person.GetDate(IndividualEventClass.EventType.Birth).ToString(), person.GetDate(IndividualEventClass.EventType.Death).ToString() });
                            item.Tag = person.GetXrefName();

                            resultList.Items.Add(item);
                        }
                    }
                }
            }
            trace.TraceInformation(" Database: " + familyTree.GetSourceFileName() + "  " + DateTime.Now);
        }
Пример #14
0
        public IndividualButton(IndividualClass individual, bool selected = false)
        {
            this.individual = individual;

            this.Text = individual.GetName() + "\n" + individual.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + individual.GetDate(IndividualEventClass.EventType.Death).ToString();
            details   = new ToolTip();
            //details.IsBalloon = true;
            FlatStyle     = FlatStyle.Flat;
            AutoSize      = true;
            Anchor        = AnchorStyles.Left | AnchorStyles.Top;
            Click        += new System.EventHandler(Clicked);
            this.MouseUp += IndividualButton_MouseUp;
            //BackColor = Color.Beige;

            //details.AutomaticDelay = 10000;
            details.AutoPopDelay = 600000;
            //string toolTip = ;
            details.SetToolTip(this, CreateToolString());
            //details.ToolTipTitle = individual.GetName();
            //details.ToolTipIcon = ToolTipIcon.Info;
            IndividualClass.IndividualSexType sex = individual.GetSex();

            if (!selected)
            {
                if (sex == IndividualClass.IndividualSexType.Female)
                {
                    this.BackColor = Color.LightPink;
                }
                else if (sex == IndividualClass.IndividualSexType.Male)
                {
                    this.BackColor = Color.LightBlue;
                }
                else if (sex == IndividualClass.IndividualSexType.Unknown)
                {
                    this.BackColor = Color.LightGray;
                }
            }
        }
Пример #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            String searchString = nameSearchTextBox.Text.ToUpper();

            //m_familyTree.SearchPerson("ekman");

            searchResultListBox.Items.Clear();

            if (m_familyTree != null)
            {
                IEnumerator <IndividualClass> iterator;
                iterator = m_familyTree.SearchPerson(searchString);

                trace.TraceInformation("dialog.ok");

                if (iterator != null)
                {
                    while (iterator.MoveNext())
                    {
                        IndividualClass indi = (IndividualClass)iterator.Current;

                        //trace.TraceInformation("iter:[" + indi.GetName() + "]");

                        searchResultListBox.Items.Add(indi.GetName());
                        //indi.Print();
                    }
                }
                else
                {
                    trace.TraceInformation("iter=null");
                }
                trace.TraceInformation("done");
            }

            //this.Close();
        }
Пример #16
0
        private void ShowActiveFamily()
        {
            trace.TraceInformation("TreeViewPanel4::ShowActiveFamily (start) " + this.CanFocus);

            while (controlList.Count > 0)
            {
                Control ctrl = controlList[0];

                this.Controls.Remove(ctrl);
                ctrl.Dispose();

                controlList.RemoveAt(0);

                //ctrl.
            }
            selectedFamily = null;

            if (selectedIndividual != null)
            {
                //int pos = 0;
                System.Drawing.Point position = new Point(0, 0);

                int ctrlHeight = 0;

                {
                    IList <FamilyXrefClass> children = selectedIndividual.GetFamilyChildList();
                    //trace.TraceInformation("GetFamilyChildList");

                    if (children != null)
                    {
                        //trace.TraceInformation("Children.count = " + children.Count);
                        foreach (FamilyXrefClass childXref in children)
                        {
                            FamilyClass childFamily = new FamilyClass();
                            childFamily = familyTree.GetFamily(childXref.GetXrefName());
                            if (childFamily != null)
                            {
                                trace.TraceInformation(" parentFamily:" + childFamily.GetXrefName());

                                if (childFamily != null)
                                {
                                    if (childFamily.GetParentList() != null)
                                    {
                                        foreach (IndividualXrefClass parentXref in childFamily.GetParentList())
                                        {
                                            IndividualClass parent = new IndividualClass();

                                            parent = familyTree.GetIndividual(parentXref.GetXrefName());

                                            if (parent != null)
                                            {
                                                IndividualButton ctrl2 = new IndividualButton();
                                                //int position.Y = 0;

                                                if (ctrlHeight == 0)
                                                {
                                                    Label label = new Label();

                                                    label.Top  = position.Y;
                                                    label.Left = position.X;
                                                    label.Text = "Parents:";

                                                    this.Controls.Add(label);
                                                    controlList.Add(label);

                                                    position.Y += label.Height;
                                                }

                                                ctrl2.AutoSize = true;
                                                ctrl2.Left     = position.X;
                                                ctrl2.Top      = position.Y;
                                                //ctrl.Height = 100;
                                                //ctrl.Width = 400;
                                                ctrl2.Text = parent.GetName() + "\n" + parent.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + parent.GetDate(IndividualEventClass.EventType.Death).ToString();
                                                trace.TraceInformation(" parent: AddControl:" + parent.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " height:" + ctrl2.Height);
                                                ctrl2.FlatStyle  = FlatStyle.Flat;
                                                ctrl2.individual = parent;
                                                ctrl2.SetParent(this);

                                                ctrl2.Click += new System.EventHandler(ctrl2.Clicked);

                                                //ctrl2.Anchor = AnchorStyles.Left | AnchorStyles.Top;

                                                //ctrl.Height = 40;
                                                //ctrl.Width = 40;
                                                //ctrl.Show();

                                                controlList.Add(ctrl2);

                                                this.Controls.Add(ctrl2);

                                                position.X += ctrl2.Width;

                                                ctrlHeight = ctrl2.Height;
                                            }
                                            else
                                            {
                                                trace.TraceEvent(TraceEventType.Error, 0, "Error not a vaild person xref:" + parentXref.GetXrefName());
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                trace.TraceEvent(TraceEventType.Error, 0, "Error not a vaild person xref:" + childXref.GetXrefName());
                            }
                        }
                    }
                }

                if (ctrlHeight != 0)
                {
                    position.X  = 0;
                    position.Y += ctrlHeight;
                    position.Y += 20;

                    ctrlHeight = 0;
                }

                {
                    {
                        Label label = new Label();

                        label.Top  = position.Y;
                        label.Left = position.X;
                        label.Text = "Selected:";

                        this.Controls.Add(label);
                        controlList.Add(label);

                        position.Y += label.Height;
                    }
                    IndividualButton ctrl = new IndividualButton();

                    ctrl.AutoSize = true;
                    ctrl.Left     = position.X;
                    ctrl.Top      = position.Y;
                    //ctrl.Height = 100;
                    //ctrl.Width = 400;
                    ctrl.Text = selectedIndividual.GetName() + "\n" + selectedIndividual.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + selectedIndividual.GetDate(IndividualEventClass.EventType.Death).ToString();

                    ctrl.Anchor    = AnchorStyles.Left | AnchorStyles.Top;
                    ctrl.FlatStyle = FlatStyle.Flat;
                    ctrl.Click    += new System.EventHandler(ctrl.Clicked);
                    ctrl.BackColor = Color.Beige;

                    ctrl.individual = selectedIndividual;
                    ctrl.SetParent(this);

                    trace.TraceInformation(" selected: AddControl:" + selectedIndividual.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl.Top + " Height:" + ctrl.Height);
                    controlList.Add(ctrl);

                    this.Controls.Add(ctrl);

                    position.X += ctrl.Width;

                    ctrlHeight = ctrl.Height;
                }

                /*if (ctrlHeight != 0)
                 * {
                 * position.Y += 20;
                 * ctrlHeight = 0;
                 * }*/

                {
                    IList <FamilyXrefClass> spouseList = selectedIndividual.GetFamilySpouseList();

                    //trace.TraceInformation("GetFamilySpouseList()");
                    if (spouseList != null)
                    {
                        //trace.TraceInformation("spouses.count = " + spouseList.Count);
                        foreach (FamilyXrefClass spouseFamilyXref in spouseList)
                        {
                            FamilyClass spouseFamily = new FamilyClass();
                            spouseFamily = familyTree.GetFamily(spouseFamilyXref.GetXrefName());

                            //trace.TraceInformation("spouses.count s2=" + spouseFamilyXref.GetXrefName());
                            if (spouseFamily != null)
                            {
                                trace.TraceInformation(" spouseFamily:" + spouseFamily.GetXrefName());
                                //trace.TraceInformation("spouses.count s3 = " + spouseFamily);
                                if (selectedFamily == null)
                                {
                                    selectedFamily = spouseFamily;
                                }
                                //trace.TraceInformation("spouses.count s4 = ");
                                if (spouseFamily.GetParentList() != null)
                                {
                                    foreach (IndividualXrefClass spouseXref in spouseFamily.GetParentList())
                                    {
                                        //trace.TraceInformation("spouses.count s5 = ");
                                        if (spouseXref.GetXrefName() != selectedIndividual.GetXrefName())
                                        {
                                            IndividualClass spouse = new IndividualClass();

                                            spouse = familyTree.GetIndividual(spouseXref.GetXrefName());

                                            if (spouse != null)
                                            {
                                                IndividualButton ctrl2 = new IndividualButton();
                                                //int position.Y = 0;

                                                ctrl2.AutoSize = true;
                                                ctrl2.Left     = position.X;
                                                ctrl2.Top      = position.Y;

                                                ctrl2.Text = spouse.GetName() + "\r" + spouse.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + spouse.GetDate(IndividualEventClass.EventType.Death).ToString();

                                                ctrl2.SetParent(this);


                                                ctrl2.FlatStyle  = FlatStyle.Flat;
                                                ctrl2.individual = spouse;
                                                ctrl2.Click     += new System.EventHandler(ctrl2.Clicked);

                                                controlList.Add(ctrl2);

                                                this.Controls.Add(ctrl2);
                                                //ctrl2.PerformLayout();
                                                position.X += ctrl2.Width;
                                                ctrlHeight  = ctrl2.Height;
                                                trace.TraceInformation(" spouse: AddControl:" + spouse.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " Height:" + ctrl2.Height);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                if (ctrlHeight != 0)
                {
                    position.X  = 0;
                    position.Y += ctrlHeight;
                    position.Y += 20;
                    ctrlHeight  = 0;
                }
                if (selectedFamily != null)
                {
                    IList <IndividualXrefClass> childXrefList = selectedFamily.GetChildList();

                    trace.TraceInformation(" childFamily:" + selectedFamily.GetXrefName());
                    if (childXrefList != null)
                    {
                        foreach (IndividualXrefClass childXref in childXrefList)
                        {
                            IndividualClass child = new IndividualClass();

                            child = familyTree.GetIndividual(childXref.GetXrefName());

                            if (child != null)
                            {
                                if (ctrlHeight == 0)
                                {
                                    Label label = new Label();

                                    label.Top  = position.Y;
                                    label.Left = position.X;
                                    label.Text = "Children:";

                                    this.Controls.Add(label);
                                    controlList.Add(label);

                                    position.Y += label.Height;
                                }
                                IndividualButton ctrl2 = new IndividualButton();
                                //int position.Y = 0;

                                ctrl2.AutoSize  = true;
                                ctrl2.Left      = position.X;
                                ctrl2.Top       = position.Y;
                                ctrl2.FlatStyle = FlatStyle.Flat;
                                ctrl2.Click    += new System.EventHandler(ctrl2.Clicked);
                                //ctrl.Height = 100;
                                //ctrl.Width = 400;
                                ctrl2.Text       = child.GetName() + "\n" + child.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + child.GetDate(IndividualEventClass.EventType.Death).ToString();
                                ctrl2.individual = child;
                                ctrl2.SetParent(this);

                                //ctrl2.Anchor = AnchorStyles.Left | AnchorStyles.Top;

                                //ctrl.Height = 40;
                                //ctrl.Width = 40;
                                //ctrl.Show();

                                controlList.Add(ctrl2);

                                this.Controls.Add(ctrl2);

                                trace.TraceInformation(" child: AddControl:" + child.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " Height:" + ctrl2.Height);

                                position.Y += ctrl2.Height;
                                ctrlHeight += ctrl2.Height;
                            }
                        }
                    }
                }
            }
            this.Top  = 0;
            this.Left = 0;

            this.Width  = 600;
            this.Height = 600;


            //this.Show();

            trace.TraceInformation("TreeViewPanel4::ShowActiveFamily (end) ");
        }
Пример #17
0
        private string CreateToolString()
        {
            IndividualEventClass ev;
            FamilyDateTimeClass  date;
            AddressClass         address;
            string str = "";

            str = individual.GetName() + "\n";

            ev = individual.GetEvent(IndividualEventClass.EventType.Birth);

            if (ev != null)
            {
                str += "Born ";

                date = ev.GetDate();

                if (date.GetDateType() != FamilyDateTimeClass.FamilyDateType.Unknown)
                {
                    str += date.ToString();
                }
                address = ev.GetAddress();
                if (address != null)
                {
                    str += " in " + address.ToString();
                }
                else
                {
                    PlaceStructureClass place = ev.GetPlace();

                    if (place != null)
                    {
                        str += " in " + place.ToString();
                    }
                }
            }
            str += "\n";// Environment.NewLine;
            ev   = individual.GetEvent(IndividualEventClass.EventType.Death);

            if (ev != null)
            {
                str += "Died ";

                date = ev.GetDate();

                if (date.GetDateType() != FamilyDateTimeClass.FamilyDateType.Unknown)
                {
                    str += date.ToString();
                }
                address = ev.GetAddress();
                if (address != null)
                {
                    str += " in " + address.ToString();
                }
                else
                {
                    PlaceStructureClass place = ev.GetPlace();

                    if (place != null)
                    {
                        str += " in " + place.ToString();
                    }
                }
            }
            {
                IList <NoteClass> noteList = individual.GetNoteList();

                if (noteList != null)
                {
                    foreach (NoteClass note in noteList)
                    {
                        if (note.note != null)
                        {
                            str += "\n";//Environment.NewLine;
                            str += note.note.Replace("\r\n", "\n").Replace("\n\n", "\n");
                            //trace.TraceInformation("ShowNote:" + note.note);
                        }
                    }
                }
            }

            //str = str.Replace("\r\n", "\n");
            //str = str.Replace("\n\r", "\n");
            return(str);
        }
        public static void SearchDuplicates(IndividualClass person1, IFamilyTreeStoreBaseClass familyTree1, IFamilyTreeStoreBaseClass familyTree2, ReportCompareResult reportDuplicate, IProgressReporterInterface reporter = null, NameEquivalenceDb nameEqDb = null)
        {
            IndividualEventClass birth = person1.GetEvent(IndividualEventClass.EventType.Birth);
            IndividualEventClass death = person1.GetEvent(IndividualEventClass.EventType.Death);

            if (reporter != null)
            {
                trace.TraceInformation(reporter.ToString());
            }
            if (((birth != null) && (birth.GetDate() != null) && (birth.GetDate().ValidDate())) ||
                ((death != null) && (death.GetDate() != null) && (death.GetDate().ValidDate())))
            {
                string searchString;

                if (familyTree2.GetCapabilities().jsonSearch)
                {
                    searchString = SearchDescriptor.ToJson(SearchDescriptor.GetSearchDescriptor(person1));
                }
                else
                {
                    searchString = person1.GetName().Replace("*", "");
                }

                IEnumerator <IndividualClass> iterator2 = familyTree2.SearchPerson(searchString);
                int cnt2 = 0;

                if (iterator2 != null)
                {
                    int cnt3 = 0;
                    do
                    {
                        IndividualClass person2 = iterator2.Current;

                        if (person2 != null)
                        {
                            cnt3++;
                            //trace.TraceInformation(reporter.ToString() + "   2:" + person2.GetName());
                            if ((familyTree1 != familyTree2) || (person1.GetXrefName() != person2.GetXrefName()))
                            {
                                if (ComparePerson(person1, person2, nameEqDb))
                                {
                                    trace.TraceData(TraceEventType.Information, 0, "   2:" + person2.GetName() + " " + person1.GetXrefName() + " " + person2.GetXrefName());
                                    reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName());
                                }
                                cnt2++;
                            }
                        }
                    } while (iterator2.MoveNext());

                    iterator2.Dispose();
                    trace.TraceInformation(" " + searchString + " matched with " + cnt2 + "," + cnt3);
                }

                if (cnt2 == 0) // No matches found for full name
                {
                    if ((person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname).Length > 0) &&
                        (person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname).Length > 0) &&
                        !person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname).Equals(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname)))
                    {
                        String strippedName = person1.GetName().Replace("*", "");

                        if (strippedName.Contains(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname)))
                        {
                            String maidenName = strippedName.Replace(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.Surname), "").Replace("  ", " ");
                            IEnumerator <IndividualClass> iterator3 = familyTree2.SearchPerson(maidenName);
                            //trace.TraceInformation(" Searching Maiden name " + maidenName);

                            if (iterator3 != null)
                            {
                                int cnt3 = 0;
                                do
                                {
                                    IndividualClass person2 = iterator3.Current;

                                    if (person2 != null)
                                    {
                                        if ((familyTree1 != familyTree2) || (person1.GetXrefName() != person2.GetXrefName()))
                                        {
                                            cnt3++;
                                            if (ComparePerson(person1, person2, nameEqDb))
                                            {
                                                trace.TraceData(TraceEventType.Information, 0, "   2b:" + person2.GetName());
                                                reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName());
                                            }
                                        }
                                    }
                                } while (iterator3.MoveNext());
                                iterator3.Dispose();
                                trace.TraceInformation(" Maiden name " + maidenName + " mathched with " + cnt3);
                            }
                        }
                        if (strippedName.Contains(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname)))
                        {
                            String marriedName = strippedName.Replace(person1.GetPersonalName().GetName(PersonalNameClass.PartialNameType.BirthSurname), "").Replace("  ", " ");
                            IEnumerator <IndividualClass> iterator3 = familyTree2.SearchPerson(marriedName);

                            //trace.TraceInformation(" Searching Married name " + marriedName);
                            if (iterator3 != null)
                            {
                                int cnt3 = 0;
                                do
                                {
                                    //IndividualClass person1 = iterator1.Current;
                                    IndividualClass person2 = iterator3.Current;

                                    if (person2 != null)
                                    {
                                        //trace.TraceInformation(reporter.ToString() + "   2:" + person2.GetName());
                                        if ((familyTree1 != familyTree2) || (person1.GetXrefName() != person2.GetXrefName()))
                                        {
                                            cnt3++;
                                            if (ComparePerson(person1, person2, nameEqDb))
                                            {
                                                trace.TraceData(TraceEventType.Information, 0, "   2c:" + person2.GetName());
                                                reportDuplicate(familyTree1, person1.GetXrefName(), familyTree2, person2.GetXrefName());
                                            }
                                        }
                                    }
                                } while (iterator3.MoveNext());
                                iterator3.Dispose();
                                trace.TraceInformation(" Married name " + marriedName + " matched to " + cnt3);
                            }
                        }
                    }
                }
            }
            else
            {
                trace.TraceData(TraceEventType.Information, 0, "No valid birth or death date for " + person1.GetName().ToString() + " skip duplicate search");
            }
        }
        public static void CompareTrees(IFamilyTreeStoreBaseClass familyTree1, IFamilyTreeStoreBaseClass familyTree2, ReportCompareResult reportDuplicate, IProgressReporterInterface reporter = null)
        {
            IEnumerator <IndividualClass> iterator1;
            int cnt1 = 0;

            NameEquivalenceDb equivDb = NameEquivalenceDb.LoadFile(NameEquivalenceDb.GetDefaultFilePath());

            if (equivDb == null)
            {
                equivDb = new DefaultNameEquivalenceDb();
                equivDb.LoadDefault();
                bool result = NameEquivalenceDb.SaveFile(NameEquivalenceDb.GetDefaultFilePath(), equivDb);
                if (!result)
                {
                    trace.TraceData(TraceEventType.Warning, 0, "File db write failed");
                }
                else
                {
                    trace.TraceData(TraceEventType.Information, 0, "File db write ok");
                }
            }

            iterator1 = familyTree1.SearchPerson(null, reporter);

            trace.TraceData(TraceEventType.Information, 0, "CompareTrees() started");

            if (iterator1 != null)
            {
                do
                {
                    IndividualClass person1 = iterator1.Current;

                    cnt1++;
                    if (person1 != null)
                    {
                        trace.TraceData(TraceEventType.Information, 0, " 1:" + cnt1 + " " + person1.GetName());
                        SearchDuplicates(person1, familyTree1, familyTree2, reportDuplicate, reporter, equivDb);
                    }
                    else
                    {
                        trace.TraceData(TraceEventType.Warning, 0, " 1: person is null" + cnt1);
                    }
                } while (iterator1.MoveNext());
                iterator1.Dispose();
            }
            else
            {
                trace.TraceInformation("iter=null");
            }
            trace.TraceInformation("CompareTrees() done");
        }
Пример #20
0
 void CheckF2iReferences(ref IndividualClass individual)
 {
     if (parentsF2iReference.ContainsKey(individual.GetXrefName()))
     {
         IList <string> spouses = parentsF2iReference[individual.GetXrefName()];
         if (spouses.Count > individual.GetFamilySpouseList().Count)
         {
             trace.TraceData(TraceEventType.Verbose, 0, individual.GetXrefName() + " missing spouse to individual " + spouses.Count + " > " + individual.GetFamilySpouseList().Count);
             foreach (string parent in spouses)
             {
                 individual.AddRelation(new FamilyXrefClass(parent), IndividualClass.RelationType.Spouse);
                 trace.TraceData(TraceEventType.Verbose, 0, individual.GetXrefName() + " adding spouse-family to individual " + parent + " to " + individual.GetName());
             }
         }
     }
     if (childrenI2fReference.ContainsKey(individual.GetXrefName()))
     {
         IList <string> children = childrenI2fReference[individual.GetXrefName()];
         if (children.Count > individual.GetFamilyChildList().Count)
         {
             trace.TraceData(TraceEventType.Verbose, 0, individual.GetXrefName() + " missing child-family in individual " + children.Count + " > " + individual.GetFamilyChildList().Count);
             foreach (string child in children)
             {
                 individual.AddRelation(new FamilyXrefClass(child), IndividualClass.RelationType.Child);
                 trace.TraceData(TraceEventType.Verbose, 0, individual.GetXrefName() + " adding child-family to individual " + child + " to " + individual.GetName());
             }
         }
     }
 }
Пример #21
0
        public void AddIndividual(IndividualClass individual)
        {
            if (individual == null)
            {
                trace.TraceData(TraceEventType.Error, 0, "GeniCache: Trying to add individual == null");
            }
            else if (individual.GetXrefName().Length == 0)
            {
                trace.TraceEvent(TraceEventType.Error, 0, "GeniCache:AddIndividual():error: no xref!");
            }
            else
            {
                bool relations = false;
                trace.TraceInformation("cached individual " + individual.GetXrefName());

                if (individual.GetFamilyChildList() != null)
                {
                    if (individual.GetFamilyChildList().Count > 0)
                    {
                        relations = true;
                    }
                }
                if (individual.GetFamilySpouseList() != null)
                {
                    if (individual.GetFamilySpouseList().Count > 0)
                    {
                        relations = true;
                    }
                }
                if (!relations)
                {
                    if (individual.GetPublic())
                    {
                        string         url  = "";
                        IList <string> urls = individual.GetUrlList();
                        if (urls.Count > 0)
                        {
                            url = urls[0];
                        }
                        trace.TraceData(TraceEventType.Information, 0, "Person has no relations! " + individual.GetXrefName() + " " + url + " " + individual.GetName());
                    }
                    CheckF2iReferences(ref individual);
                }
                CacheIndividual(individual);
                latestUpdate = DateTime.Now;
            }
        }
        public void AddToListView(ref ListView list, AncestorStatistics stats)
        {
            bool disableCounter = true;

            {
                resultList.Items.Clear();
                if (stats != null)
                {
                    IEnumerable <AncestorLineInfo> query = stats.GetAncestorList().OrderBy(ancestor => ancestor.depth);

                    //SanityCheckLimits limits = GetSanitySettings(utility.GetCurrentDirectory() + "\\SanitySettings.fssan");
                    foreach (AncestorLineInfo root in query)
                    {
                        AddItemToListView(root, limits);
                    }
                }
            }

            if (!disableCounter)
            {
                IEnumerable <HandledItem> query = stats.GetAnalysedPeopleNo().OrderByDescending(ancestor => ancestor.number);

                foreach (HandledItem item in query)
                {
                    if (item.number > 1)
                    {
                        IndividualClass person = familyTree.GetIndividual(item.xref);
                        if (person != null)
                        {
                            trace.TraceInformation("  Referenced " + item.number + " times: " + person.GetName() + " " + person.GetDate(IndividualEventClass.EventType.Birth) + " - " + person.GetDate(IndividualEventClass.EventType.Death) + " " + item.relationStackList.Count);
                            //list.Add(new ListedPerson("  Multiply Referenced " + item.number + " times: " + person.GetName() + " " + person.GetDate(IndividualEventClass.EventType.Birth) + " - " + person.GetDate(IndividualEventClass.EventType.Death), person.GetXrefName()));
                            ListViewItem lvItem = new ListViewItem(person.GetName());
                            lvItem.SubItems.AddRange(new string[] { "X:" + item.number, person.GetDate(IndividualEventClass.EventType.Birth).ToString(), person.GetDate(IndividualEventClass.EventType.Death).ToString(), "referenced " + item.number + " times" });
                            lvItem.Tag         = person.GetXrefName();
                            lvItem.ToolTipText = "";
                            foreach (RelationStack stack in item.relationStackList)
                            {
                                if (stack != null)
                                {
                                    lvItem.ToolTipText += stack.ToString(familyTree, false);
                                    lvItem.ToolTipText += "\n";
                                    trace.TraceInformation(stack.ToString(familyTree, false));
                                }
                            }


                            list.Items.Add(lvItem);
                        }
                        else
                        {
                            trace.TraceInformation("  Person == null:" + item);
                        }
                    }
                }
            }

            /*{
             * foreach (HandledItem item in analysedFamiliesNo)
             * {
             *  if (item.number > 1)
             *  {
             *    trace.TraceInformation("Duplicate family " + item.number + " " + item.xref);
             *  }
             * }
             * }*/
        }
        public IndividualClass GetIndividual(String xrefName, uint index = (uint)SelectIndex.NoIndex, PersonDetail detailLevel = PersonDetail.PersonDetail_All)
        {
            if (xrefName == null)
            {
                trace.TraceInformation("GetIndividual(root)");
                rootPersonXref = FetchRootPerson();
                xrefName       = rootPersonXref;
            }
            if (xrefName == null)
            {
                trace.TraceInformation("GetIndividual(null)!!!" + DateTime.Now);
                return(null);
            }

            if (cache.individuals.ContainsKey(xrefName))
            {
                if (printDecode)
                {
                    trace.TraceInformation("GetIndividual(" + xrefName + ") cached");
                }
                return(cache.individuals[xrefName]);
            }
            if (printDecode)
            {
                trace.TraceInformation("GetIndividual(" + xrefName + ") start " + DateTime.Now);
            }

            if (!authenticated)
            {
                Authenticate();
                GetTreeStats();
            }

            string sLine = null;;

            try
            {
                string sURL = "https://www.geni.com/api/profile-" + xrefName + "/immediate-family?only_ids=true&fields=first_name,middle_name,nicknames,last_name,maiden_name,gender,birth,death,id";

                WebRequest wrGETURL;
                wrGETURL = WebRequest.Create(sURL);
                if (authenticationToken != null)
                {
                    wrGETURL.Headers.Add("Authorization", String.Format("Bearer {0}", Uri.EscapeDataString(authenticationToken)));
                }
                if (printDecode)
                {
                    trace.TraceInformation("GetIndividual(" + xrefName + ") = " + sURL + " " + DateTime.Now);
                }
                Stream objStream = wrGETURL.GetResponse().GetResponseStream();

                StreamReader objReader = new StreamReader(objStream);

                sLine = objReader.ReadToEnd();
            }
            catch
            {
                return(null);
            }

            if (sLine != null)
            {
                IndividualClass focusPerson;

                if (printDecode)
                {
                    trace.TraceInformation("**********************************************************-start");
                    trace.TraceInformation("{0}:{1}", sLine.Length, sLine);
                    trace.TraceInformation("**********************************************************-end");
                }
                if ((sLine.StartsWith("<!DOCTYPE") || sLine.StartsWith("<HTML") || sLine.StartsWith("<html")))
                {
                    trace.TraceInformation("Bad format. Don't parse.");
                    trace.TraceInformation("**********************************************************-start");
                    trace.TraceInformation("{0}:{1}", sLine.Length, sLine);
                    trace.TraceInformation("**********************************************************-end");
                    return(null);
                }

                getIndividualResult = serializer.Deserialize <HttpGetIndividualResult>(sLine);

                if (getIndividualResult.focus != null)
                {
                    focusPerson = DecodeIndividual(getIndividualResult.focus);

                    if (focusPerson != null)
                    {
                        if (!UpdateRelations(getIndividualResult.nodes, ref focusPerson))
                        {
                            if (printDecode)
                            {
                                trace.TraceInformation("focusperson added " + focusPerson.GetXrefName() + " no relation updates..");
                            }
                        }
                        cache.individuals.Add(focusPerson.GetXrefName(), focusPerson);
                    }

                    foreach (KeyValuePair <string, HttpPerson> nodePersonPair in getIndividualResult.nodes)
                    {
                        if (nodePersonPair.Key.IndexOf("profile-") == 0)
                        {
                            if (!cache.individuals.ContainsKey(nodePersonPair.Key.Substring(8)))
                            {
                                if (nodePersonPair.Value != null)
                                {
                                    HttpPerson nodePerson = (HttpPerson)nodePersonPair.Value;

                                    IndividualClass nodeIndividual = DecodeIndividual(nodePerson);

                                    if (nodeIndividual != null)
                                    {
                                        if (printDecode)
                                        {
                                            trace.TraceInformation(" Cache person:" + nodePersonPair.Key.Substring(8) + "=" + nodeIndividual.GetName());
                                        }
                                        if (!UpdateRelations(getIndividualResult.nodes, ref nodeIndividual))
                                        {
                                            trace.TraceInformation(" Added " + nodeIndividual.GetXrefName() + " no relation updates..");
                                        }

                                        /*if (printDecode)
                                         * {
                                         * nodeIndividual.Print();
                                         * }*/
                                        cache.individuals.Add(nodeIndividual.GetXrefName(), nodeIndividual);
                                    }
                                }
                            }
                            else
                            {
                                if (printDecode)
                                {
                                    trace.TraceInformation(" Person " + nodePersonPair.Key.Substring(8) + " skipped, already cached");
                                }
                            }
                        }
                    }

                    if (printDecode)
                    {
                        trace.TraceInformation("GetIndividual() done " + DateTime.Now);
                    }
                    return(focusPerson);
                }
            }

            return(null);
        }
Пример #24
0
            ListViewItem CreateListItem(FamilyTreeStoreBaseClass familyTree1, IndividualClass person1, FamilyTreeStoreBaseClass familyTree2, IndividualClass person2)
            {
                ListViewItem item = new ListViewItem(person1.GetName());

                FamilyStatusClass.IndividualStatus status1 = FamilyStatusClass.CheckCorrectness(familyTree1, person1);
                FamilyStatusClass.IndividualStatus status2 = FamilyStatusClass.CheckCorrectness(familyTree2, person2);
                string str1 = GetShortFacts(status1);
                string str2 = GetShortFacts(status2);

                item.SubItems.AddRange(new string[] { person1.GetDate(IndividualEventClass.EventType.Birth).ToString(), person1.GetDate(IndividualEventClass.EventType.Death).ToString(), str1, person2.GetName(), person2.GetDate(IndividualEventClass.EventType.Birth).ToString(), person2.GetDate(IndividualEventClass.EventType.Death).ToString(), str2 });

                trace.TraceInformation("match1:" + GetPersonString(person1, str1));
                trace.TraceInformation("match2:" + GetPersonString(person2, str2));

                item.UseItemStyleForSubItems = false;
                if (!person1.GetDate(IndividualEventClass.EventType.Birth).ToString().Equals(person2.GetDate(IndividualEventClass.EventType.Birth).ToString()))
                {
                    //string checkChar = "Good birth";
                    int idx1 = 1;
                    int idx2 = 5;
                    if (status1.birthCorrectness == FamilyStatusClass.EventCorrectness.Perfect && status2.birthCorrectness != FamilyStatusClass.EventCorrectness.Perfect)
                    {
                        item.SubItems[idx1].BackColor = Color.LightGreen;
                        item.SubItems[idx2].BackColor = Color.LightSalmon;
                    }
                    else if (status1.birthCorrectness != FamilyStatusClass.EventCorrectness.Perfect && status2.birthCorrectness == FamilyStatusClass.EventCorrectness.Perfect)
                    {
                        item.SubItems[idx1].BackColor = Color.LightSalmon;
                        item.SubItems[idx2].BackColor = Color.LightGreen;
                    }
                    else
                    {
                        item.SubItems[idx1].BackColor = Color.Yellow;
                        item.SubItems[idx2].BackColor = Color.Yellow;
                    }
                }
                if (!person1.GetDate(IndividualEventClass.EventType.Death).ToString().Equals(person2.GetDate(IndividualEventClass.EventType.Death).ToString()))
                {
                    int idx1 = 2;
                    int idx2 = 6;
                    if (status1.deathCorrectness == FamilyStatusClass.EventCorrectness.Perfect && status2.deathCorrectness != FamilyStatusClass.EventCorrectness.Perfect)
                    {
                        item.SubItems[idx1].BackColor = Color.LightGreen;
                        item.SubItems[idx2].BackColor = Color.LightSalmon;
                    }
                    else if (status1.deathCorrectness != FamilyStatusClass.EventCorrectness.Perfect && status2.deathCorrectness == FamilyStatusClass.EventCorrectness.Perfect)
                    {
                        item.SubItems[idx1].BackColor = Color.LightSalmon;
                        item.SubItems[idx2].BackColor = Color.LightGreen;
                    }
                    else
                    {
                        item.SubItems[idx1].BackColor = Color.Yellow;
                        item.SubItems[idx2].BackColor = Color.Yellow;
                    }
                }
                if (!str1.Equals(str2))
                {
                    item.SubItems[3].BackColor = Color.Yellow;
                    item.SubItems[7].BackColor = Color.Yellow;
                    //item.GetSubItemAt(2, 0).BackColor = Color.Blue;
                    //item.GetSubItemAt(5, 0).BackColor = Color.Brown;
                }


                //item.Tag = person1.GetXrefName();
                item.Tag = new DuplicateTreeItems(person1.GetXrefName(), person2.GetXrefName());

                //matchListView1.Items.Add(item);
                return(item);
            }
Пример #25
0
        private void ShowActiveFamily()
        {
            trace.TraceInformation("TreeViewPanel2::ShowActiveFamily (start) " + this.CanFocus);

            while (controlList.Count > 0)
            {
                Control ctrl = controlList[0];

                this.Controls.Remove(ctrl);
                ctrl.Dispose();

                controlList.RemoveAt(0);
            }

            if (selectedIndividual != null)
            {
                Point position = new Point(0, 0);

                int ctrlHeight = 0;
                IDictionary <string, Point> familyPosition = new Dictionary <string, Point>();

                {
                    IList <FamilyXrefClass> children = selectedIndividual.GetFamilyChildList();

                    if (children != null)
                    {
                        trace.TraceInformation(" selected->parentFamilies.count = " + children.Count);
                        foreach (FamilyXrefClass childXref in children)
                        {
                            FamilyClass childFamily = new FamilyClass();
                            childFamily = familyTree.GetFamily(childXref.GetXrefName());

                            if (childFamily != null)
                            {
                                trace.TraceInformation(" selected->parentFamily:" + childFamily.GetXrefName());
                                if (childFamily.GetParentList() != null)
                                {
                                    foreach (IndividualXrefClass parentXref in childFamily.GetParentList())
                                    {
                                        IndividualClass parent = new IndividualClass();

                                        parent = familyTree.GetIndividual(parentXref.GetXrefName());

                                        if (parent != null)
                                        {
                                            IndividualButton ctrl2 = new IndividualButton(parent);

                                            if (ctrlHeight == 0)
                                            {
                                                Label label = new Label();

                                                label.Top  = position.Y;
                                                label.Left = position.X;
                                                label.Text = "Parents:";

                                                this.Controls.Add(label);
                                                controlList.Add(label);

                                                position.Y += label.Height;
                                            }

                                            //ctrl2.AutoSize = true;
                                            ctrl2.Left = position.X;
                                            ctrl2.Top  = position.Y;
                                            //ctrl2.Text = parent.GetName() + "\n" + parent.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + parent.GetDate(IndividualEventClass.EventType.Death).ToString();
                                            trace.TraceInformation(" parent: AddControl:" + parent.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " height:" + ctrl2.Height);
                                            //ctrl2.FlatStyle = FlatStyle.Flat;
                                            //ctrl2.individual = parent;
                                            ctrl2.SetParent(this);

                                            //ctrl2.Click += new System.EventHandler(ctrl2.Clicked);
                                            //ctrl2.MouseEnter += MouseEntered;
                                            //ctrl2.MouseLeave += MouseLeft;

                                            controlList.Add(ctrl2);

                                            this.Controls.Add(ctrl2);

                                            position.X += ctrl2.Width + 10;

                                            ctrlHeight = ctrl2.Height;
                                        }
                                        else
                                        {
                                            trace.TraceInformation("Error not a vaild person xref:" + parentXref.GetXrefName());
                                        }
                                    }
                                }
                            }
                            else
                            {
                                trace.TraceInformation("Error not a vaild person xref:" + childXref.GetXrefName());
                            }
                        }
                    }
                    else
                    {
                        trace.TraceInformation("selected->Children null ");
                    }
                }

                if (ctrlHeight != 0)
                {
                    position.X  = 0;
                    position.Y += ctrlHeight;
                    //position.Y += 20;

                    ctrlHeight = 0;
                }

                {
                    {
                        Label label = new Label();

                        label.Top  = position.Y;
                        label.Left = position.X;
                        label.Text = "Selected:";

                        this.Controls.Add(label);
                        controlList.Add(label);

                        position.Y += label.Height;
                    }
                    IndividualButton ctrl = new IndividualButton(selectedIndividual, true);

                    //ctrl.AutoSize = true;
                    ctrl.Left = position.X;
                    ctrl.Top  = position.Y;

                    //ctrl.Text = selectedIndividual.GetName() + "\n" + selectedIndividual.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + selectedIndividual.GetDate(IndividualEventClass.EventType.Death).ToString();

                    //ctrl.Anchor = AnchorStyles.Left | AnchorStyles.Top;
                    //ctrl.FlatStyle = FlatStyle.Flat;
                    //ctrl.Click += new System.EventHandler(ctrl.Clicked);
                    //ctrl.MouseEnter += new System.EventHandler(MouseEntered);
                    //ctrl.MouseLeave += new System.EventHandler(MouseLeft);
                    //ctrl.BackColor = Color.Beige;

                    //ctrl.individual = selectedIndividual;
                    ctrl.SetParent(this);

                    trace.TraceInformation(" selected: AddControl:" + selectedIndividual.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl.Top + " Height:" + ctrl.Height);
                    controlList.Add(ctrl);

                    this.Controls.Add(ctrl);

                    position.X += ctrl.Width + 10;

                    ctrlHeight = ctrl.Height;
                }

                {
                    IList <FamilyXrefClass> spouseList = selectedIndividual.GetFamilySpouseList();

                    if (spouseList != null)
                    {
                        trace.TraceInformation(" selected->spouseFamily->count:" + spouseList.Count);
                        foreach (FamilyXrefClass spouseFamilyXref in spouseList)
                        {
                            FamilyClass spouseFamily = new FamilyClass();
                            spouseFamily = familyTree.GetFamily(spouseFamilyXref.GetXrefName());

                            if (spouseFamily != null)
                            {
                                trace.TraceInformation(" selected->spouseFamily:" + spouseFamily.GetXrefName());
                                if (!familyPosition.ContainsKey(spouseFamily.GetXrefName()))
                                {
                                    Point famPos = new Point(position.X - 20, position.Y + ctrlHeight);
                                    familyPosition.Add(spouseFamilyXref.GetXrefName(), famPos);
                                    trace.TraceInformation(" selected->spouseFamily Add:" + famPos.X + "," + famPos.Y);
                                }
                                IList <IndividualXrefClass> spouseParentList = spouseFamily.GetParentList();

                                if (spouseParentList != null)
                                {
                                    foreach (IndividualXrefClass spouseXref in spouseParentList)
                                    {
                                        if (spouseXref.GetXrefName() != selectedIndividual.GetXrefName())
                                        {
                                            IndividualClass spouse = new IndividualClass();

                                            spouse = familyTree.GetIndividual(spouseXref.GetXrefName());

                                            if (spouse != null)
                                            {
                                                IndividualButton ctrl2 = new IndividualButton(spouse);
                                                //int position.Y = 0;

                                                //ctrl2.AutoSize = true;
                                                ctrl2.Left = position.X;
                                                ctrl2.Top  = position.Y;

                                                //ctrl2.Text = spouse.GetName() + "\r" + spouse.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + spouse.GetDate(IndividualEventClass.EventType.Death).ToString();

                                                ctrl2.SetParent(this);

                                                //ctrl2.FlatStyle = FlatStyle.Flat;
                                                //ctrl2.individual = spouse;
                                                //ctrl2.Click += new System.EventHandler(ctrl2.Clicked);
                                                //ctrl2.MouseEnter += MouseEntered;
                                                //ctrl2.MouseLeave += MouseLeft;

                                                controlList.Add(ctrl2);

                                                this.Controls.Add(ctrl2);

                                                position.X += ctrl2.Width + 10;
                                                ctrlHeight  = ctrl2.Height;
                                                trace.TraceInformation(" spouse: AddControl:" + spouse.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " Height:" + ctrl2.Height);
                                            }
                                            else
                                            {
                                                trace.TraceEvent(TraceEventType.Error, 0, "Error not a vaild person xref:" + spouseXref.GetXrefName());
                                            }
                                        }
                                    }
                                }
                            }
                            else
                            {
                                trace.TraceEvent(TraceEventType.Error, 0, "Error not a vaild family xref:" + spouseFamilyXref.GetXrefName());
                            }
                        }
                        if (spouseList != null)
                        {
                            foreach (FamilyXrefClass family in spouseList)
                            {
                                FamilyClass familyObject = familyTree.GetFamily(family.GetXrefName());

                                if (familyObject != null)
                                {
                                    IList <IndividualXrefClass> childXrefList = familyTree.GetFamily(family.GetXrefName()).GetChildList();

                                    if (childXrefList != null)
                                    {
                                        trace.TraceInformation(" selectedFamily->childFamily:" + family.GetXrefName() + " children.count:" + childXrefList.Count);
                                        {
                                            Label label = new Label();

                                            Point childPosition = familyPosition[family.GetXrefName()];

                                            label.Top      = childPosition.Y;
                                            label.Left     = childPosition.X;
                                            label.Text     = "Children:" + childXrefList.Count;
                                            label.AutoSize = true;

                                            this.Controls.Add(label);
                                            controlList.Add(label);

                                            childPosition.Y += label.Height;
                                            familyPosition[family.GetXrefName()] = childPosition;
                                        }
                                        foreach (IndividualXrefClass childXref in childXrefList)
                                        {
                                            IndividualClass child = new IndividualClass();

                                            child = familyTree.GetIndividual(childXref.GetXrefName());

                                            if (child != null)
                                            {
                                                IndividualButton ctrl2 = new IndividualButton(child);

                                                ctrl2.AutoSize = true;
                                                Point childPosition = familyPosition[family.GetXrefName()];
                                                ctrl2.Left      = childPosition.X;
                                                ctrl2.Top       = childPosition.Y;
                                                ctrl2.FlatStyle = FlatStyle.Flat;
                                                ctrl2.Click    += new System.EventHandler(ctrl2.Clicked);
                                                //ctrl2.MouseEnter += MouseEntered;
                                                //ctrl2.MouseLeave += MouseLeft;

                                                //ctrl2.Text = child.GetName() + "\n" + child.GetDate(IndividualEventClass.EventType.Birth).ToString() + " - " + child.GetDate(IndividualEventClass.EventType.Death).ToString();
                                                ctrl2.individual = child;
                                                ctrl2.SetParent(this);

                                                controlList.Add(ctrl2);

                                                this.Controls.Add(ctrl2);

                                                trace.TraceInformation(" child: AddControl:" + child.GetName() + " X:" + position.X + " Y:" + position.Y + " Top:" + ctrl2.Top + " Height:" + ctrl2.Height);

                                                childPosition.Y += ctrl2.Height;
                                                familyPosition[family.GetXrefName()] = childPosition;
                                                ctrlHeight += ctrl2.Height;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        trace.TraceInformation(" selectedFamily->childFamily:" + family.GetXrefName() + " children null");
                                    }
                                }
                                else
                                {
                                    trace.TraceInformation(" selectedFamily:" + family.GetXrefName() + " null");
                                }
                            }
                        }
                    }
                    else
                    {
                        trace.TraceInformation(" selected->spouseFamily null");
                    }
                }
            }
            this.Top  = 0;
            this.Left = 0;

            this.Width  = 600;
            this.Height = 600;


            //this.Show();
            trace.TraceInformation("TreeViewPanel2::ShowActiveFamily (end) ");
        }
Пример #26
0
 private string GetPersonString(IndividualClass person, string str)
 {
     return(person.GetName() + ",b:" + person.GetDate(IndividualEventClass.EventType.Birth).ToString() + ",d:" + person.GetDate(IndividualEventClass.EventType.Death).ToString() + ",f:" + str);
 }