Ejemplo n.º 1
0
        private void PaintItem(Graphics graphics, ListViewItem item)
        {
            Rectangle bounds = item.Bounds;
            UserNode  node   = new UserNode(bounds, item.ListView.PointToClient(Cursor.Position));

            node.AddClass("ListViewItem");
            node.AddClass("Item");
            node.SetParent(new ControlNode(item.ListView));

            if (item.Index % 2 == 0)
            {
                node.AddClass("Even");
            }
            else
            {
                node.AddClass("Odd");
            }

            if (item.Selected)
            {
                node.AddState(NodeStates.Checked);
            }

            IRuleset  ruleset = styleSheet.GetRuleset(node);
            Rectangle rect    = new Rectangle(bounds.X, bounds.Y, bounds.Width, bounds.Height);

            styleRenderer.PaintBackground(graphics, rect, ruleset);
            styleRenderer.PaintBorder(graphics, rect, ruleset);
        }
Ejemplo n.º 2
0
        public static void PaintParentBackground(this IStyleRenderer styleRenderer, Graphics graphics, Rectangle rectangle, Rectangle parentRectangle, IRuleset parentRuleset)
        {
            Rectangle drawRect = new Rectangle(parentRectangle.X + rectangle.X, parentRectangle.Y + rectangle.Y, parentRectangle.Width, parentRectangle.Height);

            Region oldClippingRegion = graphics.Clip;
            Region clippingRegion    = new Region();

            clippingRegion.Intersect(oldClippingRegion);
            clippingRegion.Intersect(rectangle);

            graphics.SetClip(clippingRegion, CombineMode.Replace);
            graphics.TranslateTransform(-rectangle.X, -rectangle.Y);

            styleRenderer.PaintBackground(graphics, drawRect, parentRuleset);

            graphics.TranslateTransform(rectangle.X, rectangle.Y);
            graphics.SetClip(oldClippingRegion, CombineMode.Replace);
        }