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)); } }
void AncestorUpdate(AncestorLineInfo ancestor) { if (resultList.InvokeRequired) { Invoke(new Action(() => AddItemToListView(ancestor, limits))); } else { AddItemToListView(ancestor, limits); } }
private void ResultList_MouseUp(object sender, MouseEventArgs e) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { ContextMenu menu = new ContextMenu(); menu.MenuItems.Add(new MenuItem("Open...", ResultList_Open_Click)); menu.MenuItems.Add(new MenuItem("Save...", ResultList_Save_Click)); menu.MenuItems.Add(new MenuItem("Export text...", ResultList_ExportText_Click)); menu.MenuItems.Add(new MenuItem("Export HTML...", ResultList_ExportHtml_Click)); if (parentForm != null) { string selectedPerson = parentForm.GetSelectedIndividual(); if (selectedPerson != null) { IndividualClass individual = familyTree.GetIndividual(selectedPerson); if (individual != null) { IList <string> urlList = individual.GetUrlList(); if (urlList != null) { foreach (string url in urlList) { menu.MenuItems.Add(new MenuItem(url, ResultList_Url_Click)); } } } trace.TraceData(TraceEventType.Warning, 0, "selectedperson = " + selectedPerson); if (stats != null) { AncestorLineInfo selected = stats.GetAncestor(selectedPerson); if (selected != null) { trace.TraceData(TraceEventType.Warning, 0, "selected = " + selected + " dups=" + selected.duplicate.Count); foreach (string duplicate in selected.duplicate) { menu.MenuItems.Add(new MenuItem(duplicate, ResultList_Url_Click)); } } else { trace.TraceData(TraceEventType.Warning, 0, "selected = null"); } } } } menu.Show(this, e.Location, LeftRightAlignment.Right); } }