protected override void OnDrawItem(DrawItemEventArgs e) { object obj2; if (this.Font.Height < 0) { this.Font = Control.DefaultFont; } if (e.Index < 0) { return; } if (e.Index < this.Items.Count) { obj2 = this.Items[e.Index]; } else { obj2 = base.NativeGetItemText(e.Index); } Rectangle bounds = e.Bounds; int num = 1; int num2 = this.Font.Height + (2 * num); ButtonState normal = ButtonState.Normal; if (this.flat) { normal |= ButtonState.Flat; } if (e.Index < this.Items.Count) { switch (this.CheckedItems.GetCheckedState(e.Index)) { case CheckState.Checked: normal |= ButtonState.Checked; break; case CheckState.Indeterminate: normal |= ButtonState.Checked | ButtonState.Inactive; break; } } if (Application.RenderWithVisualStyles) { CheckBoxState state = CheckBoxRenderer.ConvertFromButtonState(normal, false, (e.State & DrawItemState.HotLight) == DrawItemState.HotLight); this.idealCheckSize = CheckBoxRenderer.GetGlyphSize(e.Graphics, state).Width; } int num3 = Math.Max((num2 - this.idealCheckSize) / 2, 0); if ((num3 + this.idealCheckSize) > bounds.Height) { num3 = bounds.Height - this.idealCheckSize; } Rectangle rectangle = new Rectangle(bounds.X + num, bounds.Y + num3, this.idealCheckSize, this.idealCheckSize); if (this.RightToLeft == RightToLeft.Yes) { rectangle.X = ((bounds.X + bounds.Width) - this.idealCheckSize) - num; } if (Application.RenderWithVisualStyles) { CheckBoxState state3 = CheckBoxRenderer.ConvertFromButtonState(normal, false, (e.State & DrawItemState.HotLight) == DrawItemState.HotLight); CheckBoxRenderer.DrawCheckBox(e.Graphics, new Point(rectangle.X, rectangle.Y), state3); } else { ControlPaint.DrawCheckBox(e.Graphics, rectangle, normal); } Rectangle rect = new Rectangle((bounds.X + this.idealCheckSize) + (num * 2), bounds.Y, bounds.Width - (this.idealCheckSize + (num * 2)), bounds.Height); if (this.RightToLeft == RightToLeft.Yes) { rect.X = bounds.X; } string s = ""; Color highlight = (this.SelectionMode != System.Windows.Forms.SelectionMode.None) ? e.BackColor : this.BackColor; Color grayText = (this.SelectionMode != System.Windows.Forms.SelectionMode.None) ? e.ForeColor : this.ForeColor; if (!base.Enabled) { grayText = SystemColors.GrayText; } Font font = this.Font; s = base.GetItemText(obj2); if ((this.SelectionMode != System.Windows.Forms.SelectionMode.None) && ((e.State & DrawItemState.Selected) == DrawItemState.Selected)) { if (base.Enabled) { highlight = SystemColors.Highlight; grayText = SystemColors.HighlightText; } else { highlight = SystemColors.InactiveBorder; grayText = SystemColors.GrayText; } } using (Brush brush = new SolidBrush(highlight)) { e.Graphics.FillRectangle(brush, rect); } Rectangle layoutRectangle = new Rectangle(rect.X + 1, rect.Y, rect.Width - 1, rect.Height - (num * 2)); if (this.UseCompatibleTextRendering) { using (StringFormat format = new StringFormat()) { if (base.UseTabStops) { float num4 = 3.6f * this.Font.Height; float[] tabStops = new float[15]; float num5 = -(this.idealCheckSize + (num * 2)); for (int i = 1; i < tabStops.Length; i++) { tabStops[i] = num4; } if (Math.Abs(num5) < num4) { tabStops[0] = num4 + num5; } else { tabStops[0] = num4; } format.SetTabStops(0f, tabStops); } else if (base.UseCustomTabOffsets) { float[] destination = new float[base.CustomTabOffsets.Count]; base.CustomTabOffsets.CopyTo(destination, 0); format.SetTabStops(0f, destination); } if (this.RightToLeft == RightToLeft.Yes) { format.FormatFlags |= StringFormatFlags.DirectionRightToLeft; } format.FormatFlags |= StringFormatFlags.NoWrap; format.Trimming = StringTrimming.None; using (SolidBrush brush2 = new SolidBrush(grayText)) { e.Graphics.DrawString(s, font, brush2, layoutRectangle, format); } goto Label_049B; } } TextFormatFlags flags = TextFormatFlags.Default; flags |= TextFormatFlags.NoPrefix; if (base.UseTabStops || base.UseCustomTabOffsets) { flags |= TextFormatFlags.ExpandTabs; } if (this.RightToLeft == RightToLeft.Yes) { flags |= TextFormatFlags.RightToLeft; flags |= TextFormatFlags.Right; } TextRenderer.DrawText(e.Graphics, s, font, layoutRectangle, grayText, flags); Label_049B: if (((e.State & DrawItemState.Focus) == DrawItemState.Focus) && ((e.State & DrawItemState.NoFocusRect) != DrawItemState.NoFocusRect)) { ControlPaint.DrawFocusRectangle(e.Graphics, rect, grayText, highlight); } }