void ReadListFromFile() { OpenFileDialog fileDlg = new OpenFileDialog(); fileDlg.InitialDirectory = utility.GetCurrentDirectory(); fileDlg.Filter = "Stats List|*.fsrel"; if (fileDlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { DataContractSerializer serializer = new DataContractSerializer(typeof(RelationStackList)); FileStream readFile = new FileStream(fileDlg.FileName, FileMode.Open); RelationStackList localRelation; localRelation = (RelationStackList)serializer.ReadObject(readFile); //stats = localStats; //stats.SetFamilyTree(familyTree); readFile.Close(); if (localRelation.sourceTree != null) { if (localRelation.sourceTree != familyTree.GetSourceFileName()) { MessageBox.Show("Warning: The relation list does not seem to be from the current family tree: " + localRelation.sourceTree + " " + familyTree.GetSourceFileName()); } } ShowRelations(localRelation); ResetGui(); } }
void StartSearch() { trace.TraceInformation("ComparePanel1::StartSearch()" + DateTime.Now); if (familyTree == null) { return; } //parentForm. //startButton.Enabled = false; //dateButton.Enabled = false; resultList.Items.Clear(); trace.TraceInformation("search:" + searchTextBox.Text + " " + DateTime.Now); if (searchTextBox.Text.Length > 0) { IEnumerator <IndividualClass> iterator; searchTextBox.Items.Add(searchTextBox.Text); iterator = familyTree.SearchPerson(searchTextBox.Text); if (iterator != null) { while (iterator.MoveNext()) { IndividualClass person = (IndividualClass)iterator.Current; if (person != null) { ListViewItem item = new ListViewItem(person.GetName()); item.SubItems.AddRange(new string[] { person.GetDate(IndividualEventClass.EventType.Birth).ToString(), person.GetDate(IndividualEventClass.EventType.Death).ToString() }); item.Tag = person.GetXrefName(); resultList.Items.Add(item); } } } } trace.TraceInformation(" Database: " + familyTree.GetSourceFileName() + " " + DateTime.Now); }
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); }