Example #1
0
        public TCPersonControl(ITreeChart chart) : base(chart)
        {
            var gfxProv = AppHost.GfxProvider;

            fCtlPen   = gfxProv.CreatePen(gfxProv.CreateColor(BSDColors.Black), 2.0f);
            fCtlBrush = gfxProv.CreateSolidBrush(gfxProv.CreateColor(128, 128, 128, 128));
        }
Example #2
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);
                        }
                    }
                }
            }
        }
Example #3
0
 public TCGenerationsControl(ITreeChart chart, TreeChartKind controlMode) : base(chart)
 {
     fControlMode = controlMode;
     fBlankColor  = AppHost.GfxProvider.CreateColor(191, 191, 191);
     fSelectColor = AppHost.GfxProvider.CreateColor(128, 128, 128);
 }
Example #4
0
 protected ITreeControl(ITreeChart chart)
 {
     fChart = chart;
 }
Example #5
0
 public TCScaleControl(ITreeChart chart) : base(chart)
 {
     fControlsImage = AppHost.GfxProvider.LoadResourceImage("chart_controls.png", false);
 }