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); } }
private void RegionListBox_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0) { return; } Font txtColorFont = new Font("Arial", 6); 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 foundRegion = Regions.FirstOrDefault(p => p.RegionName == m_RegionListing.Items[e.Index].ToString()); if (foundRegion != null) { e.Graphics.FillRectangle(palette.Brush(foundRegion.RColor), colorBounds); e.Graphics.DrawRectangle(palette.Pen(e.ForeColor, 0), colorBounds); e.Graphics.DrawString(m_RegionListing.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, StringFormats.Left); e.Graphics.DrawString("123", txtColorFont, palette.Brush(foundRegion.TextColor), colorBounds, StringFormats.Center); } } }
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); } }
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); } }
private void RegionListBox_DrawItem(object sender, DrawItemEventArgs e) { if (e.Index < 0) return; Font txtColorFont = new Font("Arial", 6); 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 foundRegion = Regions.FirstOrDefault(p => p.RegionName == m_RegionListing.Items[e.Index].ToString()); if (foundRegion != null) { e.Graphics.FillRectangle(palette.Brush(foundRegion.RColor), colorBounds); e.Graphics.DrawRectangle(palette.Pen(e.ForeColor, 0), colorBounds); e.Graphics.DrawString(m_RegionListing.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, StringFormats.Left); e.Graphics.DrawString("123", txtColorFont, palette.Brush(foundRegion.TextColor), colorBounds, StringFormats.Center); } } }
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); StringFormat format = new StringFormat {Trimming = StringTrimming.EllipsisCharacter}; e.Graphics.DrawString(m_colorListBox.Items[e.Index].ToString(), e.Font, palette.Brush(e.ForeColor), textBounds, format); } }