public GDMMultimediaLink SetPrimaryMultimediaLink(GDMMultimediaRecord mediaRec) { if (mediaRec == null) { return(null); } GDMMultimediaLink mmLink = null; int num = MultimediaLinks.Count; for (int i = 0; i < num; i++) { GDMMultimediaLink lnk = MultimediaLinks[i]; if (lnk.Value == mediaRec) { mmLink = lnk; break; } } if (mmLink == null) { mmLink = this.AddMultimedia(mediaRec); } mmLink.IsPrimary = true; return(mmLink); }
private static void GEDCOMMultimediaLinkTest(GDMMultimediaRecord mediaRec, GDMIndividualRecord indiv) { GDMMultimediaLink mmLink = indiv.AddMultimedia(mediaRec); Assert.IsNotNull(mmLink.FileReferences); mmLink.Title = "Title1"; Assert.AreEqual("Title1", mmLink.Title); string buf = TestUtils.GetTagStreamText(mmLink, 1); Assert.AreEqual("1 OBJE @O2@\r\n" + "2 TITL Title1\r\n", buf); mmLink.ReplaceXRefs(new GDMXRefReplacer()); Assert.IsTrue(mmLink.IsPointer, "mmLink.IsPointer"); mmLink.IsPrimary = true; Assert.IsTrue(mmLink.IsPrimary, "mmLink.IsPrimary"); Assert.IsFalse(mmLink.IsEmpty(), "mmLink.IsEmpty()"); // its pointer mmLink.Clear(); }
public void Test_GEDCOMMultimediaLink() { var iRec = new GDMIndividualRecord(fContext.Tree); using (GDMMultimediaLink mmLink = new GDMMultimediaLink()) { Assert.IsNotNull(mmLink); Assert.IsTrue(mmLink.IsEmpty()); // extensions Assert.IsFalse(mmLink.IsPrimaryCutout); mmLink.IsPrimaryCutout = true; Assert.IsTrue(mmLink.IsPrimaryCutout); mmLink.CutoutPosition.Value = ExtRect.Create(10, 15, 500, 600); ExtRect rt = mmLink.CutoutPosition.Value; Assert.AreEqual(10, rt.Left); Assert.AreEqual(15, rt.Top); Assert.AreEqual(500, rt.Right); Assert.AreEqual(600, rt.Bottom); Assert.AreEqual(10, mmLink.CutoutPosition.X1); Assert.AreEqual(15, mmLink.CutoutPosition.Y1); Assert.AreEqual(500, mmLink.CutoutPosition.X2); Assert.AreEqual(600, mmLink.CutoutPosition.Y2); mmLink.CutoutPosition.X1 = 10; mmLink.CutoutPosition.Y1 = 10; mmLink.CutoutPosition.X2 = 300; mmLink.CutoutPosition.Y2 = 400; Assert.AreEqual(10, mmLink.CutoutPosition.X1); Assert.AreEqual(10, mmLink.CutoutPosition.Y1); Assert.AreEqual(300, mmLink.CutoutPosition.X2); Assert.AreEqual(400, mmLink.CutoutPosition.Y2); mmLink.CutoutPosition.ParseString("11 15 576 611"); Assert.IsFalse(mmLink.CutoutPosition.IsEmpty()); Assert.AreEqual("11 15 576 611", mmLink.CutoutPosition.StringValue); Assert.Throws(typeof(ArgumentException), () => { mmLink.Assign(null); }); using (var mmRec = new GDMMultimediaRecord(fContext.Tree)) { fContext.Tree.NewXRef(mmRec); Assert.IsNull(mmLink.GetUID(fContext.Tree)); mmLink.XRef = mmRec.XRef; Assert.IsNotNull(mmLink.GetUID(fContext.Tree)); } mmLink.CutoutPosition.Clear(); Assert.IsTrue(mmLink.CutoutPosition.IsEmpty()); Assert.AreEqual("", mmLink.CutoutPosition.StringValue); } }
public GDMMultimediaLink AddMultimedia(GDMMultimediaRecord mediaRec) { GDMMultimediaLink mmLink = null; if (mediaRec != null) { mmLink = new GDMMultimediaLink(this); mmLink.Value = mediaRec; fMultimediaLinks.Add(mmLink); } return(mmLink); }
public override void Assign(GDMTag source) { GDMMultimediaLink sourceObj = (source as GDMMultimediaLink); if (sourceObj == null) { throw new ArgumentException(@"Argument is null or wrong type", "source"); } base.Assign(sourceObj); fCutoutPosition = sourceObj.fCutoutPosition; AssignList(sourceObj.fFileReferences, fFileReferences); fIsPrimary = sourceObj.fIsPrimary; fIsPrimaryCutout = sourceObj.fIsPrimaryCutout; fTitle = sourceObj.fTitle; }
public GDMMultimediaLink GetPrimaryMultimediaLink() { GDMMultimediaLink result = null; int num = MultimediaLinks.Count; for (int i = 0; i < num; i++) { GDMMultimediaLink mmLink = MultimediaLinks[i]; if (mmLink.IsPrimary) { result = mmLink; break; } } return(result); }
public void Test_Common() { GDMIndividualRecord iRec = fContext.Tree.XRefIndex_Find("I1") as GDMIndividualRecord; GDMCustomEvent evt, evtd; GEDCOMRecordTest(iRec); evt = iRec.FindEvent(GEDCOMTagType.BIRT); Assert.IsNotNull(evt); evtd = iRec.FindEvent(GEDCOMTagType.DEAT); Assert.IsNotNull(evtd); Assert.IsFalse(iRec.IsLive()); GDMIndividualRecord ind3 = fContext.Tree.XRefIndex_Find("I3") as GDMIndividualRecord; Assert.IsNotNull(ind3.GetParentsFamily()); GDMIndividualRecord ind2 = fContext.Tree.XRefIndex_Find("I2") as GDMIndividualRecord; Assert.IsNotNull(ind2.GetMarriageFamily()); // GDMIndividualRecord indiRec = fContext.Tree.XRefIndex_Find("I4") as GDMIndividualRecord; Assert.IsNull(indiRec.GetMarriageFamily()); Assert.IsNotNull(indiRec.GetMarriageFamily(true)); // Assert.Throws(typeof(ArgumentException), () => { indiRec.Assign(null); }); indiRec.AutomatedRecordID = "test11"; Assert.AreEqual("test11", indiRec.AutomatedRecordID); Assert.AreEqual(GDMRecordType.rtIndividual, indiRec.RecordType); Assert.AreEqual(4, indiRec.GetId()); Assert.AreEqual("4", indiRec.GetXRefNum()); Assert.AreEqual(-1, indiRec.IndexOfSource(null)); indiRec.AddUserRef("test userref"); Assert.AreEqual("test userref", indiRec.UserReferences[0].StringValue); // Assert.IsNotNull(indiRec.Aliases); Assert.IsNotNull(indiRec.Associations); Assert.IsNotNull(indiRec.UserReferences); // for GEDCOMRecord Assert.Throws(typeof(ArgumentException), () => { indiRec.AddEvent(new GDMFamilyEvent(null)); }); GDMIndividualRecord father, mother; GDMFamilyRecord fam = indiRec.GetParentsFamily(); if (fam == null) { father = null; mother = null; } else { father = fam.Husband.Individual; mother = fam.Wife.Individual; } Assert.IsNull(father); Assert.IsNull(mother); indiRec.Sex = GDMSex.svMale; Assert.AreEqual(GDMSex.svMale, indiRec.Sex); indiRec.Restriction = GDMRestriction.rnLocked; Assert.AreEqual(GDMRestriction.rnLocked, indiRec.Restriction); indiRec.Patriarch = true; Assert.AreEqual(true, indiRec.Patriarch); indiRec.Patriarch = false; Assert.AreEqual(false, indiRec.Patriarch); indiRec.Bookmark = true; Assert.AreEqual(true, indiRec.Bookmark); indiRec.Bookmark = false; Assert.AreEqual(false, indiRec.Bookmark); Assert.Throws(typeof(ArgumentException), () => { indiRec.MoveTo(null, false); }); using (GDMIndividualRecord copyIndi = new GDMIndividualRecord(null)) { Assert.IsNotNull(copyIndi); Assert.Throws(typeof(ArgumentException), () => { copyIndi.Assign(null); }); copyIndi.Assign(indiRec); Assert.AreEqual(100.0f, indiRec.IsMatch(copyIndi, new MatchParams())); } Assert.IsFalse(indiRec.IsEmpty()); indiRec.Clear(); Assert.IsTrue(indiRec.IsEmpty()); float ca = indiRec.GetCertaintyAssessment(); Assert.AreEqual(0.0f, ca); Assert.IsNull(indiRec.GetPrimaryMultimediaLink()); GDMMultimediaLink mmLink = indiRec.SetPrimaryMultimediaLink(null); Assert.IsNull(mmLink); GDMMultimediaRecord mmRec = fContext.Tree.CreateMultimedia(); mmLink = indiRec.SetPrimaryMultimediaLink(mmRec); Assert.IsNotNull(mmLink); mmLink = indiRec.GetPrimaryMultimediaLink(); Assert.AreEqual(mmRec, mmLink.Value); Assert.AreEqual(-1, indiRec.IndexOfGroup(null)); Assert.AreEqual(-1, indiRec.IndexOfSpouse(null)); GDMIndividualRecord indi2 = fContext.Tree.XRefIndex_Find("I2") as GDMIndividualRecord; GDMAssociation asso = indiRec.AddAssociation("test", indi2); Assert.IsNotNull(asso); using (GDMIndividualRecord indi = new GDMIndividualRecord(fContext.Tree)) { Assert.IsNotNull(indi); var parts = GKUtils.GetNameParts(indi); // test with empty PersonalNames Assert.AreEqual("", parts.Surname); Assert.AreEqual("", parts.Name); Assert.AreEqual("", parts.Patronymic); indi.AddPersonalName(new GDMPersonalName(indi)); // test with empty Name parts = GKUtils.GetNameParts(indi); Assert.AreEqual("", parts.Surname); Assert.AreEqual("", parts.Name); Assert.AreEqual("", parts.Patronymic); indi.PersonalNames.Clear(); string st; Assert.AreEqual("", GKUtils.GetNameString(indi, true, false)); Assert.AreEqual("", GKUtils.GetNickString(indi)); GDMPersonalName pName = new GDMPersonalName(indi); indi.AddPersonalName(pName); pName.Pieces.Nickname = "BigHead"; pName.SetNameParts("Ivan", "Petrov", ""); st = GKUtils.GetNameString(indi, true, true); Assert.AreEqual("Petrov Ivan [BigHead]", st); st = GKUtils.GetNameString(indi, false, true); Assert.AreEqual("Ivan Petrov [BigHead]", st); Assert.AreEqual("BigHead", GKUtils.GetNickString(indi)); Assert.IsNull(indi.GetParentsFamily()); Assert.IsNotNull(indi.GetParentsFamily(true)); // MoveTo test GDMIndividualRecord ind = fContext.Tree.XRefIndex_Find("I2") as GDMIndividualRecord; indi.AddAssociation("test", ind); indi.Aliases.Add(new GDMAlias(indi)); using (GDMIndividualRecord indi3 = new GDMIndividualRecord(fContext.Tree)) { indi.MoveTo(indi3, false); st = GKUtils.GetNameString(indi3, true, true); Assert.AreEqual("Petrov Ivan [BigHead]", st); } indi.ResetOwner(fContext.Tree); Assert.AreEqual(fContext.Tree, indi.GetTree()); } indiRec.ReplaceXRefs(new GDMXRefReplacer()); }
public void Test_Common() { using (GDMIndividualAttribute customEvent = new GDMIndividualAttribute()) { Assert.IsNotNull(customEvent); Assert.IsNotNull(customEvent.Address); customEvent.Date.ParseString("28 DEC 1990"); string dateTest = "28.12.1990"; Assert.AreEqual(TestUtils.ParseDT(dateTest), customEvent.Date.GetDateTime()); Assert.AreEqual(1990, customEvent.GetChronologicalYear()); Assert.AreEqual(TestUtils.ParseDT(dateTest), customEvent.Date.Date); customEvent.Place.ParseString("Ivanovo"); Assert.AreEqual("Ivanovo", customEvent.Place.StringValue); Assert.IsNotNull(customEvent.Place); customEvent.Agency = "test agency"; Assert.AreEqual("test agency", customEvent.Agency); customEvent.Classification = "test type"; Assert.AreEqual("test type", customEvent.Classification); customEvent.Cause = "test cause"; Assert.AreEqual("test cause", customEvent.Cause); customEvent.ReligiousAffilation = "test aff"; Assert.AreEqual("test aff", customEvent.ReligiousAffilation); customEvent.Restriction = GDMRestriction.rnLocked; Assert.AreEqual(GDMRestriction.rnLocked, customEvent.Restriction); GDMLines strs = new GDMLines("test"); customEvent.PhysicalDescription = strs; Assert.AreEqual(strs.Text, customEvent.PhysicalDescription.Text); customEvent.Address.AddEmailAddress("email"); Assert.AreEqual("email", customEvent.Address.EmailAddresses[0].StringValue); } using (GDMIndividualEvent customEvent = new GDMIndividualEvent()) { Assert.IsNotNull(customEvent); // stream test customEvent.SetName(GEDCOMTagName.BIRT); customEvent.Date.ParseString("20 SEP 1970"); customEvent.Place.StringValue = "test place"; customEvent.Agency = "Agency"; customEvent.Classification = "custom"; customEvent.ReligiousAffilation = "rel_aff"; customEvent.Cause = "Cause"; customEvent.Address.AddressLine1 = "adr1"; customEvent.Restriction = GDMRestriction.rnConfidential; var note = new GDMNotes(); note.Lines.Text = "event notes"; customEvent.Notes.Add(note); var sourCit = new GDMSourceCitation(); sourCit.Description.Text = "event sour desc"; customEvent.SourceCitations.Add(sourCit); var mmLink = new GDMMultimediaLink(); mmLink.Title = "event media title"; customEvent.MultimediaLinks.Add(mmLink); using (GDMIndividualEvent copyEvent = new GDMIndividualEvent()) { Assert.IsNotNull(copyEvent); copyEvent.Assign(customEvent); var iRec = new GDMIndividualRecord(null); iRec.Events.Add(copyEvent); string buf1 = TestUtils.GetTagStreamText(iRec, 0); Assert.AreEqual("0 INDI\r\n" + "1 SEX U\r\n" + "1 BIRT\r\n" + "2 TYPE custom\r\n" + "2 DATE 20 SEP 1970\r\n" + "2 PLAC test place\r\n" + "2 ADDR\r\n" + "3 ADR1 adr1\r\n" + "2 CAUS Cause\r\n" + "2 AGNC Agency\r\n" + "2 RELI rel_aff\r\n" + "2 RESN confidential\r\n" + "2 NOTE event notes\r\n" + "2 SOUR event sour desc\r\n" + "2 OBJE\r\n" + "3 TITL event media title\r\n", buf1); } customEvent.Address.AddEmailAddress("email"); Assert.AreEqual("email", customEvent.Address.EmailAddresses[0].StringValue); } using (GDMFamilyEvent customEvent = new GDMFamilyEvent()) { Assert.IsNotNull(customEvent); customEvent.Address.AddEmailAddress("email"); Assert.AreEqual("email", customEvent.Address.EmailAddresses[0].StringValue); } }