public void LoadFile(GedcomFile file)
        {
            if (file != null && file.Head?.Note != null)
            {
                string[] lines = new string[]
                {
                    file.Head.Note.Note
                }.Union(file.Head.Note.Contents.Select(p => p.Content.Trim()).ToArray()).ToArray();

                noteRichTextBox.Lines = lines;
            }

            propertyListView.Items.Clear();

            propertyListView.Items.Add(new ListViewItem(new string[] { "Source", file.Head.Source?.Name }));
            propertyListView.Items.Add(new ListViewItem(new string[] { "Version", file.Head.Source?.Version?.Content }));
            propertyListView.Items.Add(new ListViewItem(new string[] { "Original file", file.Head.OriginalFile?.Content }));
            propertyListView.Items.Add(new ListViewItem(new string[] { "Family count", file.Families.Count.ToString() }));
            propertyListView.Items.Add(new ListViewItem(new string[] { "Individual count", file.Individuals.Count.ToString() }));
            propertyListView.Items.Add(new ListViewItem(new string[] { "Date", file.Head.Date?.Content }));
            propertyListView.Items.Add(new ListViewItem(new string[] { "Address", file.Head.Address?.Content }));
            propertyListView.Items.Add(new ListViewItem(new string[] { "Language", file.Head.Language?.Content }));
            propertyListView.Items.Add(new ListViewItem(new string[] { "Email", file.Head.Email?.Content }));

            propertyListView.AlternateHighlightRows();
            propertyListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
        }
示例#2
0
        static void Main(string[] args)
        {
            GedcomFile file = GedcomReader.ToGedcomFile(@"F:\export-BloodTree.ged");

            foreach (GedcomIndividual indi in file.Individuals)
            {
                Console.WriteLine(indi.ToString());
            }

            Console.ReadLine();
        }
示例#3
0
        private void LoadFile(string filename)
        {
            this.filename = filename;

            this.Enabled = false;

            Progress progress = new Progress();

            progress.Canceled += Progress_Canceled;
            progress.Show();

            familyTreeView.Nodes.Clear();

            progress.ReportProgress(2);
            this.file = GedcomReader.ToGedcomFile(filename);
            progress.ReportProgress(5);

            double increaseValue = (double)95 / file.Families.Count;
            double currentValue  = 5;

            foreach (GedcomFamily family in file.Families)
            {
                if (this.progressCanceled)
                {
                    break;
                }

                if (family.Children.Count == 0)
                {
                    progress.ReportProgress(string.Concat("Load family ", family.Identifier));
                }

                TreeNode famNode = new TreeNode("Familie")
                {
                    ImageIndex = 3, SelectedImageIndex = 3
                };
                TreeNode husband = new TreeNode()
                {
                    ImageIndex = 1, SelectedImageIndex = 1, Tag = family.Husband
                };
                husband.Text = family.Husband != null?family.Husband.Name.ToString() : string.Empty;

                TreeNode wife = new TreeNode()
                {
                    ImageIndex = 0, SelectedImageIndex = 0, Tag = family.Wife
                };
                wife.Text = family.Wife != null?family.Wife.Name.ToString() : string.Empty;

                famNode.Nodes.AddRange(new TreeNode[] { husband, wife });

                DateTime marriage = new DateTime();
                if (family.Marriage != null && family.Marriage.Date?.Content != null && DateTime.TryParse(family.Marriage.Date.Content, out marriage))
                {
                    famNode.Nodes.Add(Guid.NewGuid().ToString(), "Heirat: " + marriage.ToShortDateString(), 2, 2);
                }

                if (family.Children.Count > 0)
                {
                    progress.ReportProgress(string.Concat("Load family ", family.Identifier, " (", family.Children.Count, " children)"));

                    TreeNode children = new TreeNode("Kinder")
                    {
                        ImageIndex = 3, SelectedImageIndex = 3
                    };

                    children.Nodes.AddRange(family.Children.Select(p => new TreeNode(p.Name.ToString()
                                                                                     )
                    {
                        ImageIndex =
                            p.Sex.Content.ToLower().Equals("m") ? 1 : 0,
                        SelectedImageIndex =
                            p.Sex.Content.ToLower().Equals("m") ? 1 : 0,
                        Tag = p
                    }).ToArray());
                    famNode.Nodes.Add(children);
                }

                familyTreeView.Nodes.Add(famNode);
                progress.ReportProgress((int)currentValue);
                Application.DoEvents();
                currentValue += increaseValue;

                famNode.ExpandAll();
            }

            if (!this.progressCanceled)
            {
                familyTreeView.Nodes[0].EnsureVisible();
                progress.ReportProgress(100);
                statusLabel.Text = string.Format("GEDCOM Source: {0} ({1})", this.file.Head.Source.Name, this.file.Head.Source.Version);
            }

            progress.Close();

            this.Enabled          = true;
            this.progressCanceled = false;

            if (!this.Focused)
            {
                this.Focus();
            }
        }
示例#4
0
        static void Main(string[] args)
        {
            // parse command line
            string      inputGedcomFilePath;
            int         encoding;
            GedcomFile  gedcomFile;
            VisioExport visioExport;

            if (args.Length < 1)
            {
                Console.WriteLine("GedToVisio <inputGedcomFile.ged> [encoding]");
                return;
            }
            inputGedcomFilePath = System.IO.Path.GetFullPath(args[0]);

            try
            {
                encoding = args.Length < 2 ? 1251 : int.Parse(args[1]);
            }
            catch (Exception)
            {
                Console.WriteLine("Incorrect encoding - number expected, for example 1251");
                return;
            }

            // parse GEDCOM
            try
            {
                Console.WriteLine("Parsing GEDCOM file: {0}", inputGedcomFilePath);
                gedcomFile = new GedcomFile();
                gedcomFile.Load(inputGedcomFilePath, Encoding.GetEncoding(encoding));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error parsing GEDCOM file: {0}", ex);
                return;
            }

            // open Visio
            Console.WriteLine("Exporting to MS Visio");
            try
            {
                visioExport = new VisioExport();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Can't open MS Visio: {0}", ex);
                return;
            }

            // export
            try
            {
                gedcomFile.Individuals.ForEach(visioExport.Add);
                gedcomFile.Families.ForEach(visioExport.Add);

                visioExport.BuildTree();

                visioExport.Arrange();

                //visioExport.Render();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error exporting to Visio: {0}", ex);
                return;
            }

            Console.WriteLine("Done.");
        }