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;
        }
Example #2
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);
        }
Example #3
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());
        }
Example #4
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);
        }
        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;
                }
            }
        }
        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) ");
        }
            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);
            }
 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);
 }
        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);
             *  }
             * }
             * }*/
        }
        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));
            }
        }