예제 #1
0
        private void Search()
        {
            if (!string.IsNullOrEmpty(searchTextBox.Text) && this.file != null)
            {
                bool             found      = false;
                GedcomIndividual individual = this.file.Individuals.Where(p => p.Name.ToString().Contains(searchTextBox.Text)).FirstOrDefault();
                if (individual != null)
                {
                    foreach (TreeNode node in familyTreeView.Nodes)
                    {
                        if (RecursiveSearch(node, individual))
                        {
                            found = true;
                            break;
                        }
                    }
                }

                if (!found)
                {
                    MessageBox.Show(string.Concat("Der Suchbegriff '", searchTextBox.Text, "' wurde nicht gefunden"), "Suche", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                familyTreeView.Focus();
            }
        }
예제 #2
0
        private void GenerateAncestorList(string individualId, string spouseId, string childId, int depth)
        {
            if (ancestors.ContainsKey(individualId))
            {
                IncrementAppearance(individualId, childId, depth);
            }
            else
            {
                AncestorIndividual individual       = new AncestorIndividual(individualId);
                GedcomIndividual   gedcomIndividual = gedcomIndividuals[individualId];

                individual.GivenName         = gedcomIndividual.GivenName.Trim();
                individual.Surname           = gedcomIndividual.Surname.Trim();
                individual.Prefix            = gedcomIndividual.Prefix.Trim();
                individual.Suffix            = gedcomIndividual.Suffix.Trim();
                individual.Sex               = gedcomIndividual.Sex.Trim();
                individual.BirthDate         = gedcomIndividual.BirthDate.Trim();
                individual.DiedDate          = gedcomIndividual.DiedDate.Trim();
                individual.AppearanceCount   = 1;
                individual.LowestGeneration  = depth;
                individual.HighestGeneration = depth;

                if (!string.IsNullOrEmpty(childId))
                {
                    individual.ChildrenIds.Add(childId);
                }

                GedcomFamily?gedcomFamily = gedcomFamilies.FirstOrDefault(x => x.Value.Children.Contains(individualId)).Value;
                if (gedcomFamily != null)
                {
                    individual.FatherId = gedcomFamily.Value.HusbandId;
                    individual.MotherId = gedcomFamily.Value.WifeId;
                }
                individual.SpouseId = spouseId;

                ancestors.Add(individualId, individual);
                if (depth <= MaxDepth)
                {
                    if (!string.IsNullOrEmpty(individual.FatherId))
                    {
                        GenerateAncestorList(individual.FatherId, individual.MotherId, individualId, depth + 1);
                    }

                    if (!string.IsNullOrEmpty(individual.MotherId))
                    {
                        GenerateAncestorList(individual.MotherId, individual.FatherId, individualId, depth + 1);
                    }
                }
            }
        }
예제 #3
0
        private void familyTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Tag != null)
            {
                GedcomIndividual individual = (GedcomIndividual)e.Node.Tag;

                detailView.Items.Clear();

                detailView.Items.Add(new ListViewItem(new string[] { "Name", individual.Name.ToString() }));
                detailView.Items.Add(new ListViewItem(new string[] { "Geschlecht", individual.Sex.ToString().ToLower() == "f" ? "W" : "M" }));

                if (!string.IsNullOrEmpty(individual.Email?.Content))
                {
                    detailView.Items.Add(new ListViewItem(new string[] { "E-Mail", individual.Email?.ToString() }));
                }

                DateTime birthDate = new DateTime();
                if (DateTime.TryParse(individual.Birth?.Date?.Content, out birthDate))
                {
                    detailView.Items.Add(new ListViewItem(new string[] { "Geburt", birthDate.ToShortDateString() }));
                }

                DateTime deathDate = new DateTime();
                if (DateTime.TryParse(individual.Death?.Date?.Content, out deathDate))
                {
                    detailView.Items.Add(new ListViewItem(new string[] { "Tod", deathDate.ToShortDateString() }));
                }

                detailView.AlternateHighlightRows();
                detailView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);

                if (individual.Objects.Count > 0)
                {
                    GedcomObject gedcomObject = individual.Objects.Where(p => p.Form.Content.StartsWith("image/")).FirstOrDefault();

                    if (gedcomObject != null && !string.IsNullOrEmpty(gedcomObject.File?.Content))
                    {
                        pictureBox1.ImageLocation = gedcomObject.File?.Content;
                        pictureBox1.Tag           = new Tuple <string, string>(gedcomObject.Form.Content, gedcomObject.File?.Content);
                    }
                }
                else
                {
                    pictureBox1.ImageLocation = string.Empty;
                }
            }
        }
예제 #4
0
        private void bildSpeichernToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Tuple <string, string> data = (Tuple <string, string>)pictureBox1.Tag;

            string filetype = string.Empty;

            switch (data.Item1)
            {
            case "image/jpeg":
            case "image/jpg":
                filetype = "jpg";
                break;
            }

            if (data.Item2.StartsWith("http"))
            {
                SaveFileDialog sfd = new SaveFileDialog();
                sfd.Filter = string.Format("*.{0}|*.{0}", filetype);

                GedcomIndividual individual = (GedcomIndividual)familyTreeView.SelectedNode.Tag;
                sfd.FileName = individual.Name.ToString();

                if (sfd.ShowDialog() == DialogResult.OK)
                {
                    Progress progress = new Progress();
                    progress.Show();

                    WebClient client  = new WebClient();
                    string    tmpFile = string.Concat(Path.GetTempFileName(), filetype);
                    client.DownloadProgressChanged += (x, args) => {
                        progress.ReportProgress(args.ProgressPercentage);

                        progress.ReportProgress(string.Format("{0} of {1}", args.BytesReceived.FormatBytes(), args.TotalBytesToReceive.FormatBytes()));
                    };

                    client.DownloadFileCompleted += (y, args) => {
                        progress.Close();
                    };
                    client.DownloadFileAsync(new Uri(data.Item2), sfd.FileName);
                }
            }
        }
예제 #5
0
        private bool RecursiveSearch(TreeNode node, GedcomIndividual individual)
        {
            if (node.Tag != null)
            {
                GedcomIndividual tag = (GedcomIndividual)node.Tag;

                if (tag.Name.ToString().Equals(individual.Name.ToString()))
                {
                    familyTreeView.SelectedNode = node;
                    node.EnsureVisible();
                    return(true);
                }
            }

            if (node.NextVisibleNode != null)
            {
                return(RecursiveSearch(node.NextVisibleNode, individual));
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
        public void Export()
        {
            GedcomIndividual currentGedcomIndividual;
            GedcomFamily     currentGedcomFamily;

            DBAccess dbAccess = new DBAccess();

            dbAccess.Open();

            gedcomHeader.Source            = "FamilyTraces";
            gedcomHeader.SourceName        = "Family Traces";
            gedcomHeader.SourceCorporation = "Serge Meunier";
            gedcomHeader.Destination       = "Standard GEDCOM";
            gedcomHeader.Date              = DateTime.Now.ToShortDateString();
            gedcomHeader.GedcomVersion     = "5.5";
            gedcomHeader.GedcomForm        = "LINEAGE-LINKED";
            gedcomHeader.CharacterEncoding = "ANSEL";
            gedcomHeader.File              = "";
            gedcomHeader.SourceVersion     = "";

            DataSet individuals = dbAccess.GetAllIndividuals();

            for (int i = 0; i < individuals.Tables[0].Rows.Count; i++)
            {
                currentGedcomIndividual                = new GedcomIndividual("@I" + individuals.Tables[0].Rows[i]["ID"].ToString() + "@");
                currentGedcomIndividual.GivenName      = individuals.Tables[0].Rows[i]["Firstname"].ToString();
                currentGedcomIndividual.Surname        = individuals.Tables[0].Rows[i]["Surname"].ToString();
                currentGedcomIndividual.Sex            = individuals.Tables[0].Rows[i]["Gender"].ToString();
                currentGedcomIndividual.BirthDate      = individuals.Tables[0].Rows[i]["BornDate"].ToString();
                currentGedcomIndividual.BirthPlace     = individuals.Tables[0].Rows[i]["BornPlace"].ToString();
                currentGedcomIndividual.DiedDate       = individuals.Tables[0].Rows[i]["DiedDate"].ToString();
                currentGedcomIndividual.DiedPlace      = individuals.Tables[0].Rows[i]["DiedPlace"].ToString();
                currentGedcomIndividual.ParentFamilyId = "@F" + individuals.Tables[0].Rows[i]["ParentFamilyId"].ToString() + "@";
                if (individuals.Tables[0].Rows[0]["Gender"].ToString() == "M")
                {
                    DataSet family = dbAccess.GetFamilyForHusband((int)(individuals.Tables[0].Rows[i]["ID"]));
                    if (family.Tables[0].Rows.Count > 0)
                    {
                        if ((int)(family.Tables[0].Rows[0]["ID"]) != -1)
                        {
                            currentGedcomIndividual.SpouseFamilyId = "@F" + family.Tables[0].Rows[0]["ID"].ToString() + "@";
                        }
                        else
                        {
                            currentGedcomIndividual.SpouseFamilyId = "";
                        }
                    }
                    else
                    {
                        currentGedcomIndividual.SpouseFamilyId = "";
                    }
                }
                else
                {
                    DataSet family = dbAccess.GetFamilyForWife((int)(individuals.Tables[0].Rows[i]["ID"]));
                    if (family.Tables[0].Rows.Count > 0)
                    {
                        if ((int)(family.Tables[0].Rows[0]["ID"]) != -1)
                        {
                            currentGedcomIndividual.SpouseFamilyId = "@F" + family.Tables[0].Rows[0]["ID"].ToString() + "@";
                        }
                        else
                        {
                            currentGedcomIndividual.SpouseFamilyId = "";
                        }
                    }
                    else
                    {
                        currentGedcomIndividual.SpouseFamilyId = "";
                    }
                }
                gedcomIndividuals.Add(currentGedcomIndividual);
            }

            DataSet families = dbAccess.GetAllFamilies();

            for (int i = 0; i < families.Tables[0].Rows.Count; i++)
            {
                currentGedcomFamily               = new GedcomFamily("@F" + families.Tables[0].Rows[i]["ID"].ToString() + "@");
                currentGedcomFamily.HusbandId     = "@I" + families.Tables[0].Rows[i]["HusbandId"].ToString() + "@";
                currentGedcomFamily.WifeId        = "@I" + families.Tables[0].Rows[i]["WifeId"].ToString() + "@";
                currentGedcomFamily.MarriagePlace = families.Tables[0].Rows[i]["MarriagePlace"].ToString();
                DataSet children = dbAccess.GetFamilyChildren((int)(families.Tables[0].Rows[i]["ID"]));
                for (int j = 0; j < children.Tables[0].Rows.Count; j++)
                {
                    currentGedcomFamily.Children.Add("@F" + children.Tables[0].Rows[j]["ChildId"].ToString() + "@");
                }
                gedcomFamilies.Add(currentGedcomFamily);
            }
        }