private async void ItemClickedCommand_Execute(DownloadableApktool item) { if (item == null || !ServerApktools.Contains(item)) { return; } using (BusyDisposable()) using (ProgressBarDisposable()) { string downloadingApktoolPath = Path.Combine(GlobalVariables.PathToApktoolVersions, $"apktool_{item.Version}.jar"); if (item.Installed == InstallOptionsEnum.ToUninstall) { try { IOUtils.DeleteFile(downloadingApktoolPath); item.Installed = InstallOptionsEnum.ToInstall; } catch (UnauthorizedAccessException) { if (CommonUtils.RunAsAdmin(GlobalVariables.PathToAdminScripter, $"\"delete file|{downloadingApktoolPath}\"", out Process process)) { process.WaitForExit(); item.Installed = InstallOptionsEnum.ToInstall; } } return; } if (!CommonUtils.CheckRights()) { if (CommonUtils.RunAsAdmin(GlobalVariables.PathToAdminScripter, $"\"download|{item.Link}|{downloadingApktoolPath}\"", out Process process)) { process.WaitForExit(); item.Installed = InstallOptionsEnum.ToUninstall; } return; } Progress.Value = 0; await _webClient.DownloadFileTaskAsync( new Uri(item.Link), downloadingApktoolPath ); item.Installed = InstallOptionsEnum.ToUninstall; } }
public override async Task LoadItems() { using (BusyDisposable()) { try { List <DownloadableApktool> items = await DownloadApktoolsListAsync(); ServerApktools.ReplaceRange(items); } catch (Exception) { MessBox.ShowDial(StringResources.CanNotRecieveApktoolsList, StringResources.ErrorLower); } } }