Refactor and enhance DownloadManager application

Refactored and enhanced the DownloadManager application with significant updates across multiple files. Key changes include:

- **App.xaml.cs**: Re-added necessary imports, updated service registrations, and made `OnStartup` asynchronous.
- **DownloadManager.csproj**: Updated target framework, application icon, and added assembly version.
- **DownloadManager.sln**: Updated project format and added configurations for multiple platforms.
- **DownloadManagerService.cs**: Added `HistoryStorageService` dependency, introduced `Initial` method, and improved task management.
- **DownloadWorker.cs**: Enhanced error handling and changed `StartDownloadAsync` to `StartDownload`.
- **ViewModels**: Refactored to use dependency injection, updated task initialization, and added new commands for settings management.
- **UI Updates**: Improved `DownloadingPage.xaml` and `WaitingPage.xaml` with `ListView` and added headers. Restructured `SettingsPage.xaml` for better organization and added new settings options.
- **MainWindow**: Enhanced navigation and applied user-defined themes and backdrops.
- **New Files**: Added `HistoryStorageService.cs`, `ThemeToIndexConverter.cs`, `CompletedItemData.cs`, `Settings.Designer.cs`, `Settings.settings`, `Constants.cs`, `CompletedPageViewModel.cs`, `CompletedPage.xaml`, and `CompletedPage.xaml.cs` to support new features and improvements.

These changes aim to improve the application's robustness, maintainability, and user experience.
This commit is contained in:
Misaki
2024-07-03 04:37:02 +09:00
parent 3a59979efd
commit 4acbd6ba49
37 changed files with 1406 additions and 132 deletions

View File

@@ -3,7 +3,6 @@ using DownloadManager.Models;
using DownloadManager.Models.UrlGetter;
using DownloadManager.Utilities;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
namespace DownloadManager.DownloaderCore;
@@ -13,6 +12,8 @@ public class DownloadWorker(DownloadItemData itemData)
private DownloadItemData _downloadData = itemData;
public DownloadItemData DownloadData => _downloadData;
public string errorMessage = string.Empty;
public Action? OnDownloadStarted;
public Action? OnDownloadFileCompleted;
public Action? OnDownloadStop;
@@ -77,12 +78,14 @@ public class DownloadWorker(DownloadItemData itemData)
if (e.Error != null)
{
_downloadData.Status = DownloadStatus.Failed;
throw e.Error;
errorMessage = e.Error.Message;
//throw e.Error;
}
else
{
_downloadData.Status = DownloadStatus.Completed;
_worker!.Dispose();
_worker = null;
// Check md5
if (_downloadData.MD5 != null)
@@ -109,7 +112,7 @@ public class DownloadWorker(DownloadItemData itemData)
await Task.Delay(1000);
await BuildDownloadRequestAsync();
StartDownloadAsync();
StartDownload();
return true;
}
@@ -120,7 +123,7 @@ public class DownloadWorker(DownloadItemData itemData)
}
}
public void StartDownloadAsync()
public void StartDownload()
{
if (_worker == null)
return;