本文整理汇总了C#中System.Windows.Forms.DrawListViewItemEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DrawListViewItemEventArgs类的具体用法?C# DrawListViewItemEventArgs怎么用?C# DrawListViewItemEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawListViewItemEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DrawListViewItemEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: drawitem
private void drawitem(object sender, DrawListViewItemEventArgs e)
{
int i = (int)e.Item.Tag;
bool patched;
Bitmap bmp = Textures.GetTexture(i, out patched);
if (bmp != null)
{
int width = bmp.Width;
int height = bmp.Height;
if (width >= e.Bounds.Width)
width = e.Bounds.Width - 2;
if (height >= e.Bounds.Height)
height = e.Bounds.Height - 2;
e.Graphics.DrawImage(bmp, new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, width, height));
if (listView1.SelectedItems.Contains(e.Item))
e.DrawFocusRectangle();
else if (patched)
e.Graphics.DrawRectangle(Pens.LightCoral, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
else
e.Graphics.DrawRectangle(Pens.Gray, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
}
}
示例2: OnDrawItem
protected override void OnDrawItem(DrawListViewItemEventArgs e)
{
if (!UseAlternatingColors) base.OnDrawItem(e);
else e.Item.BackColor = e.ItemIndex % 2 == 0 ? OddRowColor : EvenRowColor;
e.DrawDefault = true;
}
示例3: drawitem
private void drawitem(object sender, DrawListViewItemEventArgs e)
{
int i = int.Parse(e.Item.Text.ToString());
Bitmap bmp;
char c = (char)i;
if ((int)treeView.SelectedNode.Parent.Tag == 1) // Unicode
bmp = UnicodeFonts.Fonts[(int)treeView.SelectedNode.Tag].Chars[i].GetImage();
else
bmp = (Bitmap)e.Item.Tag;
if (listView1.SelectedItems.Contains(e.Item))
e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawString(c.ToString(), Fonts.DefaultFont, Brushes.Gray, e.Bounds.X + e.Bounds.Width / 2, e.Bounds.Y + e.Bounds.Height / 2);
if (bmp != null)
{
int width = bmp.Width;
int height = bmp.Height;
if (width > e.Bounds.Width)
width = e.Bounds.Width - 2;
if (height > e.Bounds.Height)
height = e.Bounds.Height - 2;
e.Graphics.DrawImage(bmp, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, width, height));
}
e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
}
示例4: OnDrawItem
protected override void OnDrawItem(DrawListViewItemEventArgs e)
{
//We draw the current line of items (= item with subitems) on a temp bitmap, then draw the bitmap at once. This is to reduce flickering.
using (Bitmap b = new Bitmap(e.Item.Bounds.Width, e.Item.Bounds.Height))
{
using (Graphics g = Graphics.FromImage(b))
{
if (e.State.HasFlag(ListViewItemStates.Selected))
{
// selected background
g.FillRectangle(SkinManager.GetFlatButtonPressedBackgroundBrush(), new Rectangle(new Point(0, 0), e.Bounds.Size));
}
else if (e.Bounds.Contains(MouseLocation) && MouseState == MouseState.HOVER)
{
// hover background
g.FillRectangle(SkinManager.GetFlatButtonHoverBackgroundBrush(), new Rectangle(new Point(0, 0), e.Bounds.Size));
}
else
{
// draw item back color
g.FillRectangle(new SolidBrush(e.Item.BackColor), new Rectangle(new Point(0, 0), e.Bounds.Size));
}
// Draw separator
g.DrawLine(new Pen(SkinManager.GetDividersColor()), e.Bounds.Left, 0, e.Bounds.Right, 0);
// draw item
e.Graphics.DrawImage(b, e.Item.Bounds.Location);
}
}
}
示例5: listViewResults_DrawItem
void listViewResults_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (0 != (e.State & ListViewItemStates.Selected))
{
e.Graphics.FillRectangle(Brushes.Yellow, e.Bounds);
//ForeColor = Color.White;
}
else
{
//ForeColor = Color.Black;
if (e.ItemIndex % 2 == 0)
{
e.Graphics.FillRectangle(Brushes.BlanchedAlmond, e.Bounds);
}
else
{
e.Graphics.FillRectangle(Brushes.White, e.Bounds);
}
if (0 != (e.State & ListViewItemStates.Focused))
{
e.DrawFocusRectangle();
}
}
e.DrawText();
}
示例6: OnDrawItem
protected override void OnDrawItem(DrawListViewItemEventArgs e)
{
var item = (CustomListViewItem)Items[e.ItemIndex];
if (item.ImageList == null) return;
var img = item.ImageList.Images[item.ImageIndex];
e.Graphics.DrawImage(img, item.Bounds.X, item.Bounds.Y);
e.Graphics.DrawRectangle(pBlack, item.Bounds.X, item.Bounds.Y, img.Width, img.Height);
if (item.Selected && item.SelectionOpacity < 255)
item.SelectionOpacity += 5;
if (!item.Selected && item.SelectionOpacity > 0)
item.SelectionOpacity -= 5;
Pen pBlue = new Pen(Color.FromArgb(item.SelectionOpacity, Color.DodgerBlue)) { Width = 3 };
GraphicsPath rounded = RoundedRectangle.Create(item.Bounds.X - 1, item.Bounds.Y - 1, img.Width + 2, img.Height + 1, 5);
e.Graphics.DrawPath(pBlue, rounded);
base.OnDrawItem(e);
if (item.SelectionOpacity > 0 && item.SelectionOpacity < 255)
Invalidate();
}
示例7: OnDrawItem
protected override void OnDrawItem(DrawListViewItemEventArgs e)
{
base.OnDrawItem(e);
var item = e.Item as IconListViewItem;
// Draw item
e.Graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
e.Graphics.CompositingQuality = CompositingQuality.HighQuality;
e.Graphics.Clip = new Region(e.Bounds);
if (e.Item.Selected)
e.Graphics.FillRectangle(SystemBrushes.MenuHighlight, e.Bounds);
int w = Math.Min(128, item.Bitmap.Width);
int h = Math.Min(128, item.Bitmap.Height);
int x = e.Bounds.X + (e.Bounds.Width - w) / 2;
int y = e.Bounds.Y + (e.Bounds.Height - h) / 2;
var dstRect = new Rectangle(x, y, w, h);
var srcRect = new Rectangle(Point.Empty, item.Bitmap.Size);
e.Graphics.DrawImage(item.Bitmap, dstRect, srcRect, GraphicsUnit.Pixel);
var textRect = new Rectangle(
e.Bounds.Left, e.Bounds.Bottom - Font.Height - 4,
e.Bounds.Width, Font.Height + 2);
TextRenderer.DrawText(e.Graphics, item.ToolTipText, Font, textRect, ForeColor);
e.Graphics.Clip = new Region();
e.Graphics.DrawRectangle(SystemPens.ControlLight, e.Bounds);
}
示例8: IconListView_DrawItem
private void IconListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
IconListViewItem item = e.Item as IconListViewItem;
if (item == null)
{
e.DrawDefault = true;
return;
}
// Draw item
e.DrawBackground();
Pen border = SystemPens.ControlLight;
if (e.Item.Selected)
{
if (this.Focused)
border = SystemPens.Highlight;
else
border = SystemPens.ButtonFace;
}
int centerSpacing = (e.Bounds.Width - this.TileSize.Width - TilePadding.Horizontal) / 2 + TilePadding.Left;
Rectangle newBounds = new Rectangle(e.Bounds.X + centerSpacing, e.Bounds.Y + TilePadding.Top, this.TileSize.Width, this.TileSize.Height);
e.Graphics.DrawRectangle(border, newBounds);
//e.Graphics.DrawString("Whatever", this.Font, e., 0, 0);
int x = e.Bounds.X + (newBounds.Width - item.Icon.Width) / 2 + centerSpacing + 1;
int y = e.Bounds.Y + (newBounds.Height - item.Icon.Height) / 2 + TilePadding.Top + 1;
Rectangle rect = new Rectangle(x, y, item.Icon.Width, item.Icon.Height);
Region clipReg = new Region(newBounds);
e.Graphics.Clip = clipReg;
e.Graphics.DrawIcon(item.Icon, rect);
string text = string.Format("{0} x {1}", item.Icon.Width, item.Icon.Height);
SizeF stringSize = e.Graphics.MeasureString(text, this.Font);
int stringWidth = (int) Math.Round(stringSize.Width);
int stringHeight = (int) Math.Round(stringSize.Height);
x = e.Bounds.X + (e.Bounds.Width - stringWidth - TilePadding.Horizontal) / 2 + TilePadding.Left;
y = e.Bounds.Y + this.TileSize.Height + verticalSpacing + TilePadding.Top;
clipReg = new Region(e.Bounds);
e.Graphics.Clip = clipReg;
if (e.Item.Selected)
{
if (this.Focused)
{
e.Graphics.FillRectangle(SystemBrushes.Highlight, x - 1, y - 1, stringWidth + 2, stringSize.Height + 2);
e.Graphics.DrawString(text, this.Font, SystemBrushes.HighlightText, x, y);
}
else
{
e.Graphics.FillRectangle(SystemBrushes.ButtonFace, x - 1, y - 1, stringWidth + 2, stringSize.Height + 2);
e.Graphics.DrawString(text, this.Font, SystemBrushes.ControlText, x, y);
}
}
else
e.Graphics.DrawString(text, this.Font, SystemBrushes.ControlText, x, y);
}
示例9: OnDrawItem
protected override void OnDrawItem(DrawListViewItemEventArgs e)
{
float fillPercent = 0;
Color highlightColor = Color.White;
if (e.Item is MaterialListViewItem)
{
MaterialListViewItem mlvi = e.Item as MaterialListViewItem;
fillPercent = mlvi.fillPercent;
highlightColor = mlvi.highlightColor;
}
//We draw the current line of items (= item with subitems) on a temp bitmap, then draw the bitmap at once. This is to reduce flickering.
var b = new Bitmap(e.Item.Bounds.Width, e.Item.Bounds.Height);
var g = Graphics.FromImage(b);
//always draw default background
int divideSpot = (int)((fillPercent * e.Bounds.Size.Width) / 100); //The spot where the progress splits into background color
Rectangle firstRect = e.Bounds; //Set the rectnagle of where
firstRect.Width = divideSpot; //the progress is drawn
g.FillRectangle(new SolidBrush(e.Item.BackColor), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); //Draw the item's normal background
g.FillRectangle(new SolidBrush(highlightColor), new Rectangle(new Point(e.Bounds.X, 0), firstRect.Size)); //Fill with highlight
if (e.State.HasFlag(ListViewItemStates.Selected))
{
//selected background
g.FillRectangle(SkinManager.GetFlatButtonPressedBackgroundBrush(), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size));
}
else if (e.Bounds.Contains(MouseLocation) && MouseState == MouseState.HOVER)
{
//hover background
g.FillRectangle(SkinManager.GetFlatButtonHoverBackgroundBrush(), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size));
}
//Draw separator
g.DrawLine(new Pen(SkinManager.GetDividersColor()), e.Bounds.Left, 0, e.Bounds.Right, 0);
foreach (ListViewItem.ListViewSubItem subItem in e.Item.SubItems)
{
//Draw text
g.DrawString(subItem.Text, SkinManager.ROBOTO_MEDIUM_10, SkinManager.GetPrimaryTextBrush(),
new Rectangle(subItem.Bounds.Location.X + ITEM_PADDING, ITEM_PADDING, subItem.Bounds.Width - 2 * ITEM_PADDING, subItem.Bounds.Height - 2 * ITEM_PADDING),
getStringFormat());
}
e.Graphics.DrawImage((Image) b.Clone(), e.Item.Bounds.Location);
g.Dispose();
b.Dispose();
}
示例10: OnDrawItem
protected override void OnDrawItem(DrawListViewItemEventArgs e) {
// Update alternating row colours.
if ((e.ItemIndex + 1) % 2 == 0) {
e.Item.BackColor = AlternatingRowColour;
}
else {
e.Item.BackColor = DefaultRowColour;
}
e.DrawDefault = true;
base.OnDrawItem(e);
}
示例11: DrawListItems
public static void DrawListItems(object sender, DrawListViewItemEventArgs e)
{
Rectangle itemRect = new Rectangle(e.Bounds.X + 5, e.Bounds.Y, e.Bounds.Width - 10, e.Bounds.Height - 1);
SolidBrush selectedBackground = new SolidBrush(Color.FromArgb(100, 12, 123, 204));
Pen selectedStroke = new Pen(Color.FromArgb(12, 123, 204));
e.DrawDefault = true;
if (e.Item.Selected)
{
e.Graphics.FillRectangle(selectedBackground, itemRect);
e.Graphics.DrawRectangle(selectedStroke, itemRect);
}
}
示例12: OnDrawItem
protected override void OnDrawItem(DrawListViewItemEventArgs e)
{
base.FullRowSelect = _FullRowSelect;
if ( !this.ContainsFocus && !_HideSelection )
{
ListViewItemStates status = e.Item.Selected ? ListViewItemStates.Selected : e.State;
base.OnDrawItem(new DrawListViewItemEventArgs(e.Graphics, e.Item, e.Bounds, e.ItemIndex, status));
}
else
{
base.OnDrawItem(e);
}
}
示例13: OnDrawItem
protected override void OnDrawItem(DrawListViewItemEventArgs eventArgs)
{
if (eventArgs.State != 0)
{
using (var brush = new LinearGradientBrush(
eventArgs.Bounds, Color.AliceBlue, Color.CornflowerBlue, LinearGradientMode.Horizontal))
{
// Draw the background for a selected item.
eventArgs.Graphics.FillRectangle(brush, eventArgs.Bounds);
var highlightBrush = new SolidBrush(SystemColors.Highlight);
var iconRect = eventArgs.Item.GetBounds(ItemBoundsPortion.Icon);
var iconsSpacerRect = GetIconsSpacerBounds(eventArgs.Item);
// Draw selection rectangle for an item if item is selected.
if (eventArgs.Item.Selected)
{
var selectRect = new Rectangle(eventArgs.Bounds.X, eventArgs.Bounds.Y,
iconsSpacerRect.X - eventArgs.Bounds.X, eventArgs.Bounds.Height);
if (selectRect.Width != 0)
eventArgs.Graphics.FillRectangle(highlightBrush, selectRect);
selectRect = new Rectangle(iconsSpacerRect.X + iconsSpacerRect.Width, eventArgs.Bounds.Y,
eventArgs.Bounds.Width - iconsSpacerRect.X - iconsSpacerRect.Width, eventArgs.Bounds.Height);
if (selectRect.Width != 0)
eventArgs.Graphics.FillRectangle(highlightBrush, selectRect);
}
// Draw focus rectangle for an item if item is focused.
if (eventArgs.Item.Focused)
ControlPaint.DrawFocusRectangle(eventArgs.Graphics, eventArgs.Bounds);
// Draw the image for an item if there is one.
if (eventArgs.Item.ImageList != null)
{
var itemImage = eventArgs.Item.ImageList.Images[eventArgs.Item.ImageIndex];
var sourceRect = new Rectangle(0, 0, itemImage.Width, itemImage.Height);
var destinationRect = new Rectangle(iconRect.Location, sourceRect.Size);
if ((iconsSpacerRect.Width - (iconRect.X - iconsSpacerRect.X)) < destinationRect.Width)
{
destinationRect.Width = iconsSpacerRect.Width - (iconRect.X - iconsSpacerRect.X);
sourceRect.Width = iconsSpacerRect.Width - (iconRect.X - iconsSpacerRect.X);
}
eventArgs.Graphics.DrawImage(itemImage, destinationRect, sourceRect, GraphicsUnit.Pixel);
}
var labelBounds = eventArgs.Item.GetBounds(ItemBoundsPortion.Label);
var textRect = new Rectangle(labelBounds.X, eventArgs.Bounds.Y, labelBounds.Width, eventArgs.Bounds.Height);
TextRenderer.DrawText(eventArgs.Graphics, eventArgs.Item.Text, eventArgs.Item.Font, textRect,
eventArgs.Item.Selected ? SystemColors.HighlightText : SystemColors.WindowText,
GetTextFormatFlags(Columns[0]) | TextFormatFlags.EndEllipsis);
}
}
base.OnDrawItem(eventArgs);
}
示例14: HiddenWindowsListView_DrawItem
private void HiddenWindowsListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
WindowInfo currentItem = (e.Item as WindowListViewItem).Window;
switch (this.View)
{
case View.LargeIcon:
e.DrawDefault = false;
e.DrawBackground();
Rectangle itemBounds = new Rectangle(e.Bounds.Location, new Size(e.Bounds.Width, 65));
//if (e.Item.Selected)
// e.Graphics.FillRectangle(SystemColors.Highlight.ToBrush(), e.Bounds);
Rectangle iconBounds = e.Graphics.AddImage(e.Bounds, currentItem.ApplicationIcon, null,
(e.Item.Selected) ? 16 : 18);
e.Graphics.AddImage(e.Bounds,
(currentItem.IsPasswordProtected)
? ActionResource.lockwindow_small
: ActionResource.unlockwindow_small, ImageOverlayPosition.TopLeft);
if (currentItem.IsPinned)
e.Graphics.AddImage(e.Bounds, ActionResource.tack_small, ImageOverlayPosition.TopRight);
//e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.EndEllipsis | TextFormatFlags.HorizontalCenter);
Rectangle rec = new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width - 4,
e.Bounds.Height - 4);
TextRenderer.DrawText(e.Graphics, e.Item.Text, e.Item.Font, rec, e.Item.ForeColor,
TextFormatFlags.Bottom | TextFormatFlags.Left | TextFormatFlags.EndEllipsis
| TextFormatFlags.ExpandTabs | TextFormatFlags.SingleLine);
//e.DrawFocusRectangle();
break;
default:
e.DrawDefault = true;
break;
}
if ((bool) e.Item.SubItems[1].Tag != currentItem.IsPasswordProtected)
{
e.Item.SubItems[1].Tag = currentItem.IsPasswordProtected;
e.Item.SubItems[1].Text = currentItem.IsPasswordProtected ? "Yes" : "No";
}
if ((bool) e.Item.SubItems[2].Tag != currentItem.IsPinned)
{
e.Item.SubItems[2].Tag = currentItem.IsPinned;
e.Item.SubItems[2].Text = currentItem.IsPinned ? "Yes" : "No";
}
}
示例15: RssListView_DrawItem
private void RssListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if ((e.State & ListViewItemStates.Selected) != 0)
{
// Draw the background and focus rectangle for a selected item.
// e.Graphics.FillRectangle(Brushes.Maroon, e.Bounds);
e.DrawFocusRectangle();
}
else
{
// Draw the background for an unselected item.
/*using (LinearGradientBrush brush =
new LinearGradientBrush(e.Bounds, Color.Orange,
Color.Maroon, LinearGradientMode.Horizontal))
{
e.Graphics.FillRectangle(brush, e.Bounds);
}*/
}
}