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; } }
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); }
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); } }
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); }
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(); } }
private void DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { TextFormatFlags flag = e.ColumnIndex > 0 ? TextFormatFlags.HorizontalCenter : TextFormatFlags.Left; e.DrawBackground(); e.DrawText(flag); }
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 { } }
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); } }
/// <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)); } }
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); }
//------------------------------------------------------------------------------- // 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); } }
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); }
// 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); }
/// <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; } }
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); }
// ******************************************************************************** /// <summary> /// /// </summary> /// <param name="e"></param> /// <returns></returns> /// <created>UPh,22.11.2015</created> /// <changed>UPh,22.11.2015</changed> // ******************************************************************************** protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) { if (e.Item.Selected) { e.Graphics.FillRectangle(_SelectedItemBrush, e.Bounds); //e.DrawFocusRectangle(); } else { e.DrawBackground(); } if (e.ColumnIndex == 3) { Color tbcolor = Color.Empty; if (TermBaseSet != null) { TerminologyResultArgs item = GetItemAt(e.ItemIndex); if (item != null) tbcolor = TermBaseSet.GetDisplayColor(item.TermBaseID); } if (tbcolor != Color.Empty && tbcolor.ToArgb() != Color.White.ToArgb()) { SolidBrush brush = new SolidBrush(tbcolor); Rectangle rcBar = e.Bounds; rcBar.Width = 4; e.Graphics.FillRectangle(brush, rcBar); } } e.Graphics.DrawString(e.SubItem.Text, Font, _TextBrush, e.Bounds.Left + 4.0f, e.Bounds.Top + 2.0f); }
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) { e.DrawDefault = false; if(this.Columns[e.ColumnIndex].Equals(colCost)) { e.DrawBackground(); CardListItemData data = (CardListItemData)e.Item.Tag; if(!data.Hidden) CardCostUtils.DrawCardCost(e.Graphics, e.Bounds, data.CardItem.Cost); } else if(this.Columns[e.ColumnIndex].Equals(colEdition)) { e.DrawBackground(); CardListItemData data = (CardListItemData)e.Item.Tag; e.Graphics.DrawImage(Program.LogicHandler.ServicesProvider.ImagesService.GetCardSet(data.CardItem.SetCode, data.CardItem.RarityCode), e.Bounds.X, e.Bounds.Y, 14, 14); } else if(this.Columns[e.ColumnIndex].Equals(colColor)) { e.DrawBackground(); CardListItemData data = (CardListItemData)e.Item.Tag; e.Graphics.DrawImage(Program.LogicHandler.ServicesProvider.ImagesService.GetCardSymbol(data.CardItem.ColorCode), e.Bounds.X, e.Bounds.Y, 12, 12); } else e.DrawDefault = true; base.OnDrawSubItem(e); }
/// <summary> /// Event handler for the DrawSubItem event of a ListView, /// required in order to process the property /// listviewSubItem.UseItemStyleForSubItems when it is set to false. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The DrawListViewSubItem event arguments.</param> public static void ListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { ListView lView = (ListView)sender; if (e.ColumnIndex == 0) //do default drawing for the first column { e.DrawDefault = true; } else { //Draw SubItem ListViewItem.ListViewSubItem subitem = e.SubItem; if (subitem == null || subitem.Tag == null) { e.DrawDefault = true; } else if (subitem.Tag != null) { Image img = null; ImageListHelper imgHelper = (ImageListHelper)newProperties[lView][newPropertiesEnum.SmallIcons]; if (imgHelper != null) { if (subitem.Tag is string) { string imgKey = subitem.Tag.ToString(); if (imgHelper.NETImageList.Images.ContainsKey(imgKey)) { img = imgHelper.NETImageList.Images[imgKey]; } } else { if (subitem.Tag is int) { int imgIndex = Convert.ToInt32(subitem.Tag); if (imgHelper.NETImageList.Images.Count > imgIndex) { img = imgHelper.NETImageList.Images[imgIndex]; } } } } if (img != null) { e.DrawBackground(); bool focused = e.Item.ListView.Focused; Color back = e.Item.Selected ? (focused ? SystemColors.Highlight : SystemColors.Menu) : e.SubItem.ForeColor; Color fore = e.Item.Selected ? (focused ? SystemColors.HighlightText : e.SubItem.ForeColor) : e.SubItem.ForeColor; int fonty = e.Bounds.Y + ((int)(e.Bounds.Height / 2)) - ((int)(e.SubItem.Font.Height / 2)); int x = e.Bounds.X + 2; if (e.Item.Selected) { using (Brush backBrush = new SolidBrush(back)) e.Graphics.FillRectangle(backBrush, e.Bounds); } x = DrawSubItemIcon(e, x, img); using (Brush foreBrush = new SolidBrush(fore)) e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, foreBrush, x, fonty); } else e.DrawDefault = true; } else e.DrawDefault = true; } InvokeEvents(lView, DrawSubItemEventName, new object[] { sender, e }); //e.DrawDefault = true; }
/// <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 override void OnDrawSubItem(DrawListViewSubItemEventArgs e) { //if the item is not in a list view, then don't bother trying to draw it, // as it isn't visible anyway if (e.Item.ListView == null) return; base.OnDrawSubItem(e); 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; if (CheckBoxes) { CheckBoxState cbsState = e.Item.Checked ? CheckBoxState.CheckedNormal : CheckBoxState.UncheckedNormal; Size szeCheckboxSize = CheckBoxRenderer.GetGlyphSize(e.Graphics, cbsState); int intBoxY = intBoundsY + (e.Bounds.Height - szeCheckboxSize.Height) / 2; int intBoxX = intBoundsX; intBoundsX += 3 + szeCheckboxSize.Width; intBoundsWidth -= 3 + szeCheckboxSize.Width; intFontX += 3 + szeCheckboxSize.Width; intFontWidth -= 3 + szeCheckboxSize.Width; CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(intBoxX, intBoxY), cbsState); } 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)) { 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)); } }
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) { ExtendedListViewItem item = (ExtendedListViewItem)e.Item; if (item.GetType() == typeof(ExtendedImageListViewItem)) { ExtendedImageListViewItem imageitem = (ExtendedImageListViewItem)item; if (imageitem.MyImage != null) { Image img = imageitem.MyImage; int imgy = e.Bounds.Y + ((int)(e.Bounds.Height / 2)) - ((int)(img.Height / 2)); e.Graphics.DrawImage(img, x, imgy, img.Width, img.Height); x += img.Width + 2; } } e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), x, fonty); return; } ExtendedListViewSubItemAB subitem = e.SubItem as ExtendedListViewSubItemAB; if (subitem == null) { e.DrawDefault = true; } else { x = subitem.DoDraw(e, x, this.Columns[e.ColumnIndex] as ExtendedColumnHeader); e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(e.SubItem.ForeColor), x, fonty); } }
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); }
private void listView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawBackground(); e.DrawText(); }
//------------------------------------------------------------------------------- // private void lstvList_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.ColumnIndex > 0) { e.DrawDefault = true; return; } e.DrawBackground(); Image img = _imageListWrapper.GetImage(_listList[e.ItemIndex].OwnerIconURL); if (img != null) { e.Graphics.DrawImage(img, e.Bounds.Location); } else if (_imageAnimation != null) { e.Graphics.DrawImage(_imageAnimation.Image, e.Bounds.Location); } }
private void listView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { GXAddIn w = (GXAddIn)e.Item.Tag; if (e.ColumnIndex == 1 && w.ProgressPercentage != 0)//"ProgressBar" { e.DrawBackground(); Rectangle progressBarRect = e.Bounds; double progress = w.ProgressPercentage * progressBarRect.Width; progress /= 100; progressBarRect.Width = Convert.ToInt32(progress); e.Graphics.FillRectangle(System.Drawing.SystemBrushes.ActiveCaption, progressBarRect); ControlPaint.DrawBorder3D(e.Graphics, e.Bounds); } else { e.DrawDefault = true; } }
private void lvwUpdates_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { // ListViewItem thisitem = e.Item; BCUpdate.UpdateInfo upinfo = (BCUpdate.UpdateInfo)thisitem.Tag; DrawItemData usedrawdata = (DrawItemData)upinfo.Tag; //upinfo.DrawSubItem(sender, e); DrawItemData drawdata = (DrawItemData)upinfo.Tag; if (e.ColumnIndex == 2) { StringFormat centeralign = new StringFormat(); centeralign.Alignment = StringAlignment.Center; e.DrawDefault = false; e.DrawBackground(); int usepercent; int.TryParse(e.SubItem.Text, out usepercent); double percentfraction = (double)usepercent / 100; e.Graphics.DrawRectangle(new Pen(Color.Black), e.Bounds.Left+2, e.Bounds.Top+2, e.Bounds.Width - 4, e.Bounds.Height - 4); if (percentfraction > 0) { Rectangle userectangle = new Rectangle(2, 2, (int)(e.Bounds.Width * ((float)percentfraction)), e.Bounds.Height-4); if (userectangle.Width >= 1) { userectangle.Offset(e.Bounds.Left, e.Bounds.Top); progressbrush = new LinearGradientBrush(userectangle, Color.Yellow, Color.DimGray, 0f); /*if (upinfo.downloadinprogress) { if (usepercent < 100) usestring = String.Format("{0}% ({1} KB/sec)", usepercent, bytespeed / 1024); else { usestring = "Complete."; progressbrush = new LinearGradientBrush(userectangle, Color.ForestGreen, Color.Yellow, 0f); } }*/ e.Graphics.FillRectangle(progressbrush, userectangle); } } e.Graphics.DrawString(drawdata.StringDraw, new Font("Consolas", 10), Brushes.Black, e.Bounds, centeralign); } else { e.DrawDefault = true; } }
private void listViewLog_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { var item = e.Item.SubItems[e.ColumnIndex]; e.DrawBackground(); var text = item.Text; Color forecolor; if (text.StartsWith(@"ERROR", StringComparison.CurrentCultureIgnoreCase) || text.StartsWith(@"FATAL", StringComparison.CurrentCultureIgnoreCase)) { forecolor = _darkRedColor; } else if (text.StartsWith(@"WARN", StringComparison.CurrentCultureIgnoreCase)) { forecolor = Color.FromArgb(181, 166, 16); } else if (text.StartsWith(@"DEBUG")) { forecolor = Color.Black; } else { forecolor = Color.DarkBlue; } TextRenderer.DrawText(e.Graphics, item.Text, listViewLog.Font, e.Bounds, forecolor, TextFormatFlags.Left); e.DrawFocusRectangle(e.Bounds); }
private void lvCompare_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.ColumnIndex == 3) { e.DrawDefault = false; e.DrawBackground(); Color txtColor; if (e.Item.Selected && lvCompare.Focused) { e.Graphics.FillRectangle(SystemBrushes.Highlight, e.SubItem.Bounds); txtColor = Color.White; } else { e.Graphics.FillRectangle(SystemBrushes.Window, e.SubItem.Bounds); txtColor = e.SubItem.ForeColor; } Image syncIcon = null; if (e.SubItem.Text.Equals(SyncAction.CopyFileToSource.Text())) syncIcon = Properties.Resources.left_copy; else if (e.SubItem.Text.Equals(SyncAction.CopyFileToTarget.Text())) syncIcon = Properties.Resources.right_copy; else if (e.SubItem.Text.Equals(SyncAction.CollisionPromptUser.Text())) syncIcon = Properties.Resources.prompt; else if (e.SubItem.Text.Equals(SyncAction.SkipNExclude.Text())) syncIcon = Properties.Resources.exclude; else if (e.SubItem.Text.Equals(SyncAction.DeleteBothFile.Text())) syncIcon = Properties.Resources.remove; else if (e.SubItem.Text.Equals(SyncAction.DeleteSourceFile.Text())) syncIcon = Properties.Resources.delete_left; else syncIcon = Properties.Resources.delete_right; e.Graphics.DrawImage(syncIcon, e.SubItem.Bounds.X, e.SubItem.Bounds.Y, syncIcon.Width, syncIcon.Height); e.Graphics.DrawString(e.SubItem.Text, e.SubItem.Font, new SolidBrush(txtColor), e.SubItem.Bounds.Location.X + syncIcon.Width, e.SubItem.Bounds.Location.Y); } else e.DrawDefault = true; }
/// <summary> /// サブアイテム描画 /// </summary> /// <param name="e"></param> public void DrawSubItem(DrawListViewSubItemEventArgs e) { Brush textBrush; e.Graphics.SetClip(e.Bounds); if (e.ItemState.HasFlag(ListViewItemStates.Selected)) { e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds); e.Graphics.DrawImage(imageSelected, e.Bounds.X,e.Bounds.Y); textBrush = SystemBrushes.HighlightText; } else { e.DrawBackground(); e.Graphics.DrawImage(imageNormal, e.Bounds.X, e.Bounds.Y); textBrush = SystemBrushes.WindowText; } // imgSlotItem.Draw(e.Graphics, new Point(e.Bounds.X + 1, e.Bounds.Y), slotItemIndex); using (StringFormat sf = new StringFormat()) { sf.LineAlignment = StringAlignment.Center; // sf.Trimming = StringTrimming.EllipsisCharacter; sf.FormatFlags = StringFormatFlags.NoWrap; e.Graphics.DrawString(Text, SystemFonts.DialogFont, textBrush, new RectangleF(e.Bounds.X + 17, e.Bounds.Y, e.Bounds.Width - 16, e.Bounds.Height), sf); } }
void HistoryListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.ItemIndex < 0) return; //Console.WriteLine(e.ItemIndex + "-" + e.Bounds); if (this.SelectedIndices.Contains(e.ItemIndex)) { e.Graphics.FillRectangle(System.Drawing.Brushes.LightGray, e.Bounds); ControlPaint.DrawFocusRectangle(e.Graphics, e.Item.Bounds); } else { e.DrawBackground(); } // if this is the first column, we want to draw an icon as well int newX = e.Bounds.Left; if (e.ColumnIndex == 0) { // draw the icon newX = newX + 20; PastNotification pn = (PastNotification)e.Item.Tag; if (pn != null) { System.Drawing.Image img = PastNotificationManager.GetImage(pn); using (img) { if (img != null) { int x = e.Bounds.Left + 2; int y = e.Bounds.Top; e.Graphics.DrawImage(img, new System.Drawing.Rectangle(x, y, 16, 16)); } } } } // draw text string text = e.SubItem.Text.Replace("\r", " - "); System.Drawing.Rectangle rect = new System.Drawing.Rectangle(newX, e.Bounds.Top, e.Bounds.Right - newX, e.Item.Font.Height); System.Drawing.StringFormat sf = new System.Drawing.StringFormat(); sf.Trimming = System.Drawing.StringTrimming.EllipsisCharacter; sf.FormatFlags = System.Drawing.StringFormatFlags.NoClip | System.Drawing.StringFormatFlags.NoWrap; System.Drawing.Color color = (e.ColumnIndex == 0 ? e.Item.ForeColor : System.Drawing.Color.FromArgb(System.Drawing.SystemColors.GrayText.ToArgb())); System.Drawing.SolidBrush foreBrush = new System.Drawing.SolidBrush(color); using (foreBrush) { //TextFormatFlags flags = TextFormatFlags.Default | TextFormatFlags.ExternalLeading | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.NoClipping | TextFormatFlags.EndEllipsis | TextFormatFlags.LeftAndRightPadding | TextFormatFlags.SingleLine; //TextRenderer.DrawText(e.Graphics, text, e.SubItem.Font, rect, e.SubItem.ForeColor, System.Drawing.Color.Transparent, flags); e.Graphics.DrawString(text, e.SubItem.Font, foreBrush, rect, sf); } }
private void lvObjetosBanco_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.Header != lvObjetosBanco.Columns[4]) { e.DrawDefault = true; return; } e.DrawBackground(); var imageRect = new Rectangle(e.Bounds.X + ((lvObjetosBanco.Columns[e.ColumnIndex].Width / 2) - 8), e.Bounds.Y, e.Bounds.Height, e.Bounds.Height); var imgIcone = (_imgObjetosMapeados.FirstOrDefault(o => o.Key == e.Item.Text).Value) ?? ilIcones.Images["uncheked"]; if (imgIcone == null) return; e.Graphics.DrawImage(imgIcone, imageRect); }