public void SetFlag(PersonFlag flag) { fFlags.Include(flag); }
public void BuildBy(GDMIndividualRecord iRec) { try { fRec = iRec; if (iRec != null) { if (fModel.PreparedIndividuals.IndexOf(iRec.XRef) < 0) { fModel.PreparedIndividuals.Add(iRec.XRef); } var parts = GKUtils.GetNameParts(fModel.Base.Context.Tree, iRec); fSurname = parts.Surname; fName = parts.Name; fPatronymic = parts.Patronymic; fNick = GKUtils.GetNickString(iRec); fSex = iRec.Sex; TreeChartOptions options = fModel.Options; var lifeDates = iRec.GetLifeDates(); DateFormat dateFormat = (options.OnlyYears) ? DateFormat.dfYYYY : DateFormat.dfDD_MM_YYYY; IsDead = (lifeDates.DeathEvent != null); fBirthDate = GKUtils.GEDCOMEventToDateStr(lifeDates.BirthEvent, dateFormat, false); fDeathDate = GKUtils.GEDCOMEventToDateStr(lifeDates.DeathEvent, dateFormat, false); if (!options.OnlyYears) { if (options.ShowPlaces) { fBirthPlace = GKUtils.GetPlaceStr(lifeDates.BirthEvent, false); if (!string.IsNullOrEmpty(fBirthPlace) && !options.SeparateDatesAndPlacesLines) { if (!string.IsNullOrEmpty(fBirthDate)) { fBirthDate += ", "; } fBirthDate += fBirthPlace; } fDeathPlace = GKUtils.GetPlaceStr(lifeDates.DeathEvent, false); if (!string.IsNullOrEmpty(fDeathPlace) && !options.SeparateDatesAndPlacesLines) { if (!string.IsNullOrEmpty(fDeathDate)) { fDeathDate += ", "; } fDeathDate += fDeathPlace; } } if (!string.IsNullOrEmpty(fBirthDate)) { fBirthDate = ImportUtils.STD_BIRTH_SIGN + " " + fBirthDate; } if (!string.IsNullOrEmpty(fDeathDate)) { fDeathDate = ImportUtils.STD_DEATH_SIGN + " " + fDeathDate; } } if (options.SignsVisible) { EnumSet <SpecialUserRef> signs = EnumSet <SpecialUserRef> .Create(); int num = fRec.UserReferences.Count; for (int i = 0; i < num; i++) { string rs = fRec.UserReferences[i].StringValue; for (var cps = SpecialUserRef.urRI_StGeorgeCross; cps <= SpecialUserRef.urLast; cps++) { string sur = LangMan.LS(GKData.SpecialUserRefs[(int)cps].Title); if (rs == sur) { signs.Include(cps); } } } fSigns = signs; } else { fSigns = EnumSet <SpecialUserRef> .Create(); } if (options.PortraitsVisible) { try { fPortrait = PortraitsCache.Instance.GetImage(fModel.Base.Context, iRec); if (fPortrait == null && options.DefaultPortraits) { string resName = (fSex == GDMSex.svFemale) ? "pi_female_140.png" : "pi_male_140.png"; fPortrait = AppHost.GfxProvider.LoadResourceImage(resName, false); } } catch (MediaFileNotFoundException) { if (!fModel.HasMediaFail) { AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_MediaFileNotLoaded)); fModel.HasMediaFail = true; } } } CertaintyAssessment = iRec.GetCertaintyAssessment(); } else { fSurname = ""; fName = "< ? >"; fPatronymic = ""; fNick = ""; fBirthDate = ""; fBirthPlace = ""; fDeathDate = ""; fDeathPlace = ""; IsDead = false; fSex = GDMSex.svUnknown; fSigns = EnumSet <SpecialUserRef> .Create(); CertaintyAssessment = 0.0f; } } catch (Exception ex) { Logger.WriteError("TreeChartPerson.BuildBy()", ex); throw; } }
public void Test_Common() { EnumSet <RestrictionEnum> es = EnumSet <RestrictionEnum> .Create(); Assert.IsTrue(es.IsEmpty()); es.Include(null); Assert.IsTrue(es.IsEmpty()); es.Include(RestrictionEnum.rnPrivacy, RestrictionEnum.rnLocked); Assert.IsTrue(es.Contains(RestrictionEnum.rnPrivacy)); Assert.IsFalse(es.Contains(RestrictionEnum.rnNone)); Assert.IsFalse(es.IsEmpty()); es.Exclude(RestrictionEnum.rnPrivacy); Assert.IsFalse(es.Contains(RestrictionEnum.rnPrivacy)); Assert.IsTrue(es.Contains(RestrictionEnum.rnLocked)); es = EnumSet <RestrictionEnum> .Create(RestrictionEnum.rnNone, RestrictionEnum.rnLocked); Assert.IsTrue(es.Contains(RestrictionEnum.rnNone)); Assert.IsTrue(es.Contains(RestrictionEnum.rnLocked)); string test = es.ToString().Substring(64 - 8); Assert.AreEqual("00000011", test); // clone test EnumSet <RestrictionEnum> copy = (EnumSet <RestrictionEnum>)es.Clone(); test = copy.ToString().Substring(64 - 8); Assert.AreEqual("00000011", test); // clear test copy.Clear(); Assert.IsTrue(copy.IsEmpty()); // EnumSet <RestrictionEnum> es2 = EnumSet <RestrictionEnum> .Create(RestrictionEnum.rnNone, RestrictionEnum.rnLocked); Assert.IsTrue(es.Equals(es2)); Assert.IsFalse(es.Equals(null)); Assert.IsTrue(es.Contains(RestrictionEnum.rnLocked)); Assert.IsFalse(es.Contains(RestrictionEnum.rnPrivacy)); EnumSet <RestrictionEnum> es3 = EnumSet <RestrictionEnum> .Create(RestrictionEnum.rnLocked); EnumSet <RestrictionEnum> es4 = es * es3; Assert.IsTrue(es4.Contains(RestrictionEnum.rnLocked)); es = EnumSet <RestrictionEnum> .Create(RestrictionEnum.rnNone); es2 = EnumSet <RestrictionEnum> .Create(RestrictionEnum.rnLocked); Assert.IsTrue(es != es2); es = es + es2; es3 = EnumSet <RestrictionEnum> .Create(RestrictionEnum.rnNone, RestrictionEnum.rnLocked); Assert.IsTrue(es.Equals(es3)); Assert.IsFalse(es3.ContainsAll(new RestrictionEnum[] {})); Assert.IsTrue(es3.ContainsAll(RestrictionEnum.rnNone, RestrictionEnum.rnLocked)); Assert.IsFalse(es3.ContainsAll(RestrictionEnum.rnNone, RestrictionEnum.rnPrivacy)); Assert.IsFalse(es3.HasIntersect(new RestrictionEnum[] {})); Assert.IsTrue(es3.HasIntersect(RestrictionEnum.rnNone, RestrictionEnum.rnPrivacy)); Assert.IsFalse(es3.HasIntersect(RestrictionEnum.rnPrivacy)); es = es - es2; es3 = EnumSet <RestrictionEnum> .Create(RestrictionEnum.rnNone); Assert.IsTrue(es == es3); Assert.AreEqual("0000000000000000000000000000000000000000000000000000000000000001", es3.ToString()); Assert.AreNotEqual(0, es3.GetHashCode()); }