Ejemplo n.º 1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (!DesignMode)
            {
                //Graphics g = e.Graphics;
                //e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
                //using (SolidBrush bruch = new SolidBrush(Color.Transparent))
                //{
                //    g.FillRectangle(bruch, 0, 0, 25, this.Height);
                //    g.FillRectangle(bruch, 27, 0, this.Width - 27, this.Height);
                //}

                Bitmap    bitmap         = new Bitmap(Width + 15, Height + 5);
                Rectangle _BacklightLTRB = new Rectangle(20, 20, 20, 20);
                e.Graphics.SmoothingMode   = SmoothingMode.HighQuality;
                e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                ImageDrawRect.DrawRect(
                    e.Graphics,
                    Resources.main_light_bkg_top123,
                    new Rectangle
                {
                    X      = ClientRectangle.X - 3,
                    Y      = ClientRectangle.Y - 3,
                    Width  = ClientRectangle.Width + 6,
                    Height = ClientRectangle.Height + 6
                },
                    Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height),
                    1,
                    1);
            }
            base.OnPaint(e);
        }
Ejemplo n.º 2
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            g = e.Graphics;
            g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
            g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
            LineartBrush      = new LinearGradientBrush(
                new Rectangle(6, 37, ClientRectangle.Width - 12, 75),
                Color.FromArgb(130, Color.White), Color.FromArgb(190, Color.White), 90);
            g.FillRectangle(LineartBrush, new Rectangle(6, 37, ClientRectangle.Width - 12, 75));

            LineartBrush = new LinearGradientBrush(
                new Rectangle(6, 112, ClientRectangle.Width - 12, 25),
                Color.FromArgb(190, Color.White), Color.FromArgb(230, Color.White), 90);
            g.FillRectangle(LineartBrush, new Rectangle(6, 112, ClientRectangle.Width - 12, 25));

            LineartBrush = new LinearGradientBrush(
                new Rectangle(6, 137, ClientRectangle.Width - 12, ClientRectangle.Height - 174),
                Color.FromArgb(230, Color.White), Color.FromArgb(240, Color.White), 90);
            g.FillRectangle(LineartBrush, new Rectangle(6, 137, ClientRectangle.Width - 12, ClientRectangle.Height - 174));

            //if (this.WindowState==FormWindowState.Maximized)
            //{
            //ImageDrawRect.DrawRect(g, _ShadeImage, new Rectangle(this.Width - _ShadeImage.Width - 26, 47, _ShadeImage.Width, _ShadeImage.Height), Rectangle.FromLTRB(0, 0, 0, 0), 1, 1);
            //}
            if (this.WindowState == FormWindowState.Maximized)
            {
                ImageDrawRect.DrawRect(g, _LogoImage, new Rectangle(this.Width - _LogoImage.Width + 40, 15, 80, 136), 1, 1);
            }
            else
            {
                g.DrawImage(_LogoImage, new Rectangle(this.Width - _LogoImage.Width + 55, 22, 60, 102), new Rectangle(0, 0, _LogoImage.Width, _LogoImage.Height), GraphicsUnit.Pixel);
            }
            LineartBrush.Dispose();
        }
Ejemplo n.º 3
0
        //重绘窗口
        protected override void OnPaint(PaintEventArgs e)
        {
            try
            {
                g = e.Graphics;
                g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
                g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
                ImageDrawRect.DrawRect(g, _BacklightImg, ClientRectangle, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), 1, 1);

                if (_showTitle)
                {
                    if (this.ShowIcon && this.Text != "")
                    {
                        g.DrawIcon(this.Icon, new Rectangle(15, 12, 16, 16));
                        g.DrawString(this.Text, new Font("微软雅黑", 9F), new SolidBrush(Color.FromArgb(255, 255, 255)), 35, 12);
                    }
                    else
                    {
                        g.DrawString(this.Text, new Font("微软雅黑", 9F), new SolidBrush(Color.FromArgb(255, 255, 255)), 10, 12);
                    }
                }
            }
            catch
            { }
        }
Ejemplo n.º 4
0
 private void panel_Paint(object sender, PaintEventArgs e)
 {
     if (Shadow)
     {
         Rectangle _BacklightLTRB = new Rectangle(10, 10, 10, 10); //窗体光泽重绘边界
         Graphics  g = e.Graphics;
         g.SmoothingMode   = SmoothingMode.HighQuality;            //高质量
         g.PixelOffsetMode = PixelOffsetMode.HighQuality;          //高像素偏移质量
         ImageDrawRect.DrawRect(g, Properties.Resources.main_light_bkg_top123, e.ClipRectangle, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), 1, 1);
     }
 }
Ejemplo n.º 5
0
        public void CreateFloatingPanel(Control control)
        {
            Bitmap    bitmap         = new Bitmap(panel2.Width, panel2.Height);
            Rectangle _BacklightLTRB = new Rectangle(0, 0, 0, 0);//窗体光泽重绘边界
            //Graphics g = Graphics.FromImage(bitmap);
            Graphics g = control.CreateGraphics();

            g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
            g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
            ImageDrawRect.DrawRect(g, Properties.Resources.main_light_bkg_top123, control.ClientRectangle, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), 1, 1);
        }
Ejemplo n.º 6
0
        private void panel2_Paint(object sender, PaintEventArgs e)
        {
            Bitmap    bitmap         = new Bitmap(panel2.Width, panel2.Height);
            Rectangle _BacklightLTRB = new Rectangle(20, 20, 20, 20);//窗体光泽重绘边界
            //Graphics g = Graphics.FromImage(bitmap);
            Graphics g = e.Graphics;

            g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
            g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
            ImageDrawRect.DrawRect(g, Properties.Resources.main_light_bkg_top123, e.ClipRectangle, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), 1, 1);
        }
Ejemplo n.º 7
0
 //用图片绘画滑块条
 private void DrawImgTrack(Graphics g, Rectangle _tackRect, bool horizontal)
 {
     if (Track != null)
     {
         Image myImage = (Image)Track.Clone();
         if (Orientation == Orientation.Vertical)
         {
             myImage.RotateFlip(RotateFlipType.Rotate90FlipXY);
         }
         ImageDrawRect.DrawRect(g, (Bitmap)myImage, _tackRect, BackRectangle, 1, 1);
     }
 }
Ejemplo n.º 8
0
 //重绘窗口
 protected override void OnPaint(PaintEventArgs e)
 {
     try
     {
         g = e.Graphics;
         g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
         g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
         ImageDrawRect.DrawRect(g, _BacklightImg, ClientRectangle, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), 1, 1);
     }
     catch
     { }
 }
Ejemplo n.º 9
0
        public void SetBits(int x, int y)
        {
                                                                                  //绘制绘图层背景
                        Bitmap    bitmap         = new Bitmap(x, y);
                        Rectangle _BacklightLTRB = new Rectangle(20, 20, 20, 20); //窗体光泽重绘边界
                        Graphics  g = Graphics.FromImage(bitmap);

                        g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
                        g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
            ImageDrawRect.DrawRect(g, Properties.Resources.bgbk2, ClientRectangle, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), 1, 1);
             
                        if(!Bitmap.IsCanonicalPixelFormat(bitmap.PixelFormat) || !Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
                            throw new ApplicationException("图片必须是32位带Alhpa通道的图片。");

                        IntPtr oldBits  = IntPtr.Zero;
                        IntPtr screenDC = Win32.GetDC(IntPtr.Zero);
                        IntPtr hBitmap  = IntPtr.Zero;
                        IntPtr memDc    = Win32.CreateCompatibleDC(screenDC);

             
                        try {
                                Win32.Point         topLoc     = new Win32.Point(Left, Top);
                                Win32.Size          bitMapSize = new Win32.Size(Width, Height);
                                Win32.BLENDFUNCTION blendFunc  = new Win32.BLENDFUNCTION();
                                Win32.Point         srcLoc     = new Win32.Point(0, 0);
                 
                                    hBitmap = bitmap.GetHbitmap(Color.FromArgb(0));

                                oldBits = Win32.SelectObject(memDc, hBitmap);
                 
                                blendFunc.BlendOp = Win32.AC_SRC_OVER;

                                blendFunc.SourceConstantAlpha = Byte.Parse("255");
                                blendFunc.AlphaFormat         = Win32.AC_SRC_ALPHA;
                                blendFunc.BlendFlags          = 0;
                 
                                Win32.UpdateLayeredWindow(Handle, screenDC, ref topLoc, ref bitMapSize, memDc, ref srcLoc, 0, ref blendFunc, Win32.ULW_ALPHA);

                            
            } finally {
                                if(hBitmap != IntPtr.Zero)
                {
                                        Win32.SelectObject(memDc, oldBits);
                                        Win32.DeleteObject(hBitmap);
                                    
                }
                                Win32.ReleaseDC(IntPtr.Zero, screenDC);
                                Win32.DeleteDC(memDc);
                            
            }
                    
        }
Ejemplo n.º 10
0
        protected override void OnRenderDropDownButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStrip             toolStrip = e.ToolStrip;
            ToolStripDropDownItem item      = e.Item as ToolStripDropDownItem;

            if (item == null)
            {
                return;
            }
            LinearGradientMode    mode      = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
            Graphics              graphics  = e.Graphics;
            SmoothingModeGraphics graphics2 = new SmoothingModeGraphics(graphics);
            Rectangle             r         = new Rectangle(Point.Empty, item.Size);

            if (item.Pressed && item.HasDropDownItems)
            {
                if (this.ColorTable.BaseItemDown != null)
                {
                    ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemDown, r, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
                }
                else
                {
                    RenderHelperStrip.RenderBackgroundInternal(graphics, r, this.ColorTable.BaseItemPressed, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
                }
            }
            else if (item.Selected)
            {
                if (this.ColorTable.BaseItemDown != null)
                {
                    ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemMouse, r, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
                }
                else
                {
                    RenderHelperStrip.RenderBackgroundInternal(graphics, r, this.ColorTable.BaseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
                }
            }
            else
            {
                if (toolStrip is ToolStripOverflow)
                {
                    using (Brush brush = new SolidBrush(this.ColorTable.Back))
                    {
                        graphics.FillRectangle(brush, r);
                        goto Label_0256;
                    }
                }
                base.OnRenderDropDownButtonBackground(e);
            }
Label_0256:
            graphics2.Dispose();
        }
Ejemplo n.º 11
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle rc = this.ClientRectangle;
            Graphics  g  = e.Graphics;

            ImageDrawRect.DrawRect(g, _TextBoxBackImg, rc, Rectangle.FromLTRB(10, 10, 10, 10), (int)state, 5);
            if (_Isico)
            {
                if (_Ico != null)
                {
                    g.DrawImage(_Ico, new Point(_IcoPadding.Left, _IcoPadding.Top));
                }
            }
            base.OnPaint(e);
        }
Ejemplo n.º 12
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);
            base.OnPaintBackground(e);
            if (_BackImg == null)
            {
                base.OnPaint(e);
                return;
            }

            int i = (int)state;

            if (!this.Enabled)
            {
                i = 4;
            }
            if (this.CheckState == CheckState.Checked)
            {
                i += 4;
            }
            if (this.CheckState == CheckState.Indeterminate)
            {
                i += 8;
            }

            Rectangle rc = this.ClientRectangle;
            Rectangle r1 = rc;
            Rectangle textRect;
            Graphics  g = e.Graphics;

            if (this.CheckAlign == ContentAlignment.MiddleLeft)//对齐状态
            {
                r1       = new Rectangle(0, (rc.Height - 15) / 2, 16, 15);
                textRect = new Rectangle(16, 0, rc.Width - 16, rc.Height);
            }
            else
            {
                r1       = new Rectangle(r1.Right - 16, (rc.Height - 16) / 2, 16, 15);
                textRect = new Rectangle(0, 0, rc.Width - 16, rc.Height);
            }
            ImageDrawRect.DrawRect(g, _BackImg, r1, Rectangle.FromLTRB(0, 0, 0, 0), i, 12);
            Color textColor = Enabled ? ForeColor : SystemColors.GrayText;

            TextRenderer.DrawText(e.Graphics, this.Text, this.Font, textRect, textColor);
        }
Ejemplo n.º 13
0
 //重绘窗口
 protected override void OnPaint(PaintEventArgs e)
 {
     try
     {
         g = e.Graphics;
         g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
         g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
         ImageDrawRect.DrawRect(g, _BacklightImg, ClientRectangle, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), 1, 1);
         if (IsIcon)
         {
             g.DrawIcon(this.Icon, new Rectangle(12, 12, 16, 16));
         }
         if (IsTitle)
         {
             g.DrawString(this.Text, this.Font, new SolidBrush(this.ForeColor), 32, 12);
         }
     }
     catch
     { }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 重绘控件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            base.OnPaint(e);


            try
            {
                if (state == State.MouseOver && _OverImg == null)
                {
                    base.InvokePaintBackground(this, new PaintEventArgs(e.Graphics, base.ClientRectangle));
                    ImageDrawRect.DrawRect(e.Graphics, NormalImg, e.ClipRectangle, 1, 1);
                    LineartBrush = new LinearGradientBrush(
                        new Rectangle(0, 0, ClientRectangle.Width, ClientRectangle.Height),
                        Color.FromArgb(230, Color.White), Color.FromArgb(250, Color.White), 90);
                    g.FillRectangle(LineartBrush, new Rectangle(0, 0, ClientRectangle.Width, ClientRectangle.Height));
                    ImageDrawRect.DrawRect(g, ImageObject.GetResBitmap("GSSUI.ASkinImg.ButtonImg.Botton2.png"), e.ClipRectangle, Rectangle.FromLTRB(10, 10, 10, 10), 1, 5);
                }
            }
            catch
            { }
        }
Ejemplo n.º 15
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle rc = this.ClientRectangle;
            Graphics  g  = e.Graphics;

            ImageDrawRect.DrawRect(g, Properties.Resources.Textbox, rc, Rectangle.FromLTRB(10, 10, 10, 10), (int)state, 5);
            if (_Isico)
            {
                if (_Ico != null)
                {
                    Rectangle rcc = new Rectangle();
                    rcc.Height         = _Ico.Height;
                    rcc.Width          = _Ico.Width;
                    rcc.X              = rc.Width - _Ico.Width - _IcoPadding.Right - _IcoPadding.Left;
                    rcc.Y              = _IcoPadding.Top;
                    _IcoPadding.Left   = rcc.X;
                    _IcoPadding.Right  = rcc.X + rcc.Width;
                    _IcoPadding.Bottom = rcc.Y + rcc.Height;
                    g.DrawImage(_Ico, rcc);
                }
            }
            base.OnPaint(e);
        }
Ejemplo n.º 16
0
        //重绘
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;
            //取得当前需要绘画的图像
            Bitmap btm = null;

            switch (_controlState)
            {
            case ControlState.Pressed:
                btm = (Bitmap)DownBack;
                break;

            case ControlState.Hover:
                btm = (Bitmap)MouseBack;
                break;

            default:
                btm = (Bitmap)NormlBack;
                break;
            }
            if (btm != null)
            {
                //是否启用九宫绘图
                if (Palace)
                {
                    ImageDrawRect.DrawRect(g, btm, new Rectangle(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width, ClientRectangle.Height), Rectangle.FromLTRB(BackRectangle.X, BackRectangle.Y, BackRectangle.Width, BackRectangle.Height), 1, 1);
                }
                else
                {
                    g.DrawImage(btm, this.ClientRectangle);
                }
            }
            //绘制圆角
            SkinTools.CreateRegion(this, this.ClientRectangle, radius, RoundStyle);
            base.OnPaint(e);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 重绘控件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (BackImg == null)
            {
                base.OnPaint(e);
                return;
            }

            if (!this.Enabled)
            {
                this.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
            }
            else
            {
                this.ForeColor = System.Drawing.SystemColors.ControlText;
            }

            int i = (int)state;

            if (this.Focused && state != State.MouseDown && _IsTabFocus == true)
            {
                i = 5;
            }
            if (!this.Enabled)
            {
                i = 4;
            }
            Rectangle rc = this.ClientRectangle;
            Graphics  g  = e.Graphics;



            base.InvokePaintBackground(this, new PaintEventArgs(e.Graphics, base.ClientRectangle));
            try
            {
                //Color backimgcorlor = Color.Transparent;
                //// 绘制背景色
                //if (this.FindForm().BackColor != null)
                //{
                //    backimgcorlor = this.FindForm().BackColor;
                //}

                //if (this.FindForm().BackgroundImage != null)
                //{
                //    backimgcorlor = ((Bitmap)this.FindForm().BackgroundImage).GetPixel(10, 10);
                //}
                //backimgcorlor = Color.FromArgb(40, backimgcorlor);
                //using ( System.Drawing.SolidBrush backbrush=new System.Drawing.SolidBrush(backimgcorlor))
                //{
                //    Rectangle border = e.ClipRectangle;
                //    border.Width -= 2;
                //    border.Height -= 2;
                //    Rectangle rt = new Rectangle(border.Location.X + 1, border.Location.Y + 1, border.Width, border.Height);

                //    //填充绘制效果
                //    e.Graphics.FillRectangle(backbrush, rt);

                //}

                if (BackImg != null)
                {
                    if (_BacklightLTRB != Rectangle.Empty)
                    {
                        ImageDrawRect.DrawRect(g, BackImg, rc, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), i, 5);
                    }
                    else
                    {
                        ImageDrawRect.DrawRect(g, BackImg, rc, Rectangle.FromLTRB(10, 10, 10, 10), i, 5);
                    }
                }
            }
            catch
            { }

            Image img = null;
            Size  txts, imgs;

            txts = Size.Empty;
            imgs = Size.Empty;

            if (this.Image != null)
            {
                img = this.Image;
            }
            else if (this.ImageList != null && this.ImageIndex != -1)
            {
                img = this.ImageList.Images[this.ImageIndex];
            }

            if (img != null)
            {
                imgs.Width  = img.Width;
                imgs.Height = img.Height;
            }

            StringFormat format1;

            using (format1 = new StringFormat())
            {
                format1.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
                SizeF ef1 = g.MeasureString(this.Text, this.Font, new SizeF((float)rc.Width, (float)rc.Height), format1);
                txts = Size.Ceiling(ef1);
            }

            rc.Inflate(-4, -4);
            if (imgs.Width * imgs.Height != 0)
            {
                Rectangle imgr = rc;
                imgr = ImageDrawRect.HAlignWithin(imgs, imgr, this.ImageAlign);
                imgr = ImageDrawRect.VAlignWithin(imgs, imgr, this.ImageAlign);
                if (!this.Enabled)
                {
                    ControlPaint.DrawImageDisabled(g, img, imgr.Left, imgr.Top, this.BackColor);
                }
                else
                {
                    g.DrawImage(img, imgr.Left, imgr.Top, img.Width, img.Height);
                }
            }

            Rectangle txtr = rc;

            txtr = ImageDrawRect.HAlignWithin(txts, txtr, this.TextAlign);
            txtr = ImageDrawRect.VAlignWithin(txts, txtr, this.TextAlign);

            format1 = new StringFormat();
            format1.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;

            if (this.RightToLeft == RightToLeft.Yes)
            {
                format1.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
            }
            brush = new SolidBrush(this.ForeColor);
            g.DrawString(this.Text, this.Font, brush, (RectangleF)txtr, format1);
            brush.Dispose();
        }
Ejemplo n.º 18
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            //绘画背景
            if (Back != null)
            {
                //是否启用九宫绘图
                if (Palace)
                {
                    ImageDrawRect.DrawRect(g, (Bitmap)Back, this.ClientRectangle, Rectangle.FromLTRB(BackRectangle.X, BackRectangle.Y, BackRectangle.Width, BackRectangle.Height), 1, 1);
                }
                else
                {
                    g.DrawImage(Back, 0, 0, this.Width, this.Height);
                }
            }
            //绘画Item项
            for (int i = 0; i < Items.Count; i++)
            {
                Rectangle       bounds = this.GetItemRectangle(i);
                SkinListBoxItem item   = Items[i];
                if (mouseitem == Items[i] && mouseitem != this.SelectedItem && mouse)   //悬浮时
                {
                    RenderBackgroundInternal(
                        g,
                        bounds,
                        MouseColor,
                        MouseColor,
                        Color.FromArgb(200, 255, 255, 255),
                        ItemRoundStyle,
                        ItemRadius,
                        0.45f,
                        ItemBorderVisble,
                        ItemHoverGlassVisble,
                        LinearGradientMode.Vertical);
                }
                else  //非悬浮时
                {
                    if (this.SelectedItem == Items[i])//选中时
                    {
                        RenderBackgroundInternal(
                            g,
                            bounds,
                            _selectedColor,
                            _selectedColor,
                            Color.FromArgb(200, 255, 255, 255),
                            ItemRoundStyle,
                            ItemRadius,
                            0.45f,
                            ItemBorderVisble,
                            ItemGlassVisble,
                            LinearGradientMode.Vertical);
                    }
                    else
                    {
                        Color backColor;
                        if (i % 2 == 0)
                        {
                            backColor = _rowBackColor2;
                        }
                        else
                        {
                            backColor = _rowBackColor1;
                        }
                        using (SolidBrush brush = new SolidBrush(backColor))
                        {
                            g.FillRectangle(brush, bounds);
                        }
                    }
                }
                Image image = item.Image;
                //获得Img绘画范围
                Rectangle imageRect = new Rectangle(
                    bounds.X + 2,
                    bounds.Y + 2,
                    bounds.Height - 4,
                    bounds.Height - 4);

                //获得文字绘画范围
                Rectangle textRect = new Rectangle(
                    (ImageVisble ? (ImagePoint ? imageRect.Width : 0) : 0),
                    bounds.Y,
                    bounds.Width - (ImageVisble ? imageRect.Width : 0) - 2,
                    bounds.Height);

                string          text        = item.ToString();
                TextFormatFlags formatFlags =
                    TextFormatFlags.VerticalCenter;
                if (RightToLeft == RightToLeft.Yes)
                {
                    imageRect.X  = bounds.Right - imageRect.Right;
                    textRect.X   = bounds.Right - textRect.Right;
                    formatFlags |= TextFormatFlags.RightToLeft;
                    formatFlags |= TextFormatFlags.Right;
                }
                else
                {
                    formatFlags |= TextFormatFlags.Left;
                }

                if (image != null && ImageVisble)
                {
                    //如果是右边绘制图标,呢么就要使图标偏移至右方
                    if (!ImagePoint)
                    {
                        imageRect.X = bounds.Right - imageRect.Right;
                    }
                    g.InterpolationMode =
                        InterpolationMode.HighQualityBilinear;
                    if (ItemImageLayout)    //如果是true,即使局中绘制
                    {
                        g.DrawImage(image, imageRect.X + (imageRect.Width - image.Width) / 2, imageRect.Y + (imageRect.Height - image.Height) / 2);
                    }
                    else
                    {
                        g.DrawImage(
                            image,
                            imageRect,
                            0,
                            0,
                            image.Width,
                            image.Height,
                            GraphicsUnit.Pixel);
                    }
                }

                TextRenderer.DrawText(
                    g,
                    text,
                    Font,
                    textRect,
                    ForeColor,
                    formatFlags);
            }
        }
Ejemplo n.º 19
0
        protected override void OnRenderSplitButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStrip            toolStrip = e.ToolStrip;
            ToolStripSplitButton item      = e.Item as ToolStripSplitButton;

            if (item != null)
            {
                Graphics           graphics = e.Graphics;
                LinearGradientMode mode     = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
                Rectangle          bounds   = new Rectangle(Point.Empty, item.Size);
                new SmoothingModeGraphics(graphics);
                Color arrowColor = toolStrip.Enabled ? this.ColorTable.Fore : SystemColors.ControlDark;
                if (item.BackgroundImage != null)
                {
                    Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                    ControlPaintEx.DrawBackgroundImage(graphics, item.BackgroundImage, this.ColorTable.Back, item.BackgroundImageLayout, bounds, clipRect);
                }
                if (item.ButtonPressed)
                {
                    if (this.ColorTable.BaseItemDown != null)
                    {
                        ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemDown, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
                    }
                    else
                    {
                        Rectangle buttonBounds = item.ButtonBounds;
                        Padding   padding      = (item.RightToLeft == RightToLeft.Yes) ? new Padding(0, 1, 1, 1) : new Padding(1, 1, 0, 1);
                        buttonBounds = LayoutUtils.DeflateRect(buttonBounds, padding);
                        RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, this.ColorTable.BaseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
                        buttonBounds.Inflate(-1, -1);
                        graphics.SetClip(buttonBounds);
                        RenderHelperStrip.RenderBackgroundInternal(graphics, buttonBounds, this.ColorTable.BaseItemPressed, this.ColorTable.BaseItemBorder, this.ColorTable.Back, RoundStyle.Left, false, true, mode);
                        graphics.ResetClip();
                        using (Pen pen = new Pen(this.ColorTable.BaseItemSplitter))
                        {
                            graphics.DrawLine(pen, item.SplitterBounds.Left, item.SplitterBounds.Top, item.SplitterBounds.Left, item.SplitterBounds.Bottom);
                        }
                    }
                    base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                }
                else if (!item.Pressed && !item.DropDownButtonPressed)
                {
                    if (item.Selected)
                    {
                        if (this.ColorTable.BaseItemMouse != null)
                        {
                            ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemMouse, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
                        }
                        else
                        {
                            RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, this.ColorTable.BaseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
                            using (Pen pen2 = new Pen(this.ColorTable.BaseItemSplitter))
                            {
                                graphics.DrawLine(pen2, item.SplitterBounds.Left, item.SplitterBounds.Top, item.SplitterBounds.Left, item.SplitterBounds.Bottom);
                            }
                        }
                        base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                    }
                    else
                    {
                        base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                    }
                }
                else
                {
                    if (this.ColorTable.BaseItemDown != null)
                    {
                        ImageDrawRect.DrawRect(graphics, (Bitmap)this.ColorTable.BaseItemDown, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
                    }
                    else
                    {
                        RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, this.ColorTable.BaseItemPressed, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
                    }
                    base.DrawArrow(new ToolStripArrowRenderEventArgs(graphics, item, item.DropDownButtonBounds, arrowColor, ArrowDirection.Down));
                }
            }
            else
            {
                base.OnRenderSplitButtonBackground(e);
            }
        }
Ejemplo n.º 20
0
        protected override void OnPaint(PaintEventArgs e)
        {
            Rectangle rectangle;
            Rectangle rectangle2;
            Color     controlDark;
            Color     color3;

            base.OnPaint(e);
            base.OnPaintBackground(e);
            Graphics  g = e.Graphics;
            Rectangle clientRectangle = base.ClientRectangle;

            this.CalculateRect(out rectangle, out rectangle2);
            g.SmoothingMode = SmoothingMode.AntiAlias;
            Color  baseColor        = this.BaseColor;
            Color  innerBorderColor = Color.FromArgb(200, 0xff, 0xff, 0xff);
            Bitmap mouseBack        = null;
            int    num = 0;

            if (this.StopState != StopStates.NoStop)
            {
                this._controlState = (ControlState)this.StopState;
            }
            if (this.InheritColor)
            {
                baseColor = base.Parent.BackColor;
            }
            switch (this._controlState)
            {
            case ControlState.Hover:
                mouseBack   = (Bitmap)this.MouseBack;
                controlDark = this.GetColor(baseColor, 0, -13, -8, -3);
                color3      = baseColor;
                break;

            case ControlState.Pressed:
                mouseBack   = (Bitmap)this.DownBack;
                controlDark = this.GetColor(baseColor, 0, -35, -24, -9);
                color3      = baseColor;
                num         = 1;
                break;

            default:
                mouseBack   = (Bitmap)this.NormlBack;
                controlDark = baseColor;
                color3      = baseColor;
                break;
            }
            if (!base.Enabled)
            {
                controlDark = SystemColors.ControlDark;
                color3      = SystemColors.ControlDark;
            }
            if ((mouseBack != null) && (this.DrawType == DrawStyle.Img))
            {
                SkinTools.CreateRegion(this, clientRectangle, this.Radius, this.RoundStyle);
                if (this.Create && (this._controlState != this.states))
                {
                    SkinTools.CreateControlRegion(this, mouseBack, 1);
                }
                if (this.Palace)
                {
                    ImageDrawRect.DrawRect(g, mouseBack, clientRectangle, Rectangle.FromLTRB(this.BackRectangle.X, this.BackRectangle.Y, this.BackRectangle.Width, this.BackRectangle.Height), 1, 1);
                }
                else
                {
                    g.DrawImage(mouseBack, 0, 0, base.Width, base.Height);
                }
            }
            else if (this.DrawType == DrawStyle.Draw)
            {
                this.RenderBackgroundInternal(g, clientRectangle, controlDark, color3, innerBorderColor, this.RoundStyle, this.Radius, 0.35f, true, true, LinearGradientMode.Vertical);
                if (this.FadeGlow)
                {
                    this.DrawButtonBackgroundFromBuffer(e.Graphics);
                }
            }
            Image image = null;
            Size  empty = Size.Empty;

            if (base.Image != null)
            {
                if (string.IsNullOrEmpty(this.Text))
                {
                    image = base.Image;
                    empty = new Size(image.Width, image.Height);
                    clientRectangle.Inflate(-4, -4);
                    if ((empty.Width * empty.Height) != 0)
                    {
                        Rectangle withinThis = clientRectangle;
                        withinThis = ImageDrawRect.HAlignWithin(empty, withinThis, base.ImageAlign);
                        withinThis = ImageDrawRect.VAlignWithin(empty, withinThis, base.ImageAlign);
                        if (!base.Enabled)
                        {
                            ControlPaint.DrawImageDisabled(g, image, withinThis.Left, withinThis.Top, this.BackColor);
                        }
                        else
                        {
                            g.DrawImage(image, withinThis.Left + num, withinThis.Top + num, image.Width, image.Height);
                        }
                    }
                }
                else
                {
                    g.InterpolationMode = InterpolationMode.HighQualityBilinear;
                    g.DrawImage(base.Image, rectangle, -num, -num, base.Image.Width, base.Image.Height, GraphicsUnit.Pixel);
                }
            }
            else if ((base.ImageList != null) && (base.ImageIndex != -1))
            {
                image = base.ImageList.Images[base.ImageIndex];
            }
            Color foreColor = base.Enabled ? this.ForeColor : SystemColors.ControlDark;

            if (this.ForeColorSuit)
            {
                if (SkinTools.ColorSlantsDarkOrBright(baseColor))
                {
                    foreColor = Color.White;
                }
                else
                {
                    foreColor = Color.Black;
                }
            }
            TextRenderer.DrawText(g, this.Text, this.Font, rectangle2, foreColor, GetTextFormatFlags(this.TextAlign, this.RightToLeft == RightToLeft.Yes));
            this.states = this._controlState;
        }
Ejemplo n.º 21
0
        protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e)
        {
            ToolStrip       toolStrip = e.ToolStrip;
            ToolStripButton item      = e.Item as ToolStripButton;
            Graphics        graphics  = e.Graphics;

            if (item == null)
            {
                return;
            }
            LinearGradientMode    mode      = (toolStrip.Orientation == Orientation.Horizontal) ? LinearGradientMode.Vertical : LinearGradientMode.Horizontal;
            SmoothingModeGraphics graphics2 = new SmoothingModeGraphics(graphics);
            Rectangle             bounds    = new Rectangle(Point.Empty, item.Size);

            if (item.BackgroundImage != null)
            {
                Rectangle clipRect = item.Selected ? item.ContentRectangle : bounds;
                ControlPaintEx.DrawBackgroundImage(graphics, item.BackgroundImage, this.ColorTable.Back, item.BackgroundImageLayout, bounds, clipRect);
            }
            if (item.CheckState == CheckState.Unchecked)
            {
                if (item.Selected)
                {
                    Bitmap img = item.Pressed ? ((Bitmap)this.ColorTable.BaseItemDown) : ((Bitmap)this.ColorTable.BaseItemMouse);
                    if (img != null)
                    {
                        ImageDrawRect.DrawRect(graphics, img, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
                    }
                    else
                    {
                        Color baseItemHover = this.ColorTable.BaseItemHover;
                        if (item.Pressed)
                        {
                            baseItemHover = this.ColorTable.BaseItemPressed;
                        }
                        RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, baseItemHover, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
                    }
                    goto Label_0302;
                }
                if (!(toolStrip is ToolStripOverflow))
                {
                    goto Label_0302;
                }
                using (Brush brush = new SolidBrush(this.ColorTable.ItemHover))
                {
                    graphics.FillRectangle(brush, bounds);
                    goto Label_0302;
                }
            }
            Bitmap baseItemMouse = (Bitmap)this.ColorTable.BaseItemMouse;
            Color  baseColor     = ControlPaint.Light(this.ColorTable.ItemHover);

            if (item.Selected)
            {
                baseColor     = this.ColorTable.ItemHover;
                baseItemMouse = (Bitmap)this.ColorTable.BaseItemMouse;
            }
            if (item.Pressed)
            {
                baseColor     = this.ColorTable.ItemPressed;
                baseItemMouse = (Bitmap)this.ColorTable.BaseItemDown;
            }
            if (baseItemMouse == null)
            {
                RenderHelperStrip.RenderBackgroundInternal(graphics, bounds, baseColor, this.ColorTable.BaseItemBorder, this.ColorTable.Back, this.ColorTable.BaseItemRadiusStyle, this.ColorTable.BaseItemRadius, this.ColorTable.BaseItemBorderShow, this.ColorTable.BaseItemAnamorphosis, mode);
            }
            else
            {
                ImageDrawRect.DrawRect(graphics, baseItemMouse, bounds, Rectangle.FromLTRB(this.ColorTable.BackRectangle.X, this.ColorTable.BackRectangle.Y, this.ColorTable.BackRectangle.Width, this.ColorTable.BackRectangle.Height), 1, 1);
            }
Label_0302:
            graphics2.Dispose();
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 重绘控件
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if (BackImg == null)
            {
                base.OnPaint(e);
                return;
            }

            int i = (int)state;

            if (this.Focused && state != State.MouseDown && _IsTabFocus == true)
            {
                i = 5;
            }
            if (!this.Enabled)
            {
                i = 4;
            }
            Rectangle rc = this.ClientRectangle;
            Graphics  g  = e.Graphics;

            base.InvokePaintBackground(this, new PaintEventArgs(e.Graphics, base.ClientRectangle));
            try
            {
                if (BackImg != null)
                {
                    if (_BacklightLTRB != Rectangle.Empty)
                    {
                        ImageDrawRect.DrawRect(g, BackImg, rc, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), i, 5);
                    }
                    else
                    {
                        ImageDrawRect.DrawRect(g, BackImg, rc, Rectangle.FromLTRB(10, 10, 10, 10), i, 5);
                    }
                }
            }
            catch
            { }

            Image img = null;
            Size  txts, imgs;

            txts = Size.Empty;
            imgs = Size.Empty;

            if (this.Image != null)
            {
                img = this.Image;
            }
            else if (this.ImageList != null && this.ImageIndex != -1)
            {
                img = this.ImageList.Images[this.ImageIndex];
            }

            if (img != null)
            {
                imgs.Width  = img.Width;
                imgs.Height = img.Height;
            }

            StringFormat format1;

            using (format1 = new StringFormat())
            {
                format1.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;
                SizeF ef1 = g.MeasureString(this.Text, this.Font, new SizeF((float)rc.Width, (float)rc.Height), format1);
                txts = Size.Ceiling(ef1);
            }

            rc.Inflate(-4, -4);
            if (imgs.Width * imgs.Height != 0)
            {
                Rectangle imgr = rc;
                imgr = ImageDrawRect.HAlignWithin(imgs, imgr, this.ImageAlign);
                imgr = ImageDrawRect.VAlignWithin(imgs, imgr, this.ImageAlign);
                if (!this.Enabled)
                {
                    ControlPaint.DrawImageDisabled(g, img, imgr.Left, imgr.Top, this.BackColor);
                }
                else
                {
                    g.DrawImage(img, imgr.Left, imgr.Top, img.Width, img.Height);
                }
            }

            Rectangle txtr = rc;

            txtr = ImageDrawRect.HAlignWithin(txts, txtr, this.TextAlign);
            txtr = ImageDrawRect.VAlignWithin(txts, txtr, this.TextAlign);

            format1 = new StringFormat();
            format1.HotkeyPrefix = System.Drawing.Text.HotkeyPrefix.Show;

            if (this.RightToLeft == RightToLeft.Yes)
            {
                format1.FormatFlags |= StringFormatFlags.DirectionRightToLeft;
            }
            brush = new SolidBrush(this.ForeColor);
            g.DrawString(this.Text, this.Font, brush, (RectangleF)txtr, format1);
            brush.Dispose();
        }
Ejemplo n.º 23
0
        public void SetBits()
        {
            //绘制绘图层背景
            Bitmap    bitmap         = new Bitmap(Main.Width + 10, Main.Height + 10);
            Rectangle _BacklightLTRB = new Rectangle(20, 20, 20, 20);//窗体光泽重绘边界
            Graphics  g = Graphics.FromImage(bitmap);

            g.SmoothingMode   = SmoothingMode.HighQuality;   //高质量
            g.PixelOffsetMode = PixelOffsetMode.HighQuality; //高像素偏移质量
            ImageDrawRect.DrawRect(g, shadowimg, ClientRectangle, Rectangle.FromLTRB(_BacklightLTRB.X, _BacklightLTRB.Y, _BacklightLTRB.Width, _BacklightLTRB.Height), 1, 1);

            // RenderHelper.DrawImageWithNineRect(g, shadowimg, ClientRectangle, new Rectangle { Size = shadowimg.Size });

            if (!Bitmap.IsCanonicalPixelFormat(bitmap.PixelFormat) || !Bitmap.IsAlphaPixelFormat(bitmap.PixelFormat))
            {
                throw new ApplicationException("图片必须是32位带Alhpa通道的图片。");
            }

            WinAPI.POINT ptSrc     = new WinAPI.POINT(0, 0);
            WinAPI.POINT ptWinPos  = new WinAPI.POINT(base.Left, base.Top);
            WinAPI.SIZE  szWinSize = new WinAPI.SIZE(Width, Height);
            byte         biAlpha   = 0xFF;

            WinAPI.BLENDFUNCTION stBlend = new WinAPI.BLENDFUNCTION(
                (byte)WinAPI.BlendOp.AC_SRC_OVER, 0, biAlpha, (byte)WinAPI.BlendOp.AC_SRC_ALPHA);

            IntPtr gdiBitMap = IntPtr.Zero;
            IntPtr memoryDC  = IntPtr.Zero;
            IntPtr preBits   = IntPtr.Zero;
            IntPtr screenDC  = IntPtr.Zero;

            try
            {
                screenDC = WinAPI.GetDC(IntPtr.Zero);
                memoryDC = WinAPI.CreateCompatibleDC(screenDC);

                gdiBitMap = bitmap.GetHbitmap(Color.FromArgb(0));

                preBits = WinAPI.SelectObject(memoryDC, gdiBitMap);
                WinAPI.UpdateLayeredWindow(base.Handle
                                           , screenDC
                                           , ref ptWinPos
                                           , ref szWinSize
                                           , memoryDC
                                           , ref ptSrc
                                           , 0
                                           , ref stBlend
                                           , (uint)WinAPI.ULWPara.ULW_ALPHA);
            }
            finally
            {
                if (gdiBitMap != IntPtr.Zero)
                {
                    WinAPI.SelectObject(memoryDC, preBits);
                    WinAPI.DeleteObject(gdiBitMap);
                }

                WinAPI.DeleteDC(memoryDC);
                WinAPI.ReleaseDC(IntPtr.Zero, screenDC);
                g.Dispose();
                bitmap.Dispose();
            }
        }
Ejemplo n.º 24
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            base.OnPaintBackground(e);
            //变量与初始化
            Graphics  g  = e.Graphics;
            Rectangle rc = this.ClientRectangle;

            g.SmoothingMode = SmoothingMode.AntiAlias;
            Color  baseColor;
            Color  CpBaseColor = BaseColor;
            Color  borderColor;
            Color  innerBorderColor = Color.FromArgb(200, 255, 255, 255);
            Bitmap btm = null;

            //停止当前状态
            if (StopState != StopStates.NoStop)
            {
                _controlState = (ControlState)StopState;
            }
            //获取父容器色调
            if (InheritColor)
            {
                CpBaseColor = this.Parent.BackColor;
            }
            //取得当前需要绘画的图像与色调
            switch (_controlState)
            {
            case ControlState.Hover:
                btm         = (Bitmap)MouseBack;
                baseColor   = GetColor(CpBaseColor, 0, -13, -8, -3);
                borderColor = CpBaseColor;
                break;

            case ControlState.Pressed:
                btm         = (Bitmap)DownBack;
                baseColor   = GetColor(CpBaseColor, 0, -35, -24, -9);
                borderColor = CpBaseColor;
                break;

            default:
                btm         = (Bitmap)NormlBack;
                baseColor   = CpBaseColor;
                borderColor = CpBaseColor;
                break;
            }
            if (!this.Enabled)
            {
                baseColor   = SystemColors.ControlDark;
                borderColor = SystemColors.ControlDark;
            }
            //如果有图则用图绘画
            if (btm != null && DrawType == DrawStyle.Img)
            {
                //绘制圆角
                SkinTools.CreateRegion(this, rc, Radius, RoundStyle);
                //绘制不规则区域
                if (Create && _controlState != states)
                {
                    SkinTools.CreateControlRegion(this, btm, 1);
                }
                //是否启用九宫绘图
                if (Palace)
                {
                    ImageDrawRect.DrawRect(g, btm, rc, Rectangle.FromLTRB(BackRectangle.X, BackRectangle.Y, BackRectangle.Width, BackRectangle.Height), 1, 1);
                }
                else
                {
                    g.DrawImage(btm, 0, 0, this.Width, this.Height);
                }
            }
            else if (DrawType == DrawStyle.Draw)  //无图则用色调绘图
            {
                RenderBackgroundInternal(
                    g,
                    rc,
                    baseColor,
                    borderColor,
                    innerBorderColor,
                    RoundStyle,
                    Radius,
                    0.35f,
                    true,
                    true,
                    LinearGradientMode.Vertical);
                //执行动画渐变效果
                if (FadeGlow)
                {
                    DrawButtonBackgroundFromBuffer(e.Graphics);
                }
            }

            #region 绘画文字和图像
            Image img = null;
            if (imageButton == null)
            {
                imageButton        = new Button();
                imageButton.Parent = new TransparentControl();
                imageButton.SuspendLayout();
                imageButton.BackColor = Color.Transparent;
                imageButton.FlatAppearance.BorderSize = 0;
                imageButton.FlatStyle = FlatStyle.Flat;
            }
            else
            {
                imageButton.SuspendLayout();
            }
            imageButton.AutoEllipsis = AutoEllipsis;
            if (Enabled)
            {
                Color txtColor = this.Enabled ? ForeColor : SystemColors.ControlDark;
                //是否根据背景色决定字体颜色
                if (ForeColorSuit)
                {
                    //如果背景色为暗色
                    if (SkinTools.ColorSlantsDarkOrBright(CpBaseColor))
                    {
                        txtColor = Color.White;
                    }
                    else//如果背景色为亮色
                    {
                        txtColor = Color.Black;
                    }
                }
                imageButton.ForeColor = txtColor;
            }
            else
            {
                imageButton.ForeColor = Color.FromArgb((3 * ForeColor.R + BaseColor.R) >> 2,
                                                       (3 * ForeColor.G + BaseColor.G) >> 2,
                                                       (3 * ForeColor.B + BaseColor.B) >> 2);
            }
            imageButton.Font        = Font;
            imageButton.RightToLeft = RightToLeft;
            if (imageButton.Image != Image && imageButton.Image != null)
            {
                imageButton.Image.Dispose();
            }
            if (Image != null)
            {
                img = this.Image;
                if (this.ImageList != null && this.ImageIndex != -1)
                {
                    img = this.ImageList.Images[this.ImageIndex];
                }
                Bitmap map = new Bitmap(img, ImageSize);
                imageButton.Image = map;
                if (!Enabled)
                {
                    using (Graphics gr = Graphics.FromImage(imageButton.Image))
                    {
                        ControlPaint.DrawImageDisabled(gr, Image, 0, 0, this.BaseColor);
                    }
                }
            }
            imageButton.ImageAlign                 = ImageAlign;
            imageButton.ImageIndex                 = ImageIndex;
            imageButton.ImageKey                   = ImageKey;
            imageButton.ImageList                  = ImageList;
            imageButton.Padding                    = Padding;
            imageButton.Size                       = Size;
            imageButton.Text                       = Text;
            imageButton.TextAlign                  = TextAlign;
            imageButton.TextImageRelation          = TextImageRelation;
            imageButton.UseCompatibleTextRendering = UseCompatibleTextRendering;
            imageButton.UseMnemonic                = UseMnemonic;
            imageButton.ResumeLayout();
            InvokePaint(imageButton, e);
            #endregion

            //储存上一个的样式状态
            states = _controlState;
        }