//return the new x coordinate public abstract int DoDraw(DrawListViewSubItemEventArgs e, int x, EXControls.EXColumnHeader ch);
public void DrawNormalSubItem(DrawListViewSubItemEventArgs e) { DrawText(e.Graphics, e.SubItem.Bounds, Columns[e.ColumnIndex].TextAlign, SystemColors.WindowText, e.SubItem.Text); }
// Token: 0x06000977 RID: 2423 RVA: 0x00004E49 File Offset: 0x00003049 protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) { e.DrawDefault = true; base.OnDrawSubItem(e); }
private void listViewItemsQueue_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawDefault = true; }
private void listVerses_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { int num = (int)MessageBox.Show(e.SubItem.ToString()); }
private void ListView1_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { // }
public override void Draw(DrawListViewSubItemEventArgs e) { if (_hot != Rectangle.Empty) { if (_hot != e.Bounds) { ListView.Invalidate(_hot); _hot = Rectangle.Empty; } } if ((!DrawIfEmpty) && (string.IsNullOrEmpty(e.SubItem.Text))) return; Point mouse = e.Item.ListView.PointToClient(Control.MousePosition); if ((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); _hot = e.Bounds; } else { ButtonRenderer.DrawButton(e.Graphics, e.Bounds, e.SubItem.Text, Font, false, PushButtonState.Default); } }
private void ListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { // We draw the current line of items (= item with sub items) on a temp bitmap, then draw the bitmap at once. This is to reduce flickering. Bitmap _bitmap = new Bitmap(e.Item.Bounds.Width, e.Item.Bounds.Height); Graphics _graphics = Graphics.FromImage(_bitmap); if (e.ItemState.HasFlag(ListViewItemStates.Selected)) { _graphics.FillRectangle(new SolidBrush(_itemSelected), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); } else if (e.Bounds.Contains(LastPosition) && (MouseState == MouseStates.Hover)) { _graphics.FillRectangle(new SolidBrush(_itemHover), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); } else { _graphics.FillRectangle(new SolidBrush(_itemEnabled), new Rectangle(new Point(e.Bounds.X, 0), e.Bounds.Size)); } // Draw separator // graphics.DrawLine(new Pen(Color.Red), e.Bounds.Left, 0, e.Bounds.Right, 0); foreach (ListViewItem.ListViewSubItem subItem in e.Item.SubItems) { // Draw text _graphics.DrawString(subItem.Text, Font, new SolidBrush(Color.Black), new Rectangle(subItem.Bounds.X + _itemPadding, _itemPadding, subItem.Bounds.Width - (2 * _itemPadding), subItem.Bounds.Height - (2 * _itemPadding)), GetStringFormat()); } // Draw the item text for views other than the Details view if (_listView.View != View.Details) { e.DrawText(); } TextFormatFlags _textFormatFlags = TextFormatFlags.Left; StringFormat _stringFormat = new StringFormat(); // Store the column text alignment, letting it default // to Left if it has not been set to Center or Right. switch (e.Header.TextAlign) { case HorizontalAlignment.Center: { _stringFormat.Alignment = StringAlignment.Center; _textFormatFlags = TextFormatFlags.HorizontalCenter; break; } case HorizontalAlignment.Right: { _stringFormat.Alignment = StringAlignment.Far; _textFormatFlags = TextFormatFlags.Right; break; } case HorizontalAlignment.Left: { break; } default: { throw new ArgumentOutOfRangeException(); } } // Draw the text and background for a sub item with a // negative value. double _subItemValue; if ((e.ColumnIndex > 0) && double.TryParse(e.SubItem.Text, NumberStyles.Currency, NumberFormatInfo.CurrentInfo, out _subItemValue) && (_subItemValue < 0)) { // Unless the item is selected, draw the standard // background to make it stand out from the gradient. if ((e.ItemState & ListViewItemStates.Selected) == 0) { e.DrawBackground(); } // Draw the sub item text in red to highlight it. _graphics.DrawString(e.SubItem.Text, Font, Brushes.Red, e.Bounds, _stringFormat); return; } e.Graphics.DrawImage((Image)_bitmap.Clone(), new Point(0, e.Item.Bounds.Location.Y)); // Draw normal text for a sub item with a non negative // or non numerical value. e.DrawText(_textFormatFlags); _graphics.Dispose(); _bitmap.Dispose(); }
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) { base.OnDrawSubItem(e); if (e.Item.ListView == null) { return; // is being removed } int iidColumnIndex = getColumnByTag("IId").Index; int labelsColumnIndex = getColumnByTag("Labels").Index; int?resolvedCountColumnIndex = getColumnByTag("Resolved")?.Index; int?totalTimeColumnIndex = getColumnByTag("TotalTime")?.Index; int?titleColumnIndex = getColumnByTag("Title")?.Index; int?sourceBranchColumnIndex = getColumnByTag("SourceBranch")?.Index; int?targetBranchColumnIndex = getColumnByTag("TargetBranch")?.Index; int?jiraColumnIndex = getColumnByTag("Jira")?.Index; int?authorColumnIndex = getColumnByTag("Author")?.Index; bool isIIdColumnItem = e.ColumnIndex == iidColumnIndex; bool isLabelsColumnItem = e.ColumnIndex == labelsColumnIndex; bool isResolvedColumnItem = resolvedCountColumnIndex.HasValue && e.ColumnIndex == resolvedCountColumnIndex.Value; bool isTotalTimeColumnItem = totalTimeColumnIndex.HasValue && e.ColumnIndex == totalTimeColumnIndex.Value; bool isTitleColumnItem = titleColumnIndex.HasValue && e.ColumnIndex == titleColumnIndex.Value; bool isSourceBranchColumnItem = sourceBranchColumnIndex.HasValue && e.ColumnIndex == sourceBranchColumnIndex.Value; bool isTargetBranchColumnItem = targetBranchColumnIndex.HasValue && e.ColumnIndex == targetBranchColumnIndex.Value; bool isJiraColumnItem = jiraColumnIndex.HasValue && e.ColumnIndex == jiraColumnIndex.Value; bool isAuthorColumnItem = authorColumnIndex.HasValue && e.ColumnIndex == authorColumnIndex.Value; bool isWrappableColumnItem = isTitleColumnItem || isSourceBranchColumnItem || isTargetBranchColumnItem || isJiraColumnItem || isAuthorColumnItem; bool needWordWrap = isWrappableColumnItem && Program.Settings.WordWrapLongRows; StringFormatFlags formatFlags = needWordWrap ? StringFormatFlags.LineLimit : StringFormatFlags.NoWrap; StringFormat format = new StringFormat { Trimming = StringTrimming.EllipsisCharacter, FormatFlags = formatFlags }; Rectangle bounds = e.Bounds; if (e.ColumnIndex == 0 && e.Item.ListView.Columns[0].DisplayIndex != 0) { bounds = WinFormsHelpers.GetFirstColumnCorrectRectangle(e.Item.ListView, e.Item); } bool isSelected = e.Item.Selected; FullMergeRequestKey fmk = (FullMergeRequestKey)(e.Item.Tag); Color backgroundColor = getMergeRequestColor(fmk, Color.Transparent, true); WinFormsHelpers.FillRectangle(e, bounds, backgroundColor, isSelected); string text = ((ListViewSubItemInfo)(e.SubItem.Tag)).Text; bool isClickable = ((ListViewSubItemInfo)(e.SubItem.Tag)).Clickable; if (isIIdColumnItem) { FontStyle fontStyle = isClickable ? FontStyle.Underline : FontStyle.Regular; using (Font font = new Font(e.Item.ListView.Font, fontStyle)) { e.Graphics.DrawString(text, font, Brushes.Blue, bounds, format); if (isMuted(fmk)) { drawEllipseForIId(e.Graphics, format, bounds, fmk, font); } } } else if (isClickable) { using (Font font = new Font(e.Item.ListView.Font, FontStyle.Underline)) { Brush brush = Brushes.Blue; e.Graphics.DrawString(text, font, brush, bounds, format); } } else if (isSelected && isLabelsColumnItem) { using (Brush brush = new SolidBrush(getMergeRequestColor(fmk, SystemColors.Window, true))) { e.Graphics.DrawString(text, e.Item.ListView.Font, brush, bounds, format); } } else if (isResolvedColumnItem) { using (Brush brush = new SolidBrush(getDiscussionCountColor(fmk, isSelected))) { e.Graphics.DrawString(text, e.Item.ListView.Font, brush, bounds, format); } } else if (isTotalTimeColumnItem) { Brush brush = text == Constants.NotAllowedTimeTrackingText ? Brushes.Gray : Brushes.Black; e.Graphics.DrawString(text, e.Item.ListView.Font, brush, bounds, format); } else { Brush textBrush = isSelected ? SystemBrushes.HighlightText : SystemBrushes.ControlText; e.Graphics.DrawString(text, e.Item.ListView.Font, textBrush, bounds, format); } }
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) { switch (DrawMode) { case drawMode.Default: base.OnDrawSubItem(e); break; case drawMode.Stylish: base.OnDrawSubItem(e); Graphics g = e.Graphics; g.SmoothingMode = Smoothing; g.TextRenderingHint = TextRendering; TextFormatFlags flags = TextFormatFlags.Left; using (StringFormat sf = new StringFormat()) { // Store the column text alignment, letting it default // to Left if it has not been set to Center or Right. switch (e.Header.TextAlign) { case HorizontalAlignment.Center: sf.Alignment = StringAlignment.Center; flags = TextFormatFlags.HorizontalCenter; break; case HorizontalAlignment.Right: sf.Alignment = StringAlignment.Far; flags = TextFormatFlags.Right; break; } // Draw the text and background for a subitem with a // negative value. double subItemValue; if (e.ColumnIndex > 0 && Double.TryParse( e.SubItem.Text, NumberStyles, NumberFormatInfo.CurrentInfo, out subItemValue) && subItemValue < 0) { // Unless the item is selected, draw the standard // background to make it stand out from the gradient. if ((e.ItemState & ListViewItemStates.Selected) == 0) { e.DrawBackground(); } // Draw the subitem text in red to highlight it. g.DrawString(e.SubItem.Text, Font, new SolidBrush(SubTextColor), e.Bounds, sf); return; } if (ShowCellBorder) { foreach (var items in Items) { e.Graphics.DrawRectangle(CellBorderFocused.GetPen(), new Rectangle(e.Bounds.X + (int)HeaderBorder.GetPen().Width, e.Bounds.Y + (int)HeaderBorder.GetPen().Width, e.Bounds.Width - (2 * (int)HeaderBorder.GetPen().Width), e.Bounds.Height - (2 * (int)HeaderBorder.GetPen().Width))); } } // Draw normal text for a subitem with a nonnegative // or nonnumerical value. e.DrawText(flags); } break; } }
private void lvPlugins_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { var plugin = (XtbPlugin)e.Item.Tag; if (e.ColumnIndex == 2 && e.SubItem.Text.Length > 0) { if (e.Item.Selected) { e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds); } var dValue = plugin.AverageFeedbackRating; if (dValue > 0) { var sourceBmp = new Bitmap(ilImages.Images[0]); Rectangle srcRect = new Rectangle(0, 0, Convert.ToInt32(Math.Truncate(dValue / 5 * 80)), 16); Bitmap cropped = sourceBmp.Clone(srcRect, sourceBmp.PixelFormat); e.Graphics.DrawImage(cropped, new Point(e.Bounds.X, e.Bounds.Y)); e.Graphics.DrawString($"({plugin.TotalFeedbackRating})", e.Item.Font, new SolidBrush(e.Item.ForeColor), new PointF(e.Bounds.X + 80, e.Bounds.Y + 2)); } } else if (e.ColumnIndex == 0) { e.DrawDefault = true; } else { // Draw the standard header background. e.DrawBackground(); if (e.Item.Selected) { e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds); } if (e.ColumnIndex == 1 && plugin.FirstReleaseDate > DateTime.Now.AddMonths(-1) && (plugin.Action == PackageInstallAction.Install || plugin.Action == PackageInstallAction.Unavailable)) { //add a 2 pixel buffer the match default behavior Rectangle rec = new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width - 20, e.Bounds.Height - 4); TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis | 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.Item.Selected ? Color.White : e.Item.ForeColor, flags); e.Graphics.DrawImage(iiNotif.Images[3], e.Bounds.X + e.Bounds.Width - 20, e.Bounds.Y); } else { //add a 2 pixel buffer the match default behavior Rectangle rec = new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, e.Bounds.Width - 4, e.Bounds.Height - 4); TextFormatFlags flags = TextFormatFlags.Left | TextFormatFlags.EndEllipsis | 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.Item.Selected ? Color.White : e.Item.ForeColor, flags); } } }
// Token: 0x06000476 RID: 1142 RVA: 0x001D8B70 File Offset: 0x001D6F70 protected override void OnDrawSubItem(DrawListViewSubItemEventArgs drawListViewSubItemEventArgs_0) { drawListViewSubItemEventArgs_0.DrawDefault = true; base.OnDrawSubItem(drawListViewSubItemEventArgs_0); }
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) { e.SubItem.BackColor = e.Item.Index % 2 == 0 ? Color.White : Color.FromArgb(240, 240, 240); e.DrawDefault = true; base.OnDrawSubItem(e); }
private void OnListViewDrawSubItem(DrawListViewSubItemEventArgs e) { if (e.SubItem.Name != TextItemName) { e.DrawDefault = true; return; } //Log("State:" + e.Item.Selected); if (e.Item.Selected) { e.Graphics.FillRectangle(SystemBrushes.Highlight, e.Bounds); } var format = StringFormat.GenericTypographic; format.FormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.FitBlackBox | StringFormatFlags.MeasureTrailingSpaces; format.Trimming = StringTrimming.EllipsisCharacter; format.SetTabStops(0, new[] { _settings.TabSize }); float x = e.Bounds.X; float y = e.Bounds.Y; int charIndex = 0; foreach (ColorRange range in _settings.ComputeColorRanges(e.SubItem.Text)) { //Log("OLVD charIndex:" + charIndex + " range.Length:" + range.Length + " Text:[" + e.SubItem.Text + "]"); string chunk = e.SubItem.Text.Substring(charIndex, range.Length); //Log("Range:" + range + " chunk='" + chunk + "'"); Font font; if (range.ColorSet == null || range.ColorSet.Font == null) { font = listView.Font; } else { font = range.ColorSet.Font; } SizeF size = e.Graphics.MeasureString(chunk, font, new PointF(), format); var layout = new RectangleF(x, y + (e.Bounds.Height - size.Height) / 2, e.Bounds.Width - (x - e.Bounds.X), e.Bounds.Height); if (range.ColorSet != null) { if (x + size.Width < e.Bounds.Right) { //Log(" BackColor:" + range.ColorSet.BackColor + " ForeColor=" + range.ColorSet.ForeColor + " size=" + size); switch (range.ColorSet.Mode) { case ColorSetDrawMode.Frame: e.Graphics.DrawRectangle(range.ColorSet.BackPen, x, y + (e.Bounds.Height - size.Height) / 2, size.Width, size.Height); break; //case ColorizerMode.Fill: default: e.Graphics.FillRectangle(range.ColorSet.BackBrush, x, y, size.Width, e.Bounds.Height); break; } } e.Graphics.DrawString(chunk, font, range.ColorSet.ForeBrush, layout, format); } else { using (var brush = new SolidBrush(listView.ForeColor)) { e.Graphics.DrawString(chunk, font, brush, layout, format); } } x += size.Width; charIndex += range.Length; } }
protected override void Listview_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { base.Listview_DrawSubItem(sender, e); }
private void listViewJournal_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { JournalListViewItem obj = e.Item as JournalListViewItem; //e.DrawBackground(); //e.DrawText(); switch (e.ColumnIndex) { case 0: // Date if (null == obj.obj) { e.Graphics.DrawString("-- Total -- ", e.Item.Font, new SolidBrush(e.Item.ForeColor), e.Bounds); } else { e.Graphics.DrawString(obj.obj.date.ToShortDateString() + " " + obj.obj.date.ToShortTimeString(), e.Item.Font, new SolidBrush(e.Item.ForeColor), e.Bounds, new StringFormat(StringFormatFlags.LineLimit)); } break; case 1: // ammount { StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Far; format.LineAlignment = StringAlignment.Center; format.FormatFlags = StringFormatFlags.NoWrap; e.Graphics.DrawString(String.Format("{0:C}", Math.Abs(obj.obj.amount)), e.Item.Font, new SolidBrush(obj.obj.amount < 0 ? Color.Red : Color.Green), e.Bounds, format); } break; case 2: // type { e.Graphics.DrawString(String.Format("[{0:2}] {1}", obj.obj.refType.ToString(), AppData.ReferenceName[(int)obj.obj.refType]), e.Item.Font, new SolidBrush(e.Item.ForeColor), e.Bounds, new StringFormat(StringFormatFlags.LineLimit)); } break; case 3: // Name1 { e.Graphics.DrawString(String.Format("{0} [{1}]", obj.obj.ownerName1, obj.obj.ownerID1), e.Item.Font, new SolidBrush(e.Item.ForeColor), e.Bounds, new StringFormat(StringFormatFlags.LineLimit)); } break; case 4: // Name2 { e.Graphics.DrawString(String.Format("{0} [{1}]", obj.obj.ownerName2, obj.obj.ownerID2), e.Item.Font, new SolidBrush(e.Item.ForeColor), e.Bounds, new StringFormat(StringFormatFlags.LineLimit)); } break; case 5: // Arg1 { e.Graphics.DrawString(String.Format("{0} [{1}]", obj.obj.argName1, obj.obj.argID), e.Item.Font, new SolidBrush(e.Item.ForeColor), e.Bounds, new StringFormat(StringFormatFlags.LineLimit)); } break; case 6: // reason { e.Graphics.DrawString(obj.obj.reason, e.Item.Font, new SolidBrush(e.Item.ForeColor), e.Bounds, new StringFormat(StringFormatFlags.LineLimit)); } break; } e.DrawFocusRectangle(e.Bounds); }
public override int DoDraw(DrawListViewSubItemEventArgs drawListViewSubItemEventArgs_0, int int_0, EXColumnHeader excolumnHeader_0) { return(int_0); }
void SubtitleListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { Color backgroundColor = Items[e.ItemIndex].SubItems[e.ColumnIndex].BackColor; if (Focused && backgroundColor == BackColor) { e.DrawDefault = true; return; } using (StringFormat sf = new StringFormat()) { switch (e.Header.TextAlign) { case HorizontalAlignment.Center: sf.Alignment = StringAlignment.Center; break; case HorizontalAlignment.Right: sf.Alignment = StringAlignment.Far; break; } if (e.Item.Selected) { Rectangle rect = e.Bounds; if (Configuration.Settings != null) { if (backgroundColor == BackColor) { backgroundColor = Configuration.Settings.Tools.ListViewUnfocusedSelectedColor; } else { int r = backgroundColor.R - 39; int g = backgroundColor.G - 39; int b = backgroundColor.B - 39; if (r < 0) { r = 0; } if (g < 0) { g = 0; } if (b < 0) { b = 0; } backgroundColor = Color.FromArgb(backgroundColor.A, r, g, b); } SolidBrush sb = new SolidBrush(backgroundColor); e.Graphics.FillRectangle(sb, rect); } else { e.Graphics.FillRectangle(Brushes.LightBlue, rect); } rect = new Rectangle(e.Bounds.Left + 4, e.Bounds.Top + 2, e.Bounds.Width - 3, e.Bounds.Height); Font f = new System.Drawing.Font(SubtitleFontName, SubtitleFontSize, e.Item.Font.Style); //e.Graphics.DrawString(e.SubItem.Text, f, new SolidBrush(e.Item.ForeColor), rect, sf); TextRenderer.DrawText(e.Graphics, e.Item.SubItems[e.ColumnIndex].Text, f, new Point(e.Bounds.Left + 3, e.Bounds.Top + 2), e.Item.ForeColor, TextFormatFlags.NoPrefix); } else { e.DrawDefault = true; } } }
public abstract void Draw(DrawListViewSubItemEventArgs e);
private void resultListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawDefault = true; }
protected virtual void OnDrawSubItem(object sender, DrawListViewSubItemEventArgs e) { ListViewColumn column = GetColumn(e.ColumnIndex); if (column == null) { e.DrawDefault = true; return; } column.Draw(e); }
private void lvChapList_DrawSubItem_1(object sender, DrawListViewSubItemEventArgs e) { e.DrawDefault = true; }
private void propertyListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawBackground(); e.DrawText(); }
public abstract void Draw(DrawListViewSubItemEventArgs e);
private void lstFields_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawDefault = true; }
// 리스트뷰 Subitem 컬러추가 void lv_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawText(); }
protected override void OnDrawSubItem(DrawListViewSubItemEventArgs e) { }
private static void ListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawDefault = true; //采用系统默认方式绘制子项 }
public override void ConfigureSubItem(DrawListViewSubItemEventArgs e, Rectangle cellBounds, object model) { base.ConfigureSubItem(e, cellBounds, model); this.highlightTextRenderer.ConfigureSubItem(e, cellBounds, model); }
private void listViewReturns_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { e.DrawText(); }
public override int DoDraw(DrawListViewSubItemEventArgs e, int x, EXColumnHeader ch) { return(x); }
void MetroListView_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { Color itemForeColor = MetroPaint.ForeColor.Button.Disabled(Theme); if (this.View == View.Details) { if (e.Item.Selected) { e.Graphics.FillRectangle(new SolidBrush(ControlPaint.Light(MetroPaint.GetStyleColor(Style), _offset)), e.Bounds); itemForeColor = Color.White; } TextFormatFlags align = TextFormatFlags.Left; int _ded = 0, _left = 0; if (this.CheckBoxes && e.ColumnIndex == 0) { _ded = 12; _left = 14; int _top = (e.Bounds.Height / 2) - 6; using (Pen p = new Pen(itemForeColor)) { Rectangle boxRect = new Rectangle(e.Bounds.X + 2, e.Bounds.Y + _top, 12, 12); e.Graphics.DrawRectangle(p, boxRect); } if (e.Item.Checked) { Color fillColor = MetroPaint.GetStyleColor(Style); if (e.Item.Selected) { fillColor = Color.White; } using (SolidBrush b = new SolidBrush(fillColor)) { _top = (e.Bounds.Height / 2) - 4; Rectangle boxRect = new Rectangle(e.Bounds.X + 4, e.Bounds.Y + _top, 9, 9); e.Graphics.FillRectangle(b, boxRect); } } } if (this.SmallImageList != null) { int _top = 0; Image _img = null; if (e.Item.ImageIndex > -1) { _img = this.SmallImageList.Images[e.Item.ImageIndex]; } if (e.Item.ImageKey != "") { _img = this.SmallImageList.Images[e.Item.ImageKey]; } if (_img != null) { _left += _left > 0 ? 4 : 2; _top = (e.Item.Bounds.Height - _img.Height) / 2; e.Graphics.DrawImage(_img, new Rectangle(e.Item.Bounds.Left + _left, e.Item.Bounds.Top + _top, _img.Width, _img.Height)); _left += this.SmallImageList.ImageSize.Width; _ded += this.SmallImageList.ImageSize.Width; } } int _colWidth = e.Item.Bounds.Width; if (this.View == View.Details) { _colWidth = this.Columns[e.ColumnIndex].Width; } using (StringFormat sf = new StringFormat()) { TextFormatFlags flags = TextFormatFlags.Left; switch (e.Header.TextAlign) { case HorizontalAlignment.Center: sf.Alignment = StringAlignment.Center; flags = TextFormatFlags.HorizontalCenter; break; case HorizontalAlignment.Right: sf.Alignment = StringAlignment.Far; flags = TextFormatFlags.Right; break; default: sf.Alignment = StringAlignment.Near; flags = TextFormatFlags.Left; break; } double subItemValue; if (e.ColumnIndex > 0 && Double.TryParse(e.SubItem.Text, NumberStyles.Currency, NumberFormatInfo.CurrentInfo, out subItemValue)) { sf.Alignment = StringAlignment.Far; flags = TextFormatFlags.Right; } //TextFormatFlags align = TextFormatFlags.Left; Rectangle rect = new Rectangle(e.Bounds.X + _left, e.Bounds.Y, _colWidth - _ded, e.Item.Bounds.Height); TextRenderer.DrawText(e.Graphics, e.SubItem.Text, stdFont, rect, itemForeColor, align | TextFormatFlags.SingleLine | TextFormatFlags.GlyphOverhangPadding | TextFormatFlags.VerticalCenter | TextFormatFlags.WordEllipsis); } } else { e.DrawDefault = true; } }
private void lvwSecurityGroup_DrawSubItem(object sender, DrawListViewSubItemEventArgs e) { if (e.Item.Selected) { e.Graphics.FillRectangle(new SolidBrush(Color.LightBlue), e.Bounds); e.Graphics.DrawString(e.SubItem.Text, new Font("Tahoma", 8), new SolidBrush(Color.Black), e.Bounds); } else { e.DrawBackground(); e.DrawText(); } }
public void DrawBackground_NullGraphics_ThrowsNullReferenceException() { var e = new DrawListViewSubItemEventArgs(null, new Rectangle(1, 2, 3, 4), new ListViewItem(), new ListViewItem.ListViewSubItem(), 0, 0, new ColumnHeader(), ListViewItemStates.Checked); Assert.Throws <NullReferenceException>(() => e.DrawBackground()); }