本文整理汇总了C#中System.Windows.Forms.DrawListViewSubItemEventArgs.DrawBackground方法的典型用法代码示例。如果您正苦于以下问题:C# DrawListViewSubItemEventArgs.DrawBackground方法的具体用法?C# DrawListViewSubItemEventArgs.DrawBackground怎么用?C# DrawListViewSubItemEventArgs.DrawBackground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DrawListViewSubItemEventArgs
的用法示例。
在下文中一共展示了DrawListViewSubItemEventArgs.DrawBackground方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: lvObjects_DrawSubItem
private void lvObjects_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
this.columnName.Width = lvObjects.Width - 16*3 - 4;
if (e.SubItem.Tag != null)
{
if (e.Header == this.columnNetwork)
{
e.DrawBackground();
var imageRect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height);
Image imgToDraw = e.SubItem.Tag.Equals(true) ? Resources.networkIconOn : Resources.networkIconOff;
e.Graphics.DrawImage(imgToDraw, imageRect);
e.Header.Width = 16;
}
else if (e.Header == this.columnPlayer)
{
e.DrawBackground();
var imageRect = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Height, e.Bounds.Height);
Image imgToDraw = e.SubItem.Tag.Equals(true) ? Resources.playerIconOn : Resources.playerIconOff;
e.Graphics.DrawImage(imgToDraw, imageRect);
e.Header.Width = 16;
}
}
else
{
e.DrawDefault = true;
return;
}
}
示例2: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
if (e.Item.Selected)
{
e.Graphics.FillRectangle(Brushes.Yellow, e.Bounds);
}
else
{
e.DrawBackground();
}
e.Graphics.DrawString(e.SubItem.Text, Font, Brushes.Black, e.Bounds);
}
示例3: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
base.OnDrawSubItem(e);
if (e.ItemState == 0)
{
return;
}
if ((e.ItemState & ListViewItemStates.Selected) == ListViewItemStates.Selected)
e.SubItem.BackColor = System.Drawing.Color.LightSkyBlue;
else
{
ConfigData data = e.Item.Tag as ConfigData;
if (data != null && (data.HasTaskitem || data.IsAutRun))
{
e.SubItem.BackColor = System.Drawing.Color.Pink;
}
else if (e.ItemIndex % 2 != 0)
e.SubItem.BackColor = HVH_Ken_Modules.GlobalVar.Instanse.StyleColor;
else
e.SubItem.BackColor = this.BackColor;
}
e.DrawBackground();
using (StringFormat sf = new StringFormat())
{
HorizontalAlignment align = Columns[e.ColumnIndex].TextAlign;
if (align == HorizontalAlignment.Center)
sf.Alignment = StringAlignment.Center;
else if (align == HorizontalAlignment.Right)
sf.Alignment = StringAlignment.Far;
e.Graphics.DrawString(e.SubItem.Text, Font, new SolidBrush(ForeColor), e.Bounds, sf);
}
e.DrawFocusRectangle(e.Bounds);
if ((e.ItemState & ListViewItemStates.Focused) == ListViewItemStates.Focused)
{
if (this.FullRowSelect == false)
{
if (e.ColumnIndex == 0)
{
e.DrawFocusRectangle(e.Bounds);
}
}
else
e.DrawFocusRectangle(e.Bounds);
}
}
示例4: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) {
ListViewItem item = Items[e.ItemIndex];
if (item == null || !(item is HomuTactListViewItem)) {
e.DrawDefault = true;
return;
}
HomuTactListEntry entry = (item as HomuTactListViewItem).Entry;
Color texCol = Color.Black;
switch (entry.Behavior) {
case EHomuBehavior.Attack:
case EHomuBehavior.Attack1st:
case EHomuBehavior.AttackLast:
case EHomuBehavior.AttackWeak:
texCol = Color.Maroon;
break;
case EHomuBehavior.React:
case EHomuBehavior.React1st:
case EHomuBehavior.ReactLast:
texCol = Color.Violet;
break;
case EHomuBehavior.Avoid:
texCol = Color.Gray;
break;
case EHomuBehavior.Coward:
texCol = Color.Blue;
break;
}
SolidBrush drawBrush = new SolidBrush(texCol);
Point drawPoint = new Point(e.Bounds.X, e.Bounds.Y);
e.DrawBackground();
if (SelectedIndices.Contains(e.ItemIndex) == true)
e.Graphics.FillRectangle(Brushes.LightBlue, e.Bounds);
if (e.ColumnIndex == 0)
e.Graphics.DrawString(entry.ID.ToString(), new Font(Font, FontStyle.Bold), drawBrush, drawPoint);
else if (e.ColumnIndex == 1)
e.Graphics.DrawString(entry.Name, Font, drawBrush, drawPoint);
else if (e.ColumnIndex == 2)
e.Graphics.DrawString(entry.Behavior.ToString(), Font, drawBrush, drawPoint);
else if (e.ColumnIndex == 3 && entry.Behavior != EHomuBehavior.Avoid)
e.Graphics.DrawString(entry.Skill.ToString(), Font, drawBrush, drawPoint);
else if (e.ColumnIndex == 4 && entry.Behavior != EHomuBehavior.Avoid && entry.Skill != EHomuSkillUsage.NoSkill)
e.Graphics.DrawString(entry.Priority.ToString(), Font, drawBrush, drawPoint);
}
示例5: listView_DrawSubItem
private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex == 1)
{
using (var ms = new MemoryStream())
{
using (var sw = new StreamWriter(ms))
{
sw.Write(e.SubItem.Text);
sw.Flush();
ms.Seek(0, SeekOrigin.Begin);
var rtb = new RichTextBox();
{
rtb.BorderStyle = BorderStyle.None;
rtb.LoadFile(ms, RichTextBoxStreamType.RichText);
rtb.Location = e.SubItem.Bounds.Location;
rtb.Size = e.SubItem.Bounds.Size;
rtb.Parent = sender as Control;
var bmp = new Bitmap(128, 32);
rtb.DrawToBitmap(bmp, rtb.DisplayRectangle);
//bmp.Save("test.bmp");
e.Graphics.DrawImageUnscaledAndClipped(bmp, e.SubItem.Bounds);
//e.DrawBackground();
//e.Graphics.DrawString(rtb.Text, SystemFonts.DefaultFont, SystemBrushes.ControlText, e.SubItem.Bounds);
}
}
}
}
else
{
e.DrawBackground();
e.DrawText();
}
}
示例6: DrawSubItem
private void DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
TextFormatFlags flag = e.ColumnIndex > 0 ? TextFormatFlags.HorizontalCenter : TextFormatFlags.Left;
e.DrawBackground();
e.DrawText(flag);
}
示例7: ListViewDrawSubItem
private void ListViewDrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ItemIndex < 0)
return;
try {
//文字を描画する色の選択
var b = new SolidBrush(Color.DodgerBlue);
if (e.Item.SubItems[0].Text == "Recv")
b = new SolidBrush(Color.Red);
if (e.Item.Selected) {// 選択行
e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
if (e.Item.SubItems[0].Text != "Recv")
b = new SolidBrush(Color.White);
} else {
e.DrawBackground();
}
//Ver5.1.4
//e.Graphics.DrawString(e.Item.SubItems[e.ColumnIndex].Text, listView.Font, b, e.Bounds);//文字列の描画
e.Graphics.SetClip(e.Bounds);
e.Graphics.DrawString(e.Item.SubItems[e.ColumnIndex].Text, listViewTrace.Font, b, e.Bounds.X + 2, e.Bounds.Y + 2);//文字列の描画
b.Dispose();
} catch {
}
}
示例8: this_DrawSubItem
private void this_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
e.DrawBackground();
if (e.ColumnIndex == _sortcol)
{
e.Graphics.FillRectangle(_sortcolbrush, e.Bounds);
}
if ((e.ItemState & ListViewItemStates.Selected) != 0)
{
e.Graphics.FillRectangle(_highlightbrush, e.Bounds);
}
int fonty = e.Bounds.Y + ((int)(e.Bounds.Height / 2)) - ((int)(e.SubItem.Font.Height / 2));
int x = e.Bounds.X + 2;
if (e.ColumnIndex == 0)
{
EXListViewItem item = (EXListViewItem)e.Item;
e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), x, fonty);
return;
}
EXListViewSubItemAB subitem = e.SubItem as EXListViewSubItemAB;
if (subitem == null)
{
e.DrawDefault = true;
}
else
{
x = subitem.DoDraw(e, x, this.Columns[e.ColumnIndex] as EXColumnHeader);
e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), x, fonty);
}
}
示例9: OnDrawSubItem
/// <summary>
/// Raises the <see cref="ListView.DrawSubItem"/> event.
/// </summary>
/// <remarks>
/// This is where the owner draws the specific sub item. We handle this.
/// </remarks>
/// <param name="e">A <see cref="DrawListViewSubItemEventArgs"/> describing the event arguments.</param>
protected void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
if (e.Item.ListView == null)
return;
e.DrawBackground();
Int32 intBoundsX = e.Bounds.X;
Int32 intBoundsY = e.Bounds.Y;
Int32 intBoundsWidth = e.Bounds.Width;
Int32 intFontX = e.Bounds.X + 3;
Int32 intFontWidth = e.Bounds.Width - 3;
if (e.Item.SubItems[0] == e.SubItem)
{
intBoundsX += 4;
intBoundsWidth -= 4;
m_intFocusBoundsX = intBoundsX;
}
Color clrForeColor = e.SubItem.ForeColor;
if (e.Item.Selected)
{
clrForeColor = e.Item.ListView.Focused ? SystemColors.HighlightText : clrForeColor;
Color clrBackColor = e.Item.ListView.Focused ? SystemColors.Highlight : SystemColors.Control;
e.Graphics.FillRectangle(new SolidBrush(clrBackColor), new Rectangle(intBoundsX, intBoundsY, intBoundsWidth, e.Bounds.Height));
}
if ((Messages.ContainsKey(e.SubItem)) && (e.ColumnIndex == 4) && (e.SubItem.Text != ""))
{
Image imgIcon = Messages[e.SubItem].Value;
Rectangle rctIconBounds = GetMessageIconBounds(e.Bounds, imgIcon, String.IsNullOrEmpty(e.SubItem.Text) ? true : false);
Rectangle rctPaint = new Rectangle(new Point(rctIconBounds.X, intBoundsY + rctIconBounds.Y), rctIconBounds.Size);
e.Graphics.DrawImage(imgIcon, rctPaint);
intFontWidth -= rctIconBounds.Width;
}
Rectangle rctTextBounds = new Rectangle(intFontX, intBoundsY + 2, intFontWidth, e.Bounds.Height - 4);
TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font, rctTextBounds, clrForeColor, TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter);
if (e.Item.Focused)
{
Pen penFocusRectangle = new Pen(Brushes.Black);
penFocusRectangle.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
e.Graphics.DrawRectangle(penFocusRectangle, new Rectangle(m_intFocusBoundsX, intBoundsY, e.Item.Bounds.Width - m_intFocusBoundsX - 1, e.Item.Bounds.Height - 1));
}
}
示例10: _tailListView_DrawSubItem
private void _tailListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex != 1)
return;
Color? textColor = null;;
Color? backColor = null;
// Bookmark coloring has higher priority, than keyword highlight
if (MatchesBookmark(e.ItemIndex))
{
backColor = _bookmarkBackColor;
textColor = _bookmarkTextColor;
}
else
{
TailKeywordConfig keyword = MatchesKeyword(e.Item.Text, false, true);
if (keyword != null)
{
if (keyword.FormBackColor.HasValue && keyword.FormTextColor.HasValue)
{
backColor = keyword.FormBackColor.Value;
textColor = keyword.FormTextColor.Value;
}
}
}
//toggle colors if the item is highlighted
if (e.Item.Selected)
{
if (backColor.HasValue || textColor.HasValue)
{
e.SubItem.BackColor = SystemColors.Highlight;
e.SubItem.ForeColor = Color.FromArgb(SystemColors.Highlight.A, (SystemColors.Highlight.R + 128) % 256, (SystemColors.Highlight.G + 128) % 256, (SystemColors.Highlight.B + 128) % 256);
}
else
{
e.SubItem.BackColor = SystemColors.Highlight;
e.SubItem.ForeColor = SystemColors.HighlightText;
}
}
else
{
if (backColor.HasValue)
e.SubItem.BackColor = backColor.Value;
else
e.SubItem.BackColor = e.Item.ListView.BackColor;
if (textColor.HasValue)
e.SubItem.ForeColor = textColor.Value;
else
e.SubItem.ForeColor = e.Item.ListView.ForeColor;
}
// Draw the standard header background.
e.DrawBackground();
e.DrawFocusRectangle(e.Bounds);
TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.ExpandTabs | TextFormatFlags.SingleLine | TextFormatFlags.NoPrefix;
if (e.Item.Text.Length > 1000)
TextRenderer.DrawText(e.Graphics, e.Item.Text.Substring(0, 1000), e.Item.ListView.Font, e.Bounds, e.SubItem.ForeColor, flags);
else
TextRenderer.DrawText(e.Graphics, e.Item.Text, e.Item.ListView.Font, e.Bounds, e.SubItem.ForeColor, flags);
}
示例11: lstvList_DrawSubItem
//-------------------------------------------------------------------------------
//
private void lstvList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex > 0) { e.DrawDefault = true; return; }
e.DrawBackground();
List<UserProfile> profileList = (sender == lstvCommonFollower) ? _profile_followers : _profile_friends;
Image img = _imageListWrapper.GetImage(profileList[e.ItemIndex].IconURL);
if (img != null) {
e.Graphics.DrawImage(img, e.Bounds.Location);
}
else if (_imageAnimation != null) {
e.Graphics.DrawImage(_imageAnimation.Image, e.Bounds.Location);
}
}
示例12: logListView_DrawSubItem
private void logListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
var item = e.Item.SubItems[e.ColumnIndex];
e.DrawBackground();
var text = item.Text;
Color forecolor;
if (text.StartsWith(@"ERROR") || text.StartsWith(@"FATAL"))
{
forecolor = Color.DarkRed;
}
else if (text.StartsWith(@"WARN"))
{
forecolor = Color.FromArgb(181, 166, 16);
}
else if (text.StartsWith(@"DEBUG"))
{
forecolor = Color.Black;
}
else
{
forecolor = Color.DarkBlue;
}
TextRenderer.DrawText(e.Graphics, item.Text, this.logListView.Font, e.Bounds, forecolor, TextFormatFlags.Left);
e.DrawFocusRectangle(e.Bounds);
}
示例13: m_lvMatches_DrawSubItem
// We have to draw this ourselves to ensure the alignment works correctly when we change font sizes
void m_lvMatches_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
FwListView lv = (FwListView)sender;
// In the future, different image indexes may be used for affixes or other kinds of results
//int imageIndex = 0;
e.SubItem.BackColor = e.Item.Selected ?
(lv.Focused ? SystemColors.Highlight : SystemColors.GrayText) : lv.BackColor;
e.DrawBackground();
// Per LT-4815 comments, we don't want the icon. If we reinstate it, it should be the
// new find entry icon.
Image image = null; // m_ilEntries.Images[imageIndex];
Rectangle rect = e.Bounds;
if (image != null && e.ColumnIndex == 0)
{
// Create a bounds rectangle that isn't larger than the area we have to draw in
Rectangle imageRect = new Rectangle(rect.Location, new Size(Math.Min(rect.Width, image.Width), Math.Min(rect.Height, image.Height)));
e.Graphics.DrawImage(image, imageRect);
rect.X += image.Width;
}
TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.SubItem.Font, rect, lv.GetTextColor(e),
TextFormatFlags.SingleLine | TextFormatFlags.VerticalCenter);
}
示例14: listview_DrawSubItem
/// <summary>
/// 任务和BUG下的列表绘制
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void listview_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
ListView listView = (ListView)sender;
if (listView.Tag == null)
{
e.DrawDefault = true;
return;
}
SearchOperate type = (SearchOperate)listView.Tag;
//BUG的解决列和任务的完成列,绘制添加一个复选框
if ((e.ColumnIndex == 3 && type == SearchOperate.BUG) || (type == SearchOperate.TASK && e.ColumnIndex == 6))
{
e.DrawBackground();
drawCheckBox(listView, e.SubItem, e.SubItem.Tag == null ? false : (bool)e.SubItem.Tag);
}
else
{
e.DrawDefault = true;
}
}
示例15: lvViewPurchase_DrawSubItem
private void lvViewPurchase_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
var s = e.Header;
var colH = new ColumnHeader { Name = "Quitar", Text = "Quitar" };
if (s.Text != colH.Text)
{
e.DrawDefault = true;
return;
}
e.DrawBackground();
var imageRect = new Rectangle(e.Bounds.X, e.Bounds.Y, 14, 14);
e.Graphics.DrawImage(SystemIcons.Hand.ToBitmap(), imageRect);
}