Ejemplo n.º 1
0
        private static Font GetFontForStringAndRegion(string value, TemplateRegion region, Graphics g)
        {
            int fontPoint = 20;

            while (true)
            {
                FontStyle fontStyle = FontStyle.Regular;

                if (region.Bold)
                {
                    fontStyle = FontStyle.Bold | fontStyle;
                }
                if (region.Italic)
                {
                    fontStyle = FontStyle.Italic | fontStyle;
                }
                Font testFont = new Font("Arial", 14, fontStyle);

                SizeF size = g.MeasureString(value, testFont, region.Region.Width);

                if (size.Height > region.Region.Height)
                {
                    fontPoint -= 2;

                    if (fontPoint == 0)
                    {
                        return testFont;
                    }
                }
                else
                {
                    return testFont;
                }
            }
        }
 void templateRegionSelector_OnRegionChange(object sender, TemplateRegion e)
 {
     SetCurrentRegion(e);
 }
        private void SetCurrentRegion(TemplateRegion region)
        {
            this.templateRegionSelector.CurrentRegion = region;
            this.CurrentRegion = region;
            chkBold.Checked = region.Bold;
            chkInvert.Checked = region.Invert;
            chkItalic.Checked = region.Italic;
            chkCenter.Checked = region.Center;

            cboRegion.SelectedItem = region.RegionName;
        }