Example #1
0
        private void UpdateControls()
        {
            GEDCOMIndividualRecord husband, wife;

            if (fFamily == null)
            {
                husband = null;
                wife    = null;

                LockEditor(true);
            }
            else
            {
                husband = fFamily.GetHusband();
                wife    = fFamily.GetWife();

                LockEditor(fFamily.Restriction == GEDCOMRestriction.rnLocked);
            }

            txtHusband.Text          = (husband != null) ? GKUtils.GetNameString(husband, true, false) : LangMan.LS(LSID.LSID_UnkMale);
            btnHusbandAdd.Enabled    = (husband == null);
            btnHusbandDelete.Enabled = (husband != null);
            btnHusbandSel.Enabled    = (husband != null);

            txtWife.Text          = (wife != null) ? GKUtils.GetNameString(wife, true, false) : LangMan.LS(LSID.LSID_UnkFemale);
            btnWifeAdd.Enabled    = (wife == null);
            btnWifeDelete.Enabled = (wife != null);
            btnWifeSel.Enabled    = (wife != null);

            fChildrenList.UpdateSheet();
            fEventsList.UpdateSheet();
            fNotesList.UpdateSheet();
            fMediaList.UpdateSheet();
            fSourcesList.UpdateSheet();
        }
Example #2
0
        private void UpdateControls()
        {
            GEDCOMIndividualRecord husband, wife;

            if (fFamily == null)
            {
                husband = null;
                wife    = null;

                fView.LockEditor(true);
            }
            else
            {
                husband = fFamily.GetHusband();
                wife    = fFamily.GetWife();

                fView.LockEditor(fFamily.Restriction == GEDCOMRestriction.rnLocked);
            }

            fView.SetHusband((husband != null) ? GKUtils.GetNameString(husband, true, false) : null);
            fView.SetWife((wife != null) ? GKUtils.GetNameString(wife, true, false) : null);

            fView.ChildrenList.UpdateSheet();
            fView.EventsList.UpdateSheet();
            fView.NotesList.UpdateSheet();
            fView.MediaList.UpdateSheet();
            fView.SourcesList.UpdateSheet();
        }
Example #3
0
        private static void SearchKGInt(Vertex prevNode, GEDCOMIndividualRecord 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)
            {
                GEDCOMFamilyRecord fam = iRec.GetParentsFamily();
                if (fam != null)
                {
                    GEDCOMIndividualRecord father, mother;
                    father = fam.GetHusband();
                    mother = fam.GetWife();

                    SearchKGInt(currNode, father, graph, RelationKind.rkParent, RelationKind.rkChild);
                    SearchKGInt(currNode, mother, graph, RelationKind.rkParent, RelationKind.rkChild);
                }
            }

            int num = iRec.SpouseToFamilyLinks.Count;

            for (int i = 0; i < num; i++)
            {
                GEDCOMFamilyRecord     family = iRec.SpouseToFamilyLinks[i].Family;
                GEDCOMIndividualRecord spouse = ((iRec.Sex == GEDCOMSex.svMale) ? family.GetWife() : family.GetHusband());

                SearchKGInt(currNode, spouse, graph, RelationKind.rkSpouse, RelationKind.rkSpouse);

                int num2 = family.Children.Count;
                for (int j = 0; j < num2; j++)
                {
                    GEDCOMIndividualRecord child = (GEDCOMIndividualRecord)family.Children[j].Value;
                    SearchKGInt(currNode, child, graph, RelationKind.rkChild, RelationKind.rkParent);
                }
            }
        }
Example #4
0
        public bool ParentIsRequired(GEDCOMSex needSex)
        {
            TreeChartPerson p = fView.TreeBox.Selected;

            if (p == null || p.Rec == null)
            {
                return(false);
            }

            bool familyExist = p.Rec.GetParentsFamily() != null;

            if (!familyExist)
            {
                return(true);
            }

            GEDCOMIndividualRecord mother, father;
            GEDCOMFamilyRecord     fam = p.Rec.GetParentsFamily();

            if (fam == null)
            {
                father = null;
                mother = null;
            }
            else
            {
                father = fam.GetHusband();
                mother = fam.GetWife();
            }

            bool needParent = (father == null && needSex == GEDCOMSex.svMale) ||
                              (mother == null && needSex == GEDCOMSex.svFemale);

            return(needParent);
        }
Example #5
0
        public override void UpdateContents()
        {
            var iRec = fDataOwner as GEDCOMIndividualRecord;

            if (fSheetList == null || iRec == null)
            {
                return;
            }

            try
            {
                fSheetList.BeginUpdate();
                fSheetList.ClearItems();

                int idx = 0;
                foreach (GEDCOMSpouseToFamilyLink spLink in iRec.SpouseToFamilyLinks)
                {
                    idx += 1;

                    GEDCOMFamilyRecord family = spLink.Family;
                    if (family == null)
                    {
                        continue;
                    }

                    GEDCOMIndividualRecord relPerson;
                    string relName;

                    if (iRec.Sex == GEDCOMSex.svMale)
                    {
                        relPerson = family.GetWife();
                        relName   = LangMan.LS(LSID.LSID_UnkFemale);
                    }
                    else
                    {
                        relPerson = family.GetHusband();
                        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 void JumpToFather()
        {
            GEDCOMFamilyRecord family = fBase.Context.GetChildFamily(fPerson, false, null);

            if (family == null)
            {
                return;
            }

            JumpToRecord(family.GetHusband());
        }
Example #7
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            switch (e.Key)
            {
            case Keys.Plus:
                if (Keys.None == e.Modifiers)
                {
                    Zoom = Math.Min(fZoom * 1.05f, ZOOM_HIGH_LIMIT);
                }
                break;

            case Keys.Minus:
                if (Keys.None == e.Modifiers)
                {
                    Zoom = Math.Max(fZoom * 0.95f, ZOOM_LOW_LIMIT);
                }
                break;

            case Keys.D0:
                if (e.Control)
                {
                    Zoom = 1.0f;
                }
                break;

            case Keys.Left:
                if (fChartType == CircleChartType.Ancestors && fModel.RootPerson != null)
                {
                    GEDCOMFamilyRecord fam = fModel.RootPerson.GetParentsFamily();
                    var father             = (fam == null) ? null : fam.GetHusband();
                    if (father != null)
                    {
                        RootPerson = father;
                    }
                }
                break;

            case Keys.Right:
                if (fChartType == CircleChartType.Ancestors && fModel.RootPerson != null)
                {
                    GEDCOMFamilyRecord fam = fModel.RootPerson.GetParentsFamily();
                    var mother             = (fam == null) ? null : fam.GetWife();
                    if (mother != null)
                    {
                        RootPerson = mother;
                    }
                }
                break;
            }

            base.OnKeyDown(e);
        }
Example #8
0
        private void btnFatherSel_Click(object sender, EventArgs e)
        {
            GEDCOMFamilyRecord family = fBase.Context.GetChildFamily(fPerson, false, null);

            if (family == null)
            {
                return;
            }

            AcceptChanges();
            GEDCOMIndividualRecord father = family.GetHusband();

            fBase.SelectRecordByXRef(father.XRef);
            Close();
        }
Example #9
0
        private void ParentAdd(GEDCOMSex needSex)
        {
            TreeChartPerson p = fView.TreeBox.Selected;

            if (p == null || p.Rec == null)
            {
                return;
            }

            bool needParent  = false;
            bool familyExist = p.Rec.GetParentsFamily() != null;

            if (familyExist)
            {
                GEDCOMIndividualRecord mother, father;
                GEDCOMFamilyRecord     fam = p.Rec.GetParentsFamily();
                if (fam == null)
                {
                    father = null;
                    mother = null;
                }
                else
                {
                    father = fam.GetHusband();
                    mother = fam.GetWife();
                }

                needParent = (father == null && needSex == GEDCOMSex.svMale) ||
                             (mother == null && needSex == GEDCOMSex.svFemale);
            }

            if (!familyExist || needParent)
            {
                GEDCOMIndividualRecord child  = p.Rec;
                GEDCOMFamilyRecord     fam    = (familyExist) ? p.Rec.GetParentsFamily() : fBase.Context.Tree.CreateFamily();
                GEDCOMIndividualRecord parent = fBase.Context.SelectPerson(null, TargetMode.tmParent, needSex);
                if (parent != null)
                {
                    fam.AddSpouse(parent);
                    if (!familyExist)
                    {
                        fam.AddChild(child);
                    }

                    UpdateChart();
                }
            }
        }
Example #10
0
        public static bool DeleteIndividualFather(IBaseWindow baseWin, ChangeTracker localUndoman, GEDCOMIndividualRecord person)
        {
            bool result = false;

            if (AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_DetachFatherQuery)))
            {
                GEDCOMFamilyRecord family = baseWin.Context.GetChildFamily(person, false, null);
                if (family != null)
                {
                    GEDCOMIndividualRecord father = family.GetHusband();
                    result = localUndoman.DoOrdinaryOperation(OperationType.otFamilySpouseDetach, family, father);
                }
            }

            return(result);
        }
Example #11
0
        public static bool DeleteFamilyHusband(IBaseWindow baseWin, ChangeTracker localUndoman, GEDCOMFamilyRecord family)
        {
            bool result = false;

            GEDCOMIndividualRecord husband = family.GetHusband();

            if (!baseWin.Context.IsAvailableRecord(husband))
            {
                return(false);
            }

            if (AppHost.StdDialogs.ShowQuestionYN(LangMan.LS(LSID.LSID_DetachHusbandQuery)))
            {
                result = localUndoman.DoOrdinaryOperation(OperationType.otFamilySpouseDetach, family, husband);
            }

            return(result);
        }
        public void UpdateParents()
        {
            bool locked = (fView.RestrictionCombo.SelectedIndex == (int)GEDCOMRestriction.rnLocked);

            if (fPerson.ChildToFamilyLinks.Count != 0)
            {
                GEDCOMFamilyRecord family = fPerson.ChildToFamilyLinks[0].Family;
                fView.SetParentsAvl(true, locked);

                GEDCOMIndividualRecord relPerson = family.GetHusband();
                if (relPerson != null)
                {
                    fView.SetFatherAvl(true, locked);
                    fView.Father.Text = GKUtils.GetNameString(relPerson, true, false);
                }
                else
                {
                    fView.SetFatherAvl(false, locked);
                    fView.Father.Text = "";
                }

                relPerson = family.GetWife();
                if (relPerson != null)
                {
                    fView.SetMotherAvl(true, locked);
                    fView.Mother.Text = GKUtils.GetNameString(relPerson, true, false);
                }
                else
                {
                    fView.SetMotherAvl(false, locked);
                    fView.Mother.Text = "";
                }
            }
            else
            {
                fView.SetParentsAvl(false, locked);
                fView.SetFatherAvl(false, locked);
                fView.SetMotherAvl(false, locked);

                fView.Father.Text = "";
                fView.Mother.Text = "";
            }
        }
        public void UpdateControls()
        {
            if (fLink != null)
            {
                GEDCOMFamilyRecord family = fLink.Family;
                fView.SetParentsAvl(true);

                GEDCOMIndividualRecord relPerson = family.GetHusband();
                if (relPerson != null)
                {
                    fView.SetFatherAvl(true);
                    fView.Father.Text = GKUtils.GetNameString(relPerson, true, false);
                }
                else
                {
                    fView.SetFatherAvl(false);
                    fView.Father.Text = "";
                }

                relPerson = family.GetWife();
                if (relPerson != null)
                {
                    fView.SetMotherAvl(true);
                    fView.Mother.Text = GKUtils.GetNameString(relPerson, true, false);
                }
                else
                {
                    fView.SetMotherAvl(false);
                    fView.Mother.Text = "";
                }
            }
            else
            {
                fView.SetParentsAvl(false);
                fView.SetFatherAvl(false);
                fView.SetMotherAvl(false);

                fView.Father.Text = "";
                fView.Mother.Text = "";
            }
        }
Example #14
0
        private void ModifySpousesSheet(object sender, ModifyEventArgs eArgs)
        {
            GEDCOMFamilyRecord family = eArgs.ItemData as GEDCOMFamilyRecord;

            if (eArgs.Action == RecordAction.raJump && family != null)
            {
                GEDCOMIndividualRecord spouse = null;
                switch (fController.Person.Sex)
                {
                case GEDCOMSex.svMale:
                    spouse = family.GetWife();
                    break;

                case GEDCOMSex.svFemale:
                    spouse = family.GetHusband();
                    break;
                }

                fController.JumpToRecord(spouse);
            }
        }
Example #15
0
        public void ImportNames(GEDCOMIndividualRecord iRec)
        {
            if (iRec == null)
            {
                return;
            }

            try
            {
                string childName, childPat;
                var    parts = GKUtils.GetNameParts(iRec);
                childName = parts.Name;
                childPat  = parts.Patronymic;

                GEDCOMSex iSex = iRec.Sex;
                SetNameSex(childName, iSex);

                GEDCOMFamilyRecord     fam    = iRec.GetParentsFamily();
                GEDCOMIndividualRecord father = (fam == null) ? null : fam.GetHusband();

                if (father != null)
                {
                    string fatherNam;
                    parts     = GKUtils.GetNameParts(father);
                    fatherNam = parts.Name;

                    if (IsComparable(fatherNam, childPat))
                    {
                        SetName(fatherNam, childPat, iSex);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("NamesTable.ImportName(): " + ex.Message);
            }
        }
Example #16
0
        public static Graph GetPatriarchsGraph(IBaseContext context, int gensMin,
                                               bool datesCheck, bool loneSuppress)
        {
            Graph graph = new Graph();

            try
            {
                using (ExtList <PatriarchObj> patList = GetPatriarchsList(context, gensMin, datesCheck))
                {
                    // init
                    GKUtils.InitExtData(context.Tree);

                    // prepare
                    int count = patList.Count;
                    for (int i = 0; i < count; i++)
                    {
                        PatriarchObj           patNode = patList[i];
                        GEDCOMIndividualRecord iRec    = patNode.IRec;

                        int count2 = iRec.SpouseToFamilyLinks.Count;
                        for (int k = 0; k < count2; k++)
                        {
                            GEDCOMFamilyRecord family = iRec.SpouseToFamilyLinks[k].Family;
                            family.ExtData = new PGNode(family.XRef, PGNodeType.Patriarch, patNode.DescGenerations);
                        }
                    }

                    IProgressController progress = AppHost.Progress;
                    try
                    {
                        int patCount = patList.Count;
                        progress.ProgressInit(LangMan.LS(LSID.LSID_LinksSearch), patCount);

                        for (int i = 0; i < patCount; i++)
                        {
                            PatriarchObj patr = patList[i];

                            for (int j = i + 1; j < patCount; j++)
                            {
                                PatriarchObj patr2 = patList[j];

                                GEDCOMFamilyRecord cross = TreeTools.PL_SearchIntersection(patr.IRec, patr2.IRec);

                                if (cross != null)
                                {
                                    PGNode node = (PGNode)cross.ExtData;

                                    if (node != null && node.Type == PGNodeType.Patriarch)
                                    {
                                        // dummy
                                    }
                                    else
                                    {
                                        int size = GKUtils.GetDescGenerations(cross.GetHusband());
                                        if (size == 0)
                                        {
                                            size = 1;
                                        }
                                        cross.ExtData = new PGNode(cross.XRef, PGNodeType.Intersection, size);
                                    }
                                }
                            }

                            progress.ProgressStep();
                        }
                    }
                    finally
                    {
                        progress.ProgressDone();
                    }

                    // create graph
                    int count3 = patList.Count;
                    for (int i = 0; i < count3; i++)
                    {
                        PatriarchObj patNode = patList[i];
                        PL_WalkDescLinks(graph, null, patNode.IRec);
                    }

                    // clear
                    GKUtils.InitExtData(context.Tree);

                    /*if (gpl_params.aLoneSuppress) {
                     *          for (int i = aList.Count - 1; i >= 0; i--) {
                     *                  PatriarchObj patr = aList[i] as PatriarchObj;
                     *                  if (patr.ILinks.Count == 0) aList.Delete(i);
                     *          }
                     *          aList.Pack();*/
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("PatriarchsMan.GetPatriarchsGraph(): " + ex.Message);
            }

            return(graph);
        }
Example #17
0
        public void BuildAncTree()
        {
            fSegments.Clear();

            const float startRad = CircleChartModel.CENTER_RAD - 50;
            float       inRad    = startRad;

            AncPersonSegment segment = new AncPersonSegment(0);

            segment.IntRad     = 0;
            segment.ExtRad     = inRad;
            segment.StartAngle = 0 - 90.0f;
            segment.WedgeAngle = segment.StartAngle + 360.0f;
            IGfxPath path = segment.Path;

            path.StartFigure();
            path.AddEllipse(-inRad, -inRad, inRad * 2.0f, inRad * 2.0f);
            path.CloseFigure();
            fSegments.Add(segment);

            int maxSteps = 1;

            for (int gen = 1; gen <= fMaxGenerations; gen++)
            {
                inRad = startRad + ((gen - 1) * fGenWidth);
                float extRad = inRad + fGenWidth;

                maxSteps *= 2;
                float stepAngle = (360.0f / maxSteps);

                for (int step = 0; step < maxSteps; step++)
                {
                    float ang1 = (step * stepAngle) - 90.0f;
                    float ang2 = ang1 + stepAngle;

                    segment            = new AncPersonSegment(gen);
                    segment.StartAngle = ang1;
                    segment.WedgeAngle = stepAngle;
                    fRenderer.CreateCircleSegment(segment.Path, inRad, extRad, stepAngle, ang1, ang2);
                    fSegments.Add(segment);
                }
            }

            // traverse tree
            fGroupCount       = -1;
            fIndividualsCount = 0;
            if (fRootPerson == null)
            {
                return;
            }

            fIndividualsCount++;
            AncPersonSegment rootSegment = SetSegmentParams(0, fRootPerson, 0, -1);

            if (rootSegment == null)
            {
                return;
            }

            rootSegment.WedgeAngle = 360.0f;

            GEDCOMIndividualRecord father = null, mother = null;
            GEDCOMFamilyRecord     fam = fRootPerson.GetParentsFamily();

            if (fam != null && fBase.Context.IsRecordAccess(fam.Restriction))
            {
                father = fam.GetHusband();
                mother = fam.GetWife();
            }

            if (mother != null)
            {
                rootSegment.MotherSegment = TraverseAncestors(mother, 90f, 1, CircleChartModel.CENTER_RAD, 90.0f, 1, -1);
            }

            if (father != null)
            {
                rootSegment.FatherSegment = TraverseAncestors(father, 270.0f, 1, CircleChartModel.CENTER_RAD, 90.0f, 1, -1);
            }
        }
        private void ExposePerson(GEDCOMIndividualRecord iRec, string iName)
        {
            fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0, true);
            fWriter.AddParagraphChunkAnchor(iName, fBoldFont, iRec.XRef);
            fWriter.AddParagraphChunk(GKUtils.GetPedigreeLifeStr(iRec, PedigreeFormat.Compact), fTextFont);
            fWriter.EndParagraph();

            IImage image = fBase.Context.GetPrimaryBitmap(iRec, 0, 0, false);

            fWriter.AddImage(image);

            GEDCOMIndividualRecord father, mother;
            GEDCOMFamilyRecord     fam = iRec.GetParentsFamily();

            if (fam == null)
            {
                father = null;
                mother = null;
            }
            else
            {
                father = fam.GetHusband();
                mother = fam.GetWife();
            }

            if (father != null)
            {
                fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0);
                fWriter.AddParagraphChunk(LangMan.LS(LSID.LSID_Father) + ": ", fTextFont);
                fWriter.AddParagraphChunkLink(GKUtils.GetNameString(father, true, false), fLinkFont, father.XRef);
                fWriter.EndParagraph();
            }

            if (mother != null)
            {
                fWriter.BeginParagraph(TextAlignment.taLeft, 0, 0, 0);
                fWriter.AddParagraphChunk(LangMan.LS(LSID.LSID_Mother) + ": ", fTextFont);
                fWriter.AddParagraphChunkLink(GKUtils.GetNameString(mother, true, false), fLinkFont, mother.XRef);
                fWriter.EndParagraph();
            }

            if (IncludeEvents && iRec.Events.Count != 0)
            {
                int num = iRec.Events.Count;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMCustomEvent evt = iRec.Events[i];
                    if (evt.Name == "BIRT" || evt.Name == "DEAT")
                    {
                        continue;
                    }

                    string evtName = GKUtils.GetEventName(evt);
                    string evtVal  = evt.StringValue;
                    string evtDesc = GKUtils.GetEventDesc(evt, false);

                    string tmp = evtName + ": " + evtVal;
                    if (evtVal != "")
                    {
                        tmp += ", ";
                    }
                    tmp += evtDesc;

                    fWriter.AddParagraph(tmp, fTextFont);
                }
            }

            if (IncludeNotes && iRec.Notes.Count != 0)
            {
                int num = iRec.Notes.Count;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMNotes note = iRec.Notes[i];
                    fWriter.AddParagraph(GKUtils.MergeStrings(note.Notes), fTextFont);
                }
            }
        }
Example #19
0
        private void GenStep(PedigreePerson parent, GEDCOMIndividualRecord iRec, int level, int familyOrder)
        {
            if (iRec == null)
            {
                return;
            }

            PedigreePerson res = new PedigreePerson();

            res.Parent      = parent;
            res.IRec        = iRec;
            res.Level       = level;
            res.ChildIdx    = 0;
            res.FamilyOrder = familyOrder;
            fPersonList.Add(res);

            if (fOptions.PedigreeOptions.IncludeSources)
            {
                int num = iRec.SourceCitations.Count;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMSourceRecord sourceRec = iRec.SourceCitations[i].Value as GEDCOMSourceRecord;
                    if (sourceRec == null)
                    {
                        continue;
                    }

                    string srcName = GKUtils.MergeStrings(sourceRec.Title);
                    if (srcName == "")
                    {
                        srcName = sourceRec.FiledByEntry;
                    }

                    int j = fSourceList.IndexOf(srcName);
                    if (j < 0)
                    {
                        j = fSourceList.Add(srcName);
                    }

                    res.Sources.Add((j + 1).ToString());
                }
            }

            if (fKind == PedigreeKind.pkAscend)
            {
                if (iRec.ChildToFamilyLinks.Count > 0)
                {
                    GEDCOMFamilyRecord family = iRec.ChildToFamilyLinks[0].Family;
                    if (fBase.Context.IsRecordAccess(family.Restriction))
                    {
                        GEDCOMIndividualRecord prnt;

                        prnt = family.GetWife();
                        GenStep(res, prnt, level + 1, 1);

                        prnt = family.GetHusband();
                        GenStep(res, prnt, level + 1, 1);
                    }
                }
            }
            else
            {
                int num2 = iRec.SpouseToFamilyLinks.Count;
                for (int j = 0; j < num2; j++)
                {
                    GEDCOMFamilyRecord family = iRec.SpouseToFamilyLinks[j].Family;
                    if (!fBase.Context.IsRecordAccess(family.Restriction))
                    {
                        continue;
                    }

                    family.SortChilds();

                    int num3 = family.Children.Count;
                    for (int i = 0; i < num3; i++)
                    {
                        GEDCOMIndividualRecord child = family.Children[i].Value as GEDCOMIndividualRecord;
                        GenStep(res, child, level + 1, i + 1);
                    }
                }
            }
        }
        protected override void InternalGenerate()
        {
            IColor clrBlack = AppHost.GfxProvider.CreateColor(0x000000);
            IColor clrBlue  = AppHost.GfxProvider.CreateColor(0x0000FF);

            fTitleFont = fWriter.CreateFont("", 14f, true, false, clrBlack);
            fChapFont  = fWriter.CreateFont("", 12f, true, false, clrBlack);
            fTextFont  = fWriter.CreateFont("", 10f, false, false, clrBlack);

            //fWriter.AddParagraph(fTitle, fTitleFont, TextAlignment.taLeft);
            fWriter.AddParagraph(GKUtils.GetNameString(fPerson, true, false), fTitleFont, TextAlignment.taLeft);
            fWriter.NewLine();

            var evList = new List <PersonalEvent>();

            GEDCOMIndividualRecord father = null, mother = null;

            if (fPerson.ChildToFamilyLinks.Count > 0)
            {
                GEDCOMFamilyRecord family = fPerson.ChildToFamilyLinks[0].Family;
                if (fBase.Context.IsRecordAccess(family.Restriction))
                {
                    father = family.GetHusband();
                    mother = family.GetWife();
                }
            }

            ExtractEvents(EventType.Personal, evList, fPerson);

            int num2 = fPerson.SpouseToFamilyLinks.Count;

            for (int j = 0; j < num2; j++)
            {
                GEDCOMFamilyRecord family = fPerson.SpouseToFamilyLinks[j].Family;
                if (!fBase.Context.IsRecordAccess(family.Restriction))
                {
                    continue;
                }

                ExtractEvents(EventType.Spouse, evList, family);

                int num3 = family.Children.Count;
                for (int i = 0; i < num3; i++)
                {
                    GEDCOMIndividualRecord child = family.Children[i].Value as GEDCOMIndividualRecord;
                    GEDCOMCustomEvent      evt   = child.FindEvent("BIRT");
                    if (evt != null && evt.GetChronologicalYear() != 0)
                    {
                        evList.Add(new PersonalEvent(EventType.Child, child, evt));
                    }
                }
            }

            SortHelper.QuickSort(evList, EventsCompare);
            fWriter.BeginList();

            int num4 = evList.Count;

            for (int i = 0; i < num4; i++)
            {
                PersonalEvent evObj = evList[i];
                if (!evObj.Date.HasKnownYear())
                {
                    continue;
                }

                GEDCOMCustomEvent evt = evObj.Event;
                string            st  = GKUtils.GetEventName(evt);
                string            dt  = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfDD_MM_YYYY, false);

                if (ShowAges)
                {
                    int year = evt.GetChronologicalYear();
                    int age  = (evObj.Rec == fPerson) ? GKUtils.GetAge(fPerson, year) : -1;
                    if (age >= 0)
                    {
                        dt += string.Format(" ({0})", age);
                    }
                }

                string li = dt + ": " + st + ".";
                if (evt.Place.StringValue != "")
                {
                    li = li + " " + LangMan.LS(LSID.LSID_Place) + ": " + evt.Place.StringValue;
                }
                fWriter.AddListItem("   " + li, fTextFont);

                if (evObj.Rec is GEDCOMIndividualRecord)
                {
                    GEDCOMIndividualRecord iRec = evObj.Rec as GEDCOMIndividualRecord;

                    if (evt.Name == "BIRT")
                    {
                        if (evObj.Type == EventType.Personal)
                        {
                            if (father != null)
                            {
                                fWriter.AddListItem("   " + "   " + LangMan.LS(LSID.LSID_Father) + ": " + GKUtils.GetNameString(father, true, false) + " ", fTextFont);
                            }
                            if (mother != null)
                            {
                                fWriter.AddListItem("   " + "   " + LangMan.LS(LSID.LSID_Mother) + ": " + GKUtils.GetNameString(mother, true, false) + " ", fTextFont);
                            }
                        }
                        else if (evObj.Type == EventType.Child)
                        {
                            if (iRec.Sex == GEDCOMSex.svMale)
                            {
                                st = LangMan.LS(LSID.LSID_RK_Son) + ": ";
                            }
                            else
                            {
                                st = LangMan.LS(LSID.LSID_RK_Daughter) + ": ";
                            }
                            st = ConvertHelper.UniformName(st) + GKUtils.GetNameString(iRec, true, false);
                            fWriter.AddListItem("   " + "   " + st, fTextFont);
                        }
                    }
                }
                else if (evObj.Rec is GEDCOMFamilyRecord)
                {
                    GEDCOMFamilyRecord famRec = evObj.Rec as GEDCOMFamilyRecord;

                    GEDCOMIndividualRecord sp;
                    string unk;
                    if (fPerson.Sex == GEDCOMSex.svMale)
                    {
                        sp  = famRec.GetWife();
                        st  = LangMan.LS(LSID.LSID_Wife) + ": ";
                        unk = LangMan.LS(LSID.LSID_UnkFemale);
                    }
                    else
                    {
                        sp  = famRec.GetHusband();
                        st  = LangMan.LS(LSID.LSID_Husband) + ": ";
                        unk = LangMan.LS(LSID.LSID_UnkMale);
                    }

                    string sps;
                    if (sp != null)
                    {
                        sps = st + GKUtils.GetNameString(sp, true, false) /* + GKUtils.GetPedigreeLifeStr(sp, fOptions.PedigreeOptions.Format)*/;
                    }
                    else
                    {
                        sps = st + unk;
                    }
                    fWriter.AddListItem("   " + "   " + sps, fTextFont);
                }
            }

            fWriter.EndList();
        }
Example #21
0
        private void WriteExcessFmt(PedigreePerson person)
        {
            fWriter.addParagraph(LangMan.LS(LSID.LSID_Sex) + ": " + GKUtils.SexStr(person.IRec.Sex), fTextFont);

            string st = GKUtils.GetLifeExpectancyStr(person.IRec);

            if (st != "?" && st != "")
            {
                fWriter.addParagraph(LangMan.LS(LSID.LSID_LifeExpectancy) + ": " + st, fTextFont);
            }

            GEDCOMIndividualRecord father, mother;
            GEDCOMFamilyRecord     fam = person.IRec.GetParentsFamily();

            if (fam == null)
            {
                father = null;
                mother = null;
            }
            else
            {
                father = fam.GetHusband();
                mother = fam.GetWife();
            }

            if (father != null)
            {
                fWriter.addParagraphLink(LangMan.LS(LSID.LSID_Father) + ": " + GKUtils.GetNameString(father, true, false) + " ", fTextFont, idLink(father), fLinkFont);
            }
            if (mother != null)
            {
                fWriter.addParagraphLink(LangMan.LS(LSID.LSID_Mother) + ": " + GKUtils.GetNameString(mother, true, false) + " ", fTextFont, idLink(mother), fLinkFont);
            }

            ExtList <PedigreeEvent> evList = new ExtList <PedigreeEvent>(true);

            try
            {
                int i;
                if (person.IRec.Events.Count > 0)
                {
                    fWriter.addParagraph(LangMan.LS(LSID.LSID_Events) + ":", fTextFont);

                    int num = person.IRec.Events.Count;
                    for (i = 0; i < num; i++)
                    {
                        GEDCOMCustomEvent evt = person.IRec.Events[i];
                        if (!(evt is GEDCOMIndividualAttribute) || fOptions.PedigreeOptions.IncludeAttributes)
                        {
                            evList.Add(new PedigreeEvent(person.IRec, evt));
                        }
                    }
                    WriteEventList(person, evList);
                }

                int num2 = person.IRec.SpouseToFamilyLinks.Count;
                for (i = 0; i < num2; i++)
                {
                    GEDCOMFamilyRecord family = person.IRec.SpouseToFamilyLinks[i].Family;
                    if (!fBase.Context.IsRecordAccess(family.Restriction))
                    {
                        continue;
                    }

                    GEDCOMPointer sp;
                    string        unk;
                    if (person.IRec.Sex == GEDCOMSex.svMale)
                    {
                        sp  = family.Wife;
                        st  = LangMan.LS(LSID.LSID_Wife) + ": ";
                        unk = LangMan.LS(LSID.LSID_UnkFemale);
                    }
                    else
                    {
                        sp  = family.Husband;
                        st  = LangMan.LS(LSID.LSID_Husband) + ": ";
                        unk = LangMan.LS(LSID.LSID_UnkMale);
                    }

                    GEDCOMIndividualRecord irec = sp.Value as GEDCOMIndividualRecord;
                    string sps;
                    if (irec != null)
                    {
                        sps = st + GKUtils.GetNameString(irec, true, false) + GKUtils.GetPedigreeLifeStr(irec, fOptions.PedigreeOptions.Format) /* + this.idLink(this.FindPerson(irec))*/;
                    }
                    else
                    {
                        sps = st + unk;
                    }

                    fWriter.addParagraph(sps, fTextFont);

                    evList.Clear();
                    int childrenCount = family.Children.Count;
                    for (int j = 0; j < childrenCount; j++)
                    {
                        irec = (GEDCOMIndividualRecord)family.Children[j].Value;
                        evList.Add(new PedigreeEvent(irec, irec.FindEvent("BIRT")));
                    }
                    WriteEventList(person, evList);
                }
            }
            finally
            {
                evList.Dispose();
            }

            if (fOptions.PedigreeOptions.IncludeNotes && person.IRec.Notes.Count != 0)
            {
                fWriter.addParagraph(LangMan.LS(LSID.LSID_RPNotes) + ":", fTextFont);

                fWriter.beginList();

                int notesCount = person.IRec.Notes.Count;
                for (int i = 0; i < notesCount; i++)
                {
                    GEDCOMNotes note = person.IRec.Notes[i];
                    fWriter.addListItem(" " + GKUtils.MergeStrings(note.Notes), fTextFont);
                }

                fWriter.endList();
            }
        }
Example #22
0
        public void BuildAncTree()
        {
            fSegments.Clear();

            const float startRad = CircleChartModel.CENTER_RAD - 50;
            float       inRad    = startRad;

            AncPersonSegment segment = new AncPersonSegment(0);

            DefineSegment(segment, 0, 0, inRad, 0 - 90.0f, 360.0f);
            fSegments.Add(segment);

            int maxSteps = 1;

            for (int gen = 1; gen <= fVisibleGenerations; gen++)
            {
                inRad = startRad + ((gen - 1) * fGenWidth);
                float extRad = inRad + fGenWidth;

                maxSteps *= 2;
                float wedgeAngle = (360.0f / maxSteps);

                for (int step = 0; step < maxSteps; step++)
                {
                    float startAngle = (step * wedgeAngle) - 90.0f;

                    segment = new AncPersonSegment(gen);
                    DefineSegment(segment, 0, inRad, extRad, startAngle, wedgeAngle);
                    fSegments.Add(segment);
                }
            }

            // traverse tree
            fGroupCount       = -1;
            fIndividualsCount = 0;
            if (fRootPerson == null)
            {
                return;
            }

            fIndividualsCount++;
            AncPersonSegment rootSegment = SetSegmentParams(0, fRootPerson, 0, -1);

            if (rootSegment == null)
            {
                return;
            }

            rootSegment.WedgeAngle = 360.0f;

            GEDCOMIndividualRecord father = null, mother = null;
            GEDCOMFamilyRecord     fam = fRootPerson.GetParentsFamily();

            if (fam != null && fBase.Context.IsRecordAccess(fam.Restriction))
            {
                father = fam.GetHusband();
                mother = fam.GetWife();
            }

            if (mother != null)
            {
                rootSegment.MotherSegment = TraverseAncestors(mother, 90f, 1, CircleChartModel.CENTER_RAD, 90.0f, 1, -1);
            }

            if (father != null)
            {
                rootSegment.FatherSegment = TraverseAncestors(father, 270.0f, 1, CircleChartModel.CENTER_RAD, 90.0f, 1, -1);
            }
        }
Example #23
0
        private AncPersonSegment TraverseAncestors(GEDCOMIndividualRecord 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;

                    GEDCOMIndividualRecord father = null, mother = null;
                    GEDCOMFamilyRecord     fam = iRec.GetParentsFamily();
                    if (fam != null && fBase.Context.IsRecordAccess(fam.Restriction))
                    {
                        father = fam.GetHusband();
                        mother = fam.GetWife();
                    }

                    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);
            }
        }
Example #24
0
        private void ExposePerson(ColumnText mct, GEDCOMIndividualRecord iRec, string iName, float colWidth)
        {
            Paragraph pg    = new Paragraph();
            Chunk     chunk = new Chunk(iName, fBoldFont);

            chunk.SetLocalDestination(iRec.XRef);
            pg.Add(chunk);
            chunk = new Chunk(GKUtils.GetPedigreeLifeStr(iRec, PedigreeFormat.Compact), fTextFont);
            pg.Add(chunk);
            pg.KeepTogether = true;
            mct.AddElement(pg);

            // FIXME
            IImage image = fBase.Context.GetPrimaryBitmap(iRec, 0, 0, false);

            if (image != null)
            {
                itImage img = TreeChartPDFRenderer.ConvertImage(image);

                float fitWidth = colWidth * 0.5f;
                img.ScaleToFit(fitWidth, fitWidth);

                // FIXME: the moving, if the page height is insufficient for the image height

                //img.Alignment = Image.TEXTWRAP;
                img.IndentationLeft = 5f;
                img.SpacingBefore   = 5f;
                img.SpacingAfter    = 5f;

                //Paragraph imgpar = new Paragraph(new Chunk(img, 0, 0, true));
                //imgpar.KeepTogether = true;

                mct.AddElement(img);
            }

            GEDCOMIndividualRecord father, mother;
            GEDCOMFamilyRecord     fam = iRec.GetParentsFamily();

            if (fam == null)
            {
                father = null;
                mother = null;
            }
            else
            {
                father = fam.GetHusband();
                mother = fam.GetWife();
            }

            if (father != null)
            {
                pg    = new Paragraph();
                chunk = new Chunk(GKUtils.GetNameString(father, true, false), fLinkFont);
                chunk.SetLocalGoto(father.XRef);
                pg.Add(new Chunk(LangMan.LS(LSID.LSID_Father) + ": ", fTextFont)); pg.Add(chunk);
                mct.AddElement(pg);
            }

            if (mother != null)
            {
                pg    = new Paragraph();
                chunk = new Chunk(GKUtils.GetNameString(mother, true, false), fLinkFont);
                chunk.SetLocalGoto(mother.XRef);
                pg.Add(new Chunk(LangMan.LS(LSID.LSID_Mother) + ": ", fTextFont)); pg.Add(chunk);
                mct.AddElement(pg);
            }

            if (IncludeEvents && iRec.Events.Count != 0)
            {
                int num = iRec.Events.Count;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMCustomEvent evt = iRec.Events[i];
                    if (evt.Name == "BIRT" || evt.Name == "DEAT")
                    {
                        continue;
                    }

                    string evtName = GKUtils.GetEventName(evt);
                    string evtVal  = evt.StringValue;
                    string evtDesc = GKUtils.GetEventDesc(evt, false);

                    string tmp = evtName + ": " + evtVal;
                    if (evtVal != "")
                    {
                        tmp += ", ";
                    }
                    tmp += evtDesc;

                    mct.AddElement(new Paragraph(new Chunk(tmp, fTextFont)));
                }
            }

            if (IncludeNotes && iRec.Notes.Count != 0)
            {
                int num = iRec.Notes.Count;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMNotes note = iRec.Notes[i];
                    mct.AddElement(new Paragraph(GKUtils.MergeStrings(note.Notes), fTextFont));
                }
            }
        }
Example #25
0
        private void UpdateControls(bool totalUpdate = false)
        {
            bool locked = (cmbRestriction.SelectedIndex == (int)GEDCOMRestriction.rnLocked);

            if (fPerson.ChildToFamilyLinks.Count != 0)
            {
                GEDCOMFamilyRecord family = fPerson.ChildToFamilyLinks[0].Family;
                btnParentsAdd.Enabled    = false;
                btnParentsEdit.Enabled   = true && !locked;
                btnParentsDelete.Enabled = true && !locked;

                GEDCOMIndividualRecord relPerson = family.GetHusband();
                if (relPerson != null)
                {
                    btnFatherAdd.Enabled    = false;
                    btnFatherDelete.Enabled = true && !locked;
                    btnFatherSel.Enabled    = true && !locked;
                    txtFather.Text          = GKUtils.GetNameString(relPerson, true, false);
                }
                else
                {
                    btnFatherAdd.Enabled    = true && !locked;
                    btnFatherDelete.Enabled = false;
                    btnFatherSel.Enabled    = false;
                    txtFather.Text          = "";
                }

                relPerson = family.GetWife();
                if (relPerson != null)
                {
                    btnMotherAdd.Enabled    = false;
                    btnMotherDelete.Enabled = true && !locked;
                    btnMotherSel.Enabled    = true && !locked;
                    txtMother.Text          = GKUtils.GetNameString(relPerson, true, false);
                }
                else
                {
                    btnMotherAdd.Enabled    = true && !locked;
                    btnMotherDelete.Enabled = false;
                    btnMotherSel.Enabled    = false;
                    txtMother.Text          = "";
                }
            }
            else
            {
                btnParentsAdd.Enabled    = true && !locked;
                btnParentsEdit.Enabled   = false;
                btnParentsDelete.Enabled = false;

                btnFatherAdd.Enabled    = true && !locked;
                btnFatherDelete.Enabled = false;
                btnFatherSel.Enabled    = false;

                btnMotherAdd.Enabled    = true && !locked;
                btnMotherDelete.Enabled = false;
                btnMotherSel.Enabled    = false;

                txtFather.Text = "";
                txtMother.Text = "";
            }

            if (totalUpdate)
            {
                fEventsList.UpdateSheet();
                fNotesList.UpdateSheet();
                fMediaList.UpdateSheet();
                fSourcesList.UpdateSheet();
                fAssociationsList.UpdateSheet();

                fGroupsList.UpdateSheet();
                fNamesList.UpdateSheet();
                fSpousesList.UpdateSheet();
                fUserRefList.UpdateSheet();
            }

            UpdatePortrait(totalUpdate);

            // controls lock
            txtName.Enabled       = !locked;
            cmbPatronymic.Enabled = !locked;
            txtSurname.Enabled    = !locked;

            cmbSex.Enabled       = !locked;
            chkPatriarch.Enabled = !locked;
            chkBookmark.Enabled  = !locked;

            txtNamePrefix.Enabled    = !locked;
            txtNickname.Enabled      = !locked;
            txtSurnamePrefix.Enabled = !locked;
            txtNameSuffix.Enabled    = !locked;

            fEventsList.ReadOnly       = locked;
            fNotesList.ReadOnly        = locked;
            fMediaList.ReadOnly        = locked;
            fSourcesList.ReadOnly      = locked;
            fSpousesList.ReadOnly      = locked;
            fAssociationsList.ReadOnly = locked;
            fGroupsList.ReadOnly       = locked;
            fUserRefList.ReadOnly      = locked;

            ICulture culture = fBase.Context.Culture;

            txtSurname.Enabled    = txtSurname.Enabled && culture.HasSurname();
            cmbPatronymic.Enabled = cmbPatronymic.Enabled && culture.HasPatronymic();
        }