// Displays useful information about a source record in a dialog box private void ShowSourceDetailsDialog(Form formParent, CListableBool lbItem, LLClasses.CSourceRecord sr, bool bCanEditPictures, bool bFirstColumnIsCheckbox) { CRecordDetailsForm detailsForm = new CRecordDetailsForm(formParent, sr, m_gedcom, bCanEditPictures, true); detailsForm.ShowDialog(this); if (lbItem != null && sr != null) { SetSourceSubItems(lbItem, sr, bFirstColumnIsCheckbox); } EnablePrunePanelButtons(); }
// Attaches sub-items to a list item (before the list item is added to the list) private void SetSourceSubItems(CListableBool lbItem, CSourceRecord sr, bool bFirstColumnIsCheckbox) { // Store checkbox value because SubItems.Clear() clears item.Text and item.Checked as well! bool bWasChecked = lbItem.Checked; lbItem.SubItems.Clear(); lbItem.Checked = bWasChecked; if (bFirstColumnIsCheckbox) { // First nColumn (ie. item) is checkbox, so first sub-item is title. lbItem.SubItems.Add(new CListableSource(sr)); } string sRepositories = ""; foreach (CSourceRepositoryCitation src in sr.m_alSourceRepositoryCitations) { CRepositoryRecord rr = m_gedcom.GetRepositoryRecord(src.m_xrefRepo); if (rr != null) { if (rr.m_sNameOfRepository != null && rr.m_sNameOfRepository != "") { if (sRepositories != "") { sRepositories += ", "; } sRepositories += rr.m_sNameOfRepository; } } } lbItem.SubItems.Add(new ListViewItem.ListViewSubItem(lbItem, sRepositories)); int nBirths = 0; int nMarriages = 0; int nDeaths = 0; int nIndis = 0; int nFamilies = 0; int nNotes = 0; int nOther = 0; int nCitations = 0; if (sr.m_alBackreferences.Count > 0) { foreach (CBackReference br in sr.m_alBackreferences) { switch (br.m_sEventType) { case "BIRT": nBirths++; nCitations++; break; case "MARR": nMarriages++; nCitations++; break; case "DEAT": nCitations++; nDeaths++; break; default: switch (br.m_ertRecordType) { case ERecordType.Individual: nCitations++; nIndis++; break; case ERecordType.Family: // Strictly this should be plus 2 if husb & wife both known, otherwise 1 or 0. nCitations++; nFamilies++; break; case ERecordType.Note: nNotes++; break; default: nOther++; break; } break; } } } lbItem.SubItems.Add(new ListViewItem.ListViewSubItem(lbItem, nCitations.ToString())); lbItem.SubItems.Add(new ListViewItem.ListViewSubItem(lbItem, nBirths.ToString())); lbItem.SubItems.Add(new ListViewItem.ListViewSubItem(lbItem, nMarriages.ToString())); lbItem.SubItems.Add(new ListViewItem.ListViewSubItem(lbItem, nDeaths.ToString())); lbItem.SubItems.Add(new CListableString(sr.m_xref)); int nVisiblePics = sr.CountVisibleMFRs(); int nTotalPics = sr.CountAllMFRs(); if (nVisiblePics != nTotalPics) { lbItem.SubItems.Add(new CListableNumber(nVisiblePics, String.Format("{0}/{1}", nVisiblePics, nTotalPics))); } else { lbItem.SubItems.Add(new CListableNumber(nTotalPics, String.Format("{0}", nTotalPics))); } lbItem.Checked = bWasChecked; }
// Attaches sub-items to a list item (before the list item is added to the list) private void SetIndividualSubItems(CListableBool lbItem, CIndividualRecord ir, bool bCheckBoxes) { // Save checkbox state because SubItems.Clear() clears item.Text and item.Checked as well, so replace old value after calling Clear(). bool bWasChecked = lbItem.Checked; string sItemText = lbItem.Text; lbItem.SubItems.Clear(); lbItem.Text = sItemText; lbItem.Checked = bWasChecked; // If the list view has check boxes, the item is for the checkbox. // Otherwise the item is for the name, and so the sub items won't include the name. if (bCheckBoxes) { string sSurname = ""; string sFirstName = ""; s_config.CapitaliseName(ir.Name, ref sFirstName, ref sSurname); if (ir.NameSuffix != null && ir.NameSuffix != "") { sFirstName += ", " + ir.NameSuffix; } lbItem.SubItems.Add(new CListableName(ir, sSurname, sFirstName)); } CPGQualifiedDate birthDate = ir.BirthDate; if (birthDate != null) { lbItem.SubItems.Add(new CListableYear(birthDate.m_date)); } else { lbItem.SubItems.Add(new CListableYear(null)); } CPGQualifiedDate deathDate = ir.DeathDate; if (deathDate != null) { lbItem.SubItems.Add(new CListableYear(deathDate.m_date)); } else { lbItem.SubItems.Add(new CListableYear(null)); } lbItem.SubItems.Add(new CListableString(ir.m_xref)); lbItem.SubItems.Add(new CListableString(ir.UserReferenceNumber(0))); int nVisiblePics = ir.CountVisibleMFRs(); int nTotalPics = ir.CountAllMFRs(); if (nVisiblePics != nTotalPics) { lbItem.SubItems.Add(new CListableNumber(nVisiblePics, String.Format("{0}/{1}", nVisiblePics, nTotalPics))); } else { lbItem.SubItems.Add(new CListableNumber(nTotalPics, String.Format("{0}", nTotalPics))); } }
// Brings up a CRecordDetailsForm for the given individual public void ShowIndividualDetailsDialog(Form formParent, CListableBool lbItem, LLClasses.CIndividualRecord ir, bool bCanEditPictures, bool bCheckBoxes) { CRecordDetailsForm detailsForm = new CRecordDetailsForm(formParent, ir, m_gedcom, bCanEditPictures, false); detailsForm.ShowDialog(this); if (lbItem != null && ir != null) { SetIndividualSubItems(lbItem, ir, bCheckBoxes); } EnablePrunePanelButtons(); }
// Populates the list of source records for inclusion/exclusion in the website private void FillSourcesList(SortableListView listView, bool bFirstColumnIsCheckbox) { LogFile.TheLogFile.WriteLine(LogFile.DT_APP, LogFile.EDebugLevel.Note, "FillSourcesList() : " + m_gedcom.m_alSourceRecords.Count.ToString()); m_bDisablePrunepanelCheckEvent = true; // call to item.Checked below invokes event handler. Cursor.Current = Cursors.WaitCursor; Cursor.Show(); listView.Clear(); listView.View = View.Details; int nWidthTitle = listView.Width - 140 - 20; if (bFirstColumnIsCheckbox) { listView.Columns.Add("Include", 30, HorizontalAlignment.Left); nWidthTitle -= 30; } listView.Columns.Add("Title", nWidthTitle, HorizontalAlignment.Left); listView.Columns.Add("Repository", 100, HorizontalAlignment.Left); listView.Columns.Add("Citations", 60, HorizontalAlignment.Left); listView.Columns.Add("B", 30, HorizontalAlignment.Left); listView.Columns.Add("M", 30, HorizontalAlignment.Left); listView.Columns.Add("D", 30, HorizontalAlignment.Left); listView.Columns.Add("Id", 60, HorizontalAlignment.Left); listView.Columns.Add("Pics", 48, HorizontalAlignment.Left); ListViewItem[] temporaryItemsList = new ListViewItem[m_gedcom.m_alSourceRecords.Count]; int nItem = 0; foreach (GEDmill.LLClasses.CSourceRecord sr in m_gedcom.m_alSourceRecords) { CListableBool item = new CListableBool(sr, bFirstColumnIsCheckbox); SetSourceSubItems(item, sr, bFirstColumnIsCheckbox); item.Checked = !(sr.Restricted); temporaryItemsList[nItem++] = item; } listView.Items.AddRange(temporaryItemsList); listView.Sort(); m_tabpagePruneRecordsSources.Text = "Sources (" + listView.Items.Count + ")"; Cursor.Current = Cursors.Default; Cursor.Hide(); m_bDisablePrunepanelCheckEvent = false; }
// Populates the list of individuals records for inclusion/exclusion in the website // alSelectedIndividuals is a small array indicating xrefs of those individuals to mark selected. (not currently used, 3Jan08) private void FillIndividualsList(SortableListView listView, bool bExcludeRestricted, ArrayList alSelectedIndividuals, bool bFirstColumnIsCheckbox) { LogFile.TheLogFile.WriteLine(LogFile.DT_APP, LogFile.EDebugLevel.Note, "FillIndividualsList() : " + m_gedcom.m_alIndividualRecords.Count.ToString()); m_bDisablePrunepanelCheckEvent = true; Cursor.Current = Cursors.WaitCursor; Cursor.Show(); listView.Clear(); listView.View = View.Details; int nameWidth = listView.Width - 70 - 70 - 20; if (bFirstColumnIsCheckbox) { listView.Columns.Add("Include", 30, HorizontalAlignment.Left); nameWidth -= 30; } listView.Columns.Add("Name", nameWidth, HorizontalAlignment.Left); listView.Columns.Add("Born", 70, HorizontalAlignment.Left); listView.Columns.Add("Died", 70, HorizontalAlignment.Left); listView.Columns.Add("Id", 60, HorizontalAlignment.Left); listView.Columns.Add("User ref", 78, HorizontalAlignment.Left); listView.Columns.Add("Pics", 48, HorizontalAlignment.Left); // Build an array first then blit the whole array to the list control. This is faster than adding each item to the list control individually. ListViewItem[] temporaryItemsList = new ListViewItem[m_gedcom.m_alIndividualRecords.Count]; int nItem = 0; foreach (GEDmill.LLClasses.CIndividualRecord ir in m_gedcom.m_alIndividualRecords) { // Only allow fully unrestricted individuals. if (bExcludeRestricted && ir.Visibility() != LLClasses.CIndividualRecord.EVisibility.Visible) { continue; } CListableBool lbItem; if (bFirstColumnIsCheckbox) { lbItem = new CListableBool(ir, true); } else { string sSurname = ""; string sFirstName = ""; s_config.CapitaliseName(ir.Name, ref sFirstName, ref sSurname); if (ir.NameSuffix != null && ir.NameSuffix != "") { sFirstName += ", " + ir.NameSuffix; } lbItem = new CListableBool(ir, sSurname, sFirstName, false); } SetIndividualSubItems(lbItem, ir, bFirstColumnIsCheckbox); // alSelectedIndividuals is a small array indicating xrefs of those individuals to mark selected. (not currently used, 3Jan08) if (alSelectedIndividuals != null && alSelectedIndividuals.Contains(ir.m_xref)) { lbItem.Selected = true; } lbItem.Checked = !(ir.Restricted); temporaryItemsList[nItem++] = lbItem; } listView.Items.AddRange(temporaryItemsList); listView.Sort(); m_tabpagePruneRecordsIndis.Text = "Individuals (" + listView.Items.Count + ")"; Cursor.Current = Cursors.Default; Cursor.Hide(); m_bDisablePrunepanelCheckEvent = false; }