private void DrawComboBoxItem(DrawItemEventArgs e) { HighlightState hover; string fontName = (string)base.ComboBox.Items[e.Index]; bool flag = (e.State & DrawItemState.Selected) > DrawItemState.None; bool flag2 = this.hasBeenShown && (e.Bounds.Width >= (base.ComboBox.DropDownWidth / 2)); if (!flag2) { hover = HighlightState.Default; } else if (flag) { hover = HighlightState.Hover; } else { hover = HighlightState.Default; } Color selectionBackColor = SelectionHighlight.GetSelectionBackColor(hover); int num = UIUtil.ScaleWidth(3); int num2 = num; int num3 = -1; this.selectionHighlightRenderer.HighlightState = hover; using (IDrawingContext context = DrawingContextUtil.FromGraphics(e.Graphics, e.Bounds, false, FactorySource.PerThread)) { RenderLayer layer = new RenderLayer(); context.Clear(new ColorRgba128Float?((ColorRgba128Float)PaintDotNet.Imaging.SystemColors.Window)); this.selectionHighlightRenderer.RenderBackground(context, e.Bounds.ToRectFloat()); SizedFontProperties menu = this.systemFonts.Menu; PaintDotNet.UI.Media.Brush textBrush = this.selectionHighlightRenderer.EmbeddedTextBrush; TextLayout textLayout = UIText.CreateLayout(context, fontName, menu, null, HotkeyRenderMode.Ignore, (double)(e.Bounds.Width - num2), (double)e.Bounds.Height); textLayout.ParagraphAlignment = ParagraphAlignment.Center; textLayout.WordWrapping = WordWrapping.NoWrap; int num5 = num + e.Bounds.X; context.DrawTextLayout((double)num5, (double)(e.Bounds.Y + num3), textLayout, textBrush, DrawTextOptions.None); ITextLayout cachedOrCreateResource = context.GetCachedOrCreateResource <ITextLayout>(textLayout); int num4 = (int)Math.Ceiling((double)(num5 + cachedOrCreateResource.Metrics.WidthMax)); PlacedBitmap bitmap = this.TryGetFontPreview(fontName, 16f, textBrush); if (bitmap == null) { IntPtr listHwnd = UIUtil.GetListBoxHwnd(base.ComboBox); Action callback = delegate { try { PlacedBitmap bitmap = this.GetOrCreateFontPreview(fontName, 16f, textBrush); if (listHwnd != IntPtr.Zero) { this.ComboBox.BeginInvoke(() => UIUtil.InvalidateHwnd(listHwnd)); } } catch (Exception) { } }; if (this.backgroundThread == null) { this.backgroundThread = new ThreadDispatcher(ApartmentState.MTA); } this.backgroundThread.Enqueue(QueueSide.Front, callback).Observe(); } if (flag2 && (bitmap != null)) { PaintDotNet.UI.Media.Brush brush; RectFloat num7; RectFloat num6 = new RectFloat((float)((e.Bounds.Right - num) - bitmap.Bitmap.Size.Width), num3 + ((float)Math.Floor((double)((e.Bounds.Y + ((e.Bounds.Height - bitmap.LayoutRect.Height) / 2.0)) - bitmap.LayoutRect.Top))), (float)bitmap.Bitmap.Size.Width, (float)bitmap.Bitmap.Size.Height); if (num6.Left > num4) { num7 = num6; brush = null; } else { num7 = num6; num7.X += num4 - num6.X; num7.X = (float)Math.Ceiling((double)num7.X); LinearGradientBrush brush2 = new LinearGradientBrush { ColorInterpolationMode = ColorInterpolationMode.SRgbLinearInterpolation, SpreadMethod = GradientSpreadMethod.Pad }; brush2.GradientStops.Add(new GradientStop(Color.White, 0.0)); brush2.GradientStops.Add(new GradientStop(Color.White, ((double)(e.Bounds.Width - UIUtil.ScaleWidth(0x18))) / ((double)e.Bounds.Width))); brush2.GradientStops.Add(new GradientStop(Color.Transparent, 1.0)); brush2.EndPoint = new PointDouble((double)e.Bounds.Width, 0.0); brush = brush2; } using (context.CreateLayer(null)) { context.PushLayer(layer, new RectDouble?(num7), null, AntialiasMode.Aliased, new Matrix3x2Double?(Matrix3x2Float.Identity), 1.0, brush, LayerOptions.None); context.DrawBitmap(bitmap.DeviceBitmap, new RectDouble?(num7), 1.0, BitmapInterpolationMode.Linear, null); context.PopLayer(); } } } }