Updater added

This commit is contained in:
2022-08-28 12:59:41 +03:00
parent d689eee7fa
commit 68a83b052a
16 changed files with 732 additions and 110 deletions

View File

@@ -46,6 +46,32 @@ namespace PluginManager.Others
private int position = 1;
private bool positive = true;
private bool isRunning;
public async void Start()
{
if (type != ProgressBarType.NO_END)
throw new Exception("Only NO_END progress bar can use this method");
if (isRunning)
throw new Exception("This progress bar is already running");
isRunning = true;
while (isRunning)
{
UpdateNoEnd();
await System.Threading.Tasks.Task.Delay(100);
}
}
public void Stop()
{
if (type != ProgressBarType.NO_END)
throw new Exception("Only NO_END progress bar can use this method");
if (!isRunning)
throw new Exception("Can not stop a progressbar that did not start");
isRunning = false;
}
public void Update(float progress)
{
switch (type)

View File

@@ -168,9 +168,7 @@ namespace PluginManager.Others
/// <returns></returns>
public static async Task ExtractArchive(string zip, string folder, IProgress<float> progress, UnzipProgressType type)
{
if (!Directory.Exists(folder)) Directory.CreateDirectory(folder);
Directory.CreateDirectory(folder);
using (ZipArchive archive = ZipFile.OpenRead(zip))
{
if (type == UnzipProgressType.PercentageFromNumberOfFiles)
@@ -194,7 +192,8 @@ namespace PluginManager.Others
currentZIPFile++;
await Task.Delay(10);
progress.Report((float)currentZIPFile / totalZIPFiles * 100);
if (progress != null)
progress.Report((float)currentZIPFile / totalZIPFiles * 100);
}
}
else if (type == UnzipProgressType.PercentageFromTotalSize)
@@ -224,7 +223,8 @@ namespace PluginManager.Others
}
await Task.Delay(10);
progress.Report((float)currentSize / zipSize * 100);
if (progress != null)
progress.Report((float)currentSize / zipSize * 100);
}
}
}