예제 #1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (ExtraImage != null)
                {
                    ExtraImage.Dispose();
                }
            }

            base.Dispose(disposing);
        }
예제 #2
0
        private void UpdateImage()
        {
            if (counter <= 0)
            {
                ShowExtraImage = false;

                if (ExtraImage != null)
                {
                    ExtraImage.Dispose();
                }

                ExtraImage = null;
            }
            else
            {
                int    size = Height - (ExtraImagePadding * 2);
                Bitmap bmp  = new Bitmap(size, size);

                using (Graphics g = Graphics.FromImage(bmp))
                    using (Brush shadowBrush = new SolidBrush(Color.FromArgb(150, 0, 0, 0)))
                        using (Brush brush = new SolidBrush(Color.FromArgb(230, 0, 0)))
                            using (Font font = new Font("Arial", 9, FontStyle.Bold))
                                using (StringFormat stringFormat = new StringFormat())
                                {
                                    g.SmoothingMode   = SmoothingMode.HighQuality;
                                    g.PixelOffsetMode = PixelOffsetMode.Half;
                                    g.DrawRoundedRectangle(shadowBrush, null, new Rectangle(0, 1, bmp.Width, bmp.Height), 3);
                                    g.DrawRoundedRectangle(brush, null, new Rectangle(0, 0, bmp.Width, bmp.Height), 3);
                                    stringFormat.Alignment     = StringAlignment.Center;
                                    stringFormat.LineAlignment = StringAlignment.Center;
                                    string text;
                                    if (Counter > 9)
                                    {
                                        text = "+";
                                    }
                                    else
                                    {
                                        text = Counter.ToString();
                                    }
                                    g.DrawString(text, font, Brushes.White, new Rectangle(0, 0, bmp.Width, bmp.Height), stringFormat);
                                }

                if (ExtraImage != null)
                {
                    ExtraImage.Dispose();
                }

                ExtraImage     = bmp;
                ShowExtraImage = true;
            }
        }