private void PaintCheck(CheckBox control, ControlPaintArgs e) { INode controlNode = new ControlNode(control); UserNode checkNode = new UserNode(string.Empty, new[] { "Check" }); checkNode.SetParent(controlNode); checkNode.SetStates(controlNode.States); IRuleset parentRuleset = e.StyleSheet.GetRuleset(control); IRuleset ruleset = e.StyleSheet.GetRuleset(checkNode, inherit: false); if (!ruleset.Any()) { ruleset = CreateDefaultCheckRuleset(); } ruleset.InheritProperties(parentRuleset); Rectangle clientRect = e.Control.ClientRectangle; Rectangle checkRect = new Rectangle(clientRect.X, clientRect.Y + (int)(clientRect.Height / 2.0f - CheckWidth / 2.0f) - 1, CheckWidth, CheckWidth); e.StyleRenderer.PaintBackground(e.Graphics, checkRect, ruleset); e.StyleRenderer.PaintBorder(e.Graphics, checkRect, ruleset); // Draw the checkmark. if (control.Checked) { using (Pen pen = new Pen(ruleset.Color?.Value ?? SystemColors.ControlText)) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; pen.Alignment = PenAlignment.Center; pen.Width = 2.0f; pen.StartCap = LineCap.Square; pen.EndCap = LineCap.Square; e.Graphics.DrawLine(pen, checkRect.X + 3, checkRect.Y + checkRect.Height / 2.0f, checkRect.X + checkRect.Width / 2.0f - 1, checkRect.Y + checkRect.Height - 5); e.Graphics.DrawLine(pen, checkRect.X + checkRect.Width / 2.0f - 1, checkRect.Y + checkRect.Height - 5, checkRect.X + checkRect.Width - 4, checkRect.Y + 3); } } }
private void PaintCheck(RadioButton control, ControlPaintArgs e) { INode controlNode = new ControlNode(control); UserNode checkNode = new UserNode(string.Empty, new[] { "Check" }); checkNode.SetParent(controlNode); checkNode.SetStates(controlNode.States); IRuleset parentRuleset = e.StyleSheet.GetRuleset(control); IRuleset ruleset = e.StyleSheet.GetRuleset(checkNode, inherit: false); if (!ruleset.Any()) { ruleset = CreateDefaultCheckRuleset(); } ruleset.InheritProperties(parentRuleset); Rectangle clientRect = control.ClientRectangle; Rectangle checkRect = new Rectangle(clientRect.X, clientRect.Y + (int)(clientRect.Height / 2.0f - CheckWidth / 2.0f), CheckWidth, CheckWidth); e.StyleRenderer.PaintBackground(e.Graphics, checkRect, ruleset); e.StyleRenderer.PaintBorder(e.Graphics, checkRect, ruleset); // Draw the checkmark. if (control.Checked) { using (Brush brush = new SolidBrush(ruleset.Color?.Value ?? SystemColors.ControlText)) { e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; e.Graphics.PixelOffsetMode = PixelOffsetMode.HighQuality; checkRect.Inflate(-3, -3); e.Graphics.FillEllipse(brush, checkRect); } } }