protected override void OnPaint(PaintEventArgs pevent) { var g = pevent.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; g.TextRenderingHint = TextRenderingHint.AntiAlias; // clear the control g.Clear(Parent.BackColor); var CHECKBOX_CENTER = boxOffset + CHECKBOX_SIZE_HALF - 1; double animationProgress = animationManager.GetProgress(); int colorAlpha = Enabled ? (int)(animationProgress * 255.0) : SkinManager.GetCheckBoxOffDisabledColor().A; int backgroundAlpha = Enabled ? (int)(SkinManager.GetCheckboxOffColor().A *(1.0 - animationProgress)) : SkinManager.GetCheckBoxOffDisabledColor().A; var brush = new SolidBrush(Color.FromArgb(colorAlpha, Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.GetCheckBoxOffDisabledColor())); var brush3 = new SolidBrush(Enabled ? SkinManager.ColorScheme.AccentColor : SkinManager.GetCheckBoxOffDisabledColor()); var pen = new Pen(brush.Color); // draw ripple animation if (Ripple && rippleAnimationManager.IsAnimating()) { for (int i = 0; i < rippleAnimationManager.GetAnimationCount(); i++) { var animationValue = rippleAnimationManager.GetProgress(i); var animationSource = new Point(CHECKBOX_CENTER, CHECKBOX_CENTER); var rippleBrush = new SolidBrush(Color.FromArgb((int)((animationValue * 40)), ((bool)rippleAnimationManager.GetData(i)[0]) ? Color.Black : brush.Color)); var rippleHeight = (Height % 2 == 0) ? Height - 3 : Height - 2; var rippleSize = (rippleAnimationManager.GetDirection(i) == AnimationDirection.InOutIn) ? (int)(rippleHeight * (0.8d + (0.2d * animationValue))) : rippleHeight; using (var path = DrawHelper.CreateRoundRect(animationSource.X - rippleSize / 2, animationSource.Y - rippleSize / 2, rippleSize, rippleSize, rippleSize / 2)) { g.FillPath(rippleBrush, path); } rippleBrush.Dispose(); } } brush3.Dispose(); var checkMarkLineFill = new Rectangle(boxOffset, boxOffset, (int)(17.0 * animationProgress), 17); using (var checkmarkPath = DrawHelper.CreateRoundRect(boxOffset, boxOffset, 17, 17, 1f)) { SolidBrush brush2 = new SolidBrush(DrawHelper.BlendColor(Parent.BackColor, Enabled ? SkinManager.GetCheckboxOffColor() : SkinManager.GetCheckBoxOffDisabledColor(), backgroundAlpha)); Pen pen2 = new Pen(brush2.Color); g.FillPath(brush2, checkmarkPath); g.DrawPath(pen2, checkmarkPath); g.FillRectangle(new SolidBrush(Parent.BackColor), boxOffset + 2, boxOffset + 2, CHECKBOX_INNER_BOX_SIZE - 1, CHECKBOX_INNER_BOX_SIZE - 1); g.DrawRectangle(new Pen(Parent.BackColor), boxOffset + 2, boxOffset + 2, CHECKBOX_INNER_BOX_SIZE - 1, CHECKBOX_INNER_BOX_SIZE - 1); brush2.Dispose(); pen2.Dispose(); if (Enabled) { g.FillPath(brush, checkmarkPath); g.DrawPath(pen, checkmarkPath); } else if (Checked) { g.SmoothingMode = SmoothingMode.None; g.FillRectangle(brush, boxOffset + 2, boxOffset + 2, CHECKBOX_INNER_BOX_SIZE, CHECKBOX_INNER_BOX_SIZE); g.SmoothingMode = SmoothingMode.AntiAlias; } g.DrawImageUnscaledAndClipped(DrawCheckMarkBitmap(), checkMarkLineFill); } // draw checkbox text SizeF stringSize = g.MeasureString(Text, SkinManager.ROBOTO_MEDIUM_10); g.DrawString( Text, SkinManager.ROBOTO_MEDIUM_10, Enabled ? SkinManager.GetPrimaryTextBrush() : SkinManager.GetDisabledOrHintBrush(), boxOffset + TEXT_OFFSET, Height / 2 - stringSize.Height / 2); // dispose used paint objects pen.Dispose(); brush.Dispose(); }