mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-12 09:45:22 -05:00
BeginInvoke for Folder datagrid
auto-picks the correct thread for the control/form batch editor progressbar is useless cuz the editor is so fast for 99.99% of uses (only really matters for processing a folder on slow drives), yay speed.
This commit is contained in:
@@ -36,7 +36,7 @@ private static void Main()
|
||||
new Task(() => splash.ShowDialog()).Start();
|
||||
new Task(() => EncounterEvent.RefreshMGDB(WinForms.Main.MGDatabasePath)).Start();
|
||||
var main = new Main();
|
||||
splash.Invoke(splash.ForceClose);
|
||||
splash.BeginInvoke(splash.ForceClose);
|
||||
Application.Run(main);
|
||||
}
|
||||
|
||||
|
||||
@@ -204,22 +204,15 @@ void process(IList<SlotCache> d)
|
||||
}
|
||||
|
||||
// Progress Bar
|
||||
private void SetupProgressBar(int count)
|
||||
private void SetupProgressBar(int count) => PB_Show.BeginInvoke(() =>
|
||||
{
|
||||
MethodInvoker mi = () => { PB_Show.Minimum = 0; PB_Show.Step = 1; PB_Show.Value = 0; PB_Show.Maximum = count; };
|
||||
if (PB_Show.InvokeRequired)
|
||||
PB_Show.Invoke(mi);
|
||||
else
|
||||
mi.Invoke();
|
||||
}
|
||||
PB_Show.Minimum = 0;
|
||||
PB_Show.Step = 1;
|
||||
PB_Show.Value = 0;
|
||||
PB_Show.Maximum = count;
|
||||
});
|
||||
|
||||
private void SetProgressBar(int position)
|
||||
{
|
||||
if (PB_Show.InvokeRequired)
|
||||
PB_Show.Invoke((MethodInvoker)(() => PB_Show.Value = position));
|
||||
else
|
||||
PB_Show.Value = position;
|
||||
}
|
||||
private void SetProgressBar(int position) => PB_Show.BeginInvoke(() => PB_Show.Value = position);
|
||||
|
||||
private void ProcessSAV(IList<SlotCache> data, IReadOnlyList<StringInstruction> Filters, IReadOnlyList<StringInstruction> Instructions)
|
||||
{
|
||||
@@ -239,7 +232,10 @@ private void ProcessSAV(IList<SlotCache> data, IReadOnlyList<StringInstruction>
|
||||
|
||||
var spec = pk.Species;
|
||||
if (spec == 0 || spec > max)
|
||||
{
|
||||
b.ReportProgress(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.Source is SlotInfoBox info && SAV.GetSlotFlags(info.Box, info.Slot).IsOverwriteProtected())
|
||||
editor.AddSkipped();
|
||||
|
||||
@@ -30,6 +30,8 @@ public SAV_FolderList(Action<SaveFile> openSaveFile)
|
||||
|
||||
dgDataRecent.ContextMenuStrip = GetContextMenu(dgDataRecent);
|
||||
dgDataBackup.ContextMenuStrip = GetContextMenu(dgDataBackup);
|
||||
dgDataRecent.Sorted += (_, _) => GetFilterText(dgDataRecent);
|
||||
dgDataBackup.Sorted += (_, _) => GetFilterText(dgDataBackup);
|
||||
|
||||
var extra = Paths.Select(z => z.Path).Where(z => z != Main.BackupPath).Distinct();
|
||||
var backup = SaveFinder.GetSaveFiles(drives, false, [Main.BackupPath], false);
|
||||
@@ -274,17 +276,15 @@ private SaveList<SavePreview> PopulateData(DataGridView dgData, IEnumerable<Save
|
||||
var sav = new SavePreview(next, Paths);
|
||||
void Load() => LoadEntry(dgData, list, sav);
|
||||
|
||||
dgData.Invoke(Load);
|
||||
dgData.BeginInvoke(Load);
|
||||
ctr++;
|
||||
if (ctr < 15 && ctr % 7 == 0)
|
||||
dgData.Invoke(RefreshResize);
|
||||
dgData.BeginInvoke(RefreshResize);
|
||||
}
|
||||
dgData.Invoke(RefreshResize);
|
||||
dgData.BeginInvoke(RefreshResize);
|
||||
enumerator.Dispose();
|
||||
});
|
||||
|
||||
dgData.Sorted += (_, _) => GetFilterText(dgData);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user