Here are the examples of the csharp api class System.Windows.Forms.DrawItemEventArgs.DrawBackground() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
124 Examples
0
1. Example
Project: ReoGrid
Source File: FontDropDownControl.cs
Source File: FontDropDownControl.cs
void ComboBox_DrawItem(object sender, DrawItemEventArgs e) { Graphics g = e.Graphics; e.DrawBackground(); if (e.Index >= 0 && e.Index < base.Items.Count) { FontUIToolkit.DrawFontItem(g, (FontFamilyInfo)base.Items[e.Index], e.Bounds, (e.State & DrawItemState.Selected) == DrawItemState.Selected); } }
0
2. Example
Project: ReoGrid
Source File: FontListBox.cs
Source File: FontListBox.cs
void FontListBox_DrawItem(object sender, DrawItemEventArgs e) { Graphics g = e.Graphics; e.DrawBackground(); FontUIToolkit.DrawFontItem(g, (FontFamilyInfo)base.Items[e.Index], e.Bounds, (e.State & DrawItemState.Selected) == DrawItemState.Selected); }
0
3. Example
Project: ReoGrid
Source File: FontToolStripDropDown.cs
Source File: FontToolStripDropDown.cs
void ComboBox_DrawItem(object sender, DrawItemEventArgs e) { Graphics g = e.Graphics; e.DrawBackground(); FontUIToolkit.DrawFontItem(g, (FontFamilyInfo)ComboBox.Items[e.Index], e.Bounds, (e.State & DrawItemState.Selected) == DrawItemState.Selected); }
0
4. Example
Project: xenadmin
Source File: EnableableComboBox.cs
Source File: EnableableComboBox.cs
protected override void OnDrawItem(DrawItemEventArgs e) { int index = e.Index; if (index > -1) { e.DrawBackground(); IEnableableComboBoxItem item = Items[index] as IEnableableComboBoxItem; Color textColor = SystemColors.ControlText; //Paint disabled items grey - otherwise leave them black if (item != null && !item.Enabled) textColor = SystemColors.GrayText; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) textColor = SystemColors.HighlightText; Drawing.DrawText(e.Graphics, Items[index].ToString(), Font, e.Bounds.Location, textColor); } base.OnDrawItem(e); }
0
5. Example
Project: ContinuousTests
Source File: ErrorDisplay.cs
Source File: ErrorDisplay.cs
private void detailList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { if (e.Index >= 0) { e.DrawBackground(); TestResultItem item = (TestResultItem) detailList.Items[e.Index]; bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? true : false; Brush brush = selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText; RectangleF layoutRect = e.Bounds; if ( this.WordWrap && layoutRect.Width > detailList.ClientSize.Width ) layoutRect.Width = detailList.ClientSize.Width; e.Graphics.DrawString(item.ToString(),detailList.Font, brush, layoutRect); } }
0
6. Example
Project: ContinuousTests
Source File: ErrorDisplay.cs
Source File: ErrorDisplay.cs
private void detailList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { if (e.Index >= 0) { e.DrawBackground(); TestResultItem item = (TestResultItem) detailList.Items[e.Index]; bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? true : false; Brush brush = selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText; RectangleF layoutRect = e.Bounds; if ( this.WordWrap && layoutRect.Width > detailList.ClientSize.Width ) layoutRect.Width = detailList.ClientSize.Width; e.Graphics.DrawString(item.ToString(),detailList.Font, brush, layoutRect); } }
0
7. Example
Project: ContinuousTests
Source File: ErrorDisplay.cs
Source File: ErrorDisplay.cs
private void detailList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { if (e.Index >= 0) { e.DrawBackground(); TestResultItem item = (TestResultItem) detailList.Items[e.Index]; bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? true : false; Brush brush = selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText; RectangleF layoutRect = e.Bounds; if ( this.WordWrap && layoutRect.Width > detailList.ClientSize.Width ) layoutRect.Width = detailList.ClientSize.Width; e.Graphics.DrawString(item.ToString(),detailList.Font, brush, layoutRect); } }
0
8. Example
Project: VSSDK-Extensibility-Samples
Source File: ConfigDialog.cs
Source File: ConfigDialog.cs
void _termTableListBox_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); if (_termTableListBox.Items.Count > 0 && e.Index >= 0) { ListEntry entry = (ListEntry)_termTableListBox.Items[e.Index]; if (entry != null) { Color color; if (entry.IsValid) { color = e.ForeColor; } else { color = Color.FromKnownColor(KnownColor.GrayText); } entry.DrawAbbreviatedPath(e.Font, color, e.Bounds, e.Graphics); } } }
0
9. Example
Project: PowerPointLabs
Source File: CustomShapePane.cs
Source File: CustomShapePane.cs
private void CategoryBoxOwnerDraw(object sender, DrawItemEventArgs e) { var comboBox = sender as ComboBox; if (comboBox == null || e.Index == -1) { return; } var font = comboBox.Font; var text = (string)_categoryBinding[e.Index]; if (text == Globals.ThisAddIn.ShapesLabConfig.DefaultCategory) { text += " (default)"; font = new Font(font, FontStyle.Bold); } using (var brush = new SolidBrush(e.ForeColor)) { e.DrawBackground(); e.Graphics.DrawString(text, font, brush, e.Bounds); } int desiredWidth = Width - label1.Width - 60; comboBox.Width = desiredWidth > 0 ? desiredWidth : 0; }
0
10. Example
Project: ReoGrid
Source File: LineStyleControl.cs
Source File: LineStyleControl.cs
protected override void OnDrawItem(DrawItemEventArgs e) { Graphics g = e.Graphics; e.DrawBackground(); if (e.Index >= 0 && e.Index < base.Items.Count) { int x = e.Bounds.X+3; int y = e.Bounds.Y + e.Bounds.Height / 2 - 1; int x2 = e.Bounds.Right - 3; using (Pen p = new Pen(ForeColor, 2f)) { if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { p.Color = SystemColors.HighlightText; } p.DashStyle = (DashStyle)Items[e.Index]; g.DrawLine(p, x, y, x2, y); } } }
0
11. Example
Project: xenadmin
Source File: NotificationsView.cs
Source File: NotificationsView.cs
protected override void OnDrawItem(DrawItemEventArgs e) { base.OnDrawItem(e); var item = Items[e.Index] as NotificationsSubModeItem; if (item == null) return; const int IMG_LEFT_MARGIN = 16; const int IMG_RIGHT_MARGIN = 8; int itemHeight = e.Bounds.Height; int imgWidth = item.Image.Width; int imgHeight = item.Image.Height; e.DrawBackground(); e.Graphics.DrawImage(item.Image, e.Bounds.Left + IMG_LEFT_MARGIN, e.Bounds.Top + (itemHeight - imgHeight) / 2); FontStyle style = item.SubMode == NotificationsSubMode.Events && item.UnreadEntries > 0 ? FontStyle.Bold : FontStyle.Regular; using (Font font = new Font(Font, style)) { int textLeft = e.Bounds.Left + IMG_LEFT_MARGIN + imgWidth + IMG_RIGHT_MARGIN; var textRec = new Rectangle(textLeft, e.Bounds.Top, e.Bounds.Right - textLeft, itemHeight); Drawing.DrawText(e.Graphics, item.Text, font, textRec, ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.Left | TextFormatFlags.EndEllipsis); } }
0
12. Example
Project: AutoTest.Net
Source File: ErrorDisplay.cs
Source File: ErrorDisplay.cs
private void detailList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { if (e.Index >= 0) { e.DrawBackground(); TestResultItem item = (TestResultItem) detailList.Items[e.Index]; bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? true : false; Brush brush = selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText; RectangleF layoutRect = e.Bounds; if ( this.WordWrap && layoutRect.Width > detailList.ClientSize.Width ) layoutRect.Width = detailList.ClientSize.Width; e.Graphics.DrawString(item.ToString(),detailList.Font, brush, layoutRect); } }
0
13. Example
Project: AutoTest.Net
Source File: ErrorDisplay.cs
Source File: ErrorDisplay.cs
private void detailList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { if (e.Index >= 0) { e.DrawBackground(); TestResultItem item = (TestResultItem) detailList.Items[e.Index]; bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? true : false; Brush brush = selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText; RectangleF layoutRect = e.Bounds; if ( this.WordWrap && layoutRect.Width > detailList.ClientSize.Width ) layoutRect.Width = detailList.ClientSize.Width; e.Graphics.DrawString(item.ToString(),detailList.Font, brush, layoutRect); } }
0
14. Example
Project: AutoTest.Net
Source File: ErrorDisplay.cs
Source File: ErrorDisplay.cs
private void detailList_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { if (e.Index >= 0) { e.DrawBackground(); TestResultItem item = (TestResultItem) detailList.Items[e.Index]; bool selected = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? true : false; Brush brush = selected ? SystemBrushes.HighlightText : SystemBrushes.WindowText; RectangleF layoutRect = e.Bounds; if ( this.WordWrap && layoutRect.Width > detailList.ClientSize.Width ) layoutRect.Width = detailList.ClientSize.Width; e.Graphics.DrawString(item.ToString(),detailList.Font, brush, layoutRect); } }
0
15. Example
Project: VisualPlus
Source File: VisualCheckedListBox.cs
Source File: VisualCheckedListBox.cs
private void CheckedListBox_DrawItem(object sender, DrawItemEventArgs e) { // We/n ..... /n //View Source file for more details /n }
0
16. Example
Project: NSMB-Editor
Source File: SpriteEditor.cs
Source File: SpriteEditor.cs
private void spriteListBox_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); Color TextColor, BackColor = e.BackColor; if (spriteListBox.Items.Count > 0 && e.Index > -1) { if (EdControl.Level.ValidSprites[curSprites[e.Index]]) { TextColor = e.ForeColor; } else { TextColor = Color.DarkRed; if ((e.State & DrawItemState.Selected) != DrawItemState.None) { TextColor = Color.White; BackColor = Color.DarkRed; SolidBrush b = new SolidBrush(BackColor); e.Graphics.FillRectangle(b, e.Bounds); b.Dispose(); } } TextRenderer.DrawText(e.Graphics, (string)spriteListBox.Items[e.Index], spriteListBox.Font, e.Bounds, TextColor, BackColor, TextFormatFlags.Left); int SSNumber = SSTable[curSprites[e.Index] << 1]; int SSValue = SSTable[(curSprites[e.Index] << 1) + 1]; string txt = (SSNumber + 1) + "-" + SSValue; if (SSValue == 0) txt = "-"; TextRenderer.DrawText(e.Graphics, txt, spriteListBox.Font, new Rectangle(e.Bounds.X +e.Bounds.Width - 30, e.Bounds.Y, 30, e.Bounds.Height), TextColor, BackColor, TextFormatFlags.Right); } }
0
17. Example
Project: NClass
Source File: ImageComboBox.cs
Source File: ImageComboBox.cs
protected override void OnDrawItem(DrawItemEventArgs e) { e.DrawBackground(); e.DrawFocusRectangle(); object item = e.Index >= 0 ? Items[e.Index] : null; ControlDrawHelper.DrawImageComboBoxItem(e.Graphics, item, ImageList, ImageSize, e.Bounds, Font, ForeColor); base.OnDrawItem(e); }
0
18. Example
Project: Smash-Forge
Source File: MatPropList.cs
Source File: MatPropList.cs
private void matPropList_DrawItem(object sender, DrawItemEventArgs e) { // Draw the background of the ListBox control for each item. e.DrawBackground(); if (e.Index == -1) return; //Figure out the bounds for the text and color box string text = listBox1.Items[e.Index].ToString(); Rectangle textBounds = e.Bounds; // Draw the current item text based on the current Font // and the custom brush settings. e.Graphics.DrawString(text, CONSOLAS, Brushes.Black, textBounds, StringFormat.GenericDefault); // If the ListBox has focus, draw a focus rectangle around the selected item. e.DrawFocusRectangle(); }
0
19. Example
Project: Smash-Forge
Source File: MOIEditor.cs
Source File: MOIEditor.cs
private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); if (e.Index == -1) return; e.Graphics.DrawString($"Entry {e.Index+1}",e.Font, Brushes.Black, e.Bounds, StringFormat.GenericDefault); e.DrawFocusRectangle(); }
0
20. Example
Project: gitter
Source File: CustomObjectPicker.cs
Source File: CustomObjectPicker.cs
protected override void OnDrawItem(DrawItemEventArgs e) { Assert.IsNotNull(e); e.DrawBackground(); e.Graphics.TextRenderingHint = GraphicsUtility.TextRenderingHint; e.Graphics.TextContrast = GraphicsUtility.TextContrast; var selectedItem = SelectedItem; if(selectedItem == null) { OnPaintNullItem(e); } else { OnPaintItem(selectedItem, e); } }
0
21. Example
Project: PresentMonLauncher
Source File: BencherWindow.cs
Source File: BencherWindow.cs
private void cmb_Resolutions_DrawItem(object sender, DrawItemEventArgs e) { if (cmb_Resolutions.Items[e.Index].ToString().StartsWith("----")) { e.Graphics.DrawString(cmb_Resolutions.Items[e.Index].ToString(), new Font(this.Font, FontStyle.Bold), Brushes.Black, e.Bounds); } else { e.DrawBackground(); e.Graphics.DrawString(" " + cmb_Resolutions.Items[e.Index].ToString(), new Font(this.Font, FontStyle.Regular), Brushes.Black, e.Bounds); e.DrawFocusRectangle(); } }
0
22. Example
Project: PresentMonLauncher
Source File: BencherWindow.cs
Source File: BencherWindow.cs
private void cmb_GPUs_DrawItem(object sender, DrawItemEventArgs e) { if (cmb_GPUs.Items[e.Index].ToString().StartsWith("----")) { e.Graphics.DrawString(cmb_GPUs.Items[e.Index].ToString(), new Font(this.Font, FontStyle.Bold), Brushes.Black, e.Bounds); } else { e.DrawBackground(); e.Graphics.DrawString(" " + cmb_GPUs.Items[e.Index].ToString(), new Font(this.Font, FontStyle.Regular), Brushes.Black, e.Bounds); e.DrawFocusRectangle(); } }
0
23. Example
Project: OpenLiveWriter
Source File: PageParentComboBox.cs
Source File: PageParentComboBox.cs
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index != -1) { // calcluate text to paint PostIdAndNameField comboItem = Items[e.Index] as PostIdAndNameField; string text = comboItem.ToString(); if (comboItem is ParentPageComboItem) { if (e.Bounds.Width >= Width) { text = new String(' ', (comboItem as ParentPageComboItem).IndentLevel * 3) + text; } } e.DrawBackground(); using (Brush brush = new SolidBrush(e.ForeColor)) e.Graphics.DrawString(text, e.Font, brush, e.Bounds.X, e.Bounds.Y + 1); e.DrawFocusRectangle(); } }
0
24. Example
Project: libedssharp
Source File: Form1.cs
Source File: Form1.cs
private void tabControl1_DrawItem(Object sender, System.Windows.Forms.DrawItemEventArgs e) { Graphics g = e.Graphics; Brush _textBrush; // Get the item from the collection. TabPage _tabPage = tabControl1.TabPages[e.Index]; // Get the real bounds for the tab rectangle. Rectangle _tabBounds = tabControl1.GetTabRect(e.Index); if (e.State == DrawItemState.Selected) { // Draw a different background color, and don't paint a focus rectangle. _textBrush = new SolidBrush(Color.Red); g.FillRectangle(Brushes.Gray, e.Bounds); } else { _textBrush = new System.Drawing.SolidBrush(e.ForeColor); e.DrawBackground(); } // Use our own font. Font _tabFont = new Font("Arial", (float)10.0, FontStyle.Bold, GraphicsUnit.Pixel); // Draw string. Center the text. StringFormat _stringFlags = new StringFormat(); _stringFlags.Alignment = StringAlignment.Center; _stringFlags.LineAlignment = StringAlignment.Center; g.DrawString(_tabPage.Text, _tabFont, _textBrush, _tabBounds, new StringFormat(_stringFlags)); }
0
25. Example
Project: NClass
Source File: ImageComboBox.cs
Source File: ImageComboBox.cs
protected override void OnDrawItem(DrawItemEventArgs e) { e.DrawBackground(); e.DrawFocusRectangle(); object item = e.Index >= 0 ? Items[e.Index] : null; ControlDrawHelper.DrawImageComboBoxItem(e.Graphics, item, ImageList, ImageSize, e.Bounds, Font, ForeColor); base.OnDrawItem(e); }
0
26. Example
Project: ShareX
Source File: FontFamilyComboBox.cs
Source File: FontFamilyComboBox.cs
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e) { // DrawBack/n ..... /n //View Source file for more details /n }
0
27. Example
Project: ATF
Source File: EnumUITypeEditor.cs
Source File: EnumUITypeEditor.cs
void listBox_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); // Determine the forecolor based on whether or not the item is selected. Brush brush; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { brush = Brushes.White; } else { brush = Brushes.Black; } if (e.Index >= 0) { if (e.Index == m_hoverIndex && (e.State & DrawItemState.Selected) == 0) e.Graphics.FillRectangle(Brushes.LightGray, e.Bounds); // Get the item text. string text = m_names[e.Index]; // Draw the item text. e.Graphics.DrawString(text, ((Control)sender).Font, brush, e.Bounds.X, e.Bounds.Y); } }
0
28. Example
Project: SM64DSe
Source File: ObjectListForm.cs
Source File: ObjectListForm.cs
private void lbxObjectList_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); ushort id = (ushort)m_ObjectIndexIDMap[e.Index]; bool sel = (e.State & (DrawItemState.Focus | DrawItemState.Selected)) != 0; bool available; if (id == LevelObject.NUM_OBJ_TYPES) available = true; else available = m_ObjAvailable[id]; Color txtcolor; if (available) txtcolor = sel ? SystemColors.HighlightText : SystemColors.ControlText; else txtcolor = sel ? Color.LightPink : Color.Red; e.Graphics.DrawString(m_ObjectListText[id], lbxObjectList.Font, new SolidBrush(txtcolor), e.Bounds); e.DrawFocusRectangle(); }
0
29. Example
Project: NFirmwareEditor
Source File: StringEditorTabPage.cs
Source File: StringEditorTabPage.cs
private void StringListBox_DrawItem(object sender, DrawItemEventArgs e) { var listBox = sender /n ..... /n //View Source file for more details /n }
0
30. Example
Project: ShareX
Source File: FontFamilyComboBox.cs
Source File: FontFamilyComboBox.cs
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e) { // DrawBack/n ..... /n //View Source file for more details /n }
0
31. Example
Project: QTTabBar
Source File: ButtonBarOptionForm.cs
Source File: ButtonBarOptionForm.cs
private void listBoxes_DrawItem(object sender, DrawItemEventArgs e) { ListBox box = (Lis/n ..... /n //View Source file for more details /n }
0
32. Example
Project: xenadmin
Source File: ISODropDownBox.cs
Source File: ISODropDownBox.cs
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index != -1) { Object o = Items[e.Index]; e.DrawBackground(); if (o is ToStringWrapper<SR>) { Drawing.DrawText(e.Graphics, o.ToString(), Program.DefaultFontBold, e.Bounds, SystemColors.ControlText, TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); } else { Color colour = e.ForeColor; if ((e.State & DrawItemState.Disabled) != 0) colour = SystemColors.GrayText; Drawing.DrawText(e.Graphics, o.ToString(), Program.DefaultFont, e.Bounds, colour, TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); e.DrawFocusRectangle(); } } base.OnDrawItem(e); }
0
33. Example
Project: xenadmin
Source File: CslgSettings.cs
Source File: CslgSettings.cs
private void comboBox_DrawItem(object sender, DrawItemEventArgs e) { var comboBox = (ComboBox)sender; if (e.Index >= 0) { e.DrawBackground(); Drawing.DrawText(e.Graphics, comboBox.Items[e.Index].ToString(), e.Font, e.Bounds, e.ForeColor, TextFormatFlags.VerticalCenter | TextFormatFlags.EndEllipsis); if ((e.State & DrawItemState.NoFocusRect) == 0) { e.DrawFocusRectangle(); } } }
0
34. Example
Project: jirastopwatch
Source File: IssueControl.cs
Source File: IssueControl.cs
void cbJira_DrawItem(object sender, DrawItemEventArgs e) { // Draw the default background e.DrawBackground(); CBIssueItem item = (CBIssueItem)cbJira.Items[e.Index]; // Create rectangles for the columns to display Rectangle r1 = e.Bounds; Rectangle r2 = e.Bounds; r1.Width = keyWidth; r2.X = r1.Width + 5; r2.Width = 500 - keyWidth; Font font = new Font(e.Font.FontFamily, e.Font.Size * 0.8f, e.Font.Style); // Draw the text on the first column using (SolidBrush sb = new SolidBrush(e.ForeColor)) e.Graphics.DrawString(item.Key, font, sb, r1); // Draw a line to isolate the columns using (Pen p = new Pen(Color.Black)) e.Graphics.DrawLine(p, r1.Right, 0, r1.Right, r1.Bottom); // Draw the text on the second column using (SolidBrush sb = new SolidBrush(e.ForeColor)) e.Graphics.DrawString(item.Summary, font, sb, r2); // Draw a line to isolate the columns using (Pen p = new Pen(Color.Black)) e.Graphics.DrawLine(p, r1.Right, 0, r1.Right, 140); }
0
35. Example
Project: EDDiscovery
Source File: TestTabStrip.cs
Source File: TestTabStrip.cs
private void listBox1_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); // Define the default color of the brush as black. Brush myBrush = Brushes.Black; // Determine the color of the brush to draw each item based // on the index of the item to draw. switch (e.Index) { case 0: myBrush = Brushes.Red; break; case 1: myBrush = Brushes.Orange; break; case 2: myBrush = Brushes.Purple; break; } Bitmap bmp = DialogTest.Properties.Resources.galaxy_gray; e.Graphics.DrawImage(bmp, new Point(0, e.Bounds.Top)); Rectangle textarea = e.Bounds; textarea.X += bmp.Width; // Draw the current item text based on the current Font // and the custom brush settings. e.Graphics.DrawString(listBox1.Items[e.Index].ToString(), e.Font, myBrush, textarea, StringFormat.GenericDefault); // If the ListBox has focus, draw a focus rectangle around the selected item. e.DrawFocusRectangle(); }
0
36. Example
Project: trizbort
Source File: SettingsDialog.cs
Source File: SettingsDialog.cs
private void ColorListBox_DrawItem(object sender, DrawItemEventArgs e) { using (var palette = new Palette()) { e.DrawBackground(); var horizontalMargin = 2; var verticalMargin = 2; var width = 24; var colorBounds = new Rectangle(e.Bounds.Left + horizontalMargin, e.Bounds.Top + verticalMargin, width, e.Bounds.Height - verticalMargin * 2); var textBounds = new Rectangle(colorBounds.Right + horizontalMargin, e.Bounds.Top, e.Bounds.Width - colorBounds.Width - horizontalMargin * 2, e.Bounds.Height); e.Graphics.FillRectangle(palette.Brush(m_color[e.Index]), colorBounds); e.Graphics.DrawRectangle(palette.Pen(e.ForeColor, 0), colorBounds); e.Graphics.DrawString(m_colorListBox.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, StringFormats.Left); } }
0
37. Example
Project: trizbort
Source File: RoomPropertiesDialog.cs
Source File: RoomPropertiesDialog.cs
private void RegionListBox_DrawItem(object sender, DrawItemEventArgs e) { using (var palette = new Palette()) { e.DrawBackground(); var colorBounds = new Rectangle(e.Bounds.Left + HORIZONTAL_MARGIN, e.Bounds.Top + VERTICAL_MARGIN, WIDTH, e.Bounds.Height - VERTICAL_MARGIN*2); var textBounds = new Rectangle(colorBounds.Right + HORIZONTAL_MARGIN, e.Bounds.Top, e.Bounds.Width - colorBounds.Width - HORIZONTAL_MARGIN*2, e.Bounds.Height); var firstOrDefault = Settings.Regions.FirstOrDefault(p => p.RegionName == cboRegion.Items[e.Index].ToString()); if (firstOrDefault != null) e.Graphics.FillRectangle(palette.Brush(firstOrDefault.RColor), colorBounds); e.Graphics.DrawRectangle(palette.Pen(e.ForeColor, 0), colorBounds); e.Graphics.DrawString(cboRegion.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, StringFormats.Left); } }
0
38. Example
Project: trizbort
Source File: SettingsDialog.cs
Source File: SettingsDialog.cs
private void ColorListBox_DrawItem(object sender, DrawItemEventArgs e) { using (var palette = new Palette()) { e.DrawBackground(); const int horizontalMargin = 2; const int verticalMargin = 2; const int width = 24; var colorBounds = new Rectangle(e.Bounds.Left + horizontalMargin, e.Bounds.Top + verticalMargin, width, e.Bounds.Height - verticalMargin*2); var textBounds = new Rectangle(colorBounds.Right + horizontalMargin, e.Bounds.Top, e.Bounds.Width - colorBounds.Width - horizontalMargin*2, e.Bounds.Height); e.Graphics.FillRectangle(palette.Brush(Color[e.Index]), colorBounds); e.Graphics.DrawRectangle(palette.Pen(e.ForeColor, 0), colorBounds); var format = new StringFormat {Trimming = StringTrimming.EllipsisCharacter}; e.Graphics.DrawString(m_colorListBox.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, format); } }
0
39. Example
Project: logwizard
Source File: search_form.cs
Source File: search_form.cs
private void combo_DrawItem(object sender, DrawItemEventArgs e) { Debug.Assert(e.Index >= 0); // Draw the background e.DrawBackground(); // Get the item text string text = ((ComboBox)sender).Items[e.Index].ToString(); // Determine the forecolor based on whether or not the item is selected Brush brush; if ( history_[e.Index].friendly_regex_name != "" ) brush = Brushes.Red; else brush = Brushes.Black; bool italic = false; bool bold = history_[e.Index].last_view_names.Contains(lv_.name); // Draw the text e.Graphics.DrawString(text, fonts_.get_font( ((Control)sender).Font, bold, italic, false), brush, e.Bounds.X, e.Bounds.Y); }
0
40. Example
Project: PKHeX
Source File: SAV_FestivalPlaza.cs
Source File: SAV_FestivalPlaza.cs
private void LB_FacilityIndex_DrawItem(object sender, DrawItemEventArgs e) { e.DrawBackground(); e.Graphics.DrawString(((ListBox)sender).Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), new RectangleF(e.Bounds.X, e.Bounds.Y + (e.Bounds.Height - 12 >> 1), e.Bounds.Width, 12)); e.DrawFocusRectangle(); }
0
41. Example
Project: KeeAnywhere
Source File: ItemImagesContainer.cs
Source File: ItemImagesContainer.cs
private void imageListBox_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { if (e.Index >= 0 && this.imageListBox.Items.Count > 0 && e.Index < this.imageListBox.Items.Count ) { e.DrawBackground(); e.DrawFocusRectangle (); if(this.ImageList == null || this.ImageList .Images .Count == 0 || e.Index == this.imageListBox.Items.Count - 1) { e.Graphics.DrawImage (this.noneIcon ,new Rectangle (e.Bounds.X+2,e.Bounds.Y+5,this.noneIcon.Width ,this.noneIcon.Height)); e.Graphics.DrawString(this.imageListBox.Items [e.Index ].ToString (),e.Font ,new SolidBrush(e.ForeColor),(float)(e.Bounds .X+ 16 + 3),(float)(e.Bounds.Y+5)); } else { if(e.Index < this.imageListBox.Items.Count - 1) e.Graphics.DrawImage (this.ImageList.Images [e.Index ],new Rectangle (e.Bounds.X+2,e.Bounds.Y+5,this.ImageList.ImageSize.Width ,this.ImageList.ImageSize.Height)); else e.Graphics.DrawImage (this.noneIcon ,new Rectangle (e.Bounds.X+2,e.Bounds.Y+5,this.noneIcon.Width ,this.noneIcon.Height)); e.Graphics.DrawString(this.imageListBox.Items [e.Index ].ToString (),e.Font ,new SolidBrush(e.ForeColor),(float)(e.Bounds.X+this.ImageList.Images[e.Index].Width + 3),(float)(e.Bounds.Y+5)); } } }
0
42. Example
Project: LiveSplit
Source File: SpeedRunsLiveForm.cs
Source File: SpeedRunsLiveForm.cs
private void lstUsers_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index >= 0) { // // Draw the background of the ListBox control for each item. // Create a new Brush and initialize to a Black colored brush // by default. // e.DrawBackground(); Brush myBrush = (((ListBox)sender).Items[e.Index] as UserListItem).Brush; // // Draw the current item text based on the current // Font and the custom brush settings. // e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit; e.Graphics.DrawString(((ListBox)sender).Items[e.Index].ToString(), e.Font, myBrush, e.Bounds, StringFormat.GenericDefault); // // If the ListBox has focus, draw a focus rectangle // around the selected item. // e.DrawFocusRectangle(); } }
0
43. Example
Project: My-FyiReporting
Source File: ColorPicker.cs
Source File: ColorPicker.cs
protected override void OnDrawItem(DrawItemEventArgs e) { Graphics g = e.Graphics; Color BlockColor = Color.Empty; int left = RECTCOLOR_LEFT; if (e.State == DrawItemState.Selected || e.State == DrawItemState.None) e.DrawBackground(); if (e.Index == -1) { BlockColor = SelectedIndex < 0 ? BackColor : DesignerUtility.ColorFromHtml(this.Text, Color.Empty); } else BlockColor = DesignerUtility.ColorFromHtml((string)this.Items[e.Index], Color.Empty); // Fill rectangle if (BlockColor.IsEmpty && this.Text.StartsWith("=")) { g.DrawString("fx", this.Font, Brushes.Black, e.Bounds); } else { g.FillRectangle(new SolidBrush(BlockColor), left, e.Bounds.Top + RECTCOLOR_TOP, RECTCOLOR_WIDTH, ItemHeight - 2 * RECTCOLOR_TOP); } base.OnDrawItem(e); }
0
44. Example
Project: SCMBot
Source File: Main.cs
Source File: Main.cs
private void logListBox_DrawItem(object sender, DrawItemEventArgs e) { try /n ..... /n //View Source file for more details /n }
0
45. Example
Project: betterpoeditor
Source File: frmMain.cs
Source File: frmMain.cs
private void lbxEntries_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0) {/n ..... /n //View Source file for more details /n }
0
46. Example
Project: cs-script.npp
Source File: FavoritesPanel.cs
Source File: FavoritesPanel.cs
void scriptsList_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index != -1) { e.DrawBackground(); var script = scriptsList.Items[e.Index] as ScriptInfo; var brush = Brushes.Black; if ((e.State & DrawItemState.Selected) == DrawItemState.Selected) { brush = Brushes.White; } else { if (!File.Exists(script.File)) brush = Brushes.Gray; e.Graphics.FillRectangle(Brushes.White, e.Bounds); } e.Graphics.DrawString(script.ToString(), e.Font, brush, e.Bounds, StringFormat.GenericDefault); //e.DrawFocusRectangle(); } }
0
47. Example
Project: OpenLiveWriter
Source File: CategoryDisplayFormW3M1.cs
Source File: CategoryDisplayFormW3M1.cs
protected override void OnDrawItem(DrawItemEventArgs e) { if (e.Index != -1) { ParentCategoryComboItem comboItem = Items[e.Index] as ParentCategoryComboItem; e.DrawBackground(); // don't indent for main display of category string text = comboItem != null ? comboItem.ToString() : ""; if (e.Bounds.Width < Width) text = text.Trim(); Color textColor = ((e.State & DrawItemState.Selected) == DrawItemState.Selected) ? SystemColors.HighlightText : comboItem.TextColor; BidiGraphics bg = new BidiGraphics(e.Graphics, e.Bounds); bg.DrawText(text, e.Font, e.Bounds, textColor, TextFormatFlags.NoPrefix); e.DrawFocusRectangle(); } }
0
48. Example
Project: CodeInject
Source File: frmMain.cs
Source File: frmMain.cs
private void lstOutput_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index == -1) return; e.DrawBackground(); e.DrawFocusRectangle(); string[] parts = lstOutput.Items[e.Index].ToString().Split(new[] { '[', ']' }, StringSplitOptions.RemoveEmptyEntries); // 0 - time // 1 - Message Type // 2 - Message MessageType messageType = (MessageType)Enum.Parse(typeof(MessageType), parts[1], true); Font font = new Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular); SolidBrush brush = new SolidBrush(Color.Black); switch (messageType) { case MessageType.Error: brush.Color = Color.Red; break; case MessageType.Warning: brush.Color = Color.DarkOrange; break; case MessageType.Output: brush.Color = Color.Green; break; } e.Graphics.DrawString(lstOutput.Items[e.Index].ToString(), font, brush, e.Bounds); }
0
49. Example
Project: scada
Source File: FrmFontDialog.cs
Source File: FrmFontDialog.cs
private void cbFontName_DrawItem(object sender, DrawItemEventArgs e) { // ??????????? ??????? ???? ???????? e.DrawBackground(); // ??????????? ?????? ? ?????? ???????? FontListItem item = (FontListItem)cbFontName.Items[e.Index]; Font font = new Font(item.FontFamily, 14, FontStyle.Regular, GraphicsUnit.Pixel); e.Graphics.DrawString(item.ToString(), font, textBrush, e.Bounds.X + 2, e.Bounds.Y + 2); // ??????????? ?????? ???????? e.DrawFocusRectangle(); }
0
50. Example
Project: VectorChimera
Source File: ColorLists.cs
Source File: ColorLists.cs
private void DrawListColor(ListBox box, DrawItemEventArgs e) { e.DrawBackground(); if (e.Index < 0) return; int item = (int)box.Items[e.Index]; // Get the current item and cast it to MyListBoxItem int border = 5; int lineBorder = 2; e.Graphics.FillRectangle(new SolidBrush(Color.Black), new Rectangle (e.Bounds.X + border, e.Bounds.Y + border, e.Bounds.Width - border * 2, e.Bounds.Height - border * 2)); e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(item)), new Rectangle (e.Bounds.X + border + lineBorder, e.Bounds.Y + border + lineBorder, e.Bounds.Width - border * 2 - lineBorder * 2, e.Bounds.Height - border * 2 - lineBorder * 2)); e.DrawFocusRectangle(); }