public CompletenessTreeWorker( object sender, ProgressReporterInterface progress, string startIndividualXref, ref AncestorStatistics stats) { trace = new TraceSource("CompletenessTreeWorker", SourceLevels.Warning); //familyTree = stats.familyTree; progressReporter = progress; this.stats = stats; startPersonXref = startIndividualXref; backgroundWorker = new BackgroundWorker(); backgroundWorker.WorkerReportsProgress = true; backgroundWorker.DoWork += new DoWorkEventHandler(DoWork); backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(Completed); backgroundWorker.ProgressChanged += new ProgressChangedEventHandler(ProgressChanged); backgroundWorker.RunWorkerAsync(startIndividualXref); }
void ReadListFromFile() { OpenFileDialog fileDlg = new OpenFileDialog(); fileDlg.Filter = "Stats List|*.fss"; fileDlg.InitialDirectory = utility.GetCurrentDirectory(); if (fileDlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { DataContractSerializer serializer = new DataContractSerializer(typeof(AncestorStatistics)); FileStream readFile = new FileStream(fileDlg.FileName, FileMode.Open); AncestorStatistics localStats; localStats = (AncestorStatistics)serializer.ReadObject(readFile); stats = localStats; stats.SetFamilyTree(familyTree); readFile.Close(); AddToListView(ref resultList, stats); stopButton.Enabled = false; startButton.Enabled = true; ancestorGenerationNoCtrl.Enabled = true; } }
void startButton_MouseClick(object sender, MouseEventArgs e) { trace.TraceInformation("CompletenessViewPanel1::startButton_MouseClick()" + DateTime.Now); if ((selectedIndividual != null) && (startButton.Visible)) { //SearchMode runMode = SearchMode.ParentMissing; stopButton.Enabled = true; startButton.Enabled = false; descendantGenerationNoCtrl.Enabled = false; ancestorGenerationNoCtrl.Enabled = false; //dateButton.Enabled = false; resultList.Items.Clear(); int ancestorGenerations = GetSelectedInt(ancestorGenerationNoCtrl); int descendantGenerationNo = GetSelectedInt(descendantGenerationNoCtrl); //limits = GetSanitySettings(utility.GetCurrentDirectory() + "\\SanitySettings.fssan"); progressReporter = new AsyncWorkerProgress(CompletenessProgress); stats = new AncestorStatistics(familyTree, limits, ancestorGenerations, descendantGenerationNo, progressReporter, AncestorUpdate); trace.TraceInformation("selected:" + selectedIndividual.GetName() + " " + DateTime.Now); analyseTreeWorker = new CompletenessTreeWorker(this, progressReporter, selectedIndividual.GetXrefName(), ref stats); //AnalyseParents(selectedIndividual, ref stats, 1); //dateButton.Enabled = true; trace.TraceInformation(" Database: " + familyTree.GetSourceFileName() + " person " + selectedIndividual.GetName() + " " + DateTime.Now); } else { MessageBox.Show("Error: No person selected!"); } }
public void AddToListView(ref ListView list, AncestorStatistics stats) { bool disableCounter = true; { resultList.Items.Clear(); if (stats != null) { IEnumerable <AncestorLineInfo> query = stats.GetAncestorList().OrderBy(ancestor => ancestor.depth); //SanityCheckLimits limits = GetSanitySettings(utility.GetCurrentDirectory() + "\\SanitySettings.fssan"); foreach (AncestorLineInfo root in query) { AddItemToListView(root, limits); } } } if (!disableCounter) { IEnumerable <HandledItem> query = stats.GetAnalysedPeopleNo().OrderByDescending(ancestor => ancestor.number); foreach (HandledItem item in query) { if (item.number > 1) { IndividualClass person = familyTree.GetIndividual(item.xref); if (person != null) { trace.TraceInformation(" Referenced " + item.number + " times: " + person.GetName() + " " + person.GetDate(IndividualEventClass.EventType.Birth) + " - " + person.GetDate(IndividualEventClass.EventType.Death) + " " + item.relationStackList.Count); //list.Add(new ListedPerson(" Multiply Referenced " + item.number + " times: " + person.GetName() + " " + person.GetDate(IndividualEventClass.EventType.Birth) + " - " + person.GetDate(IndividualEventClass.EventType.Death), person.GetXrefName())); ListViewItem lvItem = new ListViewItem(person.GetName()); lvItem.SubItems.AddRange(new string[] { "X:" + item.number, person.GetDate(IndividualEventClass.EventType.Birth).ToString(), person.GetDate(IndividualEventClass.EventType.Death).ToString(), "referenced " + item.number + " times" }); lvItem.Tag = person.GetXrefName(); lvItem.ToolTipText = ""; foreach (RelationStack stack in item.relationStackList) { if (stack != null) { lvItem.ToolTipText += stack.ToString(familyTree, false); lvItem.ToolTipText += "\n"; trace.TraceInformation(stack.ToString(familyTree, false)); } } list.Items.Add(lvItem); } else { trace.TraceInformation(" Person == null:" + item); } } } } /*{ * foreach (HandledItem item in analysedFamiliesNo) * { * if (item.number > 1) * { * trace.TraceInformation("Duplicate family " + item.number + " " + item.xref); * } * } * }*/ }