Exemplo n.º 1
0
        private Bitmap DrawDigital(Rectangle destRect)
        {
            m_Bitmap = new Bitmap(destRect.Width, destRect.Height);

            Graphics tmpg = Graphics.FromImage(m_Bitmap);

            tmpg.CompositingQuality = CompositingQuality.HighQuality;

            tmpg.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            tmpg.SmoothingMode = SmoothingMode.HighQuality;

            LEDDisplay ssd = new LEDDisplay(tmpg);

            ssd.IsDrawShadow = this.isDrawShadow;

            GraphicsState gs = tmpg.Save();

            tmpg.TranslateTransform(destRect.X, destRect.Y);

            SizeF sizef = ssd.SizeDesign(this.DisplayedDigitalNumber, Font);

            float fScale = Math.Min(destRect.Width / sizef.Width, destRect.Height / sizef.Height);

            Font font = new Font(Font.FontFamily, fScale * Font.SizeInPoints);

            sizef = ssd.SizeDesign(this.DisplayedDigitalNumber, font);

            ledStringWidth = (int)sizef.Width;

            ledStringHeight = (int)sizef.Height;

            ssd.DrawString(this.DisplayedDigitalNumber, font, new SolidBrush(this.ledColor), (destRect.Width - sizef.Width) / 2, (destRect.Height - sizef.Height) / 2);

            tmpg.Restore(gs);

            return(m_Bitmap);
        }