本文整理汇总了C#中System.Windows.Forms.DrawListViewSubItemEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# DrawListViewSubItemEventArgs类的具体用法?C# DrawListViewSubItemEventArgs怎么用?C# DrawListViewSubItemEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawListViewSubItemEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了DrawListViewSubItemEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: listView_DrawSubItem
private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
Rectangle bounds = e.SubItem.Bounds;
if (e.ColumnIndex == 0)
{
bounds.Width = bounds.X + e.Item.SubItems[1].Bounds.X;
}
//toggle colors if the item is highlighted
if (e.Item.Selected && e.Item.ListView.Focused)
{
e.SubItem.BackColor = SystemColors.Highlight;
e.SubItem.ForeColor = e.Item.ListView.BackColor;
}
else if (e.Item.Selected && !e.Item.ListView.Focused)
{
e.SubItem.BackColor = SystemColors.Control;
e.SubItem.ForeColor = e.Item.ListView.ForeColor;
}
else
{
e.SubItem.BackColor = e.Item.ListView.BackColor;
e.SubItem.ForeColor = e.Item.ListView.ForeColor;
}
// Draw the standard header background.
e.DrawBackground();
int xOffset = 0;
if (e.ColumnIndex == 0)
{
Point glyphPoint = new Point(4, e.Item.Position.Y + 2);
MyTask task = e.Item.Tag as MyTask;
if (string.IsNullOrEmpty(task.TaskGroupName))
{
CheckBoxState state = e.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal;
CheckBoxRenderer.DrawCheckBox(e.Graphics, glyphPoint, state);
xOffset = CheckBoxRenderer.GetGlyphSize(e.Graphics, state).Width + 4;
}
else
{
RadioButtonState state = e.Item.Checked ? RadioButtonState.CheckedNormal : RadioButtonState.UncheckedNormal;
RadioButtonRenderer.DrawRadioButton(e.Graphics, glyphPoint, state);
xOffset = RadioButtonRenderer.GetGlyphSize(e.Graphics, state).Width + 4;
}
}
//add a 2 pixel buffer the match default behavior
Rectangle rec = new Rectangle(e.Bounds.X + 2 + xOffset, e.Bounds.Y + 2, e.Bounds.Width - 4, e.Bounds.Height - 4);
//TODO Confirm combination of TextFormatFlags.EndEllipsis and TextFormatFlags.ExpandTabs works on all systems. MSDN claims they're exclusive but on Win7-64 they work.
TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis | TextFormatFlags.ExpandTabs | TextFormatFlags.SingleLine;
//If a different tabstop than the default is needed, will have to p/invoke DrawTextEx from win32.
TextRenderer.DrawText(e.Graphics, e.SubItem.Text, e.Item.ListView.Font, rec, e.SubItem.ForeColor, flags);
}
示例2: 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;
}
}
示例3: dataSelectionList_DrawSubItem
private void dataSelectionList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
Color color;
switch (e.ColumnIndex)
{
case 2:
color = Color.FromArgb(int.Parse(e.SubItem.Text));
Rectangle rect = e.Bounds;
rect.Inflate(-4, -2);
using (SolidBrush brush = new SolidBrush(color))
{
e.Graphics.FillRectangle(brush, rect);
e.Graphics.DrawRectangle(Pens.Black, rect);
}
break;
case 3:
float x1 = e.SubItem.Bounds.X;
float x2 = e.SubItem.Bounds.X + e.SubItem.Bounds.Width;
float y = e.SubItem.Bounds.Y + e.SubItem.Bounds.Height / 2;
color = Color.FromArgb(int.Parse(e.Item.SubItems[2].Text));
float thickness = float.Parse(e.Item.SubItems[1].Text);
using (Pen pen = new Pen(color, thickness))
{
e.Graphics.DrawLine(pen, x1, y, x2, y);
}
break;
default:
e.DrawDefault = true;
break;
}
}
示例4: Draw
public override void Draw(DrawListViewSubItemEventArgs e)
{
if (this.hot != Rectangle.Empty)
{
if (this.hot != e.Bounds)
{
this.ListView.Invalidate(this.hot);
this.hot = Rectangle.Empty;
}
}
if ((!this.DrawIfEmpty) && (string.IsNullOrEmpty(e.SubItem.Text)))
return;
Point mouse = e.Item.ListView.PointToClient(Control.MousePosition);
if ((this.ListView.GetItemAt(mouse.X, mouse.Y) == e.Item) && (e.Item.GetSubItemAt(mouse.X, mouse.Y) == e.SubItem))
{
ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.SubItem.Text, Font, true, PushButtonState.Hot);
this.hot = e.Bounds;
}
else
{
ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.SubItem.Text, Font, false, PushButtonState.Default);
}
}
示例5: nodeListView_DrawSubItem
private void nodeListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex > 0)
{
Rectangle bounds = e.SubItem.Bounds;
if (e.Item.Selected)
{
e.Graphics.FillRectangle(HL_BRUSH, bounds);
e.SubItem.ForeColor = SystemColors.HighlightText;
}
else
{
e.Graphics.FillRectangle(new SolidBrush(e.Item.BackColor), bounds);
e.SubItem.ForeColor = e.Item.ForeColor;
}
e.DrawText(TextFormatFlags.VerticalCenter);
e.Graphics.DrawLine(LINE_PEN, bounds.Left, bounds.Top, bounds.Left, bounds.Bottom);
}
else
{
e.DrawDefault = true;
}
}
示例6: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
e.DrawDefault = true;
base.OnDrawSubItem(e);
double d;
if (e.Item.BackColor != Color.MediumPurple)
{
if (e.Item.Index % 2 == 0) //theSubItemIndex����ָ��Ҫ�ػ����
{
//e.Item.BackColor = Color.FromArgb(247, 247, 247);
e.Item.BackColor = Color.Azure;
int count = e.Item.SubItems.Count - 1;
while (count >= 1)
{
e.Item.SubItems[count].BackColor = Color.Azure;
count--;
}
//e.Item.SubItems[2].BackColor = Color.FromArgb(247, 247, 247);
}
else
{
//e.Item.ForeColor = Color.;
}
}
}
示例7: this_DrawSubItem
void this_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.SubItem is IOwnerDrawLVSubItem)
//描画をカスタマイズするサブアイテムの場合は描画を呼ぶ
((IOwnerDrawLVSubItem)e.SubItem).DrawSubItem(e);
else
//そうでなければシステムに描画を任せる
e.DrawDefault = true;
}
示例8: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
object o = ((OLVListItem) e.Item).RowObject;
if (o is TreePathReference)
{
TreePathReference r = (TreePathReference) o;
e.Item.ForeColor = ActiveGetter(r) ? ActiveForegroudColor : InactiveForegroudColor;
}
base.OnDrawSubItem(e);
}
示例9: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
if ( !this.ContainsFocus && !_HideSelection )
{
ListViewItemStates status = e.Item.Selected ? ListViewItemStates.Selected : e.ItemState;
base.OnDrawSubItem(new DrawListViewSubItemEventArgs(e.Graphics, e.Bounds, e.Item, e.SubItem, e.ItemIndex, e.ColumnIndex, e.Header, status));
}
else
base.OnDrawSubItem(e);
}
示例10: HandleDrawSubItem
private void HandleDrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ItemIndex == -1)
return;
e.Graphics.FillRectangle(new SolidBrush(e.ItemState.HasFlag(ListViewItemStates.Selected) ? oRAColours.Colour_Item_BG_0 : oRAColours.Colour_BG_P0), e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 1);
if (e.Item.Text == "")
e.Graphics.DrawLine(new Pen(oRAColours.Colour_BG_P1), Columns[0].Width - 1, e.Bounds.Y, Columns[0].Width - 1, e.Bounds.Y + e.Bounds.Height);
else
e.Graphics.DrawLine(new Pen(oRAColours.Colour_BG_P1), e.Bounds.X - 1, e.Bounds.Y, e.Bounds.X - 1, e.Bounds.Y + e.Bounds.Height);
e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
e.Graphics.DrawString(e.SubItem.Text, oRAFonts.Font_SubDescription, e.ItemState.HasFlag(ListViewItemStates.Selected) ? new SolidBrush(oRAColours.Colour_Text_H) : new SolidBrush(oRAColours.Colour_Text_N), e.Bounds.Left + 22, e.Bounds.Top + e.Bounds.Height / 2 - e.Graphics.MeasureString(e.Item.Text, oRAFonts.Font_SubDescription).Height / 2);
}
示例11: 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);
}
示例12: 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);
}
}
示例13: RssListView_DrawSubItem
private void RssListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e)
{
if (e.ColumnIndex == 1)
{
e.Graphics.FillRectangle(new SolidBrush(Color.Blue), e.Bounds);
}
else
{
//e.Graphics.DrawString(e.SubItem.Text, Font, Brushes.Red, e.Bounds);
e.DrawDefault = true;
//e.Graphics.DrawString(e.SubItem.Text,Font,Brushes.Black,e.Bounds);
}
}
示例14: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
ImageListViewSubItem item = e.SubItem as ImageListViewSubItem;
if (item == null)
{
e.DrawDefault = true;
base.OnDrawSubItem(e);
}
else
{
using (e.Graphics)
item.Drawable.Draw(e.Graphics, e.Bounds);
}
}
示例15: OnDrawSubItem
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e)
{
ListViewItem.ListViewSubItem oitem = e.Item.SubItems[e.ColumnIndex];
ProgressSubItem item = null;
if (oitem is ProgressSubItem)
item = (ProgressSubItem)oitem;
if (item != null && item.ShowProgress && item.ProgressMaxValue > 0)
{
double percent = (double)item.ProgressValue / (double)item.ProgressMaxValue;
if (percent > 1.0f)
percent = 1.0f;
Rectangle rect = item.Bounds;
Graphics g = e.Graphics;
//绘制进度条
Rectangle progressRect = new Rectangle(rect.X + 1, rect.Y + 3, rect.Width - 2, rect.Height - 5);
g.DrawRectangle(new Pen(new SolidBrush(Color.FromArgb(0x51, 0x51, 0x51)), 1), progressRect);
//绘制进度
int progressMaxWidth = progressRect.Width - 1;
int width = (int)(progressMaxWidth * percent);
if (width >= progressMaxWidth) width = progressMaxWidth;
g.FillRectangle(new SolidBrush(Color.FromArgb(0xa4, 0xa3, 0xa3)), new Rectangle(progressRect.X + 1, progressRect.Y + 1, width, progressRect.Height - 1));
if(item.ShowPercentOverflowProgress)
{
//绘制进度百分比
percent *= 100;
string percentText = string.Format("{0}% ", percent.ToString("F2"));
Size size = TextRenderer.MeasureText(percentText.ToString(), Font);
int x = (progressRect.Width - size.Width) / 2;
int y = (progressRect.Height - size.Height) / 2 + 3;
if (x <= 0) x = 1;
if (y <= 0) y = 1;
int w = size.Width;
int h = size.Height;
if (w > progressRect.Width) w = progressRect.Width;
if (h > progressRect.Height) h = progressRect.Height;
g.DrawString(percentText, this.Font, new SolidBrush(Color.Black), new Rectangle(rect.X + x, rect.Y + y, w, h));
}
}
else
{
e.DrawDefault = true;
base.OnDrawSubItem(e);
}
}