VitNX_ListView.PaintContent Method
This language is not supported or no code example is available.
Parameters
-
g
-
Graphics
protected override void PaintContent(Graphics g)
{
var range = ItemIndexesInView().ToList();
if (range.Count == 0)
return;
var top = range.Min();
var bottom = range.Max();
for (var i = top; i <= bottom; i++)
{
var width = Math.Max(ContentSize.Width, Viewport.Width);
var rect = new Rectangle(0, i * ItemHeight, width, ItemHeight);
// Background
var odd = i % 2 != 0;
var bgColor = !odd ? Colors.HeaderBackground : Colors.GreyBackground;
if (SelectedIndices.Count > 0 && SelectedIndices.Contains(i))
bgColor = Focused ? Colors.BlueSelection : Colors.GreySelection;
using (var b = new SolidBrush(bgColor))
{
g.FillRectangle(b, rect);
}
// DEBUG: Border
/*using (var p = new Pen(Colors.VitNXBorder))
{
g.DrawLine(p, new Point(rect.Left, rect.Bottom - 1), new Point(rect.Right, rect.Bottom - 1));
}*/
// Icon
if (ShowIcons && Items[i].Icon != null)
{
g.DrawImageUnscaled(Items[i].Icon, new Point(rect.Left + 5, rect.Top + (rect.Height / 2) - (_iconSize / 2)));
}
// Text
using (var b = new SolidBrush(Items[i].TextColor))
{
var stringFormat = new StringFormat
{
Alignment = StringAlignment.Near,
LineAlignment = StringAlignment.Center
};
var modFont = new Font(Font, Items[i].FontStyle);
var modRect = new Rectangle(rect.Left + 2, rect.Top, rect.Width, rect.Height);
if (ShowIcons)
modRect.X += _iconSize + 8;
g.DrawString(Items[i].Text, modFont, b, modRect, stringFormat);
}
}
}
This language is not supported or no code example is available.
.NET Framework
Supported in: 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8
.NET Core
Supported in: 5.0+, 6.0+