protected override void OnPaintBackground(PaintEventArgs e) { base.OnPaintBackground(e); int tmpShadowOffSet = Math.Min(Math.Min(_shadowOffSet, this.Width - 2), this.Height - 2); int tmpSoundCornerRadius = Math.Min(Math.Min(_roundCornerRadius, this.Width - 2), this.Height - 2); if (this.Width > 1 && this.Height > 1) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Rectangle rect = new Rectangle(0, 0, this.Width - tmpShadowOffSet - 1, this.Height - tmpShadowOffSet - 1); Rectangle rectShadow = new Rectangle(tmpShadowOffSet, tmpShadowOffSet, this.Width - tmpShadowOffSet - 1, this.Height - tmpShadowOffSet - 1); GraphicsPath graphPathShadow = A1PanelGraphics.GetRoundPath(rectShadow, tmpSoundCornerRadius); GraphicsPath graphPath = A1PanelGraphics.GetRoundPath(rect, tmpSoundCornerRadius); if (tmpSoundCornerRadius > 0) { using (PathGradientBrush gBrush = new PathGradientBrush(graphPathShadow)) { gBrush.WrapMode = WrapMode.Clamp; ColorBlend colorBlend = new ColorBlend(3); colorBlend.Colors = new Color[] { Color.Transparent, Color.FromArgb(180, Color.DimGray), Color.FromArgb(180, Color.DimGray) }; colorBlend.Positions = new float[] { 0f, .1f, 1f }; gBrush.InterpolationColors = colorBlend; e.Graphics.FillPath(gBrush, graphPathShadow); } } // Draw backgroup LinearGradientBrush brush = new LinearGradientBrush(rect, this._gradientStartColor, this._gradientEndColor, LinearGradientMode.BackwardDiagonal); e.Graphics.FillPath(brush, graphPath); e.Graphics.DrawPath(new Pen(Color.FromArgb(180, this._borderColor), _borderWidth), graphPath); // Draw Image if (_image != null) { e.Graphics.DrawImageUnscaled(_image, _imageLocation); } } }
protected override void OnPaintBackground(PaintEventArgs e) { // GraphicsPath graphPathShadow; base.OnPaintBackground(e); int tmpShadowOffSet = Math.Min(Math.Min(_shadowOffSet, this.Width - 2), this.Height - 2); int tmpSoundCornerRadius = Math.Min(Math.Min(_roundCornerRadius, this.Width - 2), this.Height - 2); if (this.Width > 1 && this.Height > 1) { e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; Rectangle rect = new Rectangle(0, 0, this.Width - tmpShadowOffSet - 1, this.Height - tmpShadowOffSet - 1); Rectangle rect2 = new Rectangle(0, 0, this.Width - tmpShadowOffSet - 1, (this.Height / 2)); // if (_shadowOffSet > 0) // { Rectangle rectShadow = new Rectangle(tmpShadowOffSet, tmpShadowOffSet, this.Width - tmpShadowOffSet - 1, this.Height - tmpShadowOffSet - 1); GraphicsPath graphPathShadow = A1PanelGraphics.GetRoundPath(rectShadow, tmpSoundCornerRadius); // } GraphicsPath graphPath = A1PanelGraphics.GetRoundPath(rect, tmpSoundCornerRadius); // GraphicsPath graphPath2 = A1PanelGraphics.GetRoundPath(rect2, tmpSoundCornerRadius); if (tmpSoundCornerRadius > 0) { using (PathGradientBrush gBrush = new PathGradientBrush(graphPathShadow)) { gBrush.WrapMode = WrapMode.Clamp; ColorBlend colorBlend = new ColorBlend(3); colorBlend.Colors = new Color[] { Color.Transparent, Color.FromArgb(180, Color.DimGray), Color.FromArgb(180, Color.DimGray) }; colorBlend.Positions = new float[] { 0f, .1f, 1f }; gBrush.InterpolationColors = colorBlend; if (_shadowOffSet > 0) { e.Graphics.FillPath(gBrush, graphPathShadow); } } } // Draw backgroup LinearGradientBrush brush = new LinearGradientBrush(rect, this._gradientStartColor, this._gradientEndColor, _linearGradientMode); // LinearGradientBrush brush2 = new LinearGradientBrush(rect2, // this._gradientStartColor, // this._gradientEndColor, // _linearGradientMode); e.Graphics.FillPath(brush, graphPath); // e.Graphics.FillPath(brush2, graphPath2); e.Graphics.DrawPath(new Pen(Color.FromArgb(180, this._borderColor), _borderWidth), graphPath); // Draw Image if (_image != null) { if (Enabled) { // Draw Image as it is e.Graphics.DrawImageUnscaled(_image, _imageLocation); } else { // Draw Image in 'disabled' style ('grayed out') System.Windows.Forms.ControlPaint.DrawImageDisabled(e.Graphics, _image, _imageLocation.X, _imageLocation.Y, BackColor); } } } }