Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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();
        }