예제 #1
0
        private void UpdateCloud()
        {
            try {
                fWords.Clear();

                if (fBase != null)
                {
                    List <StatsItem> vals      = new List <StatsItem>();
                    TreeStats        treeStats = new TreeStats(fBase.Context, fBase.GetContentList(GEDCOMRecordType.rtIndividual));
                    treeStats.GetSpecStats(fMode, vals);

                    fWords.Capacity = vals.Count;
                    foreach (var statsItem in vals)
                    {
                        string word = statsItem.Caption;
                        if (word != "?")
                        {
                            fWords.Add(new Word(statsItem.Caption, statsItem.Value));
                        }
                    }
                    fWords.Sort(CompareWords);
                }

                cloudViewer.WeightedWords = fWords;
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        public void Test_Stats()
        {
            CompositeItem compositeItem = new CompositeItem();

            Assert.IsNotNull(compositeItem);
            compositeItem.TakeVal(0.0f, GDMSex.svMale, true);
            Assert.AreEqual(0, compositeItem.CommonVal);
            Assert.AreEqual(0, compositeItem.MaleVal);
            Assert.AreEqual(0, compositeItem.FemaleVal);
            compositeItem.TakeVal(1f, GDMSex.svFemale, true);
            compositeItem.TakeVal(1f, GDMSex.svMale, true);
            Assert.AreEqual(1, compositeItem.CommonVal);
            Assert.AreEqual(1, compositeItem.MaleVal);
            Assert.AreEqual(1, compositeItem.FemaleVal);
            compositeItem.TakeVal("1", GDMSex.svFemale, true);
            compositeItem.TakeVal("1", GDMSex.svMale, true);
            Assert.AreEqual(1, compositeItem.CommonVal);
            Assert.AreEqual(1, compositeItem.MaleVal);
            Assert.AreEqual(1, compositeItem.FemaleVal);

            StatsItem statsItem = new StatsItem("test", false);

            Assert.IsNotNull(statsItem);
            Assert.AreEqual("test", statsItem.ToString());

            statsItem = new StatsItem("test2", 0);
            Assert.IsNotNull(statsItem);
            Assert.AreEqual("test2", statsItem.ToString());

            List <GDMRecord>      selectedRecords = new List <GDMRecord>();
            IGEDCOMTreeEnumerator iEnum           = fContext.Tree.GetEnumerator(GDMRecordType.rtIndividual);
            GDMRecord             current;

            while (iEnum.MoveNext(out current))
            {
                selectedRecords.Add(current);
            }

            TreeStats treeStats = new TreeStats(fContext, selectedRecords);

            Assert.IsNotNull(treeStats);

            CommonStats commonStats = treeStats.GetCommonStats();

            Assert.IsNotNull(commonStats);
            Assert.AreEqual(6, commonStats.persons, "Stats.TotalPersons");
            Assert.AreEqual(2, commonStats.persons_m, "Stats.SumM");
            Assert.AreEqual(4, commonStats.persons_f, "Stats.SumF");

            List <StatsItem> values = new List <StatsItem>();

            treeStats.GetSpecStats(StatsMode.smAncestors, values);
            treeStats.GetSpecStats(StatsMode.smDescendants, values);
            treeStats.GetSpecStats(StatsMode.smDescGenerations, values);
            treeStats.GetSpecStats(StatsMode.smSurnames, values);
            treeStats.GetSpecStats(StatsMode.smNames, values);
            treeStats.GetSpecStats(StatsMode.smPatronymics, values);
            treeStats.GetSpecStats(StatsMode.smAge, values);
            treeStats.GetSpecStats(StatsMode.smLifeExpectancy, values);
            treeStats.GetSpecStats(StatsMode.smBirthYears, values);
            treeStats.GetSpecStats(StatsMode.smBirthTenYears, values);
            treeStats.GetSpecStats(StatsMode.smDeathYears, values);
            treeStats.GetSpecStats(StatsMode.smDeathTenYears, values);
            treeStats.GetSpecStats(StatsMode.smChildsCount, values);
            treeStats.GetSpecStats(StatsMode.smChildsDistribution, values);
            treeStats.GetSpecStats(StatsMode.smBirthPlaces, values);
            treeStats.GetSpecStats(StatsMode.smDeathPlaces, values);
            treeStats.GetSpecStats(StatsMode.smResidences, values);
            treeStats.GetSpecStats(StatsMode.smOccupation, values);
            treeStats.GetSpecStats(StatsMode.smReligious, values);
            treeStats.GetSpecStats(StatsMode.smNational, values);
            treeStats.GetSpecStats(StatsMode.smEducation, values);
            treeStats.GetSpecStats(StatsMode.smCaste, values);
            treeStats.GetSpecStats(StatsMode.smFirstbornAge, values);
            treeStats.GetSpecStats(StatsMode.smMarriages, values);
            treeStats.GetSpecStats(StatsMode.smMarriageAge, values);
            treeStats.GetSpecStats(StatsMode.smSpousesDiff, values);
            treeStats.GetSpecStats(StatsMode.smHobby, values);
            treeStats.GetSpecStats(StatsMode.smAward, values);
            treeStats.GetSpecStats(StatsMode.smMili, values);
            treeStats.GetSpecStats(StatsMode.smMiliInd, values);
            treeStats.GetSpecStats(StatsMode.smMiliDis, values);
            treeStats.GetSpecStats(StatsMode.smMiliRank, values);
            treeStats.GetSpecStats(StatsMode.smAAF_1, values);
            treeStats.GetSpecStats(StatsMode.smAAF_2, values);
            treeStats.GetSpecStats(StatsMode.smCertaintyIndex, values);
            treeStats.GetSpecStats(StatsMode.smBirthByMonth, values);
            treeStats.GetSpecStats(StatsMode.smDemography, values);
        }
        public void CalcStats(StatsMode mode)
        {
            fCurrentMode = mode;

            fView.ListStats.SetColumnCaption(0, LangMan.LS(GKData.StatsTitles[(int)mode].Cap));
            fView.ListStats.SetColumnCaption(1, LangMan.LS(LSID.LSID_Value));

            fView.ListStats.BeginUpdate();
            fView.ListStats.ClearItems();
            try {
                fCurrentValues = new List <StatsItem>();
                fTreeStats.GetSpecStats(mode, fCurrentValues);

                foreach (StatsItem lv in fCurrentValues)
                {
                    fView.ListStats.AddItem(null, lv.Caption, lv.GetDisplayString());
                }
            } finally {
                fView.ListStats.EndUpdate();
            }

            fChartTitle = LangMan.LS(GKData.StatsTitles[(int)mode].Title);

            switch (mode)
            {
            case StatsMode.smAge:
                fChartXTitle = LangMan.LS(LSID.LSID_Age);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                fView.Graph.PrepareArray(fChartTitle, fChartXTitle, fChartYTitle, ChartStyle.Point, true, fCurrentValues);
                break;

            case StatsMode.smLifeExpectancy:
                fChartXTitle = LangMan.LS(LSID.LSID_LifeExpectancy);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                fView.Graph.PrepareArray(fChartTitle, fChartXTitle, fChartYTitle, ChartStyle.Point, true, fCurrentValues);
                break;

            case StatsMode.smBirthYears:
            case StatsMode.smBirthTenYears:
            case StatsMode.smDeathYears:
            case StatsMode.smDeathTenYears:
            {
                switch (mode)
                {
                case StatsMode.smBirthYears:
                case StatsMode.smDeathYears:
                    fChartXTitle = LangMan.LS(LSID.LSID_Years);
                    break;

                case StatsMode.smBirthTenYears:
                case StatsMode.smDeathTenYears:
                    fChartXTitle = LangMan.LS(LSID.LSID_Decennial);
                    break;
                }

                switch (mode)
                {
                case StatsMode.smBirthYears:
                case StatsMode.smBirthTenYears:
                    fChartYTitle = LangMan.LS(LSID.LSID_HowBirthes);
                    break;

                case StatsMode.smDeathYears:
                case StatsMode.smDeathTenYears:
                    fChartYTitle = LangMan.LS(LSID.LSID_HowDeads);
                    break;
                }

                fView.Graph.PrepareArray(fChartTitle, fChartXTitle, fChartYTitle, ChartStyle.Point, true, fCurrentValues);
                break;
            }

            case StatsMode.smChildsDistribution:
                fChartXTitle = LangMan.LS(LSID.LSID_Childs);
                fChartYTitle = LangMan.LS(LSID.LSID_Parents);
                fView.Graph.PrepareArray(fChartTitle, fChartXTitle, fChartYTitle, ChartStyle.Bar, true, fCurrentValues);
                break;

            case StatsMode.smCertaintyIndex:
                fChartXTitle = LangMan.LS(LSID.LSID_CertaintyIndex);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                fView.Graph.PrepareArray(fChartTitle, fChartXTitle, fChartYTitle, ChartStyle.Bar, true, fCurrentValues);
                break;

            case StatsMode.smBirthByMonth:
                fChartXTitle = LangMan.LS(LSID.LSID_Month);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                fView.Graph.PrepareArray(fChartTitle, fChartXTitle, fChartYTitle, ChartStyle.Bar, true, fCurrentValues);
                break;

            case StatsMode.smDemography:
                fChartXTitle = LangMan.LS(LSID.LSID_LifeExpectancy);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                fView.Graph.PrepareArray(fChartTitle, fChartXTitle, fChartYTitle, ChartStyle.ClusterBar, true, fCurrentValues);
                break;

            default:
                fView.Graph.Clear();
                break;
            }
        }
예제 #4
0
        private void CalcStats(StatsMode mode)
        {
            fListStats.SortColumn      = 0;
            fListStats.Columns[0].Text = LangMan.LS(GKData.StatsTitles[(int)mode].Cap);
            fListStats.Columns[1].Text = LangMan.LS(LSID.LSID_Value);

            fListStats.Sorting    = SortOrder.None;
            fListStats.SortColumn = -1;
            fListStats.BeginUpdate();
            fListStats.Items.Clear();

            List <StatsItem> vals = new List <StatsItem>();

            try
            {
                fTreeStats.GetSpecStats(mode, vals);
                fCurrentValues = vals;

                ListViewItem[] items = new ListViewItem[vals.Count];

                int i = 0;
                foreach (StatsItem lv in vals)
                {
                    ListViewItem item = new ListViewItem(lv.Caption);

                    string stVal = lv.GetDisplayString();
                    item.SubItems.Add(stVal);

                    items[i] = item;
                    i++;
                }

                fListStats.Items.AddRange(items);
            }
            finally
            {
                fListStats.EndUpdate();
            }

            fChartTitle = LangMan.LS(GKData.StatsTitles[(int)mode].Title);

            switch (mode)
            {
            case StatsMode.smAge:
                fChartXTitle = LangMan.LS(LSID.LSID_Age);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                PrepareArray(ChartStyle.Point, true);
                break;

            case StatsMode.smLifeExpectancy:
                fChartXTitle = LangMan.LS(LSID.LSID_LifeExpectancy);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                PrepareArray(ChartStyle.Point, true);
                break;

            case StatsMode.smBirthYears:
            case StatsMode.smBirthTenYears:
            case StatsMode.smDeathYears:
            case StatsMode.smDeathTenYears: {
                switch (mode)
                {
                case StatsMode.smBirthYears:
                case StatsMode.smDeathYears:
                    fChartXTitle = LangMan.LS(LSID.LSID_Years);
                    break;

                case StatsMode.smBirthTenYears:
                case StatsMode.smDeathTenYears:
                    fChartXTitle = LangMan.LS(LSID.LSID_Decennial);
                    break;
                }

                switch (mode)
                {
                case StatsMode.smBirthYears:
                case StatsMode.smBirthTenYears:
                    fChartYTitle = LangMan.LS(LSID.LSID_HowBirthes);
                    break;

                case StatsMode.smDeathYears:
                case StatsMode.smDeathTenYears:
                    fChartYTitle = LangMan.LS(LSID.LSID_HowDeads);
                    break;
                }

                PrepareArray(ChartStyle.Point, true);
                break;
            }

            case StatsMode.smChildsDistribution:
                fChartXTitle = LangMan.LS(LSID.LSID_Childs);
                fChartYTitle = LangMan.LS(LSID.LSID_Parents);
                PrepareArray(ChartStyle.Bar, true);
                break;

            case StatsMode.smCertaintyIndex:
                fChartXTitle = LangMan.LS(LSID.LSID_CertaintyIndex);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                PrepareArray(ChartStyle.Bar, true);
                break;

            case StatsMode.smBirthByMonth:
                fChartXTitle = LangMan.LS(LSID.LSID_Month);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                PrepareArray(ChartStyle.Bar, true);
                break;

            case StatsMode.smDemography:
                fChartXTitle = LangMan.LS(LSID.LSID_LifeExpectancy);
                fChartYTitle = LangMan.LS(LSID.LSID_People);
                PrepareArray(ChartStyle.ClusterBar, true, vals);
                break;

            default:
                fGraph.Clear();
                break;
            }
        }