mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-11 15:07:11 +00:00
Speed up Folder List entry adding
Don't autosize columns on each row addition About 15 rows appear; resize on row 0, 7, and 14, and once more when finished. was O(n), now is O(min(n,3)+1)
This commit is contained in:
parent
2e88da9d3c
commit
5155e4d29b
1 changed files with 13 additions and 3 deletions
|
@ -334,6 +334,8 @@ namespace PKHeX.WinForms
|
|||
var first = enumerator.Current;
|
||||
var sav1 = new SavePreview(first, GetParentFolderName(first));
|
||||
LoadEntryInitial(dgData, list, sav1);
|
||||
|
||||
int ctr = 1; // refresh every 7 until 15+ are loaded
|
||||
Task.Run(async () => // load the rest async
|
||||
{
|
||||
while (!dgData.IsHandleCreated)
|
||||
|
@ -345,13 +347,24 @@ namespace PKHeX.WinForms
|
|||
continue;
|
||||
var sav = new SavePreview(next, GetParentFolderName(next));
|
||||
dgData.Invoke(new Action(() => LoadEntry(dgData, list, sav)));
|
||||
ctr++;
|
||||
if (ctr < 15 && ctr % 7 == 0)
|
||||
dgData.Invoke(new Action(() => Refresh(dgData)));
|
||||
}
|
||||
dgData.Invoke(new Action(() => Refresh(dgData)));
|
||||
enumerator.Dispose();
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static void Refresh(DataGridView dgData)
|
||||
{
|
||||
dgData.SuspendLayout();
|
||||
dgData.AutoResizeColumns();
|
||||
dgData.Invalidate();
|
||||
}
|
||||
|
||||
private static void LoadEntryInitial(DataGridView dgData, SaveList<SavePreview> list, SavePreview sav)
|
||||
{
|
||||
list.Add(sav);
|
||||
|
@ -364,13 +377,10 @@ namespace PKHeX.WinForms
|
|||
|
||||
private void LoadEntry(DataGridView dgData, ICollection<SavePreview> list, SavePreview sav)
|
||||
{
|
||||
dgData.SuspendLayout();
|
||||
list.Add(sav);
|
||||
int count = list.Count;
|
||||
if (CB_FilterColumn.SelectedIndex != 0)
|
||||
ToggleRowVisibility(dgData, CB_FilterColumn.SelectedIndex - 1, TB_FilterTextContains.Text, count - 1);
|
||||
dgData.AutoResizeColumns();
|
||||
dgData.ResumeLayout();
|
||||
}
|
||||
|
||||
private void ChangeFilterIndex(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in a new issue