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

@@ -0,0 +1,12 @@
namespace DownloadManager.Models
{
public struct CompletedItemData
{
public string Name { get; set; }
public string Url { get; set; }
public string SavePath { get; set; }
public string FullName { get; set; }
public string Status { get; set; }
public string ErrorMessage { get; set; }
}
}

View File

@@ -19,7 +19,7 @@ public partial class DownloadItemData : ObservableObject
}
[ObservableProperty]
private string? fileName;
private string fileName = string.Empty;
[ObservableProperty]
private string filePath;

View File

@@ -9,4 +9,4 @@ namespace DownloadManager.Models.UrlGetter
[Description("Yande post URL")]
Yande,
}
}
}

View File

@@ -7,7 +7,7 @@ using System.Text.Json;
namespace DownloadManager.Models.UrlGetter;
public class YandeUrlGetter : IUrlGetter
{
readonly HttpClient client = new ();
readonly HttpClient client = new();
const int maxRetries = 3;
const int delayMilliseconds = 1000;
@@ -16,7 +16,7 @@ public class YandeUrlGetter : IUrlGetter
// Get the ID of the post from the URL
var id = taskUrl.Split("https://yande.re/post/show/").Last();
for (int attempt = 0; attempt < maxRetries; attempt++)
for (var attempt = 0; attempt < maxRetries; attempt++)
{
try
{
@@ -36,13 +36,14 @@ public class YandeUrlGetter : IUrlGetter
return new FileUrl(null, null, null);
}
if (!firstElement.TryGetProperty("md5", out var md5Element))
{
return new FileUrl(null, null, null);
}
var fileUrl = fileUrlElement.GetString();
var fileName = Path.GetFileName(fileUrl)?.ToUnescapedString();
if (!firstElement.TryGetProperty("md5", out var md5Element))
{
return new FileUrl(fileUrl, fileName, null);
}
var md5 = md5Element.GetString();
return new FileUrl(fileUrl, fileName, md5);