mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-26 15:02:35 +02:00
Optimize comboBox item selection
The previous implementation of the comboBox resulted in the processing of all items every time. This commit optimizes this process by only dealing with visible items, thus improving efficiency. Calculations for the visible range are now included, starting from the top item and only iterating over visible items. Signed-off-by: Ivandro Jao <ivandrofly@gmail.com>
This commit is contained in:
parent
998ee5ca95
commit
c8951235a2
@ -1029,8 +1029,11 @@ namespace Nikse.SubtitleEdit.Controls
|
||||
return;
|
||||
}
|
||||
|
||||
var cachedCount = _listView.Items.Count;
|
||||
for (var i = 0; i < cachedCount; i++)
|
||||
var topItem = _listView.TopItem;
|
||||
// calculate visible range
|
||||
var count = Math.Min(topItem.Index + _listView.Bounds.Height / topItem.Bounds.Height, _listView.Items.Count);
|
||||
|
||||
for (var i = topItem.Index; i < count; i++)
|
||||
{
|
||||
var rectangle = _listView.GetItemRect(i);
|
||||
if (rectangle.Contains(mouseArgs.Location))
|
||||
|
Loading…
Reference in New Issue
Block a user