Exemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.TextRenderingHint = TextRenderingHint.AntiAlias;

            DateTime time       = DateTime.Now;
            string   timeString = time.ToString("hh mm");

            DrawingUtils.DrawCenterString(e, timeString, ubuntuRegular220, Convert.ToSingle(Size.Width / 2.0), Convert.ToSingle(Size.Height / 2.0));
        }
Exemplo n.º 2
0
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            Image bgImage = (Image)Properties.Resources.ResourceManager.GetObject("fern");

            double bgWidthToHeightRatio = (double)bgImage.Width / (double)bgImage.Height;
            int    bgWidth  = Size.Width;
            int    bgHeight = Convert.ToInt32(Math.Ceiling(bgWidth / bgWidthToHeightRatio));

            if (bgHeight < Size.Height)
            {
                bgHeight = Size.Height;
                bgWidth  = Convert.ToInt32(Math.Ceiling(bgHeight * bgWidthToHeightRatio));
            }
            DrawingUtils.DrawCenterImage(e, bgImage, (int)Math.Round(Size.Width / 2.0), (int)Math.Round(Size.Height / 2.0), bgWidth, bgHeight);
        }