Esempio n. 1
0
        /// <summary>
        /// 显示和消失动画
        /// </summary>
        private void animate()
        {
            if (!timer1.Enabled)
            {
                if (backImg != null)
                {
                    backImg.Dispose();
                }
                backImg = null;
                backImg = new Bitmap(base.ClientRectangle.Width, base.ClientRectangle.Height);

                base.DrawToBitmap(backImg, base.ClientRectangle);

                if (alphaback != null)
                {
                    alphaback.Dispose();
                }
                alphaback = null;
                alphaback = new Bitmap(base.ClientRectangle.Width, base.ClientRectangle.Height);

                if (base.BackgroundImage != null)
                {
                    backgroundTemp       = (Bitmap)base.BackgroundImage;
                    base.BackgroundImage = null;
                }
                if (base.BackColor != Color.Transparent)
                {
                    backcolorTemp  = base.BackColor;
                    base.BackColor = Color.Transparent;
                }

                WIN32.CaptureWindow(this, ref alphaback);

                if (picbox != null)
                {
                    picbox.Dispose();
                }
                picbox = null;
                picbox = new uPictureBox();
                this.Controls.Add(picbox);
                picbox.Dock = DockStyle.Fill;

                if (!shown)
                {
                    picbox.Image = alphaback;
                }
                else
                {
                    picbox.Image = backImg;
                }
                picbox.BringToFront();
                base.Visible = true;

                if (!shown)
                {
                    if (gbackImg != null)
                    {
                        gbackImg.Dispose();
                    }
                    gbackImg = null;
                    gbackImg = Graphics.FromImage(alphaback);
                    gbackImg.SmoothingMode = SmoothingMode.HighQuality;
                }
                else
                {
                    if (gbackImg != null)
                    {
                        gbackImg.Dispose();
                    }
                    gbackImg = null;
                    gbackImg = Graphics.FromImage(backImg);
                    gbackImg.SmoothingMode = SmoothingMode.HighQuality;
                }
                isfirst = true;
                this.timer1.Start();
            }
        }