protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); var g = pevent.Graphics; g.TextRenderingHint = TextRenderingHint.AntiAlias; GraphicsPath bgGP = DrawHelper.CreateRoundRect(ClientRectangle.X, ClientRectangle.Y, ClientRectangle.Width - 1, ClientRectangle.Height - 1, _roundedCorner); //Hover Color c = MaterialSkinManager.GetFlatButtonHoverBackgroundColor(); using (Brush b = new SolidBrush(Color.FromArgb((int)(hoverAnimationManager.GetProgress() * c.A), c.RemoveAlpha()))) g.FillPath(b, bgGP); //Ripple if (animationManager.IsAnimating()) { g.SmoothingMode = SmoothingMode.AntiAlias; for (int i = 0; i < animationManager.GetAnimationCount(); i++) { var animationValue = animationManager.GetProgress(i); var animationSource = animationManager.GetSource(i); using (Brush rippleBrush = new SolidBrush(Color.FromArgb((int)(101 - (animationValue * 100)), Color.Black))) { var rippleSize = (int)(animationValue * Width * 2); g.FillEllipse(rippleBrush, new Rectangle(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize)); } } g.SmoothingMode = SmoothingMode.None; } //Text Rectangle textRect = ClientRectangle; //Icon if (Icon != null) { Rectangle iconRect = new Rectangle(8, textRect.Height / 2 - 12, 24, 24); if (String.IsNullOrEmpty(Text)) { // Center Icon iconRect.X = textRect.Width / 2 - 12; } g.DrawImage(Icon, iconRect); } if (Icon != null) { // // Resize and move Text container // // First 8: left padding // 24: icon width // Second 4: space between Icon and Text // Third 8: right padding textRect.Width -= 8 + 24 + 4 + 8; // First 8: left padding // 24: icon width // Second 4: space between Icon and Text textRect.X += 8 + 24 + 4; } g.DrawString( Text.ToUpper(), Font, Enabled ? (Primary ? MaterialSkinManager.ColorScheme.PrimaryBrush : MaterialSkinManager.GetPrimaryTextBrush()) : MaterialSkinManager.GetFlatButtonDisabledTextBrush(), textRect, new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center } ); if (!DesignMode && Controls.Count > 0) { this.DrawChildShadow(g); } }