Fix listview not going to video position - thx OmrSi :)

Fix  #3430
This commit is contained in:
Nikolaj Olsson 2019-02-28 19:03:31 +01:00
parent 1df095b43c
commit e77e1b6380

View File

@ -1456,18 +1456,15 @@ namespace Nikse.SubtitleEdit.Controls
selectedItem.Focused = true; selectedItem.Focused = true;
var topIndex = topItem.Index; var topIndex = topItem.Index;
int bottomIndex = topIndex + (Height - 30) / GetItemRect(0).Height; var numberOfVisibleItems = (Height - 30) / GetItemRect(0).Height;
if (index < topIndex || index > bottomIndex) int bottomIndex = topIndex + numberOfVisibleItems;
if (index >= bottomIndex)
{ {
var nextScrollToIndex = index + (bottomIndex - topIndex) / 2; Items[Math.Min(Items.Count - 1, index + numberOfVisibleItems)].EnsureVisible();
if (nextScrollToIndex < Items.Count && nextScrollToIndex > 1) }
{ else if (index < topIndex)
Items[nextScrollToIndex].EnsureVisible(); {
} Items[Math.Max(0, index - numberOfVisibleItems / 2)].EnsureVisible();
else
{
selectedItem.EnsureVisible();
}
} }
EndUpdate(); EndUpdate();
} }