protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); base.OnPaintBackground(e); Rectangle rectangle; //图片范围 Rectangle rectangle2; //字体范围 this.CalculateRect(out rectangle, out rectangle2); Graphics g = e.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; if (base.Enabled) { //填充按钮颜色效果 GraphicsPath aa = GetGraphicPath.CreatePath(base.ClientRectangle, _JMRadius, RoundStyle.All, true); aa.CloseFigure(); //加载鼠标进入效果 if (SFVisibleEffect) { Color col1 = ColorClass.GetColor(_JMBaseColorTwo, 0, -20, -20, -20); Color col2 = ColorClass.GetColor(_JMBaseColor, 0, -20, -20, -20); GraphicsPath bb = GetGraphicPath.CreatePath(base.ClientRectangle, _JMRadius, RoundStyle.All, true); bb.CloseFigure(); g.FillPath(new LinearGradientBrush(base.ClientRectangle, col1, col2, LinearGradientMode.Vertical), bb); g.DrawPath(new Pen(new SolidBrush(Color.DarkGray)), aa); } else if (SFDownEffect)//加载鼠标按下效果 || Focused { Color col1 = ColorClass.GetColor(_JMBaseColorTwo, 0, -35, -35, -35); Color col2 = ColorClass.GetColor(_JMBaseColor, 0, -35, -35, -35); GraphicsPath cc = GetGraphicPath.CreatePath(base.ClientRectangle, _JMRadius, RoundStyle.All, true); cc.CloseFigure(); g.FillPath(new LinearGradientBrush(base.ClientRectangle, col1, col2, LinearGradientMode.Vertical), cc); g.DrawPath(new Pen(new SolidBrush(Color.DarkGray)), aa); } else { g.FillPath(new LinearGradientBrush(base.ClientRectangle, _JMBaseColorTwo, _JMBaseColor, LinearGradientMode.Vertical), aa); g.DrawPath(new Pen(new SolidBrush(Color.DarkGray)), aa); } //加载图片 if (base.Image != null) { g.InterpolationMode = InterpolationMode.HighQualityBilinear; g.DrawImage(base.Image, rectangle); } } else//不可用为“灰色” { //填充按钮颜色效果 GraphicsPath aa = GetGraphicPath.CreatePath(base.ClientRectangle, _JMRadius, RoundStyle.All, true); aa.CloseFigure(); g.FillPath(new LinearGradientBrush(base.ClientRectangle, SystemColors.ControlDark, SystemColors.ControlDark, LinearGradientMode.Vertical), aa); g.DrawPath(new Pen(new SolidBrush(Color.DarkGray)), aa); } //加载文字 TextRenderer.DrawText(g, this.Text, this.Font, rectangle2, this.ForeColor, TextFormat.GetTextFormatFlags(this.TextAlign, this.RightToLeft == RightToLeft.Yes)); if (_JMSFNew) { e.Graphics.DrawImage(Properties.Resources._new, new Rectangle(Width - 12, Height / 2 - 5, 10, 10)); } }