Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ private class CursorUI : ListBox
private IWindowsFormsEditorService? _editorService;
private readonly TypeConverter _cursorConverter;
private readonly Dictionary<(Cursor cursor, int dpi), int> _cursorWidthCache = new();
private readonly int _cursorWidth;

public CursorUI()
{
Expand All @@ -39,6 +40,10 @@ public CursorUI()
Items.Add(obj);
}
}

using Icon defaultIcon = Icon.FromHandle(Cursors.Default.Handle);
using Icon scaledDefaultIcon = ScaleHelper.ScaleSmallIconToDpi(defaultIcon, DeviceDpi);
_cursorWidth = scaledDefaultIcon.Size.Width;
Comment thread
SimonZhao888 marked this conversation as resolved.
Outdated
}

public object? Value { get; private set; }
Expand Down Expand Up @@ -70,11 +75,11 @@ protected override void OnDrawItem(DrawItemEventArgs e)
int cursorWidth = GetCursorWidthForDpi(cursor, DeviceDpi);
Comment thread
SimonZhao888 marked this conversation as resolved.
Outdated

e.DrawBackground();
e.Graphics.FillRectangle(SystemBrushes.Control, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, cursorWidth, e.Bounds.Height - 4));
e.Graphics.DrawRectangle(SystemPens.WindowText, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, cursorWidth - 1, e.Bounds.Height - 4 - 1));
e.Graphics.FillRectangle(SystemBrushes.Control, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, _cursorWidth, e.Bounds.Height - 4));
e.Graphics.DrawRectangle(SystemPens.WindowText, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, _cursorWidth - 1, e.Bounds.Height - 4 - 1));

cursor.DrawStretched(e.Graphics, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, cursorWidth, e.Bounds.Height - 4));
e.Graphics.DrawString(text, font, brushText, e.Bounds.X + cursorWidth + 4, e.Bounds.Y + (e.Bounds.Height - font.Height) / 2);
cursor.DrawStretched(e.Graphics, new Rectangle(e.Bounds.X + 2, e.Bounds.Y + 2, _cursorWidth, e.Bounds.Height - 4));
e.Graphics.DrawString(text, font, brushText, e.Bounds.X + _cursorWidth + 4, e.Bounds.Y + (e.Bounds.Height - font.Height) / 2);
}
}

Expand Down
Loading