示例#1
0
        private void PaintSubItem(Graphics graphics, ListViewItem item, ListViewItem.ListViewSubItem subItem)
        {
            ListView     listView     = item.ListView;
            ColumnHeader columnHeader = listView.Columns[item.SubItems.IndexOf(subItem)];

            Rectangle bounds = subItem.Bounds;
            UserNode  node   = new UserNode(bounds, listView.PointToClient(Cursor.Position));

            node.SetClass("ListViewItem");
            node.AddClass("Item");
            node.SetParent(new ControlNode(listView));

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

            int textPadding = 4;

            IRuleset ruleset = styleSheet.GetRuleset(node);

            Rectangle itemRect = new Rectangle(bounds.X, bounds.Y, columnHeader.Width, bounds.Height);
            Rectangle textRect = new Rectangle(itemRect.X + textPadding, itemRect.Y, itemRect.Width - textPadding * 2, itemRect.Height);

            TextFormatFlags textFormatFlags = TextFormatFlags.Left | TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis | TextFormatFlags.NoPrefix;

            styleRenderer.PaintText(graphics, textRect, ruleset, subItem.Text, subItem.Font, textFormatFlags);
            styleRenderer.PaintBorder(graphics, itemRect, ruleset);
        }