本文整理汇总了C#中System.Windows.Forms.DrawListViewItemEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DrawListViewItemEventArgs类的具体用法?C# DrawListViewItemEventArgs怎么用?C# DrawListViewItemEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawListViewItemEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DrawListViewItemEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:svn2github,项目名称:fiddler-plus,代码行数:28,代码来源:Texture.cs
示例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;
}
开发者ID:divyashreeu,项目名称:ozeki-call-recorder,代码行数:7,代码来源:ExtendedListView.cs
示例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);
}
开发者ID:polserver,项目名称:poltools,代码行数:29,代码来源:Fonts.cs
示例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);
}
}
}
开发者ID:cz-michi,项目名称:MaterialSkin,代码行数:31,代码来源:MaterialListView.cs
示例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();
}
开发者ID:mausch,项目名称:NHWorkbench,代码行数:25,代码来源:ResultsView.cs
示例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();
}
开发者ID:EmilGedda,项目名称:QuickImage,代码行数:25,代码来源:CustomListView.cs
示例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);
}
开发者ID:modulexcite,项目名称:IconExtractor,代码行数:33,代码来源:IconListView.cs
示例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);
}
开发者ID:450640526,项目名称:HtmExplorer,代码行数:55,代码来源:IconListView.cs
示例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();
}
开发者ID:DevinPower,项目名称:MaterialSkin,代码行数:53,代码来源:MaterialListView.cs
示例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);
}
开发者ID:alexmcbride,项目名称:insimsniffer,代码行数:13,代码来源:BaseListView.cs
示例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);
}
}
开发者ID:hanveg12,项目名称:XNA_Innlevering2,代码行数:13,代码来源:ListItemManager.cs
示例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);
}
}
开发者ID:ischool-desktop,项目名称:MOD_Club.General.Zizhu,代码行数:13,代码来源:ListViewEX.cs
示例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);
}
开发者ID:TargetProcess,项目名称:Tp.Integration.Ide.VisualStudio,代码行数:49,代码来源:ListViewEx.cs
示例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";
}
}
开发者ID:priestofpsi,项目名称:Hide-My-Window,代码行数:47,代码来源:HiddenWindowsListView.cs
示例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);
}*/
}
}
开发者ID:metaburbia,项目名称:RssTray,代码行数:19,代码来源:RssListView.cs
示例16: listView1_DrawItem
private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawBackground();
e.DrawFocusRectangle();
string previewStr = char.ConvertFromUtf32(LastChar);
var sf = new StringFormat(StringFormatFlags.NoFontFallback);
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
var font = new Font(e.Item.Text, 72f, FontStyle.Regular, GraphicsUnit.Pixel);
var smallFont = new Font(e.Item.Text, 12f, FontStyle.Regular, GraphicsUnit.Pixel);
e.Graphics.DrawString(previewStr, font, SystemBrushes.WindowText, e.Bounds, sf);
RectangleF labelRect = new RectangleF(e.Bounds.X, e.Bounds.Y + (e.Bounds.Height - 24), e.Bounds.Width, 24);
e.Graphics.DrawString(e.Item.Text, smallFont, SystemBrushes.WindowText, labelRect, sf);
}
开发者ID:MiffOttah,项目名称:PerFont,代码行数:19,代码来源:Form1.cs
示例17: LvGroupsDrawItem
private void LvGroupsDrawItem(object sender, DrawListViewItemEventArgs e)
{
bool isSeparator = e.Item.Text == "-";
Brush brush;
if (e.Item == _itemAtCursor && !e.Item.Selected)
{
brush = Brushes.Gainsboro;
}
else
{
brush = !e.Item.Selected || isSeparator
? Brushes.White
: Brushes.Silver;
}
e.Graphics.FillRectangle(brush, e.Bounds);
if (!isSeparator)
{
Rectangle rect = new Rectangle(e.Item.Bounds.X + 32, e.Item.Bounds.Y + 7,
e.Item.Bounds.Width - 32, e.Item.Bounds.Height - 7);
Font font = new Font(Font, e.Item.Selected ? FontStyle.Bold : FontStyle.Regular);
e.Graphics.DrawString(e.Item.Text, font, Brushes.Black, rect);
e.Graphics.DrawImage(SmallImageList.Images[e.Item.ImageIndex],
e.Item.Bounds.Location);
}
else
{
const int margin = 6;
const float lineHeight = 1f;
Color penColor = Color.Gray;
Pen pen = new Pen(penColor, lineHeight);
pen.StartCap = pen.EndCap = LineCap.Flat;
//e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
Point ptStart = new Point(
e.Item.Bounds.X + margin,
(int)(e.Item.Bounds.Top + e.Item.Bounds.Height / 2 - lineHeight / 2) + 1);
Point ptEnd = new Point(
ptStart.X + (ClientRectangle.Width - margin * 2), ptStart.Y);
e.Graphics.DrawLine(pen, ptStart, ptEnd);
}
}
开发者ID:TimeZeroForever,项目名称:TZToolz,代码行数:43,代码来源:SettingsListView.cs
示例18: lvIcons_DrawItem
private void lvIcons_DrawItem(object sender, DrawListViewItemEventArgs e) {
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
if ((e.State & ListViewItemStates.Hot) != 0 && (e.State & ListViewItemStates.Selected) == 0) {
this._ItemHoverRenderer.DrawBackground(e.Graphics, e.Bounds);
} else if ((e.State & ListViewItemStates.Hot) != 0 && (e.State & ListViewItemStates.Selected) != 0) {
this._Selectedx2Renderer.DrawBackground(e.Graphics, e.Bounds);
} else if ((e.State & ListViewItemStates.Selected) != 0) {
this._ItemSelectedRenderer.DrawBackground(e.Graphics, e.Bounds);
} else {
e.DrawBackground();
}
var ico = _Icons[(int)e.Item.Tag].Icon;
if (ico.Width <= 48) {
e.Graphics.DrawIcon(_Icons[(int)e.Item.Tag].Icon,
e.Bounds.X + (e.Bounds.Width - ico.Width) / 2, e.Bounds.Y + (e.Bounds.Height - ico.Height) / 2 - 5);
}
e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter | TextFormatFlags.WordEllipsis);
}
开发者ID:Gainedge,项目名称:BetterExplorer,代码行数:21,代码来源:IconView.cs
示例19: OnDrawItem
protected override void OnDrawItem(DrawListViewItemEventArgs e)
{
Rectangle r = e.Bounds;
if (r.Width > this.ClientSize.Width) r.Width = this.ClientSize.Width;
Graphics g = e.Graphics;
r.X += 1; //3
r.Width -= 2;
int offset = 0;
bool isSelected = e.Item == m_hoverItem;
Brush backBrush = isSelected ? SystemBrushes.Highlight : new SolidBrush(this.BackColor);
g.FillRectangle(backBrush, r);
if (this.CheckBoxes)
{
CheckBoxState boxState = e.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal;
CheckBoxRenderer.DrawCheckBox(g, new Point(r.X + 3, r.Y + (r.Height / 2) - 6), boxState);
offset = CheckBoxRenderer.GetGlyphSize(g, boxState).Width + 6;
r.X += offset;
r.Width -= offset;
}
int imgFlags = ILD_TRANSPARENT;
if (isSelected)
imgFlags |= ILD_BLEND25;
int imgIndex = this.SmallImageList.Images.IndexOfKey(e.Item.ImageKey);
bool result = ImageList_Draw(this.SmallImageList.Handle, imgIndex, g.GetHdc(), r.X, r.Y, imgFlags);
g.ReleaseHdc();
offset = this.SmallImageList.ImageSize.Width;
r.X += offset;
r.Width -= offset;
string txt = e.Item.SubItems[0].Text;
Color backColor = isSelected ? SystemColors.Highlight : Color.Transparent;
Color foreColor = isSelected ? SystemColors.HighlightText : this.ForeColor;
TextFormatFlags textFlags = TextFormatFlags.EndEllipsis | TextFormatFlags.NoPrefix |
TextFormatFlags.VerticalCenter | TextFormatFlags.PreserveGraphicsTranslateTransform |
TextFormatFlags.SingleLine;
TextRenderer.DrawText(g, txt, this.Font, r, foreColor, backColor, textFlags);
}
开发者ID:schultzisaiah,项目名称:just-gestures,代码行数:37,代码来源:CheckListBox.cs
示例20: 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.
var b = new Bitmap(e.Item.Bounds.Width, e.Item.Bounds.Height);
var g = Graphics.FromImage(b);
//always draw default background
g.FillRectangle(new SolidBrush(SkinManager.GetApplicationBackgroundColor()), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size));
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();
}
开发者ID:robertgt90,项目名称:MaterialSkin,代码行数:36,代码来源:MaterialListView.cs
注:本文中的System.Windows.Forms.DrawListViewItemEventArgs类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论