Beispiel #1
0
        public void Search()
        {
            fView.PatriarchsList.BeginUpdate();
            ExtList <PatriarchObj> lst = null;

            try {
                fView.PatriarchsList.ClearItems();
                lst = PatriarchsMan.GetPatriarchsList(fBase.Context, (int)fView.MinGensNum.Value, !fView.WithoutDatesCheck.Checked);
                lst.QuickSort(PatriarchsCompare);

                int num = lst.Count;
                for (int i = 0; i < num; i++)
                {
                    PatriarchObj pObj  = lst[i];
                    string       pSign = ((pObj.IRec.Patriarch) ? "[*] " : "");

                    fView.PatriarchsList.AddItem(pObj.IRec, new object[] { pSign + GKUtils.GetNameString(pObj.IRec, true, false),
                                                                           pObj.BirthYear, pObj.DescendantsCount, pObj.DescGenerations });
                }
            } finally {
                if (lst != null)
                {
                    lst.Dispose();
                }
                fView.PatriarchsList.EndUpdate();
            }
        }
Beispiel #2
0
        private void btnPatSearch_Click(object sender, EventArgs e)
        {
            ListPatriarchs.BeginUpdate();
            ExtList <PatriarchObj> lst = null;

            try
            {
                ListPatriarchs.ClearItems();
                lst = PatriarchsMan.GetPatriarchsList(fBase.Context,
                                                      (int)edMinGens.Value, !chkWithoutDates.Checked.GetValueOrDefault());
                lst.QuickSort(PatriarchsCompare);

                int num = lst.Count;
                for (int i = 0; i < num; i++)
                {
                    PatriarchObj pObj  = lst[i];
                    string       pSign = ((pObj.IRec.Patriarch) ? "[*] " : "");

                    ListPatriarchs.AddItem(pObj.IRec, new object[] { pSign + GKUtils.GetNameString(pObj.IRec, true, false),
                                                                     pObj.BirthYear,
                                                                     pObj.DescendantsCount,
                                                                     pObj.DescGenerations });
                }
            }
            finally
            {
                if (lst != null)
                {
                    lst.Dispose();
                }
                ListPatriarchs.EndUpdate();
            }
        }
Beispiel #3
0
        public void SelectPlaces()
        {
            GDMIndividualRecord ind = null;

            bool condBirth     = false;
            bool condDeath     = false;
            bool condResidence = false;

            if (fView.TotalRadio.Checked)
            {
                condBirth     = fView.BirthCheck.Checked;
                condDeath     = fView.DeathCheck.Checked;
                condResidence = fView.ResidenceCheck.Checked;
            }
            else if (fView.SelectedRadio.Checked && (fView.PersonsCombo.SelectedIndex >= 0))
            {
                ind = (fView.PersonsCombo.GetSelectedTag <GDMIndividualRecord>());
            }

            fView.MapBrowser.ShowLines = (ind != null && fView.LinesVisibleCheck.Checked);
            fMapPoints.Clear();

            int num = fPlaces.Count;

            for (int i = 0; i < num; i++)
            {
                MapPlace place = fPlaces[i];
                if (place.Points.Count < 1)
                {
                    continue;
                }

                int num2 = place.PlaceRefs.Count;
                for (int j = 0; j < num2; j++)
                {
                    var            placeRef       = place.PlaceRefs[j];
                    GDMCustomEvent evt            = placeRef.Event;
                    var            evtType        = evt.GetTagType();
                    bool           checkEventType = (condBirth && evtType == GEDCOMTagType.BIRT) ||
                                                    (condDeath && evtType == GEDCOMTagType.DEAT) || (condResidence && evtType == GEDCOMTagType.RESI);

                    if ((ind != null && (placeRef.Owner == ind)) || checkEventType)
                    {
                        PlacesLoader.AddPoint(fMapPoints, place.Points[0], placeRef);
                    }
                }
            }

            if (ind != null)
            {
                // sort points by date
                fMapPoints.QuickSort(MapPointsCompare);
            }

            PlacesLoader.CopyPoints(fView.MapBrowser, fMapPoints, ind != null);
        }
Beispiel #4
0
        private void btnSelectPlaces_Click(object sender, EventArgs e)
        {
            GEDCOMIndividualRecord ind = null;

            bool condBirth     = false;
            bool condDeath     = false;
            bool condResidence = false;

            if (radTotal.Checked)
            {
                condBirth     = chkBirth.Checked.GetValueOrDefault();
                condDeath     = chkDeath.Checked.GetValueOrDefault();
                condResidence = chkResidence.Checked.GetValueOrDefault();
            }
            else if (radSelected.Checked && (cmbPersons.SelectedIndex >= 0))
            {
                GKComboItem item = (GKComboItem)cmbPersons.Items[cmbPersons.SelectedIndex];
                ind = (item.Tag as GEDCOMIndividualRecord);
            }

            fMapBrowser.ShowLines = (ind != null && chkLinesVisible.Checked.GetValueOrDefault());
            fMapPoints.Clear();

            int num = fPlaces.Count;

            for (int i = 0; i < num; i++)
            {
                MapPlace place = fPlaces[i];
                if (place.Points.Count < 1)
                {
                    continue;
                }

                int num2 = place.PlaceRefs.Count;
                for (int j = 0; j < num2; j++)
                {
                    GEDCOMCustomEvent evt = place.PlaceRefs[j].Event;

                    if ((ind != null && (evt.Parent == ind)) || (condBirth && evt.Name == "BIRT") || (condDeath && evt.Name == "DEAT") || (condResidence && evt.Name == "RESI"))
                    {
                        PlacesLoader.AddPoint(fMapPoints, place.Points[0], place.PlaceRefs[j]);
                    }
                }
            }

            if (ind != null)
            {
                // sort points by date
                fMapPoints.QuickSort(MapPointsCompare);
            }

            PlacesLoader.CopyPoints(fMapBrowser, fMapPoints, ind != null);
        }
Beispiel #5
0
        public void SelectPlaces()
        {
            GEDCOMIndividualRecord ind = null;

            bool condBirth     = false;
            bool condDeath     = false;
            bool condResidence = false;

            if (fView.TotalRadio.Checked)
            {
                condBirth     = fView.BirthCheck.Checked;
                condDeath     = fView.DeathCheck.Checked;
                condResidence = fView.ResidenceCheck.Checked;
            }
            else if (fView.SelectedRadio.Checked && (fView.PersonsCombo.SelectedIndex >= 0))
            {
                ind = (fView.PersonsCombo.SelectedTag as GEDCOMIndividualRecord);
            }

            fView.MapBrowser.ShowLines = (ind != null && fView.LinesVisibleCheck.Checked);
            fMapPoints.Clear();

            int num = fPlaces.Count;

            for (int i = 0; i < num; i++)
            {
                MapPlace place = fPlaces[i];
                if (place.Points.Count < 1)
                {
                    continue;
                }

                int num2 = place.PlaceRefs.Count;
                for (int j = 0; j < num2; j++)
                {
                    GEDCOMCustomEvent evt = place.PlaceRefs[j].Event;

                    if ((ind != null && (evt.Parent == ind)) || (condBirth && evt.Name == "BIRT") || (condDeath && evt.Name == "DEAT") || (condResidence && evt.Name == "RESI"))
                    {
                        PlacesLoader.AddPoint(fMapPoints, place.Points[0], place.PlaceRefs[j]);
                    }
                }
            }

            if (ind != null)
            {
                // sort points by date
                fMapPoints.QuickSort(MapPointsCompare);
            }

            PlacesLoader.CopyPoints(fView.MapBrowser, fMapPoints, ind != null);
        }
        private void PreparePatriarchs()
        {
            using (ExtList <PatriarchObj> lst = PatriarchsMan.GetPatriarchsList(fBase.Context, 2, false))
            {
                lst.QuickSort(PatriarchsCompare);

                int num = lst.Count;
                for (int i = 0; i < num; i++)
                {
                    PatriarchObj pObj = lst[i];
                    fPatList.AddObject(GKUtils.GetNameString(pObj.IRec, true, false), pObj.IRec);
                }
            }
        }
Beispiel #7
0
        private void ReIndex()
        {
            fPersonList.QuickSort(PersonsCompare);

            int num3 = fPersonList.Count;

            for (int i = 0; i < num3; i++)
            {
                PedigreePerson obj = fPersonList[i];

                switch (fKind)
                {
                case PedigreeKind.pkDescend_dAboville:
                    if (obj.Parent == null)
                    {
                        obj.Id = "1";
                    }
                    else
                    {
                        obj.Parent.ChildIdx++;
                        obj.Id = obj.Parent.Id + "." + obj.Parent.ChildIdx.ToString();
                    }
                    break;

                case PedigreeKind.pkAscend:
                case PedigreeKind.pkDescend_Konovalov:
                    obj.Id = (i + 1).ToString();
                    if (obj.Parent != null)
                    {
                        string pid = obj.Parent.Id;

                        int p = pid.IndexOf("-");
                        if (p >= 0)
                        {
                            pid = pid.Substring(0, p);
                        }

                        obj.Id = obj.Id + "-" + pid;
                    }
                    break;
                }
            }
        }
Beispiel #8
0
        protected override void InternalGenerate()
        {
            try {
                #if !NETSTANDARD
                IColor clrBlack = AppHost.GfxProvider.CreateColor(0x000000);
                IColor clrBlue  = AppHost.GfxProvider.CreateColor(0x0000FF);

                fLinkFont = fWriter.CreateFont("", 8f, false, true, clrBlue);
                fTextFont = fWriter.CreateFont("", 8f, false, false, clrBlack);

                fWriter.EnablePageNumbers();

                fRenderer = fWriter.GetPageRenderer();
                if (fRenderer == null)
                {
                    // TODO: warning
                    return;
                }

                IFont titleFont = fWriter.CreateFont("", 30f, true, false, clrBlack);
                fPageSize = fWriter.GetPageSize();
                float pageHeight = fPageSize.GetHeight();
                float pageWidth  = fPageSize.GetWidth();
                float halfpage   = (pageHeight - (((PDFWriter.FontHandler)titleFont).GetTextHeight())) / 2f;
                fWriter.NewLine(0.0f, halfpage);
                fWriter.AddParagraph(fTitle, titleFont, TextAlignment.taCenter);

                var chartOptions = new TreeChartOptions();
                chartOptions.Assign(GlobalOptions.Instance.TreeChartOptions);
                chartOptions.DefaultPortraits   = false;
                chartOptions.HideUnknownSpouses = true;
                chartOptions.InvertedTree       = false;
                chartOptions.Kinship            = false;
                chartOptions.ShowPlaces         = false;

                var treeBox = AppHost.Container.Resolve <ITreeChart>();
                treeBox.SetRenderer(fRenderer);
                treeBox.Base    = fBase;
                treeBox.Options = chartOptions;
                treeBox.Height  = (int)pageHeight;
                treeBox.Width   = (int)pageWidth;

                fPatList = PatriarchsMan.GetPatriarchsList(fBase.Context, 2, false);
                fPatList.QuickSort(PatriarchsCompare);

                int num = fPatList.Count;
                for (int i = 0; i < num; i++)
                {
                    var patriarch = fPatList[i].IRec;

                    fIndiQueue.Clear();
                    fIndiQueue.Add(new IndiObj(patriarch, TreeChartKind.ckDescendants));

                    for (int q = 0; q < fIndiQueue.Count; q++)
                    {
                        fWriter.NewPage();
                        TryRenderTreeSlice(treeBox, q, patriarch);
                    }
                }
                #endif
            } catch (Exception ex) {
                Logger.WriteError("TreesAlbumExporter.InternalGenerate()", ex);
                throw;
            }
        }
Beispiel #9
0
        private void WriteEventList(PedigreePerson person, ExtList <PedigreeEvent> evList)
        {
            evList.QuickSort(EventsCompare);

            int num3 = evList.Count;

            for (int i = 0; i < num3; i++)
            {
                GEDCOMCustomEvent evt = evList[i].Event;
                if (evt != null && Equals(evList[i].IRec, person.IRec))
                {
                    if (evt.Name == "BIRT")
                    {
                        evList.Exchange(i, 0);
                    }
                    else if (evt.Name == "DEAT")
                    {
                        evList.Exchange(i, evList.Count - 1);
                    }
                }
            }

            fWriter.beginList();

            int num4 = evList.Count;

            for (int i = 0; i < num4; i++)
            {
                PedigreeEvent     evObj = evList[i];
                GEDCOMCustomEvent evt   = evObj.Event;
                string            li;

                if (evObj.IRec == person.IRec)
                {
                    int    ev = GKUtils.GetPersonEventIndex(evt.Name);
                    string st;
                    if (ev == 0)
                    {
                        st = evt.Classification;
                    }
                    else
                    {
                        st = (ev > 0) ? LangMan.LS(GKData.PersonEvents[ev].Name) : evt.Name;
                    }

                    string dt = GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfDD_MM_YYYY, false);
                    li = dt + ": " + st + ".";
                    if (evt.Place.StringValue != "")
                    {
                        li = li + " " + LangMan.LS(LSID.LSID_Place) + ": " + evt.Place.StringValue;
                    }

                    fWriter.addListItem(" " + li, fTextFont);
                }
                else
                {
                    string dt = (evt == null) ? "?" : GKUtils.GEDCOMEventToDateStr(evt, DateFormat.dfDD_MM_YYYY, false);

                    string st = (evObj.IRec.Sex == GEDCOMSex.svMale) ? ": Родился " : ": Родилась ";

                    li = dt + st + GKUtils.GetNameString(evObj.IRec, true, false);
                    PedigreePerson prs = FindPerson(evObj.IRec);
                    string         id  = (prs != null) ? prs.Id : "";

                    fWriter.addListItemLink(" " + li + " ", fTextFont, id, fLinkFont);
                }
            }

            fWriter.endList();
        }
Beispiel #10
0
        private void WriteEventList(PedigreePerson person, ExtList <PedigreeEvent> evList)
        {
            evList.QuickSort(EventsCompare);

            int evtNum = evList.Count;

            for (int i = 0; i < evtNum; i++)
            {
                GDMCustomEvent evt = evList[i].Event;
                if (evt != null && Equals(evList[i].IRec, person.IRec))
                {
                    var evtType = evt.GetTagType();

                    if (evtType == GEDCOMTagType.BIRT)
                    {
                        evList.Exchange(i, 0);
                    }
                    else if (evtType == GEDCOMTagType.DEAT)
                    {
                        evList.Exchange(i, evtNum - 1);
                    }
                }
            }

            fWriter.BeginList();

            var dateFormat = GlobalOptions.Instance.DefDateFormat;

            for (int i = 0; i < evtNum; i++)
            {
                PedigreeEvent  evObj = evList[i];
                GDMCustomEvent evt   = evObj.Event;
                string         li;

                if (evObj.IRec == person.IRec)
                {
                    var    evtName = evt.GetTagName();
                    int    ev      = GKUtils.GetPersonEventIndex(evtName);
                    string st;
                    if (ev == 0)
                    {
                        st = evt.Classification;
                    }
                    else
                    {
                        st = (ev > 0) ? LangMan.LS(GKData.PersonEvents[ev].Name) : evtName;
                    }

                    string dt = GKUtils.GEDCOMEventToDateStr(evt, dateFormat, false);
                    li = dt + ": " + st + ".";
                    if (evt.Place.StringValue != "")
                    {
                        li = li + " " + LangMan.LS(LSID.LSID_Place) + ": " + evt.Place.StringValue;
                    }

                    fWriter.AddListItem(" " + li, fTextFont);
                }
                else
                {
                    string dt = (evt == null) ? "?" : GKUtils.GEDCOMEventToDateStr(evt, dateFormat, false);

                    string st = (evObj.IRec.Sex == GDMSex.svMale) ? LangMan.LS(LSID.LSID_HeWasBorn) : LangMan.LS(LSID.LSID_SheWasBorn);

                    li = string.Format("{0}: {1} {2}", dt, st, GKUtils.GetNameString(evObj.IRec, true, false));
                    PedigreePerson prs = FindPerson(evObj.IRec);
                    string         id  = (prs != null) ? prs.Id : "";

                    fWriter.AddListItemLink(" " + li + " ", fTextFont, id, fLinkFont);
                }
            }

            fWriter.EndList();
        }
Beispiel #11
0
        public void Test_Common()
        {
            using (ExtList <object> list = new ExtList <object>(true))
            {
                Assert.IsNotNull(list);
            }

            using (ExtList <object> list = new ExtList <object>())
            {
                Assert.IsNotNull(list);
                Assert.AreEqual(0, list.Count);

                Assert.Throws(typeof(ListException), () => { list[-1] = null; });

                object obj  = new object();
                object obj1 = new object();

                list.Add(obj);
                Assert.AreEqual(1, list.Count);
                Assert.AreEqual(obj, list[0]);
                Assert.AreEqual(0, list.IndexOf(obj));

                list.Delete(0);
                Assert.AreEqual(0, list.Count);

                list.Add(obj);
                Assert.AreEqual(obj, list.Extract(obj));

                list.Insert(0, obj);

                list[0] = obj;
                Assert.AreEqual(obj, list[0]);

                list.Add(null);
                Assert.AreEqual(2, list.Count);
                Assert.AreEqual(null, list[1]);
                list[1] = obj1;
                Assert.AreEqual(obj1, list[1]);

                list[1] = null;
                Assert.AreEqual(2, list.Count);
                list.Pack();
                Assert.AreEqual(1, list.Count);

                list.Remove(obj);
                Assert.AreEqual(0, list.Count);

                Assert.AreEqual(false, list.OwnsObjects);

                list.OwnsObjects = true;
                Assert.AreEqual(true, list.OwnsObjects);

                list.Clear();
                list.Add(obj);
                list.Add(obj1);
                Assert.AreEqual(obj, list[0]);
                Assert.AreEqual(obj1, list[1]);
                list.Exchange(0, 1);
                Assert.AreEqual(obj, list[1]);
                Assert.AreEqual(obj1, list[0]);
            }

            using (ExtList <ValItem> list = new ExtList <ValItem>())
            {
                Assert.IsNotNull(list);

                list.Add(new ValItem(5));
                list.Add(new ValItem(1));
                list.Add(new ValItem(17));
                list.Add(new ValItem(4));

                list.QuickSort(CompareItems);

                list.MergeSort(CompareItems);
            }
        }