Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Pull Request] Win安装包在安装和卸载时同步更新任务栏进度 #92

Merged
merged 3 commits into from
Aug 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Drawer.cs" />
<Compile Include="TaskbarManager.cs" />
<Compile Include="UninstallForm.cs">
<SubType>Form</SubType>
</Compile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ private void InstallProcess()

WebClient webClient = new WebClient();

TaskbarManager.SetProgressState(TaskbarProgressBarState.Indeterminate);

while (!File.Exists(filepath))
{
UpdateTip("正在下载 ...");
Expand Down Expand Up @@ -137,13 +139,16 @@ private void InstallProcess()

webClient.Dispose();

TaskbarManager.SetProgressState(TaskbarProgressBarState.Normal);

UpdateTip("下载完毕, 正在解压 ...");
Invoke(new Action(() =>
{
ProgressBar_Installing.Style = ProgressBarStyle.Blocks;
ProgressBar_Installing.Value = 0;
}));
UpdatePro(40);
TaskbarManager.SetProgressValue(40, 100);
Thread.Sleep(500);

ZipFile zip = new ZipFile();
Expand All @@ -152,10 +157,12 @@ private void InstallProcess()
UpdateTip("读取压缩包 ...");
Thread.Sleep(200);
zip = ZipFile.Read(filepath);
TaskbarManager.SetProgressValue(45, 100);
UpdatePro(45);
UpdateTip("解压压缩包 ...");
Thread.Sleep(200);
zip.ExtractAll(stfolder, ExtractExistingFileAction.OverwriteSilently);
TaskbarManager.SetProgressValue(50, 100);
UpdatePro(50);
zip.Dispose();
UpdateTip("解压完毕, 更新注册表 ...");
Expand All @@ -173,6 +180,7 @@ private void InstallProcess()
BeginCancel();
}
File.Delete(filepath);
TaskbarManager.SetProgressValue(60, 100);
UpdatePro(60);

UpdateTip("打开注册表 ...");
Expand All @@ -197,6 +205,7 @@ private void InstallProcess()
}
#endregion

TaskbarManager.SetProgressValue(65, 100);
UpdatePro(65);

Assembly assembly = Assembly.LoadFrom(modulePath);
Expand Down Expand Up @@ -224,6 +233,7 @@ private void InstallProcess()
}
#endregion

TaskbarManager.SetProgressValue(70, 100);
UpdatePro(70);

#region 更新 文件关联
Expand Down Expand Up @@ -265,6 +275,7 @@ private void InstallProcess()
BeginCancel();
}

TaskbarManager.SetProgressValue(75, 100);
UpdatePro(75);

UpdateTip("更新快捷方式 ...");
Expand All @@ -289,6 +300,7 @@ private void InstallProcess()
BeginCancel();
}

TaskbarManager.SetProgressValue(80, 100);
UpdatePro(80);

UpdateTip("生成卸载程序 ...");
Expand All @@ -314,6 +326,7 @@ private void InstallProcess()
BeginCancel();
}

TaskbarManager.SetProgressValue(90, 100);
UpdatePro(90);

UpdateTip("更新安装目录权限 ...");
Expand Down Expand Up @@ -354,6 +367,7 @@ private void InstallProcess()
BeginCancel();
}

TaskbarManager.SetProgressValue(100, 100);
UpdatePro(100);

UpdateTip("安装目录权限更新成功 ...");
Expand All @@ -364,6 +378,8 @@ private void InstallProcess()
{
MessageBox.Show("Install succeed! | 安装成功", "KitX",
MessageBoxButtons.OK, MessageBoxIcon.Information);

TaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);
}));

try
Expand Down Expand Up @@ -428,6 +444,8 @@ private void CreateShortCut(ref WshShell shell, string location, string targetPa

private void CancelProcess()
{
TaskbarManager.SetProgressState(TaskbarProgressBarState.Paused);

Invoke(new Action(() =>
{
Btn_BeginInstall.Enabled = false;
Expand All @@ -447,6 +465,8 @@ private void CancelProcess()

Directory.Delete(stfolder, true);

TaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);

Invoke(new Action(() =>
{
UpdateTip("等待用户操作 ...");
Expand Down
Loading