示例#1
0
        public void CalcBounds(int lines, ChartRenderer renderer)
        {
            try
            {
                InitInfo(lines);
                DefineExpands();

                int maxwid = 0;
                for (int k = 0; k < lines; k++)
                {
                    int wt = renderer.GetTextWidth(Lines[k], fModel.DrawFont);
                    if (maxwid < wt)
                    {
                        maxwid = wt;
                    }
                }

                int pad2side = (fModel.NodePadding * 2);

                fWidth  = pad2side + maxwid;
                fHeight = pad2side + renderer.GetTextHeight(fModel.DrawFont) * lines;

                if (fPortrait != null)
                {
                    ExtRect portRt = ExtRect.Create(0, 0, fHeight - 1, fHeight - 1);
                    portRt.Inflate(3, 3);

                    int   rtW   = portRt.GetWidth();
                    int   rtH   = portRt.GetHeight();
                    int   imgW  = fPortrait.Width;
                    int   imgH  = fPortrait.Height;
                    float ratio = SysUtils.ZoomToFit(imgW, imgH, rtW, rtH);
                    imgW = (int)Math.Round(imgW * ratio);
                    imgH = (int)Math.Round(imgH * ratio);

                    PortraitArea   = ExtRect.CreateBounds(portRt.Left, portRt.Top, imgW, imgH);
                    fPortraitWidth = imgW;

                    fWidth += imgW;
                }
            }
            catch (Exception ex)
            {
                Logger.LogWrite("TreeChartPerson.CalcBounds(): " + ex.Message);
            }
        }
示例#2
0
        public void CalcBounds(int lines, ChartRenderer renderer)
        {
            try {
                TreeChartOptions options = fModel.Options;

                InitInfo(lines);
                DefineExpands();

                int bh = renderer.GetTextHeight(fModel.BoldFont);
                int th = renderer.GetTextHeight(fModel.DrawFont);

                int maxwid = 0;
                int height = 0;
                for (int k = 0; k < lines; k++)
                {
                    IFont font;
                    if (options.BoldNames && k < NameLines)
                    {
                        height += bh;
                        font    = fModel.BoldFont;
                    }
                    else
                    {
                        height += th;
                        font    = fModel.DrawFont;
                    }

                    int wt = renderer.GetTextWidth(Lines[k], font);
                    if (maxwid < wt)
                    {
                        maxwid = wt;
                    }
                }

                int pad2side = (fModel.NodePadding * 2);

                fWidth  = pad2side + maxwid;
                fHeight = pad2side + height;

                if (fPortrait != null)
                {
                    ExtRect portRt = ExtRect.Create(0, 0, fHeight - 1, fHeight - 1);
                    portRt.Inflate(-3, -3);

                    int   rtW   = portRt.GetWidth();
                    int   rtH   = portRt.GetHeight();
                    int   imgW  = fPortrait.Width;
                    int   imgH  = fPortrait.Height;
                    float ratio = GfxHelper.ZoomToFit(imgW, imgH, rtW, rtH);
                    imgW = (int)Math.Round(imgW * ratio);
                    imgH = (int)Math.Round(imgH * ratio);

                    PortraitArea   = ExtRect.CreateBounds(portRt.Left, portRt.Top, imgW, imgH);
                    fPortraitWidth = imgW;

                    fWidth += imgW;
                }
            } catch (Exception ex) {
                Logger.WriteError("TreeChartPerson.CalcBounds()", ex);
            }
        }