// Private members

        private void PaintDropDownArrow(ComboBox control, ControlPaintArgs e)
        {
            INode    controlNode       = new ControlNode(control);
            UserNode dropDownArrowNode = new UserNode(string.Empty, new[] { "DropDownArrow" });

            dropDownArrowNode.SetParent(controlNode);
            dropDownArrowNode.SetStates(controlNode.States);

            IRuleset ruleset = e.StyleSheet.GetRuleset(dropDownArrowNode);

            // Create the arrow rectangle to match the bounds of the default control.

            Rectangle clientRect = control.ClientRectangle;
            Rectangle arrowRect  = new Rectangle(clientRect.Right - 12, clientRect.Y + 9, 7, 6);

            e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;

            using (Pen pen = new Pen(ruleset.Color?.Value ?? SystemColors.ControlText)) {
                pen.Width     = 2.0f;
                pen.Alignment = PenAlignment.Center;
                pen.StartCap  = LineCap.Flat;
                pen.EndCap    = LineCap.Flat;

                PointF bottomMidpoint = new PointF(arrowRect.Left + arrowRect.Width / 2.0f, arrowRect.Bottom - 1);

                e.Graphics.DrawLine(pen, new PointF(arrowRect.Left, arrowRect.Top), bottomMidpoint);
                e.Graphics.DrawLine(pen, new PointF(arrowRect.Right, arrowRect.Top), bottomMidpoint);
            }
        }
        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 INode CreateItemNode(ListBox control, int itemindex)
        {
            object    item     = control.Items[itemindex];
            Rectangle itemRect = control.GetItemRectangle(itemindex);

            NodeStates states = NodeStates.None;

            if (control.SelectedItems.Contains(item))
            {
                states |= NodeStates.Checked;
            }

            if (ControlUtilities.MouseIntersectsWith(control, itemRect))
            {
                if (Control.MouseButtons.HasFlag(MouseButtons.Left))
                {
                    states |= NodeStates.Active;
                }
                else
                {
                    states |= NodeStates.Hover;
                }
            }

            UserNode node = new UserNode(string.Empty, new[] { "ListBoxItem", "Item" });

            node.SetParent(new ControlNode(control));
            node.SetStates(states);

            if (itemindex % 2 == 0)
            {
                node.AddClass("even");
            }
            else
            {
                node.AddClass("odd");
            }

            return(node);
        }
        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);
                }
            }
        }