public void RelationProgress(int progressPercent, string text = null) { trace.TraceInformation("RelationFinderViewPanel::RelationProgress(" + progressPercent + ")"); parentForm.TextCallback(progressPercent, text); if (progressPercent < 0) { //AddToListView(ref resultList, stats); if (relWorker != null) RelationStackList relations = relWorker.GetRelationStack(); if (relations != null) { this.relationList = relations; ShowRelations(this.relationList); SaveListToFile("relations_" + FamilyUtility.MakeFilename(familyTree.GetSourceFileName() + "_" + DateTime.Now.ToString() + "_" + resultNoCtrl.SelectedItem.ToString() + "_gen_" + ".fsrel"), relationList); } relWorker = null; //SaveListToFile(utility.GetCurrentDirectory() + "\\" + FamilyUtility.MakeFilename("relations_" + familyTree.GetSourceFileName() + "_" + DateTime.Now.ToString() + "_" + resultNoCtrl.SelectedItem.ToString() + "_gen_" + (checkDescendants ? "_desc_" : "") + ".fss")); resultNoCtrl.Enabled = true; stopButton.Enabled = false; startButton.Enabled = true; //descendants.Enabled = true; } }
public void WriteToFile(string filename) { using (StreamWriter writer = new StreamWriter(FamilyUtility.MakeFilename(filename + "_import_" + DateTime.Now.ToString() + ".txt"))) { foreach (string str in importResultList) { writer.Write(str + FamilyUtility.GetLinefeed()); } } }
public MDIFamilyParent() { InitializeComponent(); individualForm = new IndividualForm(); FamilyForm2 childForm = new FamilyForm2(false); string webList = childForm.GetWebTypeList(); utility = new FamilyUtility(); if (webList.Length > 0) { toolStripMenuItemOpenWeb.Visible = true; int strPosStart = webList.IndexOf('{'); int strLength = webList.IndexOf('}') - 1; while ((strPosStart >= 0) && (strPosStart < webList.Length) && (strLength > 0)) { string webName = webList.Substring(strPosStart + 1, strLength); trace.TraceInformation("add sub menu:" + webName); ToolStripMenuItem newWebItem = new ToolStripMenuItem(); newWebItem.Name = webName; newWebItem.Text = webName; //newWebItem.MouseUp += newWebItem_MouseUp; newWebItem.Click += newWebItem_Click; toolStripMenuItemOpenWeb.DropDownItems.Add(newWebItem); if (webList.Substring(strPosStart + strLength).IndexOf('{') >= 0) { strPosStart = strPosStart + strLength + webList.Substring(strPosStart + strLength).IndexOf('{'); if ((strPosStart >= 0) && (strPosStart < webList.Length)) { strLength = webList.Substring(strPosStart).IndexOf('}') - 1; } } else { strPosStart = -1; } } } else { toolStripMenuItemOpenWeb.Visible = false; } }
/*void resultList_MouseClick(object sender, MouseEventArgs e) * { * trace.TraceInformation("CompletenessViewPanel1::resultList_MouseClick()" +sender.ToString() ); * }*/ public void CompletenessProgress(int progressPercent, string text = null) { trace.TraceInformation("CompletenessViewPanel1::CompletenessProgress(" + progressPercent + ")"); parentForm.TextCallback(progressPercent, text); if (progressPercent < 0) { AddToListView(ref resultList, stats); SaveListToFile(utility.GetCurrentDirectory() + "\\" + FamilyUtility.MakeFilename("treeanalysis_" + familyTree.GetSourceFileName() + "_" + DateTime.Now.ToString() + "_" + stats.GetAncestorGenerationNo() + "_ancestGen_" + stats.GetDescendantGenerationNo() + "_descGen_.fss")); ancestorGenerationNoCtrl.Enabled = true; stopButton.Enabled = false; startButton.Enabled = true; descendantGenerationNoCtrl.Enabled = true; } }
public TreeCompareForm(IList <Form> mdiChildren, MDIFamilyParent parent) { this.parent = parent; InitializeComponent(); formList = new List <FamilyForm2>(); matchListView1.Columns.Add("Name (tree 1)", 120, HorizontalAlignment.Left); matchListView1.Columns.Add("Birth", 80, HorizontalAlignment.Left); matchListView1.Columns.Add("Death", 80, HorizontalAlignment.Left); matchListView1.Columns.Add("Quality", 80, HorizontalAlignment.Left); matchListView1.Columns.Add("Name (tree 2)", 120, HorizontalAlignment.Left); matchListView1.Columns.Add("Birth", 80, HorizontalAlignment.Left); matchListView1.Columns.Add("Death", 80, HorizontalAlignment.Left); matchListView1.Columns.Add("Quality", 80, HorizontalAlignment.Left); matchListView1.Columns.Add("Difference", 80, HorizontalAlignment.Left); matchListView1.SelectedIndexChanged += matchListView1_SelectedIndexChanged; matchListView1.ContextMenuStrip = new ContextMenuStrip(); ToolStripItem openItem = new ToolStripMenuItem(); openItem.Text = "Open..."; openItem.MouseUp += ContextMenuStrip_SelectOpen; ToolStripItem saveItem = new ToolStripMenuItem(); saveItem.Text = "Save..."; saveItem.MouseUp += ContextMenuStrip_SelectSave; ToolStripItem exportItemText = new ToolStripMenuItem(); exportItemText.Text = "Export text..."; exportItemText.MouseUp += ContextMenuStrip_SelectExportText; ToolStripItem exportItemHtml = new ToolStripMenuItem(); exportItemHtml.Text = "Export HTML..."; exportItemHtml.MouseUp += ContextMenuStrip_SelectExportHtml; ToolStripItem showPersons = new ToolStripMenuItem(); showPersons.Text = "Show doublets..."; showPersons.MouseUp += ContextMenuStrip_SelectPersons; //matchListView1.ContextMenuStrip.Items.Add("Open"); matchListView1.ContextMenuStrip.Items.Add(openItem); matchListView1.ContextMenuStrip.Items.Add(saveItem); matchListView1.ContextMenuStrip.Items.Add(exportItemText); matchListView1.ContextMenuStrip.Items.Add(exportItemHtml); matchListView1.ContextMenuStrip.Items.Add(showPersons); //matchListView1.ContextMenuStrip.MouseClick += ContextMenuStrip_MouseClick; //matchListView1.ContextMenuStrip.Items.Add(saveItem); utility = new FamilyUtility(); foreach (Form form in mdiChildren) { if (form.GetType() == typeof(FamilyForm2)) { string windowName = form.Text; if (windowName.LastIndexOf('\\') >= 0) { windowName = windowName.Substring(windowName.LastIndexOf('\\') + 1); } listBox1.Items.Add(windowName); listBox2.Items.Add(windowName); formList.Add((FamilyForm2)form); } } }
private void Parse(string decodeFilename) { TextParseState state = TextParseState.Start1; int dashCount = 0; int lineFeedCount = 0; string parsedId = ""; string parseString = ""; FamilyUtility utility = new FamilyUtility(); TextParserSettings parserSettings = GetParserSettings(utility.GetCurrentDirectory() + "\\TextDecoderSettings.xml"); BufferParseState parseState = new BufferParseState(fileBuffer, parserSettings.pageBreakStrings); System.IO.StreamWriter personFile = new System.IO.StreamWriter(decodeFilename, false, Encoding.UTF8, 4096); while (!parseState.EndOfFile()) { char ch = parseState.GetNextChar(); switch (state) { case TextParseState.Start1: if (ch == '-') { dashCount++; } else if (ch != ' ') { dashCount = 0; } if ((dashCount >= 3) && (ch == ' ')) { state = TextParseState.Start2; dashCount = 0; } break; case TextParseState.Start2: if ((ch >= '0') && (ch <= '9') || (ch == '.') || (ch == ':')) { parsedId += ch; } if ((parsedId != "") && (ch == ' ')) { state = TextParseState.Start3; } break; case TextParseState.Start3: if (ch == '-') { dashCount++; } if (dashCount >= 3) { if (ch == '\r') { state = TextParseState.ReadPerson; dashCount = 0; } } break; case TextParseState.ReadPerson: if ((ch != '\r') && (ch != '\n')) { parseString += ch; lineFeedCount = 0; } else if (ch == '\r') { if (lineFeedCount++ == 0) { parseString += " "; } /*if(lineFeedCount >= 3) * { * lineFeedCount = 0; * state = TextParseState.DecodePerson; * }*/ } if (ch == '-') { dashCount++; } else { dashCount = 0; } if (dashCount >= 3) { dashCount = 0; state = TextParseState.DecodePerson; } break; case TextParseState.DecodePerson: if (parseString.LastIndexOf("---") == (parseString.Length - 3)) { parseString = parseString.Substring(0, parseString.Length - 3); //filePos -= 5; parseState.MoveToPreviousLineStart(); } personFile.WriteLine(parsedId + ":" + parseString); string newXrefId = xrefMapLists.GetMapper(XrefType.Individual).GetXRef(parsedId, true); ParsePerson(newXrefId, parseString, parserSettings); //backgroundWorker;progresschanged parsedId = ""; parseString = ""; state = TextParseState.Start1; break; //case TextParseState.End: // break; } if (parseState.UpdateProgress()) { backgroundWorker.ReportProgress((int)parseState.GetProgress(), "Importing..."); } } if ((parsedId.Length > 0) && (parseString.Length > 0)) { string newXrefId = xrefMapLists.GetMapper(XrefType.Individual).GetXRef(parsedId, true); personFile.WriteLine(parsedId + ":" + newXrefId + ":" + parseString); ParsePerson(newXrefId, parseString, parserSettings); parsedId = ""; parseString = ""; } personFile.Close(); backgroundWorker = null; trace.TraceInformation("Text file parsing finished at "); }
public bool ReadFile(String filename, ref IFamilyTreeStoreBaseClass inFamilyTree) { printMemory = false;// true; trace.TraceInformation("TextDecoder::Readfile(" + filename + ") Start " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); familyTree = inFamilyTree; trace.TraceInformation(familyTree.GetShortTreeInfo()); //familyTree.Print(); if (printMemory) { memory = new MemoryClass(); memory.PrintMemory(); } xrefMapLists = new XrefMapLists(inFamilyTree); fileBuffer = new FileBufferClass(); fileBuffer.ReadFile(filename); trace.TraceInformation("TextDecoder::Readfile() size " + fileBuffer.GetSize()); if (printMemory) { memory.PrintMemory(); } String HeadString = ""; trace.TraceInformation("Text file " + filename + " read ok, size " + fileBuffer.GetSize()); if (fileBuffer.GetSize() < 12) { trace.TraceInformation("Text file too small!: " + filename + ", size:" + fileBuffer.GetSize()); return(false); } Byte[] fileDataBuffer = fileBuffer.GetBuffer(); for (int i = 0; i < 12; i++) { trace.TraceInformation(" data:" + (int)fileDataBuffer[i]); HeadString += (char)fileDataBuffer[i]; } trace.TraceInformation(""); familyTree.SetSourceFileType("Text"); if (printMemory) { memory.PrintMemory(); } if (printMemory) { memory.PrintMemory(); } //familyTree.Print(); trace.TraceData(TraceEventType.Verbose, 0, familyTree.GetShortTreeInfo()); trace.TraceInformation("TextDecoder::Readfile() Done " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); string directory = "/tmp/"; if (!Directory.Exists(directory)) { //Directory.CreateDirectory(directory); directory = ""; } if ((directory.Length > 0) && filename.Contains(directory)) { filename = filename.Substring(directory.Length); } Parse(directory + FamilyUtility.MakeFilename(filename + "_text_parsed_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".txt")); xrefMapLists.Analyze(trace); return(true); }
public bool ReadFile(String fileName, ref FamilyTreeStoreBaseClass inFamilyTree) { printMemory = false;// true; trace.TraceInformation("TextDecoder::Readfile(" + fileName + ") Start " + DateTime.Now); familyTree = inFamilyTree; familyTree.Print(); if (printMemory) { memory = new MemoryClass(); memory.PrintMemory(); } xrefMapLists = new XrefMapLists(inFamilyTree); fileBuffer = new FileBufferClass(); fileBuffer.ReadFile(fileName); trace.TraceInformation("TextDecoder::Readfile() size " + fileBuffer.GetSize()); if (printMemory) { memory.PrintMemory(); } String HeadString = ""; trace.TraceInformation("Text file " + fileName + " read ok, size " + fileBuffer.GetSize()); if (fileBuffer.GetSize() < 12) { trace.TraceInformation("Text file too small!: " + fileName + ", size:" + fileBuffer.GetSize()); return(false); } Byte[] fileDataBuffer = fileBuffer.GetBuffer(); for (int i = 0; i < 12; i++) { trace.TraceInformation(" data:" + (int)fileDataBuffer[i]); HeadString += (char)fileDataBuffer[i]; } trace.TraceInformation(""); familyTree.SetSourceFileType("Text"); if (printMemory) { memory.PrintMemory(); } if (printMemory) { memory.PrintMemory(); } familyTree.Print(); trace.TraceInformation("TextDecoder::Readfile() Done " + DateTime.Now); Parse(FamilyUtility.MakeFilename(fileName + "_parsed_" + DateTime.Now.ToString() + ".txt")); xrefMapLists.Analyze(trace); return(true); }
public CompletenessViewPanel1() { trace = new TraceSource("PersonViewPanel1", SourceLevels.Warning); controlList = new List <Control>(); this.Dock = DockStyle.Fill; parentForm = null; //descendantGenerationNo = 0; settingsButton = new Button(); settingsButton.Text = "Settings"; settingsButton.Left = 0; this.settingsButton.MouseClick += settingsButton_MouseClick; this.Controls.Add(settingsButton); startButton = new Button(); startButton.Text = "Analyse"; startButton.Name = "Parent"; startButton.Left = settingsButton.Right; this.startButton.MouseClick += startButton_MouseClick; this.Controls.Add(startButton); stopButton = new Button(); stopButton.Left = startButton.Right; stopButton.Text = "Stop"; this.stopButton.MouseClick += stopButton_MouseClick; stopButton.Enabled = false; //stopButton. this.Controls.Add(stopButton); ancestorGenerationNoCtrl = new DomainUpDown(); ancestorGenerationNoCtrl.Left = stopButton.Right; ancestorGenerationNoCtrl.Items.Add("All g. ancestors"); for (int i = 20; i >= 5; i--) { ancestorGenerationNoCtrl.Items.Add(i.ToString() + " g. ancestors"); } ancestorGenerationNoCtrl.SelectedItem = "5 g. ancestors"; ancestorGenerationNoCtrl.Width = 100; //ancestorGenerationNoCtrl.AutoSize = true; this.Controls.Add(ancestorGenerationNoCtrl); descendantGenerationNoCtrl = new DomainUpDown(); descendantGenerationNoCtrl.Text = "Descendants"; descendantGenerationNoCtrl.Left = ancestorGenerationNoCtrl.Right; descendantGenerationNoCtrl.Enabled = true; descendantGenerationNoCtrl.AutoSize = true; descendantGenerationNoCtrl.Items.Add("All g. descendants"); for (int i = 10; i >= 0; i--) { descendantGenerationNoCtrl.Items.Add(i.ToString() + " g. descendants"); } descendantGenerationNoCtrl.SelectedItem = "0 g. descendants"; descendantGenerationNoCtrl.Width = 100; this.Controls.Add(descendantGenerationNoCtrl); stopButton.Enabled = false; //stopButton. resultList = new ListView(); resultList.Top = startButton.Bottom; //resultList.Width = 400; //resultList.Height = 400; resultList.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; resultList.Left = 3; //resultList.Margin.Right = 3; resultList.Location = new System.Drawing.Point(3, 20); resultList.Size = new System.Drawing.Size(200, 80); //resultList.Left = 3; //resultList.MultiColumn = true; //resultList.ScrollAlwaysVisible = true; //resultList.MouseClick += resultList_MouseClick; resultList.SelectedIndexChanged += resultList_SelectedIndexChanged; resultList.Columns.Add("Name", 120, HorizontalAlignment.Left); resultList.Columns.Add("Distance", 40, HorizontalAlignment.Right); resultList.Columns.Add("Relation", 40, HorizontalAlignment.Left); resultList.Columns.Add("Birth", 80, HorizontalAlignment.Left); resultList.Columns.Add("Death", 80, HorizontalAlignment.Left); resultList.Columns.Add("Details", 250, HorizontalAlignment.Left); resultList.View = View.Details; resultList.AllowColumnReorder = true; resultList.FullRowSelect = true; resultList.ShowItemToolTips = true; resultList.MouseUp += ResultList_MouseUp; /*resultList.ContextMenuStrip = new ContextMenuStrip(); * ToolStripItem openItem = new ToolStripMenuItem(); * openItem.Text = "Open..."; * openItem.MouseUp += ContextMenuStrip_SelectOpen; * resultList.ContextMenuStrip.Items.Add(openItem); * * ToolStripItem saveItem = new ToolStripMenuItem(); * saveItem.Text = "Save..."; * saveItem.MouseUp += ContextMenuStrip_SelectSave; * resultList.ContextMenuStrip.Items.Add(saveItem); * * ToolStripItem exportItem = new ToolStripMenuItem(); * exportItem.Text = "Export to Text..."; * exportItem.MouseUp += ContextMenuStrip_SelectExport; * resultList.ContextMenuStrip.Items.Add(exportItem);*/ this.Controls.Add(resultList); utility = new FamilyUtility(); limits = GetSanitySettings(utility.GetCurrentDirectory() + "\\SanitySettings.fssan"); trace.TraceInformation("CompletenessViewPanel1::CompletenessViewPanel1()"); }
public bool DownloadImages2(FamilyTreeStoreBaseClass tree) { IEnumerator <IndividualClass> individualIterator = tree.SearchPerson(); List <IndividualClass> individualList = new List <IndividualClass>(); FamilyUtility utility = new FamilyUtility(); String dirname = utility.GetCurrentDirectory() + "\\" + FamilyUtility.MakeFilename("ImageDownload_" + tree.GetSourceFileName() + "_" + DateTime.Now.ToString()); Directory.CreateDirectory(dirname); List <String> endings = new List <string>(); endings.Add("_large.jpg"); endings.Add("_medium.jpg"); endings.Add("_t.jpg"); endings.Add("_t2.jpg"); while (individualIterator.MoveNext()) { individualList.Add(individualIterator.Current); } foreach (IndividualClass person in individualList) { IList <MultimediaLinkClass> links = person.GetMultimediaLinkList(); IList <MultimediaLinkClass> newLinks = new List <MultimediaLinkClass>(); IList <String> dlLinks = new List <String>(); IList <String> dlLinksBase = new List <String>(); IList <String> dlLinksTrue = new List <String>(); foreach (MultimediaLinkClass link in links) { Boolean webimage = (link.GetLink().ToLower().IndexOf("http:") >= 0) || (link.GetLink().ToLower().IndexOf("https:") >= 0); if (webimage) { dlLinks.Add(link.GetLink()); } } foreach (String link in dlLinks) { String basename = link; if (link.ToLower().IndexOf(".jpg") >= 0) { foreach (String ending in endings) { if (link.ToLower().IndexOf(ending) >= 0) { basename = link.Substring(0, link.ToLower().IndexOf(ending)); if (dlLinksBase.IndexOf(basename) < 0) { dlLinksBase.Add(basename); } } } } } foreach (String link in dlLinksBase) { int bestIndex = -1; int index = 0; while ((bestIndex < 0) && (index < endings.Count)) { String newLink = link + endings[index]; bestIndex = dlLinks.IndexOf(newLink); dlLinksTrue.Add(newLink); index++; } } foreach (String link in dlLinksTrue) { String filename = dirname + "\\" + FamilyUtility.MakeFilename(person.GetXrefName() + " " + person.GetName() + " " + GetLastPart(link)); if (filename.Length > 255) { filename = filename.Substring(0, 255); } filename = filename + ".jpg"; //trace.TraceInformation(filename); if (SaveImageLocal(filename, link, ImageFormat.Jpeg)) { newLinks.Add(new MultimediaLinkClass("image/jpeg", filename)); } } foreach (MultimediaLinkClass link in newLinks) { person.AddMultimediaLink(link); } } return(true); }
public RelationFinderPanel() { controlList = new List <Control>(); this.Dock = DockStyle.Fill; parentForm = null; //checkDescendants = false; startButton = new Button(); startButton.Text = "Analyse"; startButton.Name = "Parent"; startButton.Left = 0; this.startButton.MouseClick += startButton_MouseClick; this.Controls.Add(startButton); stopButton = new Button(); stopButton.Left = startButton.Right; stopButton.Text = "Stop"; stopButton.Enabled = false; //stopButton. resultNoCtrl = new DomainUpDown(); resultNoCtrl.Left = stopButton.Right; resultNoCtrl.Items.Add("All"); for (int i = 20; i >= 5; i--) { resultNoCtrl.Items.Add(i.ToString()); } resultNoCtrl.SelectedItem = "5"; resultNoCtrl.Width = 50; //resultNoCtrl.AutoSize = true; this.Controls.Add(resultNoCtrl); this.stopButton.MouseClick += stopButton_MouseClick; this.Controls.Add(stopButton); resultList = new TreeView(); resultList.Top = startButton.Bottom; //resultList.Width = 400; //resultList.Height = 400; resultList.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right; resultList.Left = 3; //resultList.Margin.Right = 3; resultList.Location = new System.Drawing.Point(3, 20); resultList.Size = new System.Drawing.Size(200, 80); //resultList.Left = 3; resultList.NodeMouseClick += resultList_NodeMouseClick; resultList.ContextMenuStrip = new ContextMenuStrip(); ToolStripItem openItem = new ToolStripMenuItem(); openItem.Text = "Open..."; openItem.MouseUp += ContextMenuStrip_SelectOpen; ToolStripItem saveItem = new ToolStripMenuItem(); saveItem.Text = "Save..."; saveItem.MouseUp += ContextMenuStrip_SelectSave; ToolStripItem exportItemText = new ToolStripMenuItem(); exportItemText.Text = "Export text..."; exportItemText.MouseUp += ContextMenuStrip_SelectExportText; ToolStripItem exportItemHtml = new ToolStripMenuItem(); exportItemHtml.Text = "Export HTML..."; exportItemHtml.MouseUp += ContextMenuStrip_SelectExportHtml; //matchListView1.ContextMenuStrip.Items.Add("Open"); resultList.ContextMenuStrip.Items.Add(openItem); resultList.ContextMenuStrip.Items.Add(saveItem); resultList.ContextMenuStrip.Items.Add(exportItemText); resultList.ContextMenuStrip.Items.Add(exportItemHtml); utility = new FamilyUtility(); this.Controls.Add(resultList); relWorker = null; trace.TraceInformation("RelationFinderPanel::RelationFinderPanel()"); ResetGui(); }