本文整理汇总了C#中System.Windows.Forms.DrawListViewItemEventArgs.DrawText方法的典型用法代码示例。如果您正苦于以下问题:C# DrawListViewItemEventArgs.DrawText方法的具体用法?C# DrawListViewItemEventArgs.DrawText怎么用?C# DrawListViewItemEventArgs.DrawText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DrawListViewItemEventArgs
的用法示例。
在下文中一共展示了DrawListViewItemEventArgs.DrawText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: drawframe
private void drawframe(object sender, DrawListViewItemEventArgs e)
{
int i = (int)e.Item.Tag;
bool patched;
Bitmap bmp = Art.GetStatic(i, out patched);
if (bmp == null)
{
if (e.Item.Selected)//((e.State & ListViewItemStates.Focused) != 0)
e.Graphics.FillRectangle(BrushSelectBack, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 14);
else
e.Graphics.DrawRectangle(PenCommonBorder, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13);
e.Graphics.FillRectangle(BrushEmptyBack, e.Bounds.X + 5, e.Bounds.Y + 5, e.Bounds.Width - 10, e.Bounds.Height - 10);
return;
}
else
{
if (e.Item.Selected)//((e.State & ListViewItemStates.Focused) != 0)
e.Graphics.FillRectangle(BrushSelectBack, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13);
else if (ChangesInTiledataOrRadarCol[LandMaxIndex + i])
e.Graphics.FillRectangle(BrushChangeBack, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13);
else if (patched)
e.Graphics.FillRectangle(BrushPatchBack, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13);
else
e.Graphics.FillRectangle(BrushBackground, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13);
if (frames_ParentControl == null ? frameClipToolStripMenuItem.Checked : Options.ArtItemClip)
{
e.Graphics.DrawImage(bmp, e.Bounds.X + 1, e.Bounds.Y + 1,
new Rectangle(0, 0, e.Bounds.Width - 1, e.Bounds.Height - 14),
GraphicsUnit.Pixel);
}
else
{
int width = bmp.Width;
int height = bmp.Height;
int boundWidth = e.Bounds.Width;
int boundHeight = e.Bounds.Height - 13;
if (width > boundWidth)
{
width = boundWidth;
height = boundHeight * bmp.Height / bmp.Width;
}
if (height > boundHeight)
{
height = boundHeight;
width = boundWidth * bmp.Width / bmp.Height;
}
e.Graphics.DrawImage(bmp,
new Rectangle(e.Bounds.X + 1, e.Bounds.Y + 1, width, height));
}
//e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height);
e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
//e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
if (!e.Item.Selected)//((e.State & ListViewItemStates.Focused) == 0)
e.Graphics.DrawRectangle(PenCommonBorder, e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height - 13);
else
e.Graphics.DrawRectangle(PenSelectBorder, e.Bounds.X, e.Bounds.Y, e.Bounds.Width - 1, e.Bounds.Height - 14);
}
}
示例4: listViewdrawItem
private void listViewdrawItem(object sender, DrawListViewItemEventArgs e)
{
int graphic = (int)e.Item.Tag;
int hue = 0;
frames = Animations.GetAnimation(graphic, 0, 1, ref hue, false, true);
if (frames == null)
return;
Bitmap bmp = frames[0].Bitmap;
int width = bmp.Width;
int height = bmp.Height;
if (width > e.Bounds.Width)
width = e.Bounds.Width;
if (height > e.Bounds.Height)
height = e.Bounds.Height;
e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height);
e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
if (listView.SelectedItems.Contains(e.Item))
e.DrawFocusRectangle();
else
e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
}
示例5: Frames_ListView_DrawItem
private void Frames_ListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
Bitmap bmp = m_Animation[(int)e.Item.Tag];
int width = bmp.Width;
int height = bmp.Height;
if (width > e.Bounds.Width)
width = e.Bounds.Width;
if (height > e.Bounds.Height)
height = e.Bounds.Height;
e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height);
e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
}
示例6: DataListView_DrawItem
/// <summary>
/// Draws text for the listview item
/// </summary>
private void DataListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
// Draw the item text for views other than the Details view.
if (DataListView.View != View.Details)
e.DrawText();
}
示例7: lvMasterDesField_DrawItem
private void lvMasterDesField_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawBackground();
e.DrawText();
e.DrawFocusRectangle();
ListViewItem.ListViewSubItem LVSI = e.Item.SubItems[3];
if (LVSI != null)
{
Rectangle cellBounds = LVSI.Bounds;
Rectangle rect = cellBounds;
Point buttonLocation = new Point();
buttonLocation.Y = cellBounds.Y + 1;
buttonLocation.X = cellBounds.X + 1;
Rectangle ButtonBounds = new Rectangle();
ButtonBounds.X = cellBounds.X + 1;
ButtonBounds.Y = cellBounds.Y + 1;
ButtonBounds.Width = cellBounds.Width - 2;
ButtonBounds.Height = cellBounds.Height - 3;
Pen pen1 = new Pen(Brushes.White, 1);
Pen pen2 = new Pen(Brushes.Black, 1);
Pen pen3 = new Pen(Brushes.DimGray, 1);
SolidBrush myBrush = new SolidBrush(SystemColors.Control);
e.Graphics.FillRectangle(myBrush, ButtonBounds.X, ButtonBounds.Y, ButtonBounds.Width, ButtonBounds.Height);
e.Graphics.DrawLine(pen2, ButtonBounds.X, ButtonBounds.Y + ButtonBounds.Height, ButtonBounds.X + ButtonBounds.Width, ButtonBounds.Y + ButtonBounds.Height);
e.Graphics.DrawLine(pen2, ButtonBounds.X + ButtonBounds.Width, ButtonBounds.Y, ButtonBounds.X + ButtonBounds.Width, ButtonBounds.Y + ButtonBounds.Height);
StringFormat sf1 = new StringFormat();
sf1.Alignment = StringAlignment.Center;
sf1.LineAlignment = StringAlignment.Center;
e.Graphics.DrawString("...", new Font("SimSun", 5), Brushes.Black, ButtonBounds.X + 10, ButtonBounds.Y + 5, sf1);
}
}
示例8: listView1_DrawItem
private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
{
//
if(ImageLoadingTip.Length != (sender as ListView).Items.Count)
{
return;
}
string imageKey = e.Item.ImageKey;
#region 非大图标默认显示
if (listView1.View != View.LargeIcon)
{
int id;
if (int.TryParse(e.Item.ImageKey, out id))
{
listView1.Items.Find(e.Item.Name, true)[0].ImageKey = "image";
}
e.DrawDefault = true;
return;
}
#endregion
SRRC_ResourceEntity ent = e.Item.Tag as SRRC_ResourceEntity;
//SRLogHelper.Instance.AddLog("日志", "DrawItem," + e.Item.Name + "," + DateTime.Now.ToString("ss.ffff"));
//大图标,图片,未加载,图像字典中不包含。使用未加载是因为图像已提交加载,但未加载完成时,预防再次提交而使用。
if (listView1.View == View.LargeIcon && e.Item.ImageKey == "image" && !ImageLoadingTip[e.ItemIndex]
&& !SROperation2.Instance.Center1ImageDict.ContainsKey(ent.Id.ToString())) //图片类型,未加载图片
{
ImageLoadingTip[e.ItemIndex] = true;
// Thread t = new Thread(new ParameterizedThreadStart(DownLoadImage));
// t.Start(new string[] { ent.Id.ToString(), ent.Serverip.Replace(Param.IP,Param.ServerCacheIP.Trim('\\')) + ent.Path });
SROperation2.Instance.Center1ImageBlockingCollection.Add(new KeyValuePair<string, string>(ent.Id.ToString(), ent.Serverip.Replace(Param.IP, Param.ServerCacheIP.Trim('\\')) + ent.Path));
e.DrawDefault = true;
}
else
{
try
{
Image image1;
if(SROperation2.Instance.Center1ImageDict.ContainsKey(ent.Id.ToString()))
{
image1 = SROperation2.Instance.Center1ImageDict[ent.Id.ToString()];
}
else
{
image1 = SROperation2.Instance.Center1ImageDict[e.Item.ImageKey];
}
Size size = e.Item.ImageList.ImageSize;
e.Graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
e.Graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
if ((e.State & ListViewItemStates.Selected) != 0 && e.Item.Selected)
{
e.Graphics.FillRectangle(new SolidBrush(Color.Gray), e.Bounds);
Rectangle re = new Rectangle(e.Bounds.X + (e.Bounds.Width - size.Width) / 2, e.Bounds.Y + 2, size.Width, size.Height);
e.Graphics.DrawImage(image1, re);
//绘制次数
re = new Rectangle(re.X, re.Y + (re.Height - listView1.Font.Height + 2), re.Width, listView1.Font.Height + 2);
//e.Graphics.FillRectangle(new SolidBrush(Color.Silver), re);
e.Graphics.DrawString((e.Item.Tag as SRRC_ResourceEntity).Usecount.ToString(), listView1.Font, new SolidBrush(Color.Red), re, new StringFormat() { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Center });
if(ent.Iscomposite)
{
e.Graphics.DrawString("*", listView1.Font, new SolidBrush(Color.Red), re, new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
}
}
else
{
Rectangle re = new Rectangle(e.Bounds.X + (e.Bounds.Width - size.Width) / 2, e.Bounds.Y + 2, size.Width, size.Height);
e.Graphics.DrawImage(image1, re);
//绘制次数
re = new Rectangle(re.X, re.Y + (re.Height - listView1.Font.Height + 2), re.Width, listView1.Font.Height + 2);
//e.Graphics.FillRectangle(new SolidBrush(Color.Silver), re);
e.Graphics.DrawString((e.Item.Tag as SRRC_ResourceEntity).Usecount.ToString(), listView1.Font, new SolidBrush(Color.Red), re, new StringFormat() { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Center });
if (ent.Iscomposite)
{
e.Graphics.DrawString("*", listView1.Font, new SolidBrush(Color.Red), re, new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
}
}
e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
}
catch (Exception ex)
{
SRLogHelper.Instance.AddLog("异常","Center1","DrawItem", ex.Message);
}
}
}
示例9: DrawFrameItem
private void DrawFrameItem(object sender, DrawListViewItemEventArgs e)
{
AnimIdx edit = Ultima.AnimationEdit.GetAnimation(FileType, CurrBody, CurrAction, CurrDir);
Bitmap[] currbits = edit.GetFrames();
Bitmap bmp = currbits[(int)e.Item.Tag];
int width = bmp.Width;
int height = bmp.Height;
if (listView1.SelectedItems.Contains(e.Item))
e.Graphics.DrawRectangle(new Pen(Color.Red), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
else
e.Graphics.DrawRectangle(new Pen(Color.Gray), e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height);
e.Graphics.DrawImage(bmp, e.Bounds.X, e.Bounds.Y, width, height);
e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
}
示例10: lstFiles_DrawItem
private void lstFiles_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawBackground();
e.DrawDefault = true;
e.DrawText();
e.DrawFocusRectangle();
}
示例11: C1_DrawItem
void C1_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (main == null)
return;
e.DrawBackground();
e.DrawFocusRectangle();
RectangleF E = e.Bounds;
SizeF Q = e.Graphics.MeasureString(e.Item.Text, F);
Guid g = Guid.Empty;
if (e.Item.Tag is gCInventory_PS_Wrapper.InventoryItem)
g = (e.Item.Tag as gCInventory_PS_Wrapper.InventoryItem).ItemGuid;
else g = (Guid)e.Item.Tag;
if (ResourceManager.Rects.ContainsKey(g))
{
RectangleF r0 = ResourceManager.Rects[g];
RectangleF r1 = E;
r1.Height -= Q.Height;
float sh = (r1.Height / r0.Height);
float sw = (r1.Width / r0.Width);
if (sw > sh)//new box not heigh enough
{
float h = r0.Height * sh;
float w = r0.Width * sh;
float q0 = (r1.Width - w) / 2.0f;
r1.X += q0;
r1.Width = w;
r1.Height = h;
}
else
{
}
e.Graphics.DrawImage(main, r1, r0, GraphicsUnit.Pixel);
}
e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
}
示例12: ListView_DrawItem
/// <summary>
/// Draws the backgrounds for entire ListView items.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ListView_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.Aqua, e.Bounds);
e.DrawFocusRectangle();
}
else
{
// Draw the background for an unselected item.
using (LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, Color.White, Color.Aqua, LinearGradientMode.BackwardDiagonal))
{
e.Graphics.FillRectangle(brush, e.Bounds);
}
}
// Draw the item text for views other than the Details view.
//if (listView1.View != View.Details)
//{
e.DrawText();
//}
}
示例13: listView_DrawItem
private void listView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (e.Item.Tag != null)
{
e.Item.Checked = (bool)e.Item.Tag;
}
e.DrawBackground();
e.DrawText();
}
示例14: OnDrawItem
private void OnDrawItem(object sender, DrawListViewItemEventArgs e)
{
Graphics g = e.Graphics;
//画图标
Image img = ((ListViewNF)(e.Item.ListView)).ImageListNF[e.Item.ImageIndex];
Rectangle bounds = e.Bounds;
int imgStartX = -img.Width / 2;
int imgStartY = -img.Height / 2;
g.TranslateTransform(bounds.Left + bounds.Width/2, bounds.Top + 2 + img.Height / 2);
if (m_isSetting)
{
g.RotateTransform(m_rockAngle);
}
if (e.Item == m_hotItem)//(e.State & ListViewItemStates.Selected) != 0)
{
//选中的暗色处理
ImageAttributes attr = new ImageAttributes();
float[][] colorMatrixElements = {
new float[] {0.5f, 0, 0, 0, 0},
new float[] {0, 0.5f, 0, 0, 0},
new float[] {0, 0, 0.5f, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {0.1f, 0.2f, 0.2f, 0, 1}};
ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);
attr.SetColorMatrix(colorMatrix,ColorMatrixFlag.Default,ColorAdjustType.Bitmap);
g.DrawImage(img, new Rectangle(imgStartX, imgStartY, img.Width , img.Height ), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, attr);
}
else
g.DrawImage(img, new Point(imgStartX, imgStartY));
//画删除小圈
if (m_isSetting)
{
g.CompositingQuality = CompositingQuality.HighQuality;
g.SmoothingMode = SmoothingMode.AntiAlias;
g.FillEllipse(new SolidBrush(Color.White), new Rectangle(imgStartX, imgStartY-2, 18, 18));
g.FillEllipse(new SolidBrush(Color.Black), new Rectangle(imgStartX + 2, imgStartY, 14, 14));
g.DrawLine(new Pen(Color.White), new Point(imgStartX + 4, imgStartY + 2), new Point(imgStartX + 14, imgStartY + 12));
g.DrawLine(new Pen(Color.White), new Point(imgStartX + 14, imgStartY + 2), new Point(imgStartX + 4, imgStartY + 12));
}
//画文字
e.DrawText(TextFormatFlags.Bottom | TextFormatFlags.HorizontalCenter);
}
示例15: listViewShowItems_Highlight
private void listViewShowItems_Highlight(object sender, DrawListViewItemEventArgs e)
{
// If this item is the selected item
if (e.Item != null)
{
if (e.Item.Selected)
{
// If the selected item has focus Set the colors to the normal colors for a selected item
e.Item.ForeColor = SystemColors.HighlightText;
e.Item.BackColor = SystemColors.Highlight;
}
else
{
// Set the normal colors for items that are not selected
e.Item.ForeColor = listViewShowItems.ForeColor;
e.Item.BackColor = listViewShowItems.BackColor;
}
e.DrawBackground();
e.DrawText();
}
}