private static void CheckFamilyRecord(IBaseContext baseContext, GDMTree tree, GEDCOMFormat format, GDMFamilyRecord fam) { for (int i = 0, num = fam.Events.Count; i < num; i++) { GDMCustomEvent evt = fam.Events[i]; CheckEvent(tree, format, evt); } for (int i = fam.Children.Count - 1; i >= 0; i--) { if (fam.Children[i].Value == null) { fam.Children.DeleteAt(i); } } GDMRecord val = fam.Husband.Value; if (!string.IsNullOrEmpty(fam.Husband.XRef) && val == null) { fam.Husband.Value = null; } val = fam.Wife.Value; if (!string.IsNullOrEmpty(fam.Wife.XRef) && val == null) { fam.Wife.Value = null; } }
private AncPersonSegment TraverseAncestors(GDMIndividualRecord iRec, float v, int gen, float rad, float ro, int prevSteps, int groupIndex) { try { fIndividualsCount++; if (fGroupsMode && groupIndex == -1) { AncPersonSegment otherSegment = (AncPersonSegment)FindSegmentByRec(iRec); if (otherSegment != null) { fGroupCount++; groupIndex = fGroupCount; TraverseGroups(otherSegment, groupIndex); } } int genSize = 1 << gen; float ang = (360.0f / genSize); int idx = prevSteps + (int)(v / ang); AncPersonSegment segment = SetSegmentParams(idx, iRec, rad, groupIndex); if (segment != null && gen < fVisibleGenerations) { float inRad = rad; float extRad = rad + fGenWidth; segment.IntRad = inRad - 50; segment.ExtRad = extRad - 50; GDMIndividualRecord father = null, mother = null; GDMFamilyRecord fam = fBase.Context.Tree.GetParentsFamily(iRec); if (fam != null && fBase.Context.IsRecordAccess(fam.Restriction)) { fBase.Context.Tree.GetSpouses(fam, out father, out mother); } int ps = prevSteps + genSize; if (father != null) { v -= (Math.Abs(ang - ro) / 2.0f); segment.FatherSegment = TraverseAncestors(father, v, gen + 1, rad + fGenWidth, ro / 2.0f, ps, groupIndex); } if (mother != null) { v += (ang / 2.0f); segment.MotherSegment = TraverseAncestors(mother, v, gen + 1, rad + fGenWidth, ro / 2.0f, ps, groupIndex); } } return(segment); } catch { return(null); } }
public void ImportNames(GDMIndividualRecord iRec) { if (iRec == null) { return; } try { string childName, childPat; var parts = GKUtils.GetNameParts(iRec, false); childName = parts.Name; childPat = parts.Patronymic; GDMSex iSex = iRec.Sex; SetNameSex(childName, iSex); GDMFamilyRecord fam = iRec.GetParentsFamily(); GDMIndividualRecord father = (fam == null) ? null : fam.Husband.Individual; if (father != null) { string fatherName; parts = GKUtils.GetNameParts(father, false); fatherName = parts.Name; if (IsComparable(fatherName, childPat)) { SetName(fatherName, childPat, iSex); } } } catch (Exception ex) { Logger.LogWrite("NamesTable.ImportName(): " + ex.Message); } }
private void CheckChildLink(GDMFamilyRecord fam, int index) { GDMIndividualLink childLink = fam.Children[index]; var childRec = fTree.GetPtrValue <GDMIndividualRecord>(childLink); if (childRec == null) { fam.Children.DeleteAt(index); return; } if (fFormat == GEDCOMFormat.gf_AGES) { var frelTag = FindSubTagValue(childLink, "_FREL"); var mrelTag = FindSubTagValue(childLink, "_MREL"); if (frelTag == "ADOPTED" && mrelTag == "ADOPTED") { GDMChildToFamilyLink ctfLink = childRec.FindChildToFamilyLink(fam); ctfLink.PedigreeLinkageType = GDMPedigreeLinkageType.plAdopted; childLink.DeleteTag("_FREL"); childLink.DeleteTag("_MREL"); } } }
private GDMFamilyRecord GetParentsFamily(GDMIndividualRecord father, GDMIndividualRecord mother) { GDMFamilyRecord result = null; string fatherXRef = (father == null) ? string.Empty : father.XRef; string motherXRef = (mother == null) ? string.Empty : mother.XRef; var famEnum = fTree.GetEnumerator(GDMRecordType.rtFamily); GDMRecord record; while (famEnum.MoveNext(out record)) { var famRec = record as GDMFamilyRecord; if (famRec.Husband.XRef == fatherXRef && famRec.Wife.XRef == motherXRef) { result = famRec; break; } } if (result == null) { result = fTree.CreateFamily(); result.AddSpouse(father); result.AddSpouse(mother); } return(result); }
private static void PL_WalkDescLinks(Graph graph, PGNode prevNode, GDMIndividualRecord ancestor) { for (int i = 0, count = ancestor.SpouseToFamilyLinks.Count; i < count; i++) { GDMFamilyRecord family = ancestor.SpouseToFamilyLinks[i].Family; PGNode node = family.ExtData as PGNode; if (node != null && node.Type != PGNodeType.Default) { Vertex vtx = graph.FindVertex(node.FamilyXRef); if (vtx == null) { vtx = graph.AddVertex(node.FamilyXRef, node); } if (prevNode != null) { graph.AddDirectedEdge(prevNode.FamilyXRef, node.FamilyXRef, 1, null); } prevNode = node; } for (int k = 0, count2 = family.Children.Count; k < count2; k++) { GDMIndividualRecord child = family.Children[k].Individual; PL_WalkDescLinks(graph, prevNode, child); } } }
public object gt_get_family_wife(object recPtr) { GDMFamilyRecord fam = recPtr as GDMFamilyRecord; recPtr = (fam == null) ? null : fam.Wife.Value; return(recPtr); }
public override void UpdateContents() { var iRec = fDataOwner as GDMIndividualRecord; if (fSheetList == null || iRec == null) { return; } try { fSheetList.BeginUpdate(); fSheetList.ClearItems(); foreach (GDMChildToFamilyLink cfLink in iRec.ChildToFamilyLinks) { GDMFamilyRecord famRec = fBaseContext.Tree.GetPtrValue(cfLink); fSheetList.AddItem(cfLink, new object[] { GKUtils.GetFamilyString(fBaseContext.Tree, famRec), LangMan.LS(GKData.ParentTypes[(int)cfLink.PedigreeLinkageType]) }); } fSheetList.EndUpdate(); } catch (Exception ex) { Logger.WriteError("ParentsSublistModel.UpdateContents()", ex); } }
private static bool CheckPersonsEx(GDMIndividualRecord rec1, GDMIndividualRecord rec2) { GDMFamilyRecord fam1 = rec1.GetParentsFamily(); GDMFamilyRecord fam2 = rec2.GetParentsFamily(); return(!Equals(fam1, fam2)); }
private void ArborViewer1_MouseMove(object sender, MouseEventArgs e) { Point mpt = new Point(e.Location); ArborNode resNode = fArborViewer.getNodeByCoord(mpt.X, mpt.Y); if (resNode == null) { if (fTipShow) { //fTip.Hide(arborViewer1); fArborViewer.ToolTip = string.Empty; fTipShow = false; } } else { if (!fTipShow) { string xref = resNode.Sign; GDMFamilyRecord famRec = fBase.Context.Tree.XRefIndex_Find(xref) as GDMFamilyRecord; string txt = GKUtils.GetFamilyString(fBase.Context.Tree, famRec) + " [" + xref + "] " /* + resNode.Mass.ToString()*/; //fTip.Show(txt, arborViewer1, mpt.X + 24, mpt.Y); fArborViewer.ToolTip = txt; fTipShow = true; } } }
private void ArborViewer1_MouseMove(object sender, MouseEventArgs e) { ArborNode resNode = arborViewer1.getNodeByCoord(e.X, e.Y); if (resNode == null) { if (fTipShow) { fTip.Hide(arborViewer1); fTipShow = false; } } else { if (!fTipShow) { string xref = resNode.Sign; GDMFamilyRecord famRec = fBase.Context.Tree.XRefIndex_Find(xref) as GDMFamilyRecord; string txt = GKUtils.GetFamilyString(famRec) + " [" + xref + "] " /* + resNode.Mass.ToString()*/; fTip.Show(txt, arborViewer1, e.X + 24, e.Y); fTipShow = true; } } }
private static void SearchKGInt(IBaseContext context, Vertex prevNode, GDMIndividualRecord iRec, KinshipsGraph graph, RelationKind relation, RelationKind inverseRelation) { if (iRec == null) { return; } Vertex currNode = graph.FindVertex(iRec.XRef); if (currNode != null) { if (prevNode != null) { graph.AddRelation(prevNode, currNode, relation, inverseRelation); } return; } else { currNode = graph.AddIndividual(iRec); if (prevNode != null) { graph.AddRelation(prevNode, currNode, relation, inverseRelation); } } if (iRec.ChildToFamilyLinks.Count > 0) { GDMFamilyRecord fam = context.Tree.GetParentsFamily(iRec); if (fam != null) { GDMIndividualRecord father, mother; father = context.Tree.GetPtrValue(fam.Husband); mother = context.Tree.GetPtrValue(fam.Wife); SearchKGInt(context, currNode, father, graph, RelationKind.rkParent, RelationKind.rkChild); SearchKGInt(context, currNode, mother, graph, RelationKind.rkParent, RelationKind.rkChild); } } int num = iRec.SpouseToFamilyLinks.Count; for (int i = 0; i < num; i++) { GDMFamilyRecord family = context.Tree.GetPtrValue(iRec.SpouseToFamilyLinks[i]); GDMIndividualRecord spouse = (iRec.Sex == GDMSex.svMale) ? context.Tree.GetPtrValue(family.Wife) : context.Tree.GetPtrValue(family.Husband); SearchKGInt(context, currNode, spouse, graph, RelationKind.rkSpouse, RelationKind.rkSpouse); int num2 = family.Children.Count; for (int j = 0; j < num2; j++) { GDMIndividualRecord child = context.Tree.GetPtrValue(family.Children[j]); SearchKGInt(context, currNode, child, graph, RelationKind.rkChild, RelationKind.rkParent); } } }
private void CheckFamilyRecord(GDMFamilyRecord fam) { for (int i = 0, num = fam.Events.Count; i < num; i++) { GDMCustomEvent evt = fam.Events[i]; CheckEvent(evt); } for (int i = fam.Children.Count - 1; i >= 0; i--) { CheckChildLink(fam, i); } GDMRecord val = fTree.GetPtrValue <GDMIndividualRecord>(fam.Husband); if (!string.IsNullOrEmpty(fam.Husband.XRef) && val == null) { fam.Husband.XRef = string.Empty; } val = fTree.GetPtrValue <GDMIndividualRecord>(fam.Wife); if (!string.IsNullOrEmpty(fam.Wife.XRef) && val == null) { fam.Wife.XRef = string.Empty; } }
public void ImportNames(IBaseContext context, GDMIndividualRecord iRec) { if (context == null || iRec == null) { return; } try { string childName, childPat; var parts = GKUtils.GetNameParts(context.Tree, iRec, false); childName = parts.Name; childPat = parts.Patronymic; GDMSex iSex = iRec.Sex; SetNameSex(childName, iSex); GDMFamilyRecord fam = context.Tree.GetParentsFamily(iRec); GDMIndividualRecord father = (fam == null) ? null : context.Tree.GetPtrValue(fam.Husband); if (father != null) { string fatherName; parts = GKUtils.GetNameParts(context.Tree, father, false); fatherName = parts.Name; if (IsComparable(fatherName, childPat)) { SetName(fatherName, childPat, iSex); } } } catch (Exception ex) { Logger.WriteError("NamesTable.ImportName()", ex); } }
public object gt_get_family_husband(object recPtr) { GDMFamilyRecord fam = recPtr as GDMFamilyRecord; recPtr = (fam == null) ? null : fam.Husband.Value; return(recPtr); }
public static bool AddIndividualMother(IBaseWindow baseWin, ChangeTracker localUndoman, GDMIndividualRecord person) { bool result = false; GDMIndividualRecord mother = baseWin.Context.SelectPerson(person, TargetMode.tmChild, GDMSex.svFemale); if (mother != null) { GDMFamilyRecord family = baseWin.Context.GetChildFamily(person, true, mother); if (family != null) { if (family.Wife.Value == null) { // new family result = localUndoman.DoOrdinaryOperation(OperationType.otFamilySpouseAttach, family, mother); } else { // selected family with wife Logger.LogWrite("BaseController.AddMother(): fail, because family already has mother"); result = true; } } } return(result); }
public bool ParentIsRequired(GDMSex needSex) { TreeChartPerson p = fView.TreeBox.Selected; if (p == null || p.Rec == null) { return(false); } bool familyExist = p.Rec.GetParentsFamily() != null; if (!familyExist) { return(true); } GDMIndividualRecord mother, father; GDMFamilyRecord fam = p.Rec.GetParentsFamily(); if (fam == null) { father = null; mother = null; } else { father = fam.Husband.Individual; mother = fam.Wife.Individual; } bool needParent = (father == null && needSex == GDMSex.svMale) || (mother == null && needSex == GDMSex.svFemale); return(needParent); }
public static bool AddIndividualFather(IBaseWindow baseWin, ChangeTracker localUndoman, GDMIndividualRecord person) { bool result = false; GDMIndividualRecord father = baseWin.Context.SelectPerson(person, TargetMode.tmChild, GDMSex.svMale); if (father != null) { GDMFamilyRecord family = baseWin.Context.GetChildFamily(person, true, father); if (family != null) { var husb = baseWin.Context.Tree.GetPtrValue <GDMIndividualRecord>(family.Husband); if (husb == null) { // new family result = localUndoman.DoOrdinaryOperation(OperationType.otFamilySpouseAttach, family, father); } else { // selected family with husband Logger.WriteError("BaseController.AddFather(): fail, because family already has father"); result = true; } } } return(result); }
// Gets the n'th child in the fr, or returns the default individual if first child requested and no fr. private GDMIndividualRecord GetChild(GDMFamilyRecord famRec, int nChild, GDMIndividualRecord irDefault) { GDMIndividualRecord irChild = null; if (famRec != null && nChild < famRec.Children.Count) { // The ordering of children in the tree can be selected to be the same as it is in the GEDCOM file. This // is because the file should be ordered as the user chose to order the fr when entering the data in // their fr history app, regardless of actual birth dates. if (CConfig.Instance.KeepSiblingOrder) { irChild = fTree.GetPtrValue(famRec.Children[nChild]); } else { irChild = fTree.GetPtrValue(famRec.Children[nChild]); } } else { // Return the default individual as first and only child of fr. if (nChild == 0) { irChild = irDefault; } } return(irChild); }
public object gt_get_family_wife(object recPtr) { GDMFamilyRecord fam = recPtr as GDMFamilyRecord; recPtr = (fam == null) ? null : fBase.Context.Tree.GetPtrValue <GDMRecord>(fam.Wife); return(recPtr); }
private bool CheckPersonsEx(GDMIndividualRecord rec1, GDMIndividualRecord rec2) { var tree = fBase.Context.Tree; GDMFamilyRecord fam1 = tree.GetParentsFamily(rec1); GDMFamilyRecord fam2 = tree.GetParentsFamily(rec2); return(!Equals(fam1, fam2)); }
private void CheckSpouses(StringList buffer, GDMIndividualRecord curPerson) { int num2 = buffer.Count; for (int i = 0; i < num2; i++) { string line = buffer[i]; if (string.IsNullOrEmpty(line)) { continue; } try { var slRet = ImportUtils.ParseSpouseLine(line); if (slRet != null) { // define sex string spSex = slRet.Spouse; GDMSex sx = (spSex[0] == 'М') ? GDMSex.svMale : GDMSex.svFemale; // extract name line = line.Substring(slRet.Pos).Trim(); if (!string.IsNullOrEmpty(line)) { GDMIndividualRecord spouse = DefinePerson(line, sx); GDMFamilyRecord family = GetFamilyByNum(curPerson, slRet.MarrNum); if (spouse == null || family == null) { // TODO: error to log, reporting causes } else { family.AddSpouse(spouse); // extract marriage date if (!string.IsNullOrEmpty(slRet.ExtData)) { string marrDate = slRet.ExtData.Substring(1, slRet.ExtData.Length - 2).Trim(); if (marrDate != "") { SetEvent(family, GEDCOMTagName.MARR, marrDate); } } } } } } catch (Exception ex) { Logger.LogWrite("Importer.CheckSpouses(): " + ex.Message); } } }
public static bool ModifyFamily(IBaseWindow baseWin, ref GDMFamilyRecord familyRec, TargetMode targetType, GDMIndividualRecord target) { bool result; try { baseWin.Context.BeginUpdate(); GDMTree tree = baseWin.Context.Tree; if (targetType == TargetMode.tmSpouse && target != null) { GDMSex sex = target.Sex; if (sex < GDMSex.svMale || sex > GDMSex.svFemale) { AppHost.StdDialogs.ShowError(LangMan.LS(LSID.LSID_IsNotDefinedSex)); return(false); } } using (var dlg = AppHost.ResolveDialog <IFamilyEditDlg>(baseWin)) { bool exists = (familyRec != null); if (!exists) { familyRec = new GDMFamilyRecord(tree); familyRec.InitNew(); } try { baseWin.Context.LockRecord(familyRec); dlg.Family = familyRec; dlg.SetTarget(targetType, target); result = (AppHost.Instance.ShowModalX(dlg, false)); } finally { baseWin.Context.UnlockRecord(familyRec); } if (!exists) { if (result) { tree.AddRecord(familyRec); } else { familyRec.Clear(); familyRec.Dispose(); familyRec = null; } } } } finally { baseWin.Context.EndUpdate(); } return(result); }
private void ModifySpousesSheet(object sender, ModifyEventArgs eArgs) { GDMFamilyRecord family = eArgs.ItemData as GDMFamilyRecord; if (eArgs.Action == RecordAction.raJump && family != null) { fController.JumpToPersonSpouse(family); } }
public void EditParents() { GDMFamilyRecord family = fBase.Context.GetChildFamily(fPerson, false, null); if (family != null && BaseController.ModifyFamily(fBase, ref family, TargetMode.tmNone, null)) { UpdateControls(); } }
private void FamilyEditDlg_Handler(FamilyEditDlg dlg) { GDMFamilyRecord familyRecord = dlg.Family; var tabs = new TabControlTester("tabsFamilyData", dlg); GKSheetListTester sheetTester; // father PersonEditDlgTests.SetCreateIndividualHandler(this, GDMSex.svMale); ClickButton("btnHusbandAdd", dlg); ModalFormHandler = MessageBox_YesHandler; ClickButton("btnHusbandDelete", dlg); // mother PersonEditDlgTests.SetCreateIndividualHandler(this, GDMSex.svFemale); ClickButton("btnWifeAdd", dlg); ModalFormHandler = MessageBox_YesHandler; ClickButton("btnWifeDelete", dlg); // childs Assert.AreEqual(0, familyRecord.Children.Count); tabs.SelectTab(0); PersonEditDlgTests.SetCreateIndividualHandler(this, GDMSex.svFemale); ClickToolStripButton("fChildsList_ToolBar_btnAdd", dlg); Assert.AreEqual(1, familyRecord.Children.Count); //SelectSheetListItem("fEventsList", dlg, 0); //ModalFormHandler = EventEditDlg_Select_Handler; //ClickToolStripButton("fChildsList_ToolBar_btnEdit", dlg); //Assert.AreEqual(1, familyRecord.Childrens.Count); ModalFormHandler = MessageBox_YesHandler; SelectSheetListItem("fChildsList", dlg, 0); ClickToolStripButton("fChildsList_ToolBar_btnDelete", dlg); Assert.AreEqual(0, familyRecord.Children.Count); // events Assert.AreEqual(0, familyRecord.Events.Count); tabs.SelectTab(1); SetModalFormHandler(this, EventEditDlgTests.EventEditDlg_Select_Handler); ClickToolStripButton("fEventsList_ToolBar_btnAdd", dlg); Assert.AreEqual(1, familyRecord.Events.Count); SelectSheetListItem("fEventsList", dlg, 0); SetModalFormHandler(this, EventEditDlgTests.EventEditDlg_Select_Handler); ClickToolStripButton("fEventsList_ToolBar_btnEdit", dlg); Assert.AreEqual(1, familyRecord.Events.Count); ModalFormHandler = MessageBox_YesHandler; SelectSheetListItem("fEventsList", dlg, 0); ClickToolStripButton("fEventsList_ToolBar_btnDelete", dlg); Assert.AreEqual(0, familyRecord.Events.Count); StructsDlg_Handler(familyRecord, dlg, tabs, new int[] { 2, 3, 4 }); ClickButton("btnAccept", dlg); }
private void WriteCompactFmt(PedigreePerson person) { if (fOptions.PedigreeOptions.IncludeNotes && person.IRec.Notes.Count != 0) { int num = person.IRec.Notes.Count; for (int i = 0; i < num; i++) { GDMLines noteLines = fTree.GetNoteLines(person.IRec.Notes[i]); fWriter.AddParagraph(GKUtils.MergeStrings(noteLines), fTextFont); } } bool spIndex = person.IRec.SpouseToFamilyLinks.Count > 1; int num2 = person.IRec.SpouseToFamilyLinks.Count; for (int i = 0; i < num2; i++) { GDMFamilyRecord family = fTree.GetPtrValue(person.IRec.SpouseToFamilyLinks[i]); if (fBase.Context.IsRecordAccess(family.Restriction)) { GDMIndividualRecord spRec; string st; string unk; if (person.IRec.Sex == GDMSex.svMale) { spRec = fTree.GetPtrValue(family.Wife); st = LangMan.LS(LSID.LSID_WifeSign); unk = LangMan.LS(LSID.LSID_UnkFemale); } else { spRec = fTree.GetPtrValue(family.Husband); st = LangMan.LS(LSID.LSID_HusbSign); unk = LangMan.LS(LSID.LSID_UnkMale); } if (spIndex) { st += (i + 1).ToString(); } st += " - "; if (spRec != null) { st = st + GKUtils.GetNameString(spRec, true, false) + GKUtils.GetPedigreeLifeStr(spRec, fOptions.PedigreeOptions.Format) /* + this.idLink(this.FindPerson(irec))*/; } else { st += unk; } fWriter.AddParagraph(st, fTextFont); } } }
public override void UpdateContents() { var iRec = fDataOwner as GDMIndividualRecord; if (fSheetList == null || iRec == null) { return; } try { fSheetList.BeginUpdate(); fSheetList.ClearItems(); int idx = 0; foreach (GDMSpouseToFamilyLink spLink in iRec.SpouseToFamilyLinks) { idx += 1; GDMFamilyRecord family = spLink.Family; if (family == null) { continue; } GDMIndividualRecord relPerson; string relName; if (iRec.Sex == GDMSex.svMale) { relPerson = family.Wife.Individual; relName = LangMan.LS(LSID.LSID_UnkFemale); } else { relPerson = family.Husband.Individual; relName = LangMan.LS(LSID.LSID_UnkMale); } if (relPerson != null) { relName = GKUtils.GetNameString(relPerson, true, false); } fSheetList.AddItem(family, new object[] { idx, relName, new GEDCOMDateItem(GKUtils.GetMarriageDate(family)) }); } fSheetList.EndUpdate(); } catch (Exception ex) { Logger.LogWrite("SpousesSublistModel.UpdateContents(): " + ex.Message); } }
public override void Setup() { base.Setup(); fBase = new BaseWindowStub(); fFamilyRecord = new GDMFamilyRecord(fBase.Context.Tree); fDialog = new FamilyEditDlg(fBase); fDialog.Family = fFamilyRecord; fDialog.Show(); }
public void JumpToMother() { GDMFamilyRecord family = fBase.Context.GetChildFamily(fPerson, false, null); if (family == null) { return; } JumpToRecord(family.Wife); }