diff --git a/WindowsTools/Properties/AssemblyInfo.cs b/WindowsTools/Properties/AssemblyInfo.cs
index ea13ed8..74f3c60 100644
--- a/WindowsTools/Properties/AssemblyInfo.cs
+++ b/WindowsTools/Properties/AssemblyInfo.cs
@@ -4,8 +4,8 @@
[assembly: AssemblyCompany("高怡飞")]
[assembly: AssemblyCopyright("Copyright ©2024 高怡飞, All Rights Reserved.")]
[assembly: AssemblyDescription("Windows 工具箱")]
-[assembly: AssemblyFileVersion("2.5.528.0")]
-[assembly: AssemblyInformationalVersion("2.5.528.0")]
+[assembly: AssemblyFileVersion("2.5.602.0")]
+[assembly: AssemblyInformationalVersion("2.5.602.0")]
[assembly: AssemblyProduct("Windows 工具箱")]
[assembly: AssemblyTitle("Windows 工具箱")]
-[assembly: AssemblyVersion("2.5.528.0")]
+[assembly: AssemblyVersion("2.5.602.0")]
diff --git a/WindowsTools/Services/Controls/Download/BitsService.cs b/WindowsTools/Services/Controls/Download/BitsService.cs
index c0f1281..9b79b88 100644
--- a/WindowsTools/Services/Controls/Download/BitsService.cs
+++ b/WindowsTools/Services/Controls/Download/BitsService.cs
@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Diagnostics.Tracing;
using System.IO;
-using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using WindowsTools.Services.Root;
@@ -129,7 +128,7 @@ public static unsafe void CreateDownload(string url, string saveFilePath)
DownloadID = downloadID
};
backgroundCopyCallback.StatusChanged += OnStatusChanged;
- downloadJob.SetNotifyInterface(new UnknownWrapper(backgroundCopyCallback).WrappedObject);
+ downloadJob.SetNotifyInterface(backgroundCopyCallback);
downloadJob.GetProgress(out BG_JOB_PROGRESS progress);
DownloadCreated?.Invoke(backgroundCopyCallback.DownloadID, Path.GetFileName(saveFilePath), saveFilePath, url, progress.BytesTotal is ulong.MaxValue ? 0 : progress.BytesTotal);
diff --git a/WindowsTools/Services/Controls/Download/DeliveryOptimizationService.cs b/WindowsTools/Services/Controls/Download/DeliveryOptimizationService.cs
index 532aaf5..042eb14 100644
--- a/WindowsTools/Services/Controls/Download/DeliveryOptimizationService.cs
+++ b/WindowsTools/Services/Controls/Download/DeliveryOptimizationService.cs
@@ -80,7 +80,7 @@ public static void CreateDownload(string url, string saveFilePath)
DODownloadStatusCallback doDownloadStatusCallback = new();
doDownloadStatusCallback.StatusChanged += OnStatusChanged;
- doDownload.SetProperty(DODownloadProperty.DODownloadProperty_CallbackInterface, new UnknownWrapper(doDownloadStatusCallback).WrappedObject);
+ doDownload.SetProperty(DODownloadProperty.DODownloadProperty_CallbackInterface, new UnknownWrapper(doDownloadStatusCallback));
doDownload.SetProperty(DODownloadProperty.DODownloadProperty_ForegroundPriority, true);
doDownload.GetProperty(DODownloadProperty.DODownloadProperty_Id, out object id);
@@ -96,7 +96,7 @@ public static void CreateDownload(string url, string saveFilePath)
}
}
- doDownload.Start(IntPtr.Zero);
+ int Result = doDownload.Start(IntPtr.Zero);
}
}
catch (Exception e)
diff --git a/WindowsTools/Strings/AddDownloadTask.Designer.cs b/WindowsTools/Strings/AddDownloadTask.Designer.cs
deleted file mode 100644
index 188d4cc..0000000
--- a/WindowsTools/Strings/AddDownloadTask.Designer.cs
+++ /dev/null
@@ -1,117 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// 此代码由工具生成。
-// 运行时版本:4.0.30319.42000
-//
-// 对此文件的更改可能会导致不正确的行为,并且如果
-// 重新生成代码,这些更改将会丢失。
-//
-//------------------------------------------------------------------------------
-
-namespace WindowsTools.Strings {
- using System;
-
-
- ///
- /// 一个强类型的资源类,用于查找本地化的字符串等。
- ///
- // 此类是由 StronglyTypedResourceBuilder
- // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
- // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
- // (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- public class AddDownloadTask {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal AddDownloadTask() {
- }
-
- ///
- /// 返回此类使用的缓存的 ResourceManager 实例。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WindowsTools.Strings.AddDownloadTask", typeof(AddDownloadTask).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// 重写当前线程的 CurrentUICulture 属性,对
- /// 使用此强类型资源类的所有资源查找执行重写。
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- public static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// 查找类似 Add download task 的本地化字符串。
- ///
- public static string AddTask {
- get {
- return ResourceManager.GetString("AddTask", resourceCulture);
- }
- }
-
- ///
- /// 查找类似 Please input the download file name 的本地化字符串。
- ///
- public static string DownloadFileNamePHText {
- get {
- return ResourceManager.GetString("DownloadFileNamePHText", resourceCulture);
- }
- }
-
- ///
- /// 查找类似 Select the folder to save 的本地化字符串。
- ///
- public static string DownloadFolderPHText {
- get {
- return ResourceManager.GetString("DownloadFolderPHText", resourceCulture);
- }
- }
-
- ///
- /// 查找类似 Please input the download link 的本地化字符串。
- ///
- public static string DownloadLinkPHText {
- get {
- return ResourceManager.GetString("DownloadLinkPHText", resourceCulture);
- }
- }
-
- ///
- /// 查找类似 The file path you entered is invalid. Please try again 的本地化字符串。
- ///
- public static string FileNameInvalid {
- get {
- return ResourceManager.GetString("FileNameInvalid", resourceCulture);
- }
- }
-
- ///
- /// 查找类似 Select folder 的本地化字符串。
- ///
- public static string SelectFolderToolTip {
- get {
- return ResourceManager.GetString("SelectFolderToolTip", resourceCulture);
- }
- }
- }
-}
diff --git a/WindowsTools/Strings/AddDownloadTask.en-us.resx b/WindowsTools/Strings/AddDownloadTask.en-us.resx
deleted file mode 100644
index d81755c..0000000
--- a/WindowsTools/Strings/AddDownloadTask.en-us.resx
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- Add download task
-
-
- Please input the download file name
-
-
- Select the folder to save
-
-
- Please input the download link
-
-
- The file path you entered is invalid. Please try again
-
-
- Select folder
-
-
\ No newline at end of file
diff --git a/WindowsTools/Strings/AddDownloadTask.resx b/WindowsTools/Strings/AddDownloadTask.resx
deleted file mode 100644
index d81755c..0000000
--- a/WindowsTools/Strings/AddDownloadTask.resx
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- Add download task
-
-
- Please input the download file name
-
-
- Select the folder to save
-
-
- Please input the download link
-
-
- The file path you entered is invalid. Please try again
-
-
- Select folder
-
-
\ No newline at end of file
diff --git a/WindowsTools/Strings/AddDownloadTask.zh-hans.resx b/WindowsTools/Strings/AddDownloadTask.zh-hans.resx
deleted file mode 100644
index 93267f5..0000000
--- a/WindowsTools/Strings/AddDownloadTask.zh-hans.resx
+++ /dev/null
@@ -1,138 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- 添加下载任务
-
-
- 请输入下载文件名称
-
-
- 选择保存的文件夹
-
-
- 请输入下载链接
-
-
- 您输入的文件路径不合法,请重新输入
-
-
- 选择文件夹
-
-
\ No newline at end of file
diff --git a/WindowsTools/Strings/DownloadManager.Designer.cs b/WindowsTools/Strings/DownloadManager.Designer.cs
index 280a8ac..2b1760b 100644
--- a/WindowsTools/Strings/DownloadManager.Designer.cs
+++ b/WindowsTools/Strings/DownloadManager.Designer.cs
@@ -60,6 +60,15 @@ internal DownloadManager() {
}
}
+ ///
+ /// 查找类似 Add download task 的本地化字符串。
+ ///
+ public static string AddTask {
+ get {
+ return ResourceManager.GetString("AddTask", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Add download task 的本地化字符串。
///
@@ -69,6 +78,15 @@ public static string AddTaskToolTip {
}
}
+ ///
+ /// 查找类似 Cancel 的本地化字符串。
+ ///
+ public static string Cancel {
+ get {
+ return ResourceManager.GetString("Cancel", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Downloaded completed 的本地化字符串。
///
@@ -150,6 +168,42 @@ public static string DeleteWithFileToolTip {
}
}
+ ///
+ /// 查找类似 Download 的本地化字符串。
+ ///
+ public static string Download {
+ get {
+ return ResourceManager.GetString("Download", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Please input the download file name 的本地化字符串。
+ ///
+ public static string DownloadFileNamePHText {
+ get {
+ return ResourceManager.GetString("DownloadFileNamePHText", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Select the folder to save 的本地化字符串。
+ ///
+ public static string DownloadFolderPHText {
+ get {
+ return ResourceManager.GetString("DownloadFolderPHText", resourceCulture);
+ }
+ }
+
+ ///
+ /// 查找类似 Please input the download link 的本地化字符串。
+ ///
+ public static string DownloadLinkPHText {
+ get {
+ return ResourceManager.GetString("DownloadLinkPHText", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Download settings 的本地化字符串。
///
@@ -177,6 +231,15 @@ public static string FileInformation {
}
}
+ ///
+ /// 查找类似 The file path you entered is invalid. Please try again 的本地化字符串。
+ ///
+ public static string FileNameInvalid {
+ get {
+ return ResourceManager.GetString("FileNameInvalid", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Download completed: 的本地化字符串。
///
@@ -258,6 +321,15 @@ public static string SearchEmptyDescription {
}
}
+ ///
+ /// 查找类似 Select folder 的本地化字符串。
+ ///
+ public static string SelectFolderToolTip {
+ get {
+ return ResourceManager.GetString("SelectFolderToolTip", resourceCulture);
+ }
+ }
+
///
/// 查找类似 Share file 的本地化字符串。
///
diff --git a/WindowsTools/Strings/DownloadManager.en-us.resx b/WindowsTools/Strings/DownloadManager.en-us.resx
index 70aeeeb..2b82eb8 100644
--- a/WindowsTools/Strings/DownloadManager.en-us.resx
+++ b/WindowsTools/Strings/DownloadManager.en-us.resx
@@ -117,9 +117,15 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Add download task
+
Add download task
+
+ Cancel
+
Downloaded completed
@@ -147,6 +153,18 @@
Local files are deleted when records are deleted
+
+ Download
+
+
+ Please input the download file name
+
+
+ Select the folder to save
+
+
+ Please input the download link
+
Download settings
@@ -156,6 +174,9 @@
View file information
+
+ The file path you entered is invalid. Please try again
+
Download completed:
@@ -183,6 +204,9 @@
No matching download records were found
+
+ Select folder
+
Share file
diff --git a/WindowsTools/Strings/DownloadManager.resx b/WindowsTools/Strings/DownloadManager.resx
index 70aeeeb..2b82eb8 100644
--- a/WindowsTools/Strings/DownloadManager.resx
+++ b/WindowsTools/Strings/DownloadManager.resx
@@ -117,9 +117,15 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ Add download task
+
Add download task
+
+ Cancel
+
Downloaded completed
@@ -147,6 +153,18 @@
Local files are deleted when records are deleted
+
+ Download
+
+
+ Please input the download file name
+
+
+ Select the folder to save
+
+
+ Please input the download link
+
Download settings
@@ -156,6 +174,9 @@
View file information
+
+ The file path you entered is invalid. Please try again
+
Download completed:
@@ -183,6 +204,9 @@
No matching download records were found
+
+ Select folder
+
Share file
diff --git a/WindowsTools/Strings/DownloadManager.zh-hans.resx b/WindowsTools/Strings/DownloadManager.zh-hans.resx
index 3ddcb7b..cba64b2 100644
--- a/WindowsTools/Strings/DownloadManager.zh-hans.resx
+++ b/WindowsTools/Strings/DownloadManager.zh-hans.resx
@@ -117,9 +117,15 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+ 添加下载任务
+
添加下载任务
+
+ 取消
+
已下载完成
@@ -147,6 +153,18 @@
删除记录的同时删除本地文件
+
+ 下载
+
+
+ 请输入下载文件名称
+
+
+ 选择保存的文件夹
+
+
+ 请输入下载链接
+
下载设置
@@ -156,6 +174,9 @@
查看文件信息
+
+ 您输入的文件路径不合法,请重新输入
+
已下载完成:
@@ -183,6 +204,9 @@
没有搜索到符合的下载记录
+
+ 选择文件夹
+
分享文件
diff --git a/WindowsTools/Views/Pages/AddDownloadTaskPage.xaml b/WindowsTools/Views/Pages/AddDownloadTaskPage.xaml
deleted file mode 100644
index 1d2470b..0000000
--- a/WindowsTools/Views/Pages/AddDownloadTaskPage.xaml
+++ /dev/null
@@ -1,135 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/WindowsTools/Views/Pages/AddDownloadTaskPage.xaml.cs b/WindowsTools/Views/Pages/AddDownloadTaskPage.xaml.cs
deleted file mode 100644
index 5689579..0000000
--- a/WindowsTools/Views/Pages/AddDownloadTaskPage.xaml.cs
+++ /dev/null
@@ -1,234 +0,0 @@
-using System;
-using System.ComponentModel;
-using System.Diagnostics.Tracing;
-using System.IO;
-using System.Threading.Tasks;
-using System.Windows.Forms;
-using Windows.UI.Xaml;
-using Windows.UI.Xaml.Controls;
-using Windows.UI.Xaml.Media;
-using WindowsTools.Helpers.Controls;
-using WindowsTools.Services.Controls.Download;
-using WindowsTools.Services.Controls.Settings;
-using WindowsTools.Services.Root;
-using WindowsTools.Strings;
-using WindowsTools.UI.Dialogs;
-using WindowsTools.Views.Windows;
-
-// 抑制 IDE0060 警告
-#pragma warning disable IDE0060
-
-namespace WindowsTools.Views.Pages
-{
- ///
- /// 添加下载任务页面
- ///
- public sealed partial class AddDownloadTaskPage : Page, INotifyPropertyChanged
- {
- private bool _isPrimaryButtonEnabled;
-
- public bool IsPrimaryButtonEnabled
- {
- get { return _isPrimaryButtonEnabled; }
-
- set
- {
- if (!Equals(_isPrimaryButtonEnabled, value))
- {
- _isPrimaryButtonEnabled = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsPrimaryButtonEnabled)));
- }
- }
- }
-
- private string _downloadLinkText;
-
- public string DownloadLinkText
- {
- get { return _downloadLinkText; }
-
- set
- {
- if (!Equals(_downloadLinkText, value))
- {
- _downloadLinkText = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownloadLinkText)));
- }
- }
- }
-
- private string _downloadFileNameText;
-
- public string DownloadFileNameText
- {
- get { return _downloadFileNameText; }
-
- set
- {
- if (!Equals(_downloadFileNameText, value))
- {
- _downloadFileNameText = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownloadFileNameText)));
- }
- }
- }
-
- private string _downloadFolderText;
-
- public string DownloadFolderText
- {
- get { return _downloadFolderText; }
-
- set
- {
- if (!Equals(_downloadFolderText, value))
- {
- _downloadFolderText = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownloadFolderText)));
- }
- }
- }
-
- private SolidColorBrush _dialogBackground;
-
- public SolidColorBrush DialogBackground
- {
- get { return _dialogBackground; }
-
- set
- {
- if (!Equals(_dialogBackground, value))
- {
- _dialogBackground = value;
- PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DialogBackground)));
- }
- }
- }
-
- public event PropertyChangedEventHandler PropertyChanged;
-
- public AddDownloadTaskPage()
- {
- InitializeComponent();
- DownloadFolderText = DownloadOptionsService.DownloadFolder;
- RequestedTheme = (ElementTheme)Enum.Parse(typeof(ElementTheme), ThemeService.AppTheme.Value.ToString());
- IsPrimaryButtonEnabled = !string.IsNullOrEmpty(DownloadLinkText) && !string.IsNullOrEmpty(DownloadFolderText);
- }
-
- ///
- /// 获取输入的下载链接
- ///
- private void OnDownloadLinkTextChanged(object sender, TextChangedEventArgs args)
- {
- DownloadLinkText = (sender as global::Windows.UI.Xaml.Controls.TextBox).Text;
-
- if (!string.IsNullOrEmpty(DownloadLinkText))
- {
- Task.Run(() =>
- {
- try
- {
- bool createSucceeded = Uri.TryCreate(DownloadLinkText, UriKind.Absolute, out Uri uri);
- if (createSucceeded && uri.Segments.Length >= 1)
- {
- string fileName = uri.Segments[uri.Segments.Length - 1];
- if (fileName is not "/")
- {
- AddDownloadTaskWindow.Current?.BeginInvoke(() =>
- {
- DownloadFileNameText = fileName;
- IsPrimaryButtonEnabled = !string.IsNullOrEmpty(DownloadLinkText) && !string.IsNullOrEmpty(DownloadFolderText);
- });
- }
- }
- }
- catch (Exception e)
- {
- LogService.WriteLog(EventLevel.Warning, "Parse download link file name failed", e);
- }
- });
- }
- else
- {
- DownloadFileNameText = string.Empty;
- IsPrimaryButtonEnabled = !string.IsNullOrEmpty(DownloadLinkText) && !string.IsNullOrEmpty(DownloadFolderText);
- }
- }
-
- ///
- /// 获取输入的下载链接
- ///
- private void OnDownloadFileNameTextChanged(object sender, TextChangedEventArgs args)
- {
- DownloadFileNameText = (sender as global::Windows.UI.Xaml.Controls.TextBox).Text;
-
- IsPrimaryButtonEnabled = !string.IsNullOrEmpty(DownloadLinkText) && !string.IsNullOrEmpty(DownloadFileNameText) && !string.IsNullOrEmpty(DownloadFolderText);
- }
-
- ///
- /// 获取输入的下载目录
- ///
- private void OnDownloadFolderTextChanged(object sender, TextChangedEventArgs args)
- {
- DownloadFolderText = (sender as global::Windows.UI.Xaml.Controls.TextBox).Text;
- }
-
- ///
- /// 选择文件夹
- ///
- private void OnSelectFolderClicked(object sender, RoutedEventArgs args)
- {
- FolderBrowserDialog dialog = new()
- {
- Description = FileProperties.SelectFolder,
- ShowNewFolderButton = true,
- RootFolder = Environment.SpecialFolder.Desktop
- };
- DialogResult result = dialog.ShowDialog();
- if (result is DialogResult.OK || result is DialogResult.Yes)
- {
- DownloadFolderText = dialog.SelectedPath;
- }
- }
-
- ///
- /// 下载文件
- ///
- private async void OnDownloadClicked(object sender, RoutedEventArgs args)
- {
- // 检查文件路径
- if (DownloadFileNameText.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || DownloadFolderText.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
- {
- FileNameInvalidTeachingTip.IsOpen = true;
- await Task.Delay(2000);
- FileNameInvalidTeachingTip.IsOpen = false;
- return;
- }
-
- string filePath = Path.Combine(DownloadFolderText, DownloadFileNameText);
-
- // 检查本地文件是否存在
- if (File.Exists(filePath))
- {
- MainWindow.Current.BeginInvoke(async () =>
- {
- await ContentDialogHelper.ShowAsync(new FileCheckDialog(DownloadLinkText, filePath), MainWindow.Current.Content as FrameworkElement);
- });
- AddDownloadTaskWindow.Current?.Close();
- }
- else
- {
- DownloadSchedulerService.CreateDownload(DownloadLinkText, Path.Combine(DownloadFolderText, DownloadFileNameText));
- AddDownloadTaskWindow.Current?.Close();
- }
- }
-
- ///
- /// 关闭窗口
- ///
- private void OnCloseClicked(object sender, RoutedEventArgs args)
- {
- AddDownloadTaskWindow.Current?.Close();
- }
- }
-}
diff --git a/WindowsTools/Views/Pages/DownloadManagerPage.xaml b/WindowsTools/Views/Pages/DownloadManagerPage.xaml
index 064fb72..492e90f 100644
--- a/WindowsTools/Views/Pages/DownloadManagerPage.xaml
+++ b/WindowsTools/Views/Pages/DownloadManagerPage.xaml
@@ -22,6 +22,153 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/WindowsTools/Views/Pages/DownloadManagerPage.xaml.cs b/WindowsTools/Views/Pages/DownloadManagerPage.xaml.cs
index b3ad9e6..e89f225 100644
--- a/WindowsTools/Views/Pages/DownloadManagerPage.xaml.cs
+++ b/WindowsTools/Views/Pages/DownloadManagerPage.xaml.cs
@@ -9,17 +9,23 @@
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Threading.Tasks;
+using System.Windows.Forms;
using Windows.ApplicationModel.DataTransfer;
using Windows.Storage;
+using Windows.System;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Input;
using WindowsTools.Extensions.DataType.Enums;
+using WindowsTools.Helpers.Controls;
using WindowsTools.Models;
using WindowsTools.Models.Controls.Download;
using WindowsTools.Services.Controls.Download;
+using WindowsTools.Services.Controls.Settings;
using WindowsTools.Services.Root;
using WindowsTools.Strings;
+using WindowsTools.UI.Dialogs;
using WindowsTools.Views.Windows;
using WindowsTools.WindowsAPI.ComTypes;
using WindowsTools.WindowsAPI.PInvoke.Shell32;
@@ -34,6 +40,8 @@ namespace WindowsTools.Views.Pages
///
public sealed partial class DownloadManagerPage : Page, INotifyPropertyChanged
{
+ private bool isAllowClosed = false;
+
private string _searchDownload;
public string SearchDownload
@@ -66,6 +74,70 @@ public bool IsSearchEmpty
}
}
+ private bool _isPrimaryButtonEnabled;
+
+ public bool IsPrimaryButtonEnabled
+ {
+ get { return _isPrimaryButtonEnabled; }
+
+ set
+ {
+ if (!Equals(_isPrimaryButtonEnabled, value))
+ {
+ _isPrimaryButtonEnabled = value;
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsPrimaryButtonEnabled)));
+ }
+ }
+ }
+
+ private string _downloadLinkText;
+
+ public string DownloadLinkText
+ {
+ get { return _downloadLinkText; }
+
+ set
+ {
+ if (!Equals(_downloadLinkText, value))
+ {
+ _downloadLinkText = value;
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownloadLinkText)));
+ }
+ }
+ }
+
+ private string _downloadFileNameText;
+
+ public string DownloadFileNameText
+ {
+ get { return _downloadFileNameText; }
+
+ set
+ {
+ if (!Equals(_downloadFileNameText, value))
+ {
+ _downloadFileNameText = value;
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownloadFileNameText)));
+ }
+ }
+ }
+
+ private string _downloadFolderText;
+
+ public string DownloadFolderText
+ {
+ get { return _downloadFolderText; }
+
+ set
+ {
+ if (!Equals(_downloadFolderText, value))
+ {
+ _downloadFolderText = value;
+ PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(DownloadFolderText)));
+ }
+ }
+ }
+
private ObservableCollection DownloadCollection { get; } = [];
public event PropertyChangedEventHandler PropertyChanged;
@@ -73,6 +145,8 @@ public bool IsSearchEmpty
public DownloadManagerPage()
{
InitializeComponent();
+ DownloadFolderText = DownloadOptionsService.DownloadFolder;
+ IsPrimaryButtonEnabled = !string.IsNullOrEmpty(DownloadLinkText) && !string.IsNullOrEmpty(DownloadFolderText);
DownloadSchedulerService.DownloadCreated += OnDownloadCreated;
DownloadSchedulerService.DownloadContinued += OnDownloadContinued;
DownloadSchedulerService.DownloadPaused += OnDownloadPaused;
@@ -336,13 +410,12 @@ private void OnSearchDownloadQuerySubmitted(object sender, AutoSuggestBoxQuerySu
///
private void OnAddTaskClicked(object sender, RoutedEventArgs args)
{
- if (AddDownloadTaskWindow.Current is null)
+ FlyoutShowOptions flyoutShowOptions = new()
{
- new AddDownloadTaskWindow();
- AddDownloadTaskWindow.Current.Left = MainWindow.Current.Left + (MainWindow.Current.Width - AddDownloadTaskWindow.Current.Width) / 2;
- AddDownloadTaskWindow.Current.Top = MainWindow.Current.Top + (MainWindow.Current.Height - AddDownloadTaskWindow.Current.Height) / 2;
- AddDownloadTaskWindow.Current.Show(MainWindow.Current);
- }
+ Placement = FlyoutPlacementMode.Full,
+ ShowMode = FlyoutShowMode.Standard,
+ };
+ AddDownloadTaskFlyout.ShowAt(MainWindow.Current.Content, flyoutShowOptions);
}
///
@@ -562,6 +635,156 @@ private void OnDownloadCompleted(Guid downloadID, DownloadSchedulerModel downloa
});
}
+ ///
+ /// 浮出控件打开时触发的事件
+ ///
+ private void OnOpening(object sender, object args)
+ {
+ DownloadLinkText = string.Empty;
+ DownloadFileNameText = string.Empty;
+ DownloadFolderText = DownloadOptionsService.DownloadFolder;
+ IsPrimaryButtonEnabled = !string.IsNullOrEmpty(DownloadLinkText) && !string.IsNullOrEmpty(DownloadFolderText);
+ }
+
+ ///
+ /// 浮出控件关闭时触发的事件
+ ///
+ private void OnClosing(FlyoutBase sender, FlyoutBaseClosingEventArgs args)
+ {
+ if (isAllowClosed)
+ {
+ isAllowClosed = false;
+ }
+ else
+ {
+ args.Cancel = true;
+ }
+ }
+
+ private void OnFlyoutKeyDown(object sender, KeyRoutedEventArgs args)
+ {
+ if (args.Key is VirtualKey.Escape)
+ {
+ isAllowClosed = true;
+ AddDownloadTaskFlyout.Hide();
+ }
+ }
+
+ ///
+ /// 获取输入的下载链接
+ ///
+ private void OnDownloadLinkTextChanged(object sender, TextChangedEventArgs args)
+ {
+ DownloadLinkText = (sender as global::Windows.UI.Xaml.Controls.TextBox).Text;
+
+ if (!string.IsNullOrEmpty(DownloadLinkText))
+ {
+ Task.Run(() =>
+ {
+ try
+ {
+ bool createSucceeded = Uri.TryCreate(DownloadLinkText, UriKind.Absolute, out Uri uri);
+ if (createSucceeded && uri.Segments.Length >= 1)
+ {
+ string fileName = uri.Segments[uri.Segments.Length - 1];
+ if (fileName is not "/")
+ {
+ MainWindow.Current.BeginInvoke(() =>
+ {
+ DownloadFileNameText = fileName;
+ IsPrimaryButtonEnabled = !string.IsNullOrEmpty(DownloadLinkText) && !string.IsNullOrEmpty(DownloadFolderText);
+ });
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ LogService.WriteLog(EventLevel.Warning, "Parse download link file name failed", e);
+ }
+ });
+ }
+ else
+ {
+ DownloadFileNameText = string.Empty;
+ IsPrimaryButtonEnabled = !string.IsNullOrEmpty(DownloadLinkText) && !string.IsNullOrEmpty(DownloadFolderText);
+ }
+ }
+
+ ///
+ /// 获取输入的下载链接
+ ///
+ private void OnDownloadFileNameTextChanged(object sender, TextChangedEventArgs args)
+ {
+ DownloadFileNameText = (sender as global::Windows.UI.Xaml.Controls.TextBox).Text;
+
+ IsPrimaryButtonEnabled = !string.IsNullOrEmpty(DownloadLinkText) && !string.IsNullOrEmpty(DownloadFileNameText) && !string.IsNullOrEmpty(DownloadFolderText);
+ }
+
+ ///
+ /// 获取输入的下载目录
+ ///
+ private void OnDownloadFolderTextChanged(object sender, TextChangedEventArgs args)
+ {
+ DownloadFolderText = (sender as global::Windows.UI.Xaml.Controls.TextBox).Text;
+ }
+
+ ///
+ /// 选择文件夹
+ ///
+ private void OnSelectFolderClicked(object sender, RoutedEventArgs args)
+ {
+ FolderBrowserDialog dialog = new()
+ {
+ Description = FileProperties.SelectFolder,
+ ShowNewFolderButton = true,
+ RootFolder = Environment.SpecialFolder.Desktop
+ };
+ DialogResult result = dialog.ShowDialog();
+ if (result is DialogResult.OK || result is DialogResult.Yes)
+ {
+ DownloadFolderText = dialog.SelectedPath;
+ }
+ }
+
+ ///
+ /// 下载文件
+ ///
+ private void OnDownloadClicked(object sender, RoutedEventArgs args)
+ {
+ // 检查文件路径
+ if (DownloadFileNameText.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0 || DownloadFolderText.IndexOfAny(Path.GetInvalidPathChars()) >= 0)
+ {
+ return;
+ }
+
+ string filePath = Path.Combine(DownloadFolderText, DownloadFileNameText);
+
+ // 检查本地文件是否存在
+ if (File.Exists(filePath))
+ {
+ MainWindow.Current.BeginInvoke(async () =>
+ {
+ await ContentDialogHelper.ShowAsync(new FileCheckDialog(DownloadLinkText, filePath), MainWindow.Current.Content as FrameworkElement);
+ });
+ }
+ else
+ {
+ DownloadSchedulerService.CreateDownload(DownloadLinkText, Path.Combine(DownloadFolderText, DownloadFileNameText));
+ }
+
+ isAllowClosed = true;
+ AddDownloadTaskFlyout.Hide();
+ }
+
+ ///
+ /// 关闭对话框
+ ///
+ private void OnCloseClicked(object sender, RoutedEventArgs args)
+ {
+ isAllowClosed = true;
+ AddDownloadTaskFlyout.Hide();
+ }
+
#endregion 第二部分:自定义事件
}
}
diff --git a/WindowsTools/Views/Windows/AddDownloadTaskWindow.cs b/WindowsTools/Views/Windows/AddDownloadTaskWindow.cs
deleted file mode 100644
index 4b01409..0000000
--- a/WindowsTools/Views/Windows/AddDownloadTaskWindow.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-using Mile.Xaml;
-using System.ComponentModel;
-using System.Windows.Forms;
-using Windows.UI.Xaml;
-using WindowsTools.Views.Pages;
-
-namespace WindowsTools.Views.Windows
-{
- ///
- /// 添加下载任务窗口
- ///
- public class AddDownloadTaskWindow : Form
- {
- private readonly IContainer components = new Container();
- public WindowsXamlHost windowsXamlHost = new();
-
- public UIElement Content { get; set; } = new AddDownloadTaskPage();
-
- public static AddDownloadTaskWindow Current { get; private set; }
-
- public AddDownloadTaskWindow()
- {
- AllowDrop = false;
- AutoScaleMode = AutoScaleMode.Font;
- Current = this;
- Controls.Add(windowsXamlHost);
- FormBorderStyle = FormBorderStyle.FixedSingle;
- Height = 410 * DeviceDpi / 96;
- MaximizeBox = false;
- MinimizeBox = false;
- ShowIcon = false;
- ShowInTaskbar = false;
- StartPosition = FormStartPosition.Manual;
- Width = 600 * DeviceDpi / 96;
- windowsXamlHost.AutoSize = true;
- windowsXamlHost.Dock = DockStyle.Fill;
- windowsXamlHost.Child = Content;
- }
-
- #region 第一部分:窗口类内置需要重载的事件
-
- ///
- /// 关闭窗体后发生的事件
- ///
- protected override void OnFormClosed(FormClosedEventArgs args)
- {
- base.OnFormClosed(args);
- Current = null;
- }
-
- ///
- /// 按 Esc 键时,关闭窗口
- ///
- protected override void OnKeyDown(KeyEventArgs args)
- {
- base.OnKeyDown(args);
-
- if (args.KeyCode is Keys.Escape)
- {
- Close();
- }
- }
-
- ///
- /// 处置由主窗体占用的资源
- ///
- protected override void Dispose(bool disposing)
- {
- base.Dispose(disposing);
- if (disposing && components is not null)
- {
- components.Dispose();
- }
- }
-
- #endregion 第一部分:窗口类内置需要重载的事件
- }
-}
diff --git a/WindowsTools/Views/Windows/MainWindow.cs b/WindowsTools/Views/Windows/MainWindow.cs
index a14dd87..75928b0 100644
--- a/WindowsTools/Views/Windows/MainWindow.cs
+++ b/WindowsTools/Views/Windows/MainWindow.cs
@@ -120,8 +120,6 @@ protected override void OnActivated(EventArgs args)
{
systemBackdropConfiguration.IsInputActive = true;
}
-
- AddDownloadTaskWindow.Current?.Activate();
}
///
@@ -259,7 +257,11 @@ protected override void OnMove(EventArgs args)
// 关闭浮出控件
if (popupRoot.Child as FlyoutPresenter is not null)
{
- popupRoot.IsOpen = false;
+ if (!(popupRoot.Child as FlyoutPresenter).Name.Equals("DialogFlyout"))
+ {
+ popupRoot.IsOpen = false;
+ }
+
break;
}
@@ -299,12 +301,19 @@ protected override void OnSizeChanged(EventArgs args)
if (Content.XamlRoot is not null)
{
IReadOnlyList PopupRoot = VisualTreeHelper.GetOpenPopupsForXamlRoot(Content.XamlRoot);
- foreach (Popup popup in PopupRoot)
+ foreach (Popup popupRoot in PopupRoot)
{
// 关闭内容对话框
- if (popup.Child as ContentDialog is not null)
+ if (popupRoot.Child as ContentDialog is not null)
+ {
+ (popupRoot.Child as ContentDialog).Hide();
+ break;
+ }
+
+ // 关闭浮出控件
+ if (popupRoot.Child as FlyoutPresenter is not null)
{
- (popup.Child as ContentDialog).Hide();
+ popupRoot.IsOpen = false;
break;
}
}
diff --git a/WindowsTools/WindowsAPI/ComTypes/CWinSATCallbacks.cs b/WindowsTools/WindowsAPI/ComTypes/CWinSATCallbacks.cs
index fc9c8f9..42c1216 100644
--- a/WindowsTools/WindowsAPI/ComTypes/CWinSATCallbacks.cs
+++ b/WindowsTools/WindowsAPI/ComTypes/CWinSATCallbacks.cs
@@ -46,7 +46,15 @@ public class CWinSATCallbacks : IWinSATInitiateEvents
/// 完成状态的说明。 此字符串在此回调的生命周期内有效。 如果在回调返回后需要,请复制字符串。
public void WinSATComplete(int hresult, string strDescription)
{
- Result = (WINSAT_RESULT)hresult;
+ try
+ {
+ Result = (WINSAT_RESULT)hresult;
+ }
+ catch(Exception)
+ {
+ Result = WINSAT_RESULT.WINSAT_ERROR_COMPLETED_ERROR;
+ }
+
Description = strDescription;
StatusCompleted?.Invoke(this, EventArgs.Empty);
}
diff --git a/WindowsTools/WindowsAPI/ComTypes/DODownloadStatusCallback.cs b/WindowsTools/WindowsAPI/ComTypes/DODownloadStatusCallback.cs
index f4fc8ca..e1d7229 100644
--- a/WindowsTools/WindowsAPI/ComTypes/DODownloadStatusCallback.cs
+++ b/WindowsTools/WindowsAPI/ComTypes/DODownloadStatusCallback.cs
@@ -6,7 +6,7 @@ namespace WindowsTools.WindowsAPI.ComTypes
///
/// IDODownloadStatusCallback 接口的实现
///
- public partial class DODownloadStatusCallback : IDODownloadStatusCallback
+ public class DODownloadStatusCallback : IDODownloadStatusCallback
{
public Guid DownloadID { get; set; } = Guid.Empty;
diff --git a/WindowsTools/WindowsTools.csproj b/WindowsTools/WindowsTools.csproj
index 416b544..d67b1ce 100644
--- a/WindowsTools/WindowsTools.csproj
+++ b/WindowsTools/WindowsTools.csproj
@@ -44,12 +44,6 @@
About.resx
-
- True
- True
- AddDownloadTask.resx
-
-
True
True
@@ -308,9 +302,6 @@
-
-
-
diff --git a/WindowsToolsPackage/Package.appxmanifest b/WindowsToolsPackage/Package.appxmanifest
index 6e2d6b0..6168d71 100644
--- a/WindowsToolsPackage/Package.appxmanifest
+++ b/WindowsToolsPackage/Package.appxmanifest
@@ -12,7 +12,7 @@
+ Version="2.5.602.0" />
ms-resource:PackageDisplayName
diff --git a/WindowsToolsShellExtension/Properties/AssemblyInfo.cs b/WindowsToolsShellExtension/Properties/AssemblyInfo.cs
index 631987b..bc4d3db 100644
--- a/WindowsToolsShellExtension/Properties/AssemblyInfo.cs
+++ b/WindowsToolsShellExtension/Properties/AssemblyInfo.cs
@@ -6,11 +6,11 @@
[assembly: AssemblyCompany("高怡飞")]
[assembly: AssemblyCopyright("Copyright ©2024 高怡飞, All Rights Reserved.")]
[assembly: AssemblyDescription("Windows 工具箱 右键菜单扩展")]
-[assembly: AssemblyFileVersion("2.5.528.0")]
-[assembly: AssemblyInformationalVersion("2.5.528.0")]
+[assembly: AssemblyFileVersion("2.5.602.0")]
+[assembly: AssemblyInformationalVersion("2.5.602.0")]
[assembly: AssemblyProduct("Windows 工具箱 右键菜单扩展")]
[assembly: AssemblyTitle("Windows 工具箱 右键菜单扩展")]
-[assembly: AssemblyVersion("2.5.528.0")]
+[assembly: AssemblyVersion("2.5.602.0")]
// 应用程序默认区域性的资源控制器设置
[assembly: NeutralResourcesLanguage("en-us")]