本文整理汇总了C#中System.Windows.Forms.DrawListViewItemEventArgs.DrawFocusRectangle方法的典型用法代码示例。如果您正苦于以下问题:C# DrawListViewItemEventArgs.DrawFocusRectangle方法的具体用法?C# DrawListViewItemEventArgs.DrawFocusRectangle怎么用?C# DrawListViewItemEventArgs.DrawFocusRectangle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.DrawListViewItemEventArgs
的用法示例。
在下文中一共展示了DrawListViewItemEventArgs.DrawFocusRectangle方法的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: 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);
}*/
}
}
示例3: 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);
}
示例4: 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);
}
}
示例5: MyList_DrawItem
private void MyList_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (e.State == 0)
{
return;
}
e.DrawDefault = false;
if (e.Item.Selected)
{
// 選択中の行
var brs1 = ((Control)sender).Focused ? _brsHighLight : _brsDeactiveSelection;
e.Graphics.FillRectangle(brs1, e.Bounds);
}
else
{
var cl = e.Item.BackColor;
var brs2 =
cl == _clrSelf ? _brsBackColorMine :
cl == _clrAtSelf ? _brsBackColorAt :
cl == _clrTarget ? _brsBackColorYou :
cl == _clrAtTarget ? _brsBackColorAtYou :
cl == _clrAtFromTarget ? _brsBackColorAtFromTarget :
cl == _clrAtTo ? _brsBackColorAtTo : _brsBackColorNone;
e.Graphics.FillRectangle(brs2, e.Bounds);
}
if ((e.State & ListViewItemStates.Focused) == ListViewItemStates.Focused)
{
e.DrawFocusRectangle();
}
DrawListViewItemIcon(e);
}
示例6: OnDrawItem
private static void OnDrawItem(object sender, DrawListViewItemEventArgs e)
{
//Check if the item is selected
bool isExternal = ((Workshare.Reports.MailMessage.Message)e.Item.Tag).SentExternally;
if (( e.State & ListViewItemStates.Selected) != 0)
{
// Draw the back ground in light green
e.Graphics.FillRectangle(Brushes.LightGreen, e.Bounds);
e.DrawFocusRectangle();
}
else
{
using (LinearGradientBrush brush = new LinearGradientBrush(e.Bounds, (isExternal ? m_settings.ExternalEmailColour.Background : Color.WhiteSmoke), Color.WhiteSmoke, LinearGradientMode.Horizontal))
{
e.Graphics.FillRectangle(brush, e.Bounds);
}
}
// Draw the image List icon
Icon ico = Icon.FromHandle(((Bitmap)e.Item.ImageList.Images[e.Item.ImageIndex]).GetHicon());
e.Graphics.DrawIcon(ico, e.Bounds.X, e.Bounds.Y);
if ( string.Compare( View.Columns[0].Tag.ToString(), "RatingIcon", true, System.Threading.Thread.CurrentThread.CurrentCulture) != 0 )
{
using (Font headerFont = new Font(View.Font.FontFamily, View.Font.Size))
{
using( SolidBrush sb = new SolidBrush((isExternal ? m_settings.ExternalEmailColour.Foreground : Color.Black)) )
{
e.Graphics.DrawString(e.Item.Text, headerFont, sb, e.Bounds.X + 16, e.Bounds.Y);
}
}
}
else
{
Icon rate = Properties.Resources.RATING_NONE;
if (string.Compare(Properties.Resources.TEXT_HIGH, e.Item.Text, true, System.Threading.Thread.CurrentThread.CurrentCulture) == 0)
rate = Properties.Resources.RATING_HIGH;
if (string.Compare(Properties.Resources.TEXT_MEDIUM, e.Item.Text, true, System.Threading.Thread.CurrentThread.CurrentCulture) == 0)
rate = Properties.Resources.RATING_MEDIUM;
if (string.Compare(Properties.Resources.TEXT_LOW, e.Item.Text, true, System.Threading.Thread.CurrentThread.CurrentCulture) == 0)
rate = Properties.Resources.RATING_LOW;
e.Graphics.DrawIcon(rate, e.Bounds.X +17, e.Bounds.Y);
}
}
示例7: SubtitleListView_DrawItem
private void SubtitleListView_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (!Focused && (e.State & ListViewItemStates.Selected) != 0)
{
//Rectangle r = new Rectangle(e.Bounds.Left + 1, e.Bounds.Top + 1, e.Bounds.Width - 2, e.Bounds.Height - 2);
//e.Graphics.FillRectangle(Brushes.LightGoldenrodYellow, r);
if (e.Item.Focused)
e.DrawFocusRectangle();
}
else
{
e.DrawDefault = true;
}
}
示例8: MyList_DrawItem
private void MyList_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (e.State == 0) return;
e.DrawDefault = false;
if (!e.Item.Selected) //e.ItemStateでうまく判定できない???
{
SolidBrush brs2 = null;
if (e.Item.BackColor == _clSelf)
brs2 = _brsBackColorMine;
else if (e.Item.BackColor == _clAtSelf)
brs2 = _brsBackColorAt;
else if (e.Item.BackColor == _clTarget)
brs2 = _brsBackColorYou;
else if (e.Item.BackColor == _clAtTarget)
brs2 = _brsBackColorAtYou;
else if (e.Item.BackColor == _clAtFromTarget)
brs2 = _brsBackColorAtFromTarget;
else if (e.Item.BackColor == _clAtTo)
brs2 = _brsBackColorAtTo;
else
brs2 = _brsBackColorNone;
e.Graphics.FillRectangle(brs2, e.Bounds);
}
else
{
//選択中の行
if (((Control)sender).Focused)
e.Graphics.FillRectangle(_brsHighLight, e.Bounds);
else
e.Graphics.FillRectangle(_brsDeactiveSelection, e.Bounds);
}
if ((e.State & ListViewItemStates.Focused) == ListViewItemStates.Focused) e.DrawFocusRectangle();
this.DrawListViewItemIcon(e);
}
示例9: listView2_DrawItem
private void listView2_DrawItem(object sender, DrawListViewItemEventArgs e)
{
if (_pdfDoc != null)
{
Rectangle bounds = e.Bounds;
bounds.Offset(-1, -5);
Rectangle shadowRect = new Rectangle(bounds.Location, bounds.Size);
Rectangle pageRect = new Rectangle(bounds.Location, bounds.Size);
int pgNum = e.ItemIndex + 1;
PDFPage pg;
if(!_pdfDoc.Pages.TryGetValue(pgNum,out pg))
return;
pg.RenderThumbnailFinished -= new RenderNotifyFinishedHandler(pg_RenderThumbnailFinished);
pg.RenderThumbnailFinished+=new RenderNotifyFinishedHandler(pg_RenderThumbnailFinished);
shadowRect.Offset(3, 3);
shadowRect.Inflate(-6, -10);
pageRect.Inflate(-6, -10);
e.Graphics.FillRectangle(Brushes.LightGray, shadowRect);
Bitmap bmp = pg.LoadThumbnail(128, (int)(128 * pg.Height / pg.Width));
if(bmp!=null)
e.Graphics.DrawImageUnscaledAndClipped(bmp, pageRect);
e.Graphics.DrawRectangle(Pens.LightGray, pageRect);
StringFormat stringFormat = new StringFormat();
stringFormat.Alignment = StringAlignment.Center;
stringFormat.LineAlignment = StringAlignment.Center;
e.Graphics.DrawString(e.Item.Text, listView2.Font, Brushes.Black, new RectangleF(e.Bounds.X, e.Bounds.Y + e.Bounds.Height - 10, e.Bounds.Width, 10), stringFormat);
e.DrawFocusRectangle();
}
}
示例10: listView1_DrawItem
private void listView1_DrawItem(object sender, DrawListViewItemEventArgs e)
{
e.DrawDefault = false;
Image img = imageList1.Images[0];
if (e.Item.ImageIndex == 0)
e.Graphics.DrawImage(img, new Point(e.Bounds.Left, e.Bounds.Top + 1));
int newTextY = e.Bounds.Y;
if (e.Item.Text.Contains('\n') == false)
{
newTextY += ((e.Bounds.Height / 2) - (e.Item.Font.Height / 2));
}
else
{
newTextY += ((e.Bounds.Height / 2) - ((int) (e.Graphics.MeasureString(e.Item.Text, e.Item.Font).Height / 2)));
}
Point newLoc = new Point(e.Bounds.Left + img.Width + 1, newTextY);
Size newSize = new Size(e.Bounds.Width - img.Width - 1, e.Bounds.Height);
Rectangle textBounds = new Rectangle( newLoc, newSize );
e.DrawFocusRectangle();
e.Graphics.DrawString(e.Item.Text, e.Item.Font, Brushes.White, textBounds, StringFormat.GenericTypographic);
}
示例11: lvContacts_DrawItem
private void lvContacts_DrawItem(object sender, DrawListViewItemEventArgs e)
{
Rectangle ImageRect = e.Bounds;
ImageRect.Inflate(-2, -2);
ImageRect.Width = 32;
Rectangle TextRect = e.Bounds;
TextRect.X = ImageRect.Right + 2;
TextRect.Width = e.Bounds.Width - TextRect.X;
Rectangle IconRect = TextRect;
IconRect.Inflate(-1, 0);
IconRect.Y = ImageRect.Bottom - 16;
IconRect.Width = 16;
IconRect.Height = 16;
if ((e.State & ListViewItemStates.Selected) != 0)
{
// Draw the background and focus rectangle for a selected item.
e.Graphics.FillRectangle(lvBackgroundBrush, e.Bounds);
e.DrawFocusRectangle();
}
else
{
// Draw the background for an unselected item.
e.Graphics.FillRectangle(Brushes.White, e.Bounds);
}
// Draw the item text for views other than the Details view.
if (lvContacts.View != View.Details)
{
JabberID jabberID = (JabberID) e.Item.Tag;
Contact contact = AppController.Instance.Contacts[jabberID.UserName];
e.Graphics.DrawImage(contact.AvatarImage, ImageRect);
//e.DrawText();
TextRenderer.DrawText(e.Graphics, e.Item.Text, e.Item.Font, TextRect, e.Item.ForeColor,
TextFormatFlags.GlyphOverhangPadding);
e.Graphics.DrawImage(StatusImageList.Images[(int) contact.UserStatus], IconRect);
}
}
示例12: OnDrawItem
// ********************************************************************************
/// <summary>
///
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
/// <created>UPh,31.10.2015</created>
/// <changed>UPh,31.10.2015</changed>
// ********************************************************************************
protected override void OnDrawItem(DrawListViewItemEventArgs e)
{
if (e.Item.Selected)
e.Graphics.FillRectangle(_SelectedItemBrush, e.Bounds);
else
e.DrawBackground();
TermListItem item = GetItemAt(e.ItemIndex);
Color tbcolor = Color.Empty;
if (TermBaseSet != null)
{
if (item != null)
tbcolor = TermBaseSet.GetDisplayColor(item.TermBaseID);
}
if (tbcolor != Color.Empty)
{
SolidBrush brush = new SolidBrush(tbcolor);
Rectangle rcBar = e.Bounds;
rcBar.Width = 4;
e.Graphics.FillRectangle(brush, rcBar);
}
Rectangle rect = e.Bounds;
rect.X += 4;
rect.Y += 2;
if (item != null && item.Status == TermStatus.prohibited)
{
e.Graphics.DrawImage(Resources.Prohibited_sm, rect.Left, rect.Top);
rect.X += 12;
}
e.Graphics.DrawString(e.Item.Text, Font, _TextBrush, rect.X, rect.Y);
e.DrawFocusRectangle();
}
示例13: OnDrawItem
/// <summary>
/// Raises the <see cref="ListView.DrawItem"/> event.
/// </summary>
/// <remarks>
/// This is where the owner draws the complete item. We handle this
/// is the item contains a sub item that has an associated message;
/// otherwise we let the default drawing take place.
/// </remarks>
/// <param name="e">A <see cref="DrawListViewItemEventArgs"/> describing the event arguments.</param>
protected override void OnDrawItem(DrawListViewItemEventArgs e)
{
e.DrawDefault = true;
Int32 intSubItemsRight = 0;
for (Int32 i = 0; i < e.Item.SubItems.Count; i++)
{
if (Messages.ContainsKey(e.Item.SubItems[i]))
e.DrawDefault = false;
if (i > 0 && intSubItemsRight < e.Item.SubItems[i].Bounds.Right)
intSubItemsRight += e.Item.SubItems[i].Bounds.Right;
}
if (!e.DrawDefault)
{
if (e.Item.Focused && !CheckBoxes)
e.DrawFocusRectangle();
if (e.Item.Selected)
{
Color clrBackColor = e.Item.ListView.Focused ? SystemColors.Highlight : SystemColors.Control;
e.Graphics.FillRectangle(new SolidBrush(clrBackColor), new Rectangle(intSubItemsRight, e.Bounds.Y, e.Item.Bounds.Width - intSubItemsRight, e.Bounds.Height));
}
}
base.OnDrawItem(e);
}
示例14: lstShow_DrawItem
private void lstShow_DrawItem(object sender, DrawListViewItemEventArgs e)
{
ListView listView = new ListView();
listView = (ListView)sender;
e.DrawBackground();
e.Graphics.DrawString(listView.Items[e.ItemIndex].Text, e.Item.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
for (int i = 0; i < _lstResult.Count; i++)
{
if (e.ItemIndex.ToString() == _lstResult[i])
{
bool selected = ((e.State & ListViewItemStates.Selected) == ListViewItemStates.Selected);
//搜尋過後尚未選取發生的事件
if(!selected)
{
e.Graphics.FillRectangle(new SolidBrush(Color.Silver), e.Bounds);
e.Graphics.DrawString(listView.Items[e.ItemIndex].Text, e.Item.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault);
}
//搜尋過選取時發生的事件
else
{
}
}
//搜尋過後不符合的項目想發生的事件往這寫
}
if (((e.State & ListViewItemStates.Selected) == ListViewItemStates.Selected))
{
////設定指定物件填充背景的大小
//Rectangle r = new Rectangle(e.Bounds.Left + 4, e.Bounds.Top, TextRenderer.MeasureText(e.Item.Text, e.Item.Font).Width, e.Bounds.Height);
////設定填充的顏色和無間
//e.Graphics.FillRectangle(SystemBrushes.Highlight, r);
////設定物件中的字體顏色
//e.Item.ForeColor = SystemColors.HighlightText;
//e.DrawText();
e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds);
e.Graphics.DrawString(listView.Items[e.ItemIndex].Text, e.Item.Font, Brushes.White, e.Bounds, StringFormat.GenericDefault);
}
e.DrawFocusRectangle();
}
示例15: lvLibrary_DrawItem
void lvLibrary_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.YellowGreen, e.Bounds);
if (this.lvLibrary.SelectedItems.Contains(e.Item)) {
e.Graphics.FillRectangle(Brushes.Gold, e.Bounds);
}
TileViewItem vSVI = (TileViewItem)e.Item;
e.Graphics.DrawImage(vSVI.mTile.Image, e.Bounds.Location.X, e.Bounds.Location.Y, Tile.WIDTH_PX*2, Tile.HEIGHT_PX*2);
Rectangle vR = new Rectangle(e.Bounds.Location, e.Bounds.Size);
vR.Offset(Tile.WIDTH_PX * 2, 0);
e.Graphics.DrawString(
vSVI.mTile.UID.ToString(),
lvLibrary.Font,
Brushes.Black,
vR,
StringFormat.GenericDefault
);
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);
}
}
}