예제 #1
0
        private void TryRenderTreeSlice(ITreeChart treeBox, int index, GDMIndividualRecord currentPatriarch)
        {
            IndiObj indi = fIndiQueue[index];

            fProcessed.Add(indi.IRec.XRef);

            int         depthLimit  = 3;
            float       scaleFactor = 1.0f;
            int         tries       = 0;
            RenderStage stage       = RenderStage.Normal;

            while (true)
            {
                treeBox.Model.DepthLimit = depthLimit;
                treeBox.Model.Scale      = scaleFactor;
                treeBox.GenChart(indi.IRec, indi.TreeKind, false);
                tries += 1;

                ExtSize imageSize = treeBox.GetImageSize();
                var     sf        = GfxHelper.ZoomToFit(imageSize.Width, imageSize.Height, fPageSize.GetWidth(), fPageSize.GetHeight());

                if (sf < 1.0f)
                {
                    // need to reduce image's size
                    switch (stage)
                    {
                    case RenderStage.Normal:
                        depthLimit -= 1;
                        stage       = RenderStage.Shrink;
                        break;

                    case RenderStage.Grow:
                        depthLimit -= 1;
                        stage       = RenderStage.Break;
                        break;

                    case RenderStage.Shrink:
                        scaleFactor = sf;
                        stage       = RenderStage.Break;
                        break;
                    }
                }
                else if (sf > 1.0f)
                {
                    // need to increase image's size
                    switch (stage)
                    {
                    case RenderStage.Normal:
                    case RenderStage.Grow:
                        depthLimit += 1;
                        stage       = RenderStage.Grow;
                        break;

                    case RenderStage.Shrink:
                        scaleFactor = sf;
                        stage       = RenderStage.Break;
                        break;
                    }
                }

                if (stage == RenderStage.Break || tries > 10)
                {
                    break;
                }
            }

            scaleFactor = Math.Min(1.0f, scaleFactor);
            treeBox.Model.DepthLimit = depthLimit;
            treeBox.Model.Scale      = scaleFactor;
            treeBox.GenChart(indi.IRec, indi.TreeKind, false);
            treeBox.RenderImage(RenderTarget.Printer, true);

            var indiNums = new GKVarCache <GDMIndividualRecord, int>();

            for (int i = 0; i < treeBox.Model.Persons.Count; i++)
            {
                TreeChartPerson     person  = treeBox.Model.Persons[i];
                GDMIndividualRecord indiRec = person.Rec;
                if (indiRec == null)
                {
                    continue;
                }

                int iNum = indiNums[indiRec];

                var    offset = treeBox.Model.GetOffsets();
                int    ix     = offset.X + person.Rect.Left;
                int    iy     = offset.Y + person.Rect.Top - (int)fTextFont.Size;
                string iRef   = indiRec.XRef + "#" + iNum;
                fRenderer.DrawAnchor(iRef, iRef, fTextFont, null, ix, iy);

                iNum += 1;
                indiNums[indiRec] = iNum;

                if (!person.CanExpand)
                {
                    continue;
                }

                ix   = offset.X + person.Rect.Left;
                iy   = offset.Y + person.Rect.Bottom;
                iRef = indiRec.XRef + "#" + iNum;
                fRenderer.DrawHyperlink(iRef, iRef, fLinkFont, null, ix, iy);

                if (person.HasFlag(PersonFlag.pfAncWalk))
                {
                    if (person.HasFlag(PersonFlag.pfHasInvAnc) && !IsPatriarchsDescendant(indiRec, currentPatriarch))
                    {
                        CheckQueue(indiRec, TreeChartKind.ckAncestors);
                    }
                }
                else if (person.HasFlag(PersonFlag.pfDescWalk))
                {
                    if (person.HasFlag(PersonFlag.pfSpouse))
                    {
                        if (person.HasFlag(PersonFlag.pfHasInvAnc) && !IsPatriarchsDescendant(indiRec, currentPatriarch))
                        {
                            CheckQueue(indiRec, TreeChartKind.ckAncestors);
                        }
                    }
                    else
                    {
                        if (person.HasFlag(PersonFlag.pfHasInvDesc) && TreeTools.PL_SearchAnc(fTree, indiRec, currentPatriarch, true))
                        {
                            CheckQueue(indiRec, TreeChartKind.ckDescendants);
                        }
                    }
                }
            }
        }
예제 #2
0
        private void CheckGroups()
        {
            IProgressController progress = AppHost.Progress;

            gkLogChart1.Clear();
            tvGroups.DataStore = null;

            progress.ProgressInit(LangMan.LS(LSID.LSID_CheckFamiliesConnection), fTree.RecordsCount);
            List <GEDCOMIndividualRecord> prepared     = new List <GEDCOMIndividualRecord>();
            List <GEDCOMRecord>           groupRecords = new List <GEDCOMRecord>();

            try
            {
                var rootItem = new TreeItem();

                int groupNum = 0;

                int num = fTree.RecordsCount;
                for (int i = 0; i < num; i++)
                {
                    GEDCOMRecord rec = fTree[i];

                    if (rec.RecordType == GEDCOMRecordType.rtIndividual)
                    {
                        GEDCOMIndividualRecord iRec = rec as GEDCOMIndividualRecord;
                        if (prepared.IndexOf(iRec) < 0)
                        {
                            groupNum++;
                            groupRecords.Clear();

                            TreeTools.WalkTree(iRec, TreeTools.TreeWalkMode.twmAll, groupRecords);

                            int cnt = groupRecords.Count;

                            TreeItem groupItem = new TreeItem();
                            groupItem.Text = groupNum.ToString() + " " + LangMan.LS(LSID.LSID_Group).ToLower() + " (" + cnt.ToString() + ")";
                            rootItem.Children.Add(groupItem);

                            for (int j = 0; j < cnt; j++)
                            {
                                iRec = (GEDCOMIndividualRecord)groupRecords[j];
                                prepared.Add(iRec);

                                string pn = GKUtils.GetNameString(iRec, true, false);
                                if (iRec.Patriarch)
                                {
                                    pn = "(*) " + pn;
                                }

                                groupItem.Children.Add(new GKTreeNode(pn, iRec));
                            }
                            groupItem.Expanded = true;

                            gkLogChart1.AddFragment(cnt);
                        }
                    }

                    progress.ProgressStep();
                }

                tvGroups.DataStore = rootItem;
                tvGroups.RefreshData();
            }
            finally
            {
                groupRecords.Clear();
                //prepared.Dispose();
                progress.ProgressDone();
            }
        }
예제 #3
0
 public void Clear()
 {
     TreeTools.SearchPlaces_Clear(fPlaces);
     fPlaces.Dispose();
 }
예제 #4
0
 private void btnMergeToRight_Click(object sender, EventArgs e)
 {
     TreeTools.MergeRecord(fBase, fRec2, fRec1, fBookmark);
     SetRec1(null);
     SetRec2(fRec2);
 }
예제 #5
0
 public void Test_GetUnlinkedNamesakes()
 {
     Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.GetUnlinkedNamesakes(null); });
     List <TreeTools.ULIndividual> uln = TreeTools.GetUnlinkedNamesakes(fBaseWin);
 }
예제 #6
0
 public TreeNode buildTreeTest(object[] objs)
 {
     return(TreeTools.buildTree(objs));
 }
예제 #7
0
 public static void PruneMarkConnected(this GDMTree tree, GDMIndividualRecord iRec, List <GDMRecord> marks)
 {
     TreeTools.WalkTree(iRec, TreeTools.TreeWalkMode.twmAll, PruneMarkProc, marks);
 }
예제 #8
0
 public void Test_MergeRecord_Null()
 {
     Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.MergeRecord(null, null, null, false); });
     Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.MergeRecord(fBaseWin, null, null, false); });
 }
예제 #9
0
 public static void PruneDescendants(this GDMTree tree, GDMIndividualRecord iRec, bool visible)
 {
     TreeTools.WalkTree(iRec, TreeTools.TreeWalkMode.twmDescendants, PruneProc, ((object)visible));
 }
예제 #10
0
 public static void RestrictDescendants(GDMTree tree, GDMIndividualRecord iRec, bool visible)
 {
     TreeTools.WalkTree(tree, iRec, TreeTools.TreeWalkMode.twmDescendants, RestrictProc, visible);
 }
예제 #11
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);
        }
예제 #12
0
 public void Test_CompareTree()
 {
     Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(null, null, null); });
     Assert.Throws(typeof(ArgumentNullException), () => { TreeTools.CompareTree(fBaseWin.Context, null, null); });
 }
예제 #13
0
 public static void RestrictAncestors(GDMTree tree, GDMIndividualRecord iRec, bool visible)
 {
     TreeTools.WalkTree(tree, iRec, TreeTools.TreeWalkMode.twmAncestors, RestrictProc, ((object)visible));
 }