Beispiel #1
0
        private void InternalDraw(ChartDrawMode drawMode, BackgroundMode background)
        {
            // drawing relative offset of tree on graphics
            int spx = 0;
            int spy = 0;

            Size     clientSize = ClientSize;
            ExtPoint scrollPos  = new ExtPoint(Math.Abs(AutoScrollPosition.X), Math.Abs(AutoScrollPosition.Y));

            if (drawMode == ChartDrawMode.dmInteractive)
            {
                spx += -scrollPos.X;
                spy += -scrollPos.Y;

                Rectangle viewPort = GetImageViewPort();
                fModel.VisibleArea = ExtRect.CreateBounds(scrollPos.X, scrollPos.Y, viewPort.Width, viewPort.Height);
            }
            else
            {
                fModel.VisibleArea = ExtRect.CreateBounds(0, 0, fModel.ImageWidth, fModel.ImageHeight);
            }

            if (drawMode == ChartDrawMode.dmInteractive || drawMode == ChartDrawMode.dmStaticCentered)
            {
                if (fModel.ImageWidth < clientSize.Width)
                {
                    spx += (clientSize.Width - fModel.ImageWidth) / 2;
                }

                if (fModel.ImageHeight < clientSize.Height)
                {
                    spy += (clientSize.Height - fModel.ImageHeight) / 2;
                }
            }

            fModel.SetOffsets(spx, spy);

            DrawBackground(background);

            #if DEBUG_IMAGE
            using (Pen pen = new Pen(Color.Red)) {
                fRenderer.DrawRectangle(pen, Color.Transparent, fSPX, fSPY, fImageWidth, fImageHeight);
            }
            #endif

            bool hasDeep = (fSelected != null && fSelected != fModel.Root && fSelected.Rec != null);

            if (hasDeep && fOptions.DeepMode == DeepMode.Background)
            {
                DrawDeep(fOptions.DeepMode, spx, spy);
            }

            fRenderer.SetTranslucent(0.0f);
            fModel.Draw(drawMode);

            if (hasDeep && fOptions.DeepMode == DeepMode.Foreground)
            {
                DrawDeep(fOptions.DeepMode, spx, spy);
            }
        }
Beispiel #2
0
        private void InternalDraw(ChartDrawMode drawMode, BackgroundMode background)
        {
            // drawing relative offset of tree on graphics
            int spx = 0;
            int spy = 0;

            if (drawMode == ChartDrawMode.dmInteractive)
            {
                var imageViewport = base.ImageViewport;
                spx = imageViewport.Left;
                spy = imageViewport.Top;
                fModel.VisibleArea = UIHelper.Rt2Rt(base.Viewport);
            }
            else
            {
                if (drawMode == ChartDrawMode.dmStaticCentered)
                {
                    Size clientSize = CanvasRectangle.Size;

                    if (fModel.ImageWidth < clientSize.Width)
                    {
                        spx += (clientSize.Width - fModel.ImageWidth) / 2;
                    }

                    if (fModel.ImageHeight < clientSize.Height)
                    {
                        spy += (clientSize.Height - fModel.ImageHeight) / 2;
                    }
                }

                fModel.VisibleArea = ExtRect.CreateBounds(0, 0, fModel.ImageWidth, fModel.ImageHeight);
            }

            fModel.SetOffsets(spx, spy);

            DrawBackground(background);

#if DEBUG_IMAGE
            using (Pen pen = new Pen(Color.Red)) {
                fRenderer.DrawRectangle(pen, Color.Transparent, fSPX, fSPY, fImageWidth, fImageHeight);
            }
#endif

            bool hasDeep = (fSelected != null && fSelected != fModel.Root && fSelected.Rec != null);

            if (hasDeep && fOptions.DeepMode == DeepMode.Background)
            {
                DrawDeep(fOptions.DeepMode, spx, spy);
            }

            fRenderer.SetTranslucent(0.0f);
            fModel.Draw(drawMode);

            if (hasDeep && fOptions.DeepMode == DeepMode.Foreground)
            {
                DrawDeep(fOptions.DeepMode, spx, spy);
            }
        }
Beispiel #3
0
        private void DrawDeep(DeepMode mode, int spx, int spy)
        {
            try {
                using (var deepModel = new TreeChartModel()) {
                    deepModel.Assign(fModel);
                    deepModel.SetRenderer(fRenderer);
                    deepModel.DepthLimitAncestors   = 2;
                    deepModel.DepthLimitDescendants = 2;
                    deepModel.GenChart(fSelected.Rec, TreeChartKind.ckBoth, true);
                    deepModel.RecalcChart(true);

                    var pers = deepModel.FindPersonByRec(fSelected.Rec);
                    if (pers == null)
                    {
                        Logger.WriteError("TreeChartBox.DrawDeep(): unexpected failure");
                        return;
                    }

                    int dmX = (spx + (fSelected.PtX - pers.PtX));
                    int dmY = (spy + (fSelected.PtY - pers.PtY));
                    deepModel.SetOffsets(dmX, dmY);
                    deepModel.VisibleArea = ExtRect.CreateBounds(0, 0, deepModel.ImageWidth, deepModel.ImageHeight);

                    switch (mode)
                    {
                    case DeepMode.Background:
                        fRenderer.SetTranslucent(0.75f);
                        break;

                    case DeepMode.Foreground:
                        fRenderer.SetTranslucent(0.25f);
                        IPen   xpen   = fRenderer.CreatePen(ChartRenderer.GetColor(BSDColors.Black), 2.0f);
                        IColor bColor = ChartRenderer.GetColor(BSDColors.White);
                        fRenderer.DrawRoundedRectangle(xpen, bColor, dmX, dmY, deepModel.ImageWidth, deepModel.ImageHeight, 6);
                        fRenderer.SetTranslucent(0.00f);
                        break;
                    }

                    deepModel.Draw(ChartDrawMode.dmStatic);
                }
            } catch (Exception ex) {
                Logger.WriteError("TreeChartBox.DrawDeep()", ex);
            }
        }
Beispiel #4
0
        private void InternalDraw(ChartDrawMode drawMode, BackgroundMode background)
        {
            // drawing relative offset of tree on graphics
            int spx = 0;
            int spy = 0;

            if (drawMode == ChartDrawMode.dmInteractive)
            {
                /*Rectangle viewPort = GetImageViewPort();
                 * fSPX = -viewPort.Left;
                 * fSPY = -viewPort.Top;*/

                spx += fBorderWidth - -AutoScrollPosition.X;
                spy += fBorderWidth - -AutoScrollPosition.Y;

                Size sz = ClientSize;

                if (fModel.ImageWidth < sz.Width)
                {
                    spx += (sz.Width - fModel.ImageWidth) / 2;
                }

                if (fModel.ImageHeight < sz.Height)
                {
                    spy += (sz.Height - fModel.ImageHeight) / 2;
                }

                fModel.VisibleArea = GetSourceImageRegion();
            }
            else
            {
                if (drawMode == ChartDrawMode.dmStaticCentered)
                {
                    Size sz = ClientSize;

                    if (fModel.ImageWidth < sz.Width)
                    {
                        spx += (sz.Width - fModel.ImageWidth) / 2;
                    }

                    if (fModel.ImageHeight < sz.Height)
                    {
                        spy += (sz.Height - fModel.ImageHeight) / 2;
                    }
                }

                fModel.VisibleArea = ExtRect.CreateBounds(0, 0, fModel.ImageWidth, fModel.ImageHeight);
            }

            fModel.SetOffsets(spx, spy);

            DrawBackground(background);

            #if DEBUG_IMAGE
            using (Pen pen = new Pen(Color.Red)) {
                fRenderer.DrawRectangle(pen, Color.Transparent, fSPX, fSPY, fImageWidth, fImageHeight);
            }
            #endif

            fModel.Draw(fModel.Root, fModel.Kind, drawMode);
        }