public override void UpdateContents() { var source = fDataOwner as GDMSourceRecord; if (fSheetList == null || source == null) { return; } try { fSheetList.BeginUpdate(); fSheetList.ClearItems(); foreach (GDMRepositoryCitation repCit in source.RepositoryCitations) { GDMRepositoryRecord rep = repCit.Value as GDMRepositoryRecord; if (rep == null) { continue; } fSheetList.AddItem(repCit, new object[] { rep.RepositoryName }); } fSheetList.EndUpdate(); } catch (Exception ex) { Logger.LogWrite("SourceRepositoriesSublistModel.UpdateContents(): " + ex.Message); } }
public override void UpdateContents() { var source = fDataOwner as GDMSourceRecord; if (fSheetList == null || source == null) { return; } try { fSheetList.BeginUpdate(); fSheetList.ClearItems(); foreach (GDMRepositoryCitation repCit in source.RepositoryCitations) { GDMRepositoryRecord rep = fBaseContext.Tree.GetPtrValue <GDMRepositoryRecord>(repCit); if (rep == null) { continue; } fSheetList.AddItem(repCit, new object[] { rep.RepositoryName }); } fSheetList.EndUpdate(); } catch (Exception ex) { Logger.WriteError("SourceRepositoriesSublistModel.UpdateContents()", ex); } }
public override void Setup() { base.Setup(); fBase = new BaseWindowStub(); fRepositoryRecord = new GDMRepositoryRecord(fBase.Context.Tree); fDialog = new RepositoryEditDlg(fBase); fDialog.Repository = fRepositoryRecord; fDialog.Show(); }
public override void Setup() { TestUtils.InitGEDCOMProviderTest(); WFAppHost.ConfigureBootstrap(false); fBase = new BaseWindowStub(); fRepositoryRecord = new GDMRepositoryRecord(fBase.Context.Tree); fDialog = new RepositoryEditDlg(fBase); fDialog.Repository = fRepositoryRecord; fDialog.Show(); }
public static bool ModifyRepository(IBaseWindow baseWin, ref GDMRepositoryRecord repRec) { bool result; try { baseWin.Context.BeginUpdate(); GDMTree tree = baseWin.Context.Tree; using (var dlg = AppHost.ResolveDialog <IRepositoryEditDlg>(baseWin)) { bool exists = repRec != null; if (!exists) { repRec = new GDMRepositoryRecord(tree); repRec.InitNew(); } try { baseWin.Context.LockRecord(repRec); dlg.Repository = repRec; result = AppHost.Instance.ShowModalX(dlg, false); } finally { baseWin.Context.UnlockRecord(repRec); } if (!exists) { if (result) { tree.AddRecord(repRec); } else { repRec.Dispose(); repRec = null; } } } } finally { baseWin.Context.EndUpdate(); } return(result); }
public override void Modify(object sender, ModifyEventArgs eArgs) { var source = fDataOwner as GDMSourceRecord; if (fBaseWin == null || fSheetList == null || source == null) { return; } GDMRepositoryCitation cit = eArgs.ItemData as GDMRepositoryCitation; bool result = false; switch (eArgs.Action) { case RecordAction.raAdd: GDMRepositoryRecord rep = fBaseWin.Context.SelectRecord(GDMRecordType.rtRepository, null) as GDMRepositoryRecord; if (rep != null) { result = fUndoman.DoOrdinaryOperation(OperationType.otSourceRepositoryCitationAdd, source, rep); } break; case RecordAction.raDelete: if (cit != null && AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_DetachRepositoryQuery))) { var repRec = fBaseContext.Tree.GetPtrValue <GDMRepositoryRecord>(cit); result = fUndoman.DoOrdinaryOperation(OperationType.otSourceRepositoryCitationRemove, source, repRec); } break; } if (result) { fBaseWin.Context.Modified = true; eArgs.IsChanged = true; } }
public void Test_LMRepository() { var listManager = new RepositoryListMan(fContext); Assert.IsNotNull(listManager); GDMRepositoryRecord repoRec = fContext.Tree.XRefIndex_Find("R1") as GDMRepositoryRecord; listManager.Fetch(repoRec); listManager.QuickFilter = "*"; Assert.IsTrue(listManager.CheckFilter()); listManager.QuickFilter = "*repos*"; Assert.IsTrue(listManager.CheckFilter()); listManager.QuickFilter = "*xxxx*"; Assert.IsFalse(listManager.CheckFilter()); var lvMock = new ListViewMock(); listManager.UpdateColumns(lvMock); var listItem = new GKListItem("", null); listManager.UpdateItem(0, listItem, repoRec); }
private bool ProcessSourceRepositoryCitation(bool redo) { GDMSourceRecord srcRec = fObj as GDMSourceRecord; GDMRepositoryRecord repRec = fNewVal as GDMRepositoryRecord; if (srcRec == null || repRec == null) { return(false); } if (fType == OperationType.otSourceRepositoryCitationRemove) { redo = !redo; } if (redo) { srcRec.AddRepository(repRec); } else { srcRec.RemoveRepository(repRec); } return(true); }
public void Test_ShowXInfo() { StringList summary = new StringList(); summary.Clear(); GKUtils.ShowFamilyInfo(fContext, null, null); GDMFamilyRecord famRec = fContext.Tree.XRefIndex_Find("F1") as GDMFamilyRecord; GKUtils.ShowFamilyInfo(fContext, famRec, summary); summary.Clear(); GKUtils.ShowGroupInfo(null, null); GDMGroupRecord grpRec = fContext.Tree.XRefIndex_Find("G1") as GDMGroupRecord; GKUtils.ShowGroupInfo(grpRec, summary); summary.Clear(); GKUtils.ShowMultimediaInfo(null, null); GDMMultimediaRecord mmRec = fContext.Tree.XRefIndex_Find("O1") as GDMMultimediaRecord; GKUtils.ShowMultimediaInfo(mmRec, summary); summary.Clear(); GKUtils.ShowNoteInfo(null, null); GDMNoteRecord noteRec = fContext.Tree.XRefIndex_Find("N1") as GDMNoteRecord; GKUtils.ShowNoteInfo(noteRec, summary); summary.Clear(); GKUtils.ShowPersonInfo(fContext, null, null); GDMIndividualRecord indRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord; GKUtils.ShowPersonInfo(fContext, indRec, summary); summary.Clear(); GKUtils.ShowSourceInfo(null, null); GDMSourceRecord srcRec = fContext.Tree.XRefIndex_Find("S1") as GDMSourceRecord; GKUtils.ShowSourceInfo(srcRec, summary); summary.Clear(); GKUtils.ShowRepositoryInfo(null, null); GDMRepositoryRecord repRec = fContext.Tree.XRefIndex_Find("R1") as GDMRepositoryRecord; GKUtils.ShowRepositoryInfo(repRec, summary); summary.Clear(); GKUtils.ShowResearchInfo(null, null); GDMResearchRecord resRec = fContext.Tree.XRefIndex_Find("RS1") as GDMResearchRecord; GKUtils.ShowResearchInfo(resRec, summary); summary.Clear(); GKUtils.ShowTaskInfo(null, null); GDMTaskRecord taskRec = fContext.Tree.XRefIndex_Find("TK1") as GDMTaskRecord; GKUtils.ShowTaskInfo(taskRec, summary); summary.Clear(); GKUtils.ShowCommunicationInfo(null, null); GDMCommunicationRecord commRec = fContext.Tree.XRefIndex_Find("CM1") as GDMCommunicationRecord; GKUtils.ShowCommunicationInfo(commRec, summary); summary.Clear(); GKUtils.ShowLocationInfo(null, null); GDMLocationRecord locRec = fContext.Tree.XRefIndex_Find("L1") as GDMLocationRecord; GKUtils.ShowLocationInfo(locRec, summary); }
private static int ItemsCompare(GDMRepositoryRecord item1, GDMRepositoryRecord item2) { return(item1.RepositoryName.CompareTo(item2.RepositoryName)); }
public override void Fetch(GDMRecord aRec) { fRec = (aRec as GDMRepositoryRecord); }
public static void FillContext(IBaseContext context) { // a null result if the record is not defined GDMCustomEvent evt = context.CreateEventEx(null, GEDCOMTagName.BIRT, "xxxxx", "xxxxx"); Assert.IsNull(evt); // first individual (I1) GDMIndividualRecord iRec = context.CreatePersonEx("Ivan", "Ivanovich", "Ivanov", GDMSex.svMale, true); Assert.IsNotNull(iRec); evt = iRec.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evt.Date.ParseString("28 DEC 1990"); evt.Place.StringValue = "Ivanovo"; GDMCustomEvent evtd = context.CreateEventEx(iRec, GEDCOMTagName.DEAT, "28 DEC 2010", "Ivanovo"); Assert.IsNotNull(evtd); // second individual, wife (I2) GDMIndividualRecord iRec2 = context.CreatePersonEx("Maria", "Petrovna", "Ivanova", GDMSex.svFemale, true); evt = iRec2.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evt.Date.ParseString("17 MAR 1991"); evt.Place.StringValue = "Ivanovo"; iRec.AddAssociation("spouse", iRec2); // third individual, child (I3) GDMIndividualRecord iRec3 = context.CreatePersonEx("Anna", "Ivanovna", "Ivanova", GDMSex.svFemale, true); evt = iRec3.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evt.Date.ParseString("11 FEB 2010"); evt.Place.StringValue = "Ivanovo"; // their family GDMFamilyRecord famRec = context.Tree.CreateFamily(); Assert.IsNotNull(famRec); famRec.AddSpouse(iRec); famRec.AddSpouse(iRec2); famRec.AddChild(iRec3); context.CreateEventEx(famRec, GEDCOMTagName.MARR, "01 JAN 2000", "unknown"); // individual outside the family (I4) GDMIndividualRecord iRec4 = context.CreatePersonEx("Alex", "", "Petrov", GDMSex.svMale, true); evt = iRec4.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evt.Date.ParseString("15 JUN 1989"); evt.Place.StringValue = "Far Forest"; evt = context.CreateEventEx(iRec4, GEDCOMTagName.RESI, "12 FEB", "Far Forest"); Assert.IsNotNull(evt); // fifth (I5) GDMIndividualRecord iRec5 = context.CreatePersonEx("Anna", "", "Jones", GDMSex.svFemale, false); Assert.IsNotNull(iRec5); // sixth (I6) GDMIndividualRecord iRec6 = context.CreatePersonEx("Mary", "", "Jones", GDMSex.svFemale, false); Assert.IsNotNull(iRec6); evt = context.CreateEventEx(iRec6, GEDCOMTagName.BIRT, "12 FEB 1650", "Far Forest"); GDMFamilyRecord famRec2 = context.Tree.CreateFamily(); Assert.IsNotNull(famRec2); famRec2.AddSpouse(iRec3); //famRec2.AddSpouse(iRec4); famRec2.AddChild(iRec5); famRec2.AddChild(iRec6); // group for tests GDMGroupRecord groupRec = context.Tree.CreateGroup(); groupRec.GroupName = "GroupTest"; Assert.IsNotNull(groupRec, "group1 != null"); groupRec.AddMember(iRec); // location for tests GDMLocationRecord locRec = context.Tree.CreateLocation(); locRec.LocationName = "Test Location"; locRec.Map.Lati = 5.11111; locRec.Map.Long = 7.99999; Assert.IsNotNull(locRec, "locRec != null"); // repository for tests GDMRepositoryRecord repoRec = context.Tree.CreateRepository(); repoRec.RepositoryName = "Test repository"; Assert.IsNotNull(repoRec, "repoRec != null"); // research for tests GDMResearchRecord resRec = context.Tree.CreateResearch(); resRec.ResearchName = "Test research"; Assert.IsNotNull(resRec, "resRec != null"); // source for tests GDMSourceRecord srcRec = context.Tree.CreateSource(); srcRec.ShortTitle = "Test source"; Assert.IsNotNull(srcRec, "srcRec != null"); iRec.AddSource(srcRec, "p1", 0); // note for tests GDMNoteRecord noteRec = context.Tree.CreateNote(); noteRec.SetNoteText("Test note"); Assert.IsNotNull(noteRec, "noteRec != null"); iRec.AddNote(noteRec); // task for tests GDMTaskRecord tskRec = context.Tree.CreateTask(); tskRec.Goal = "Test task"; Assert.IsNotNull(tskRec, "tskRec != null"); // media for tests GDMMultimediaRecord mediaRec = context.Tree.CreateMultimedia(); mediaRec.FileReferences.Add(new GDMFileReferenceWithTitle()); GDMFileReferenceWithTitle fileRef = mediaRec.FileReferences[0]; fileRef.Title = "Test multimedia"; fileRef.LinkFile("sample.png"); Assert.IsNotNull(mediaRec, "mediaRec != null"); iRec.AddMultimedia(mediaRec); // communication for tests GDMCommunicationRecord commRec = context.Tree.CreateCommunication(); commRec.CommName = "Test communication"; Assert.IsNotNull(commRec, "commRec != null"); }
// The main method that causes the page to be created. public bool Create(Stats stats) { // Sanity check if (fSourceRecord == null) { return(false); } // Create the strings to use for the HTML file. string pageDescription = "GEDmill GEDCOM to HTML page for " + fSourceRecord.ShortTitle; string keywords = "family tree history " + fSourceRecord.ShortTitle; string filename = string.Concat(CConfig.Instance.OutputFolder, "\\sour", fSourceRecord.XRef); string fullFilename = string.Concat(filename, ".", CConfig.Instance.HtmlExtension); HTMLFile f = null; try { // Create a new file with an HTML header. f = new HTMLFile(fullFilename, fSourceRecord.ShortTitle, pageDescription, keywords); // Create a navbar to main site, front page etc. OutputPageHeader(f, "", "", true, true); f.WriteLine(" <div class=\"hr\" />"); f.WriteLine(""); f.WriteLine(" <div id=\"page\"> <!-- page -->"); // Write the page's title text. f.WriteLine(" <div id=\"main\">"); f.WriteLine(" <div id=\"summary\">"); f.WriteLine(" <div id=\"names\">"); string sourName = fSourceRecord.ShortTitle; if (sourName == "") { sourName = "Source "; bool gotSourceName = false; // Try user reference number foreach (var userRef in fSourceRecord.UserReferences) { if (userRef.StringValue != "") { sourName += userRef.StringValue; gotSourceName = true; break; } } if (!gotSourceName && fSourceRecord.AutomatedRecordID != null && fSourceRecord.AutomatedRecordID != "") { sourName += fSourceRecord.AutomatedRecordID; } else if (!gotSourceName) { sourName += fSourceRecord.XRef; } } f.WriteLine("<h1>{0}</h1>", EscapeHTML(sourName, false)); // Add repository information foreach (var sourCit in fSourceRecord.RepositoryCitations) { GDMRepositoryRecord repoRec = fTree.GetPtrValue <GDMRepositoryRecord>(sourCit); if (repoRec != null) { if (!string.IsNullOrEmpty(repoRec.RepositoryName)) { f.WriteLine("<h2>{0}</h2>", EscapeHTML(repoRec.RepositoryName, false)); } foreach (GDMNotes ns in repoRec.Notes) { WriteNotes(f, ns); } } foreach (GDMNotes ns in sourCit.Notes) { WriteNotes(f, ns); } } // Add Publication Information string pubFacts; if (CConfig.Instance.ObfuscateEmails) { pubFacts = ObfuscateEmail(fSourceRecord.Publication.Lines.Text); } else { pubFacts = fSourceRecord.Publication.Lines.Text; } if (!string.IsNullOrEmpty(pubFacts)) { if (pubFacts.Length > 7 && pubFacts.ToUpper().Substring(0, 7) == "HTTP://") { f.WriteLine("<h2><a href=\"{0}\">{1}</a></h2>", pubFacts, EscapeHTML(pubFacts, false)); } else { f.WriteLine("<h2>{0}</h2>", EscapeHTML(pubFacts, false)); } } f.WriteLine(" </div> <!-- names -->"); f.WriteLine(" </div> <!-- summary -->"); // Collect together multimedia links. if (CConfig.Instance.AllowMultimedia) { // Fill m_alMultimediaList: AddMultimedia(fSourceRecord.MultimediaLinks, string.Concat(fSourceRecord.XRef, "mms"), string.Concat(fSourceRecord.XRef, "mos"), CConfig.Instance.MaxSourceImageWidth, CConfig.Instance.MaxSourceImageHeight, stats); } // Add pics OutputMultimedia(f); // Add textFromSource string cleanText = fSourceRecord.Text.Lines.Text; if (CConfig.Instance.ObfuscateEmails) { cleanText = ObfuscateEmail(cleanText); } if (!string.IsNullOrEmpty(cleanText)) { f.WriteLine(" <div id=\"text\">"); f.WriteLine(" <h1>Text</h1>"); f.WriteLine(" <p class=\"pretext\">"); f.WriteLine(EscapeHTML(cleanText, false)); f.WriteLine(" </p>"); f.WriteLine(" </div> <!-- text -->"); } // Add notes OutputNotes(f, fSourceRecord.Notes); if (!CConfig.Instance.SupressBackreferences) { f.WriteLine(" <div id=\"citations\">"); f.WriteLine(" <h1>Citations</h1>"); f.WriteLine(" <ul>"); var htBackrefs = GMHelper.MakeBackReferences(fSourceRecord); IDictionaryEnumerator enumerator = htBackrefs.GetEnumerator(); while (enumerator.MoveNext()) { GDMIndividualRecord ir = (GDMIndividualRecord)(enumerator.Value); if (ir != null && GMHelper.GetVisibility(ir)) { string link = MakeLink(ir); if (link != "") { f.WriteLine("<li>{0}</li>", link); } } } f.WriteLine(" </ul>"); f.WriteLine(" </div> <!-- citations -->"); } f.WriteLine(" </div> <!-- main -->"); // Add footer (Record date, W3C sticker, GEDmill credit etc.) OutputFooter(f, fSourceRecord); f.WriteLine(" </div> <!-- page -->"); } catch (IOException e) { fLogger.WriteError("Caught IO Exception(6) : ", e); } catch (ArgumentException e) { fLogger.WriteError("Caught Argument Exception(6) : ", e); } finally { if (f != null) { f.Close(); // Adds standard footer to the file } } return(true); }
public static bool EditRecord(IBaseWindow baseWin, GDMRecord rec) { bool result = false; switch (rec.RecordType) { case GDMRecordType.rtIndividual: GDMIndividualRecord ind = rec as GDMIndividualRecord; result = ModifyIndividual(baseWin, ref ind, null, TargetMode.tmNone, GDMSex.svUnknown); break; case GDMRecordType.rtFamily: GDMFamilyRecord fam = rec as GDMFamilyRecord; result = ModifyFamily(baseWin, ref fam, TargetMode.tmNone, null); break; case GDMRecordType.rtNote: GDMNoteRecord note = rec as GDMNoteRecord; result = ModifyNote(baseWin, ref note); break; case GDMRecordType.rtMultimedia: GDMMultimediaRecord mmRec = rec as GDMMultimediaRecord; result = ModifyMedia(baseWin, ref mmRec); break; case GDMRecordType.rtSource: GDMSourceRecord src = rec as GDMSourceRecord; result = ModifySource(baseWin, ref src); break; case GDMRecordType.rtRepository: GDMRepositoryRecord rep = rec as GDMRepositoryRecord; result = ModifyRepository(baseWin, ref rep); break; case GDMRecordType.rtGroup: GDMGroupRecord grp = rec as GDMGroupRecord; result = ModifyGroup(baseWin, ref grp); break; case GDMRecordType.rtResearch: GDMResearchRecord rsr = rec as GDMResearchRecord; result = ModifyResearch(baseWin, ref rsr); break; case GDMRecordType.rtTask: GDMTaskRecord tsk = rec as GDMTaskRecord; result = ModifyTask(baseWin, ref tsk); break; case GDMRecordType.rtCommunication: GDMCommunicationRecord comm = rec as GDMCommunicationRecord; result = ModifyCommunication(baseWin, ref comm); break; case GDMRecordType.rtLocation: GDMLocationRecord loc = rec as GDMLocationRecord; result = ModifyLocation(baseWin, ref loc); break; } return(result); }
public static GDMRecord AddRecord(IBaseWindow baseWin, GDMRecordType rt, Target target) { bool result = false; GDMRecord rec = null; switch (rt) { case GDMRecordType.rtIndividual: { // FIXME: legacy code, checkit if (target == null) { target = new Target(); target.TargetMode = TargetMode.tmParent; } GDMIndividualRecord indivRec = null; result = ModifyIndividual(baseWin, ref indivRec, target.TargetIndividual, target.TargetMode, target.NeedSex); rec = indivRec; break; } case GDMRecordType.rtFamily: { if (target == null) { target = new Target(); } TargetMode famTarget = (target.TargetMode != TargetMode.tmFamilyChild) ? TargetMode.tmNone : target.TargetMode; GDMFamilyRecord fam = null; result = ModifyFamily(baseWin, ref fam, famTarget, target.TargetIndividual); rec = fam; break; } case GDMRecordType.rtNote: { GDMNoteRecord note = null; result = ModifyNote(baseWin, ref note); rec = note; break; } case GDMRecordType.rtMultimedia: { GDMMultimediaRecord mmRec = null; result = ModifyMedia(baseWin, ref mmRec); rec = mmRec; break; } case GDMRecordType.rtSource: { GDMSourceRecord src = null; result = ModifySource(baseWin, ref src); rec = src; break; } case GDMRecordType.rtRepository: { GDMRepositoryRecord rep = null; result = ModifyRepository(baseWin, ref rep); rec = rep; break; } case GDMRecordType.rtGroup: { GDMGroupRecord grp = null; result = ModifyGroup(baseWin, ref grp); rec = grp; break; } case GDMRecordType.rtResearch: { GDMResearchRecord rsr = null; result = ModifyResearch(baseWin, ref rsr); rec = rsr; break; } case GDMRecordType.rtTask: { GDMTaskRecord tsk = null; result = ModifyTask(baseWin, ref tsk); rec = tsk; break; } case GDMRecordType.rtCommunication: { GDMCommunicationRecord comm = null; result = ModifyCommunication(baseWin, ref comm); rec = comm; break; } case GDMRecordType.rtLocation: { GDMLocationRecord loc = null; result = ModifyLocation(baseWin, ref loc); rec = loc; break; } } return((result) ? rec : null); }