Beispiel #1
0
        private void DrawForm(object sender, EventArgs e)
        {
            using (Bitmap backImage = new Bitmap(this.Width, this.Height))
            {
                using (Graphics graphics = Graphics.FromImage(backImage))
                {
                    Rectangle rectangle = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
                    using (Brush backColorBrush = new SolidBrush(this.BackColor))
                    {
                        graphics.FillRectangle(backColorBrush, rectangle);
                    }
                    // on paint 는 컨트롤 그리기 전 처리

                    //OnPaint(new PaintEventArgs(graphics,rectangle));

                    foreach (Control ctrl in this.Controls)
                    {
                        using (Bitmap bmp = new Bitmap(ctrl.Width, ctrl.Height))
                        {
                            Rectangle rect = new Rectangle(0, 0, ctrl.Width, ctrl.Height);
                            ctrl.DrawToBitmap(bmp, rect);
                            graphics.DrawImage(bmp, ctrl.Location);
                        }
                    }
                    PerPixelAlphaBlend.SetBitmap(backImage, Left, Top, Handle);
                }
            }
        }
 private void DrawForm(object pSender, EventArgs pE)
 {
     using (Bitmap backImage = new Bitmap(this.Width, this.Height))
     {
         using (Graphics graphics = Graphics.FromImage(backImage))
         {
             Rectangle gradientRectangle = new Rectangle(0, 0, this.Width - 1, this.Height - 1);
             using (Brush b = new LinearGradientBrush(gradientRectangle, Color.DarkSlateBlue, Color.MediumPurple, 0.0f))
             {
                 graphics.SmoothingMode = SmoothingMode.HighQuality;
                 RoundedRectangle.FillRoundedRectangle(graphics, b, gradientRectangle, 35);
                 foreach (Control ctrl in this.Controls)
                 {
                     using (Bitmap bmp = new Bitmap(ctrl.Width, ctrl.Height))
                     {
                         Rectangle rect = new Rectangle(0, 0, ctrl.Width, ctrl.Height);
                         ctrl.DrawToBitmap(bmp, rect);
                         graphics.DrawImage(bmp, ctrl.Location);
                     }
                 }
                 PerPixelAlphaBlend.SetBitmap(backImage, Left, Top, Handle);
             }
         }
     }
 }