diff --git a/Description/README_EN-US.md b/Description/README_EN-US.md index 43873d2..f5358be 100644 --- a/Description/README_EN-US.md +++ b/Description/README_EN-US.md @@ -69,6 +69,7 @@ A toolbox that integrates multiple gadgets. | System information | Unfinished | | Driver manager | Unfinished | | Update manager | Unfinished | +| Loopback manager | Finished | | Windows system assessment tool | Finished | ------ diff --git a/Description/README_ZH-CN.md b/Description/README_ZH-CN.md index 45f09e1..c654783 100644 --- a/Description/README_ZH-CN.md +++ b/Description/README_ZH-CN.md @@ -69,6 +69,7 @@ | 系统信息 | 未完成 | | 驱动管理 | 未完成 | | 更新管理 | 未完成 | +| 网络回环管理 | 已完成 | | Windows 系统评估 | 已完成 | ------ diff --git a/Description/StudyReferenceCode.md b/Description/StudyReferenceCode.md index c2d546b..1cfbc57 100644 --- a/Description/StudyReferenceCode.md +++ b/Description/StudyReferenceCode.md @@ -8,4 +8,5 @@ > * [ExplorerExtensions.Sample](https://github.com/cnbluefire/ExplorerExtensions.Sample)  > * [Generating valid tokens to access Limited Access Features in Windows 10](https://www.withinrafael.com/2021/01/04/generating-valid-tokens-to-access-limited-access-features-in-windows-10)  > * [Loaf](https://github.com/DinoChan/Loaf)  -> * [Mile.Xaml.Samples](https://github.com/ProjectMile/Mile.Xaml.Samples)  \ No newline at end of file +> * [Mile.Xaml.Samples](https://github.com/ProjectMile/Mile.Xaml.Samples)  +> * [UWP-Loopback-Exemption-Manager](https://github.com/themerror/UWP-Loopback-Exemption-Manager)  \ No newline at end of file diff --git a/README.md b/README.md index 3741463..f2114db 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ | 系统信息 | 未完成 | | 驱动管理 | 未完成 | | 更新管理 | 未完成 | +| 网络回环管理 | 已完成 | | Windows 系统评估 | 已完成 | ------ diff --git a/WindowsTools/App.xaml.cs b/WindowsTools/App.xaml.cs index 98a6e68..3a2721d 100644 --- a/WindowsTools/App.xaml.cs +++ b/WindowsTools/App.xaml.cs @@ -55,11 +55,13 @@ protected virtual void Dispose(bool disposing) if (disposing) { this.ThreadUninitialize(); + if (MainWindow.Current is not null && !MainWindow.Current.IsDisposed) { MainWindow.Current?.Close(); } + GlobalNotificationService.SendNotification(); DownloadSchedulerService.TerminateDownload(); DownloadSchedulerService.CloseDownloadScheduler(); SystemTrayService.CloseSystemTray(); diff --git a/WindowsTools/Helpers/Converters/ValueConverterHelper.cs b/WindowsTools/Helpers/Converters/ValueConverterHelper.cs index 1630f6e..2c8aa78 100644 --- a/WindowsTools/Helpers/Converters/ValueConverterHelper.cs +++ b/WindowsTools/Helpers/Converters/ValueConverterHelper.cs @@ -71,14 +71,7 @@ public static Visibility IntToVisibilityReverseConvert(int value) /// public static Visibility StringToVisibilityConvert(string value) { - if (string.IsNullOrEmpty(value)) - { - return Visibility.Collapsed; - } - else - { - return Visibility.Visible; - } + return string.IsNullOrEmpty(value) ? Visibility.Collapsed : Visibility.Visible; } /// diff --git a/WindowsTools/Helpers/Root/CopyPasteHelper.cs b/WindowsTools/Helpers/Root/CopyPasteHelper.cs index 5f49f78..4fcb4e7 100644 --- a/WindowsTools/Helpers/Root/CopyPasteHelper.cs +++ b/WindowsTools/Helpers/Root/CopyPasteHelper.cs @@ -45,14 +45,7 @@ public static Image ReadClipboardImage() else if (iData.GetDataPresent(DataFormats.FileDrop)) { StringCollection files = Clipboard.GetFileDropList(); - if (files.Count is 0) - { - return null; - } - else - { - return Image.FromFile(files[0]); - } + return files.Count is 0 ? null : Image.FromFile(files[0]); } else if (iData.GetDataPresent(DataFormats.Text)) { @@ -62,14 +55,7 @@ public static Image ReadClipboardImage() { return null; } - if (File.Exists(path)) - { - return Image.FromFile(path); - } - else - { - return null; - } + return File.Exists(path) ? Image.FromFile(path) : null; } else { diff --git a/WindowsTools/Models/LoopbackModel.cs b/WindowsTools/Models/LoopbackModel.cs index 09678c6..33423a9 100644 --- a/WindowsTools/Models/LoopbackModel.cs +++ b/WindowsTools/Models/LoopbackModel.cs @@ -25,18 +25,18 @@ public Visibility IsVisible } } - private bool _isChecked; + private bool _isSelected; - public bool IsChecked + public bool IsSelected { - get { return _isChecked; } + get { return _isSelected; } set { - if (!Equals(_isChecked, value)) + if (!Equals(_isSelected, value)) { - _isChecked = value; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsChecked))); + _isSelected = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsSelected))); } } } @@ -46,7 +46,7 @@ public bool IsChecked /// /// 应用程序运行的二进制路径 /// - public string[] StringBinaries { get; set; } + public string[] AppBinariesPath { get; set; } /// /// 应用容器的全局唯一名称 @@ -73,7 +73,7 @@ public bool IsChecked /// /// 应用容器所属用户的名称 /// - public string UserAccountSIDName { get; set; } + public string AppContainerUserName { get; set; } /// /// 应用容器的包标识符 diff --git a/WindowsTools/Properties/AssemblyInfo.cs b/WindowsTools/Properties/AssemblyInfo.cs index a11c949..6af7973 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.6.626.0")] -[assembly: AssemblyInformationalVersion("2.6.626.0")] +[assembly: AssemblyFileVersion("2.6.627.0")] +[assembly: AssemblyInformationalVersion("2.6.627.0")] [assembly: AssemblyProduct("Windows 工具箱")] [assembly: AssemblyTitle("Windows 工具箱")] -[assembly: AssemblyVersion("2.6.626.0")] +[assembly: AssemblyVersion("2.6.627.0")] diff --git a/WindowsTools/Services/Controls/Download/BitsService.cs b/WindowsTools/Services/Controls/Download/BitsService.cs index 67f59b7..b59a1a1 100644 --- a/WindowsTools/Services/Controls/Download/BitsService.cs +++ b/WindowsTools/Services/Controls/Download/BitsService.cs @@ -129,7 +129,7 @@ public static unsafe void CreateDownload(string url, string saveFilePath) DownloadID = downloadID }; backgroundCopyCallback.StatusChanged += OnStatusChanged; - downloadJob.SetNotifyInterface(new UnknownWrapper (backgroundCopyCallback).WrappedObject); + downloadJob.SetNotifyInterface(new UnknownWrapper(backgroundCopyCallback).WrappedObject); 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/Root/GlobalNotificationService.cs b/WindowsTools/Services/Root/GlobalNotificationService.cs new file mode 100644 index 0000000..49f3ae2 --- /dev/null +++ b/WindowsTools/Services/Root/GlobalNotificationService.cs @@ -0,0 +1,23 @@ +using System; + +namespace WindowsTools.Services.Root +{ + /// + /// 应用进程内全局通知 + /// + public static class GlobalNotificationService + { + /// + /// 应用程序退出时发生的事件 + /// + public static event EventHandler ApplicationExit; + + /// + /// 发送消息通知 + /// + public static void SendNotification() + { + ApplicationExit?.Invoke(null, EventArgs.Empty); + } + } +} diff --git a/WindowsTools/Strings/LoopbackManager.Designer.cs b/WindowsTools/Strings/LoopbackManager.Designer.cs index 3ea1d5b..6c9d510 100644 --- a/WindowsTools/Strings/LoopbackManager.Designer.cs +++ b/WindowsTools/Strings/LoopbackManager.Designer.cs @@ -60,6 +60,51 @@ internal LoopbackManager() { } } + /// + /// 查找类似 App binaries path 的本地化字符串。 + /// + public static string AppBinariesPath { + get { + return ResourceManager.GetString("AppBinariesPath", resourceCulture); + } + } + + /// + /// 查找类似 App container name 的本地化字符串。 + /// + public static string AppContainerName { + get { + return ResourceManager.GetString("AppContainerName", resourceCulture); + } + } + + /// + /// 查找类似 App container SID 的本地化字符串。 + /// + public static string AppContainerSID { + get { + return ResourceManager.GetString("AppContainerSID", resourceCulture); + } + } + + /// + /// 查找类似 App container user 的本地化字符串。 + /// + public static string AppContainerUser { + get { + return ResourceManager.GetString("AppContainerUser", resourceCulture); + } + } + + /// + /// 查找类似 Description 的本地化字符串。 + /// + public static string Description { + get { + return ResourceManager.GetString("Description", resourceCulture); + } + } + /// /// 查找类似 The device has no application 的本地化字符串。 /// @@ -69,6 +114,33 @@ public static string EmptyDescription { } } + /// + /// 查找类似 Learn loopback 的本地化字符串。 + /// + public static string LearnLoopback { + get { + return ResourceManager.GetString("LearnLoopback", resourceCulture); + } + } + + /// + /// 查找类似 Loading network loopback information, please wait... 的本地化字符串。 + /// + public static string LoadingLoopback { + get { + return ResourceManager.GetString("LoadingLoopback", resourceCulture); + } + } + + /// + /// 查找类似 Open working directory 的本地化字符串。 + /// + public static string OpenWorkingDirectoryToolTip { + get { + return ResourceManager.GetString("OpenWorkingDirectoryToolTip", resourceCulture); + } + } + /// /// 查找类似 Refresh 的本地化字符串。 /// @@ -123,6 +195,15 @@ public static string SelectAll { } } + /// + /// 查找类似 Selected 的本地化字符串。 + /// + public static string SelectedToolTip { + get { + return ResourceManager.GetString("SelectedToolTip", resourceCulture); + } + } + /// /// 查找类似 Select none 的本地化字符串。 /// @@ -140,5 +221,32 @@ public static string Title { return ResourceManager.GetString("Title", resourceCulture); } } + + /// + /// 查找类似 [Unknown] 的本地化字符串。 + /// + public static string Unknown { + get { + return ResourceManager.GetString("Unknown", resourceCulture); + } + } + + /// + /// 查找类似 Unselected 的本地化字符串。 + /// + public static string UnSelectedToolTip { + get { + return ResourceManager.GetString("UnSelectedToolTip", resourceCulture); + } + } + + /// + /// 查找类似 Working directory 的本地化字符串。 + /// + public static string WorkingDirectory { + get { + return ResourceManager.GetString("WorkingDirectory", resourceCulture); + } + } } } diff --git a/WindowsTools/Strings/LoopbackManager.en-us.resx b/WindowsTools/Strings/LoopbackManager.en-us.resx index 0f48f83..995de37 100644 --- a/WindowsTools/Strings/LoopbackManager.en-us.resx +++ b/WindowsTools/Strings/LoopbackManager.en-us.resx @@ -117,9 +117,33 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + App binaries path + + + App container name + + + App container SID + + + App container user + + + Description + The device has no application + + Learn loopback + + + Loading network loopback information, please wait... + + + Open working directory + Refresh @@ -138,10 +162,22 @@ Select all + + Selected + Select none Loop back manager + + [Unknown] + + + Unselected + + + Working directory + \ No newline at end of file diff --git a/WindowsTools/Strings/LoopbackManager.resx b/WindowsTools/Strings/LoopbackManager.resx index 0f48f83..995de37 100644 --- a/WindowsTools/Strings/LoopbackManager.resx +++ b/WindowsTools/Strings/LoopbackManager.resx @@ -117,9 +117,33 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + App binaries path + + + App container name + + + App container SID + + + App container user + + + Description + The device has no application + + Learn loopback + + + Loading network loopback information, please wait... + + + Open working directory + Refresh @@ -138,10 +162,22 @@ Select all + + Selected + Select none Loop back manager + + [Unknown] + + + Unselected + + + Working directory + \ No newline at end of file diff --git a/WindowsTools/Strings/LoopbackManager.zh-hans.resx b/WindowsTools/Strings/LoopbackManager.zh-hans.resx index 1e2cc74..8f96a8a 100644 --- a/WindowsTools/Strings/LoopbackManager.zh-hans.resx +++ b/WindowsTools/Strings/LoopbackManager.zh-hans.resx @@ -117,9 +117,33 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + 应用二进制路径 + + + 应用容器名称 + + + 应用容器 SID + + + 应用容器用户 + + + 描述信息 + 该设备没有任何应用 + + 了解网络回环 + + + 正在加载网络回环信息中,请稍候... + + + 打开工作目录 + 刷新 @@ -138,10 +162,22 @@ 全选 + + 已选择 + 全部不选 网络回环管理 + + [未知] + + + 未选择 + + + 工作目录 + \ No newline at end of file diff --git a/WindowsTools/Strings/Notification.Designer.cs b/WindowsTools/Strings/Notification.Designer.cs index afc0588..e06341c 100644 --- a/WindowsTools/Strings/Notification.Designer.cs +++ b/WindowsTools/Strings/Notification.Designer.cs @@ -222,6 +222,24 @@ public static string LogCleanSuccessfully { } } + /// + /// 查找类似 The network loopback is set failed 的本地化字符串。 + /// + public static string LoopbackSetResultFailed { + get { + return ResourceManager.GetString("LoopbackSetResultFailed", resourceCulture); + } + } + + /// + /// 查找类似 The network loopback is set successfully 的本地化字符串。 + /// + public static string LoopbackSetResultSuccessfully { + get { + return ResourceManager.GetString("LoopbackSetResultSuccessfully", resourceCulture); + } + } + /// /// 查找类似 The application is the latest version 的本地化字符串。 /// diff --git a/WindowsTools/Strings/Notification.en-us.resx b/WindowsTools/Strings/Notification.en-us.resx index 3f76e50..e2d0b97 100644 --- a/WindowsTools/Strings/Notification.en-us.resx +++ b/WindowsTools/Strings/Notification.en-us.resx @@ -171,6 +171,12 @@ All log records were cleaned up successfully + + The network loopback is set failed + + + The network loopback is set successfully + The application is the latest version diff --git a/WindowsTools/Strings/Notification.resx b/WindowsTools/Strings/Notification.resx index 3f76e50..e2d0b97 100644 --- a/WindowsTools/Strings/Notification.resx +++ b/WindowsTools/Strings/Notification.resx @@ -171,6 +171,12 @@ All log records were cleaned up successfully + + The network loopback is set failed + + + The network loopback is set successfully + The application is the latest version diff --git a/WindowsTools/Strings/Notification.zh-hans.resx b/WindowsTools/Strings/Notification.zh-hans.resx index f67fdef..caeb5bf 100644 --- a/WindowsTools/Strings/Notification.zh-hans.resx +++ b/WindowsTools/Strings/Notification.zh-hans.resx @@ -171,6 +171,12 @@ 所有日志记录清除成功 + + 网络回环设置失败 + + + 网络回环设置成功 + 应用已是最新版本 diff --git a/WindowsTools/Styles/HyperlinkButton.xaml b/WindowsTools/Styles/HyperlinkButton.xaml index e9b73f6..116bec6 100644 --- a/WindowsTools/Styles/HyperlinkButton.xaml +++ b/WindowsTools/Styles/HyperlinkButton.xaml @@ -175,4 +175,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Styles/ListView.xaml b/WindowsTools/Styles/ListView.xaml index a70e72e..9c477aa 100644 --- a/WindowsTools/Styles/ListView.xaml +++ b/WindowsTools/Styles/ListView.xaml @@ -59,4 +59,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Styles/MenuFlyout.xaml b/WindowsTools/Styles/MenuFlyout.xaml index 8c511df..2b6f8a9 100644 --- a/WindowsTools/Styles/MenuFlyout.xaml +++ b/WindowsTools/Styles/MenuFlyout.xaml @@ -236,4 +236,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/UI/Dialogs/AppInformationDialog.xaml b/WindowsTools/UI/Dialogs/AppInformationDialog.xaml index 16955bb..b25e5e1 100644 --- a/WindowsTools/UI/Dialogs/AppInformationDialog.xaml +++ b/WindowsTools/UI/Dialogs/AppInformationDialog.xaml @@ -116,4 +116,4 @@ TextWrapping="Wrap" /> - + \ No newline at end of file diff --git a/WindowsTools/UI/Dialogs/AppRunningDialog.xaml b/WindowsTools/UI/Dialogs/AppRunningDialog.xaml index 4cd1083..6d6f7e3 100644 --- a/WindowsTools/UI/Dialogs/AppRunningDialog.xaml +++ b/WindowsTools/UI/Dialogs/AppRunningDialog.xaml @@ -10,4 +10,4 @@ CloseButtonText="{x:Bind string:Dialog.OK}" Content="{x:Bind string:Dialog.AppRunning}" Style="{StaticResource DefaultContentDialogStyle}" - mc:Ignorable="d" /> + mc:Ignorable="d" /> \ No newline at end of file diff --git a/WindowsTools/UI/Dialogs/FileCheckDialog.xaml b/WindowsTools/UI/Dialogs/FileCheckDialog.xaml index 8a60153..b0abe70 100644 --- a/WindowsTools/UI/Dialogs/FileCheckDialog.xaml +++ b/WindowsTools/UI/Dialogs/FileCheckDialog.xaml @@ -15,4 +15,4 @@ SecondaryButtonClick="{x:Bind OnSecondaryButtonClicked}" SecondaryButtonText="{x:Bind string:Dialog.OpenFolder}" Style="{StaticResource DefaultContentDialogStyle}" - mc:Ignorable="d" /> + mc:Ignorable="d" /> \ No newline at end of file diff --git a/WindowsTools/UI/Dialogs/LicenseDialog.xaml b/WindowsTools/UI/Dialogs/LicenseDialog.xaml index be1db63..5bdf38b 100644 --- a/WindowsTools/UI/Dialogs/LicenseDialog.xaml +++ b/WindowsTools/UI/Dialogs/LicenseDialog.xaml @@ -17,4 +17,4 @@ ScrollViewer.VerticalScrollMode="Enabled" Text="{x:Bind LicenseText, Mode=OneWay}" TextWrapping="Wrap" /> - + \ No newline at end of file diff --git a/WindowsTools/UI/Dialogs/OperationFailedDialog.xaml b/WindowsTools/UI/Dialogs/OperationFailedDialog.xaml index e0ac9a9..e6c2485 100644 --- a/WindowsTools/UI/Dialogs/OperationFailedDialog.xaml +++ b/WindowsTools/UI/Dialogs/OperationFailedDialog.xaml @@ -194,4 +194,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/UI/Dialogs/RestartAppsDialog.xaml b/WindowsTools/UI/Dialogs/RestartAppsDialog.xaml index aff2299..6b9a05a 100644 --- a/WindowsTools/UI/Dialogs/RestartAppsDialog.xaml +++ b/WindowsTools/UI/Dialogs/RestartAppsDialog.xaml @@ -19,4 +19,4 @@ Text="{x:Bind string:Dialog.RestartContent}" TextAlignment="Justify" TextWrapping="Wrap" /> - + \ No newline at end of file diff --git a/WindowsTools/UI/TeachingTips/DataCopyTip.xaml b/WindowsTools/UI/TeachingTips/DataCopyTip.xaml index 28ced75..21e2fa3 100644 --- a/WindowsTools/UI/TeachingTips/DataCopyTip.xaml +++ b/WindowsTools/UI/TeachingTips/DataCopyTip.xaml @@ -16,4 +16,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/UI/TeachingTips/DataCopyTip.xaml.cs b/WindowsTools/UI/TeachingTips/DataCopyTip.xaml.cs index 8525ef2..f32a9e9 100644 --- a/WindowsTools/UI/TeachingTips/DataCopyTip.xaml.cs +++ b/WindowsTools/UI/TeachingTips/DataCopyTip.xaml.cs @@ -35,39 +35,17 @@ private void InitializeContent(DataCopyKind dataCopyKind, bool isSuccessfully, b } case DataCopyKind.FilePath: { - if (isMultiSelected) - { - Content = string.Format(Notification.FilePathSelectedCopy, count); - } - else - { - Content = Notification.FilePathCopy; - } - + Content = isMultiSelected ? string.Format(Notification.FilePathSelectedCopy, count) : (object)Notification.FilePathCopy; break; } case DataCopyKind.OperationFailed: { - if (isMultiSelected) - { - Content = string.Format(Notification.OperationFailedSelectedCopy, count); - } - else - { - Content = Notification.OperationFailedCopy; - } + Content = isMultiSelected ? string.Format(Notification.OperationFailedSelectedCopy, count) : (object)Notification.OperationFailedCopy; break; } case DataCopyKind.String: { - if (isMultiSelected) - { - Content = string.Format(Notification.StringSelectedCopy, count); - } - else - { - Content = Notification.StringCopy; - } + Content = isMultiSelected ? string.Format(Notification.StringSelectedCopy, count) : (object)Notification.StringCopy; break; } case DataCopyKind.UpdateInformation: diff --git a/WindowsTools/UI/TeachingTips/LanguageChangeTip.xaml b/WindowsTools/UI/TeachingTips/LanguageChangeTip.xaml index 2cc7187..ac91d10 100644 --- a/WindowsTools/UI/TeachingTips/LanguageChangeTip.xaml +++ b/WindowsTools/UI/TeachingTips/LanguageChangeTip.xaml @@ -12,4 +12,4 @@ PlacementMargin="0,20,0,0" PreferredPlacement="Bottom" Style="{StaticResource TeachingTipStyle}" - mc:Ignorable="d" /> + mc:Ignorable="d" /> \ No newline at end of file diff --git a/WindowsTools/UI/TeachingTips/ListEmptyTip.xaml b/WindowsTools/UI/TeachingTips/ListEmptyTip.xaml index da45547..93aa7bb 100644 --- a/WindowsTools/UI/TeachingTips/ListEmptyTip.xaml +++ b/WindowsTools/UI/TeachingTips/ListEmptyTip.xaml @@ -12,4 +12,4 @@ PlacementMargin="0,20,0,0" PreferredPlacement="Bottom" Style="{StaticResource TeachingTipStyle}" - mc:Ignorable="d" /> + mc:Ignorable="d" /> \ No newline at end of file diff --git a/WindowsTools/UI/TeachingTips/LogCleanTip.xaml b/WindowsTools/UI/TeachingTips/LogCleanTip.xaml index 763ab4a..907494f 100644 --- a/WindowsTools/UI/TeachingTips/LogCleanTip.xaml +++ b/WindowsTools/UI/TeachingTips/LogCleanTip.xaml @@ -15,4 +15,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/UI/TeachingTips/LogCleanTip.xaml.cs b/WindowsTools/UI/TeachingTips/LogCleanTip.xaml.cs index df3e135..c9e502c 100644 --- a/WindowsTools/UI/TeachingTips/LogCleanTip.xaml.cs +++ b/WindowsTools/UI/TeachingTips/LogCleanTip.xaml.cs @@ -28,7 +28,7 @@ private void InitializeContent(bool cleanResult) } else { - LogCleanSuccess.Text = Notification.LogCleanFailed; + LogCleanFailed.Text = Notification.LogCleanFailed; LogCleanSuccess.Visibility = Visibility.Collapsed; LogCleanFailed.Visibility = Visibility.Visible; } diff --git a/WindowsTools/UI/TeachingTips/LoopbackSetResultToolTip.xaml b/WindowsTools/UI/TeachingTips/LoopbackSetResultToolTip.xaml new file mode 100644 index 0000000..c892190 --- /dev/null +++ b/WindowsTools/UI/TeachingTips/LoopbackSetResultToolTip.xaml @@ -0,0 +1,18 @@ + + + + + + + \ No newline at end of file diff --git a/WindowsTools/UI/TeachingTips/LoopbackSetResultToolTip.xaml.cs b/WindowsTools/UI/TeachingTips/LoopbackSetResultToolTip.xaml.cs new file mode 100644 index 0000000..262980f --- /dev/null +++ b/WindowsTools/UI/TeachingTips/LoopbackSetResultToolTip.xaml.cs @@ -0,0 +1,37 @@ +using Microsoft.UI.Xaml.Controls; +using Windows.UI.Xaml; +using WindowsTools.Strings; + +namespace WindowsTools.UI.TeachingTips +{ + /// + /// 日志记录清除应用内通知 + /// + public sealed partial class LoopbackSetResultToolTip : TeachingTip + { + public LoopbackSetResultToolTip(bool setResult) + { + InitializeComponent(); + InitializeContent(setResult); + } + + /// + /// 初始化内容 + /// + private void InitializeContent(bool setResult) + { + if (setResult) + { + LoopbackSetSuccess.Text = Notification.LoopbackSetResultSuccessfully; + LoopbackSetSuccess.Visibility = Visibility.Visible; + LoopbackSetFailed.Visibility = Visibility.Collapsed; + } + else + { + LoopbackSetFailed.Text = Notification.LoopbackSetResultFailed; + LoopbackSetSuccess.Visibility = Visibility.Collapsed; + LoopbackSetFailed.Visibility = Visibility.Visible; + } + } + } +} diff --git a/WindowsTools/UI/TeachingTips/NoOperationTip.xaml b/WindowsTools/UI/TeachingTips/NoOperationTip.xaml index c174aee..e6280f4 100644 --- a/WindowsTools/UI/TeachingTips/NoOperationTip.xaml +++ b/WindowsTools/UI/TeachingTips/NoOperationTip.xaml @@ -12,4 +12,4 @@ PlacementMargin="0,20,0,0" PreferredPlacement="Bottom" Style="{StaticResource TeachingTipStyle}" - mc:Ignorable="d" /> + mc:Ignorable="d" /> \ No newline at end of file diff --git a/WindowsTools/UI/TeachingTips/OperationResultTip.xaml b/WindowsTools/UI/TeachingTips/OperationResultTip.xaml index 7074e20..a9b6feb 100644 --- a/WindowsTools/UI/TeachingTips/OperationResultTip.xaml +++ b/WindowsTools/UI/TeachingTips/OperationResultTip.xaml @@ -15,4 +15,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/UI/TeachingTips/QuickOperationTip.xaml b/WindowsTools/UI/TeachingTips/QuickOperationTip.xaml index 141c149..05921b4 100644 --- a/WindowsTools/UI/TeachingTips/QuickOperationTip.xaml +++ b/WindowsTools/UI/TeachingTips/QuickOperationTip.xaml @@ -15,4 +15,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/UI/TeachingTips/TextEmptyTip.xaml b/WindowsTools/UI/TeachingTips/TextEmptyTip.xaml index 91f90da..b7e4cba 100644 --- a/WindowsTools/UI/TeachingTips/TextEmptyTip.xaml +++ b/WindowsTools/UI/TeachingTips/TextEmptyTip.xaml @@ -12,4 +12,4 @@ PlacementMargin="0,20,0,0" PreferredPlacement="Bottom" Style="{StaticResource TeachingTipStyle}" - mc:Ignorable="d" /> + mc:Ignorable="d" /> \ No newline at end of file diff --git a/WindowsTools/Views/Pages/AllToolsPage.xaml b/WindowsTools/Views/Pages/AllToolsPage.xaml index 478bd89..3d28475 100644 --- a/WindowsTools/Views/Pages/AllToolsPage.xaml +++ b/WindowsTools/Views/Pages/AllToolsPage.xaml @@ -229,4 +229,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/CodeScannerPage.xaml b/WindowsTools/Views/Pages/CodeScannerPage.xaml index a479fa9..f19fb26 100644 --- a/WindowsTools/Views/Pages/CodeScannerPage.xaml +++ b/WindowsTools/Views/Pages/CodeScannerPage.xaml @@ -426,4 +426,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/ColorPickerPage.xaml b/WindowsTools/Views/Pages/ColorPickerPage.xaml index 7745407..5605b13 100644 --- a/WindowsTools/Views/Pages/ColorPickerPage.xaml +++ b/WindowsTools/Views/Pages/ColorPickerPage.xaml @@ -20,4 +20,4 @@ FontSize="22" Text="{x:Bind string:ColorPicker.Title}" /> - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/DownloadManagerPage.xaml b/WindowsTools/Views/Pages/DownloadManagerPage.xaml index 7a313cf..982f481 100644 --- a/WindowsTools/Views/Pages/DownloadManagerPage.xaml +++ b/WindowsTools/Views/Pages/DownloadManagerPage.xaml @@ -673,4 +673,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/DriverManagerPage.xaml b/WindowsTools/Views/Pages/DriverManagerPage.xaml index eaeaba2..12017ed 100644 --- a/WindowsTools/Views/Pages/DriverManagerPage.xaml +++ b/WindowsTools/Views/Pages/DriverManagerPage.xaml @@ -20,4 +20,4 @@ FontSize="22" Text="{x:Bind string:DriverManager.Title}" /> - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/ExtensionNamePage.xaml b/WindowsTools/Views/Pages/ExtensionNamePage.xaml index cefb6d1..e7eae8c 100644 --- a/WindowsTools/Views/Pages/ExtensionNamePage.xaml +++ b/WindowsTools/Views/Pages/ExtensionNamePage.xaml @@ -324,4 +324,4 @@ Style="{StaticResource AccentButtonStyle}" /> - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/ExtensionNamePage.xaml.cs b/WindowsTools/Views/Pages/ExtensionNamePage.xaml.cs index bceb057..4904873 100644 --- a/WindowsTools/Views/Pages/ExtensionNamePage.xaml.cs +++ b/WindowsTools/Views/Pages/ExtensionNamePage.xaml.cs @@ -535,14 +535,7 @@ public void AddToExtensionNamePage(List extensionNameList) /// private bool CheckOperationState() { - if (SelectedType is ExtensionNameSelectedKind.None) - { - return false; - } - else - { - return true; - } + return SelectedType is not ExtensionNameSelectedKind.None; } /// diff --git a/WindowsTools/Views/Pages/FileCertificatePage.xaml b/WindowsTools/Views/Pages/FileCertificatePage.xaml index 4625d67..4de4915 100644 --- a/WindowsTools/Views/Pages/FileCertificatePage.xaml +++ b/WindowsTools/Views/Pages/FileCertificatePage.xaml @@ -187,4 +187,4 @@ Style="{StaticResource AccentButtonStyle}" /> - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/FileNamePage.xaml b/WindowsTools/Views/Pages/FileNamePage.xaml index 5d8ee38..089ed48 100644 --- a/WindowsTools/Views/Pages/FileNamePage.xaml +++ b/WindowsTools/Views/Pages/FileNamePage.xaml @@ -696,4 +696,4 @@ Style="{StaticResource AccentButtonStyle}" /> - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/FileNamePage.xaml.cs b/WindowsTools/Views/Pages/FileNamePage.xaml.cs index 634690b..add927e 100644 --- a/WindowsTools/Views/Pages/FileNamePage.xaml.cs +++ b/WindowsTools/Views/Pages/FileNamePage.xaml.cs @@ -722,14 +722,7 @@ private string GetChangeRule(int index) /// private bool CheckOperationState() { - if (RenameRule == string.Empty && StartNumber == string.Empty && IsChecked == false && LookUpString == string.Empty && ReplaceString == string.Empty) - { - return false; - } - else - { - return true; - } + return RenameRule != string.Empty || StartNumber != string.Empty || IsChecked != false || LookUpString != string.Empty || ReplaceString != string.Empty; } /// diff --git a/WindowsTools/Views/Pages/FilePropertiesPage.xaml b/WindowsTools/Views/Pages/FilePropertiesPage.xaml index d0c9cfa..181ce9f 100644 --- a/WindowsTools/Views/Pages/FilePropertiesPage.xaml +++ b/WindowsTools/Views/Pages/FilePropertiesPage.xaml @@ -361,4 +361,4 @@ Style="{StaticResource AccentButtonStyle}" /> - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/FilePropertiesPage.xaml.cs b/WindowsTools/Views/Pages/FilePropertiesPage.xaml.cs index beeda88..ae3c15e 100644 --- a/WindowsTools/Views/Pages/FilePropertiesPage.xaml.cs +++ b/WindowsTools/Views/Pages/FilePropertiesPage.xaml.cs @@ -645,14 +645,7 @@ public void AddToFilePropertiesPage(List filePropertie /// private bool CheckOperationState() { - if (IsReadOnlyChecked is false && IsArchiveChecked is false && IsCreateDateChecked is false && IsHideChecked is false && IsSystemChecked is false && IsModifyDateChecked is false) - { - return false; - } - else - { - return true; - } + return IsReadOnlyChecked is true || IsArchiveChecked is true || IsCreateDateChecked is true || IsHideChecked is true || IsSystemChecked is true || IsModifyDateChecked is true; } /// diff --git a/WindowsTools/Views/Pages/IconExtractPage.xaml b/WindowsTools/Views/Pages/IconExtractPage.xaml index 18b7d10..4100964 100644 --- a/WindowsTools/Views/Pages/IconExtractPage.xaml +++ b/WindowsTools/Views/Pages/IconExtractPage.xaml @@ -334,4 +334,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/LoopbackManagerPage.xaml b/WindowsTools/Views/Pages/LoopbackManagerPage.xaml index fddddcb..2bbc90e 100644 --- a/WindowsTools/Views/Pages/LoopbackManagerPage.xaml +++ b/WindowsTools/Views/Pages/LoopbackManagerPage.xaml @@ -8,11 +8,13 @@ xmlns:model="using:WindowsTools.Models" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" xmlns:string="using:WindowsTools.Strings" + xmlns:sys="using:System" NavigationCacheMode="Enabled" mc:Ignorable="d"> + @@ -23,11 +25,24 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WindowsTools/Views/Pages/LoopbackManagerPage.xaml.cs b/WindowsTools/Views/Pages/LoopbackManagerPage.xaml.cs index d6836bc..e43f702 100644 --- a/WindowsTools/Views/Pages/LoopbackManagerPage.xaml.cs +++ b/WindowsTools/Views/Pages/LoopbackManagerPage.xaml.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; +using System.Diagnostics; using System.Diagnostics.Tracing; using System.Linq; using System.Runtime.InteropServices; @@ -11,8 +12,11 @@ using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Input; +using WindowsTools.Helpers.Controls.Extensions; using WindowsTools.Models; using WindowsTools.Services.Root; +using WindowsTools.Strings; +using WindowsTools.UI.TeachingTips; using WindowsTools.Views.Windows; using WindowsTools.WindowsAPI.PInvoke.FirewallAPI; using WindowsTools.WindowsAPI.PInvoke.Shlwapi; @@ -29,18 +33,18 @@ public sealed partial class LoopbackManagerPage : Page, INotifyPropertyChanged { private IntPtr pACs; - private bool _isProcessing; + private bool _isLoadCompleted; - public bool IsProcessing + public bool IsLoadCompleted { - get { return _isProcessing; } + get { return _isLoadCompleted; } set { - if (!Equals(_isProcessing, value)) + if (!Equals(_isLoadCompleted, value)) { - _isProcessing = value; - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsProcessing))); + _isLoadCompleted = value; + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsLoadCompleted))); } } } @@ -100,10 +104,14 @@ public bool IsSaved public LoopbackManagerPage() { InitializeComponent(); - Task.Run(GetLoopbackData); + + IsLoadCompleted = false; + IsSaved = false; + Task.Run(GetLoopbackDataAsync); + GlobalNotificationService.ApplicationExit += OnApplicationExit; } - #region 第一部分: + #region 第一部分:XamlUICommand 命令调用时挂载的事件 /// /// 点击复选框时使保存按钮处于可选状态 @@ -116,10 +124,37 @@ private void OnCheckExecuteRequested(XamlUICommand sender, ExecuteRequestedEvent } } - #endregion 第一部分: + /// + /// 打开应用程序的工作目录 + /// + private void OnOpenWorkingDirectoryRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) + { + string parameter = args.Parameter as string; + + if (!string.IsNullOrEmpty(parameter)) + { + Task.Run(() => + { + Process.Start(parameter); + }); + } + } + + #endregion 第一部分:XamlUICommand 命令调用时挂载的事件 #region 第二部分:网络回环管理页面——挂载的事件 + /// + /// 了解网络回环 + /// + private void OnLearnLoopbackClicked(object sender, RoutedEventArgs args) + { + Task.Run(() => + { + Process.Start("https://learn.microsoft.com/previous-versions/windows/apps/hh780593(v=win.10)"); + }); + } + /// /// 查询搜索内容 /// @@ -153,7 +188,7 @@ private void OnSearchAppNameQuerySubmitted(object sender, AutoSuggestBoxQuerySub continue; } - if (!string.IsNullOrEmpty(loopbackItem.UserAccountSIDName) && loopbackItem.UserAccountSIDName.Contains(SearchAppNameText)) + if (!string.IsNullOrEmpty(loopbackItem.AppContainerUserName) && loopbackItem.AppContainerUserName.Contains(SearchAppNameText)) { loopbackItem.IsVisible = Visibility.Visible; continue; @@ -200,7 +235,7 @@ private void OnSelectAllClicked(object sender, RoutedEventArgs args) { if (loopbackItem.IsVisible is Visibility.Visible) { - loopbackItem.IsChecked = true; + loopbackItem.IsSelected = true; } } } @@ -215,7 +250,7 @@ private void OnSelectNoneClicked(object sender, RoutedEventArgs args) { if (loopbackItem.IsVisible is Visibility.Visible) { - loopbackItem.IsChecked = false; + loopbackItem.IsSelected = false; } } } @@ -225,10 +260,14 @@ private void OnSelectNoneClicked(object sender, RoutedEventArgs args) /// private void OnResetClicked(object sender, RoutedEventArgs args) { - IsSaved = true; + IsSaved = false; + SearchAppNameText = string.Empty; + IsSearchEmpty = false; + foreach (LoopbackModel loopbackItem in LoopbackCollection) { - loopbackItem.IsChecked = loopbackItem.IsOldChecked; + loopbackItem.IsVisible = Visibility.Visible; + loopbackItem.IsSelected = loopbackItem.IsOldChecked; } } @@ -237,8 +276,10 @@ private void OnResetClicked(object sender, RoutedEventArgs args) /// private void OnRefreshClicked(object sender, RoutedEventArgs args) { + IsLoadCompleted = false; + IsSaved = false; LoopbackCollection.Clear(); - Task.Run(GetLoopbackData); + Task.Run(GetLoopbackDataAsync); } /// @@ -246,14 +287,49 @@ private void OnRefreshClicked(object sender, RoutedEventArgs args) /// private void OnSaveClicked(object sender, RoutedEventArgs args) { + IsSaved = false; + List selectedLoopbackList = []; + foreach (LoopbackModel loopbackItem in LoopbackCollection) + { + if (loopbackItem.IsSelected is true) + { + loopbackItem.IsOldChecked = loopbackItem.IsSelected; + selectedLoopbackList.Add(loopbackItem); + } + } + + Task.Run(() => + { + SetLoopbackState(selectedLoopbackList); + }); } #endregion 第二部分:网络回环管理页面——挂载的事件 + #region 第三部分:自定义事件 + + /// + /// 应用程序退出时触发的事件 + /// + private void OnApplicationExit(object sender, EventArgs args) + { + try + { + FreeResources(); + GlobalNotificationService.ApplicationExit -= OnApplicationExit; + } + catch (Exception e) + { + LogService.WriteLog(EventLevel.Error, "Release loopback manager resources failed", e); + } + } + + #endregion 第三部分:自定义事件 + /// /// 获取应用数据 /// - private void GetLoopbackData() + private async Task GetLoopbackDataAsync() { pACs = IntPtr.Zero; List inetLoopbackList = GetLoopbackList(); @@ -265,10 +341,10 @@ private void GetLoopbackData() { bool isEnabled = GetLoopbackEnabled(inetContainerItem.appContainerSid, inetLoopbackEnabledList); - StringBuilder displayNameBuilder = new(); + StringBuilder displayNameBuilder = new(1024); ShlwapiLibrary.SHLoadIndirectString(inetContainerItem.displayName, displayNameBuilder, displayNameBuilder.Capacity, IntPtr.Zero); - StringBuilder descriptionBuilder = new(); + StringBuilder descriptionBuilder = new(1024); ShlwapiLibrary.SHLoadIndirectString(inetContainerItem.description, descriptionBuilder, descriptionBuilder.Capacity, IntPtr.Zero); INET_FIREWALL_AC_BINARIES inetBinaries = inetContainerItem.binaries; @@ -313,24 +389,24 @@ private void GetLoopbackData() LogService.WriteLog(EventLevel.Error, "Parse user sid failed", e); } - LoopbackModel appContainerItem = new() + LoopbackModel loopbackItem = new() { - AppContainerName = inetContainerItem.appContainerName, + AppContainerName = string.IsNullOrEmpty(inetContainerItem.appContainerName) ? LoopbackManager.Unknown : inetContainerItem.appContainerName, AppContainerSID = inetContainerItem.appContainerSid, - AppContainerSIDName = appContainerSid.ToString(), - DisplayName = displayNameBuilder.ToString(), - Description = descriptionBuilder.ToString(), - WorkingDirectory = inetContainerItem.workingDirectory, - PackageFullName = inetContainerItem.packageFullName, - StringBinaries = stringBinaries is not null ? stringBinaries : [], - UserAccountSIDName = userAccountType is not null ? userAccountType.ToString() : string.Empty, - IsChecked = isEnabled, + AppContainerSIDName = string.IsNullOrEmpty(appContainerSid.ToString()) ? LoopbackManager.Unknown : appContainerSid.ToString(), + DisplayName = string.IsNullOrEmpty(displayNameBuilder.ToString()) ? LoopbackManager.Unknown : displayNameBuilder.ToString(), + Description = string.IsNullOrEmpty(descriptionBuilder.ToString()) ? LoopbackManager.Unknown : descriptionBuilder.ToString(), + WorkingDirectory = string.IsNullOrEmpty(inetContainerItem.workingDirectory) ? LoopbackManager.Unknown : inetContainerItem.workingDirectory, + PackageFullName = string.IsNullOrEmpty(inetContainerItem.packageFullName) ? LoopbackManager.Unknown : inetContainerItem.packageFullName, + AppBinariesPath = stringBinaries is not null ? stringBinaries : LoopbackManager.Unknown.Split(), + AppContainerUserName = userAccountType is not null ? userAccountType.ToString() : LoopbackManager.Unknown, + IsSelected = isEnabled, IsOldChecked = isEnabled, }; MainWindow.Current.BeginInvoke(() => { - LoopbackCollection.Add(appContainerItem); + LoopbackCollection.Add(loopbackItem); }); } catch (Exception) @@ -338,6 +414,12 @@ private void GetLoopbackData() continue; } } + + await Task.Delay(500); + MainWindow.Current.BeginInvoke(() => + { + IsLoadCompleted = true; + }); } /// @@ -425,15 +507,31 @@ private void SetLoopbackState(List loopbackList) foreach (LoopbackModel loopbackItem in loopbackList) { - if (loopbackItem.IsChecked) + if (loopbackItem.IsSelected) { - sidAndAttributesArray[count].Attributes = 0; - sidAndAttributesArray[count].Sid = loopbackItem.AppContainerSID; + sidAndAttributesArray[count] = new SID_AND_ATTRIBUTES + { + Attributes = 0u, + Sid = loopbackItem.AppContainerSID + }; count++; } } - FirewallAPILibrary.NetworkIsolationSetAppContainerConfig(loopbackList.Count, sidAndAttributesArray); + if (FirewallAPILibrary.NetworkIsolationSetAppContainerConfig(loopbackList.Count, sidAndAttributesArray) is 0) + { + MainWindow.Current.BeginInvoke(() => + { + TeachingTipHelper.Show(new LoopbackSetResultToolTip(true)); + }); + } + else + { + MainWindow.Current.BeginInvoke(() => + { + TeachingTipHelper.Show(new LoopbackSetResultToolTip(false)); + }); + } } } diff --git a/WindowsTools/Views/Pages/MainPage.xaml b/WindowsTools/Views/Pages/MainPage.xaml index c922443..2d884b6 100644 --- a/WindowsTools/Views/Pages/MainPage.xaml +++ b/WindowsTools/Views/Pages/MainPage.xaml @@ -370,4 +370,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/MainPage.xaml.cs b/WindowsTools/Views/Pages/MainPage.xaml.cs index 6e8bc31..9707bd7 100644 --- a/WindowsTools/Views/Pages/MainPage.xaml.cs +++ b/WindowsTools/Views/Pages/MainPage.xaml.cs @@ -650,14 +650,7 @@ public void SendReceivedFilesList(List filesList) private bool GetWindowMaximizeState(bool isWindowMaximized, bool isWindowMaximizeEnabled, string isReverse) { - if (isWindowMaximizeEnabled) - { - return isReverse == nameof(isReverse) ? isWindowMaximized.Equals(false) : isWindowMaximized; - } - else - { - return false; - } + return isWindowMaximizeEnabled ? isReverse == nameof(isReverse) ? isWindowMaximized.Equals(false) : isWindowMaximized : false; } } } diff --git a/WindowsTools/Views/Pages/PriExtractPage.xaml b/WindowsTools/Views/Pages/PriExtractPage.xaml index efbd03c..e90fa12 100644 --- a/WindowsTools/Views/Pages/PriExtractPage.xaml +++ b/WindowsTools/Views/Pages/PriExtractPage.xaml @@ -773,4 +773,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/SettingsPage.xaml b/WindowsTools/Views/Pages/SettingsPage.xaml index 20a8f30..913b8ba 100644 --- a/WindowsTools/Views/Pages/SettingsPage.xaml +++ b/WindowsTools/Views/Pages/SettingsPage.xaml @@ -971,4 +971,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/ShellMenuPage.xaml b/WindowsTools/Views/Pages/ShellMenuPage.xaml index d7e8118..9c3bb92 100644 --- a/WindowsTools/Views/Pages/ShellMenuPage.xaml +++ b/WindowsTools/Views/Pages/ShellMenuPage.xaml @@ -210,4 +210,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/SimulateUpdatePage.xaml b/WindowsTools/Views/Pages/SimulateUpdatePage.xaml index d42d571..6b32b9c 100644 --- a/WindowsTools/Views/Pages/SimulateUpdatePage.xaml +++ b/WindowsTools/Views/Pages/SimulateUpdatePage.xaml @@ -79,4 +79,4 @@ Text="{x:Bind string:SimulateUpdate.ComputerRestart}" /> - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/SystemInfoPage.xaml b/WindowsTools/Views/Pages/SystemInfoPage.xaml index 9794e63..76e87a4 100644 --- a/WindowsTools/Views/Pages/SystemInfoPage.xaml +++ b/WindowsTools/Views/Pages/SystemInfoPage.xaml @@ -217,4 +217,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/UpdateManagerPage.xaml b/WindowsTools/Views/Pages/UpdateManagerPage.xaml index fc87ffe..a20f464 100644 --- a/WindowsTools/Views/Pages/UpdateManagerPage.xaml +++ b/WindowsTools/Views/Pages/UpdateManagerPage.xaml @@ -1584,4 +1584,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/UpperAndLowerCasePage.xaml b/WindowsTools/Views/Pages/UpperAndLowerCasePage.xaml index be3b631..c51cd5a 100644 --- a/WindowsTools/Views/Pages/UpperAndLowerCasePage.xaml +++ b/WindowsTools/Views/Pages/UpperAndLowerCasePage.xaml @@ -326,4 +326,4 @@ Style="{StaticResource AccentButtonStyle}" /> - + \ No newline at end of file diff --git a/WindowsTools/Views/Pages/UpperAndLowerCasePage.xaml.cs b/WindowsTools/Views/Pages/UpperAndLowerCasePage.xaml.cs index 45b2c56..4dd34ee 100644 --- a/WindowsTools/Views/Pages/UpperAndLowerCasePage.xaml.cs +++ b/WindowsTools/Views/Pages/UpperAndLowerCasePage.xaml.cs @@ -469,14 +469,7 @@ public void AddtoUpperAndLowerCasePage(List upperAndLowerCas /// private bool CheckOperationState() { - if (SelectedType is UpperAndLowerSelectedKind.None) - { - return false; - } - else - { - return true; - } + return SelectedType is not UpperAndLowerSelectedKind.None; } /// diff --git a/WindowsTools/Views/Pages/WinSATPage.xaml b/WindowsTools/Views/Pages/WinSATPage.xaml index ec532df..91cb110 100644 --- a/WindowsTools/Views/Pages/WinSATPage.xaml +++ b/WindowsTools/Views/Pages/WinSATPage.xaml @@ -540,4 +540,4 @@ - + \ No newline at end of file diff --git a/WindowsTools/Views/Windows/MainWindow.cs b/WindowsTools/Views/Windows/MainWindow.cs index 75928b0..a0ebfb9 100644 --- a/WindowsTools/Views/Windows/MainWindow.cs +++ b/WindowsTools/Views/Windows/MainWindow.cs @@ -130,14 +130,7 @@ protected override void OnDeactivate(EventArgs args) base.OnDeactivate(args); if (systemBackdropConfiguration is not null) { - if (AlwaysShowBackdropService.AlwaysShowBackdropValue) - { - systemBackdropConfiguration.IsInputActive = true; - } - else - { - systemBackdropConfiguration.IsInputActive = false; - } + systemBackdropConfiguration.IsInputActive = AlwaysShowBackdropService.AlwaysShowBackdropValue; } } diff --git a/WindowsTools/WindowsAPI/ComTypes/CWinSATCallbacks.cs b/WindowsTools/WindowsAPI/ComTypes/CWinSATCallbacks.cs index 42c1216..aea9b53 100644 --- a/WindowsTools/WindowsAPI/ComTypes/CWinSATCallbacks.cs +++ b/WindowsTools/WindowsAPI/ComTypes/CWinSATCallbacks.cs @@ -50,7 +50,7 @@ public void WinSATComplete(int hresult, string strDescription) { Result = (WINSAT_RESULT)hresult; } - catch(Exception) + catch (Exception) { Result = WINSAT_RESULT.WINSAT_ERROR_COMPLETED_ERROR; } diff --git a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/FirewallAPILibrary.cs b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/FirewallAPILibrary.cs index 9331a80..3ba2698 100644 --- a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/FirewallAPILibrary.cs +++ b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/FirewallAPILibrary.cs @@ -39,7 +39,7 @@ public static class FirewallAPILibrary /// appContainerSids 成员中的应用容器数。 /// 安全标识符 (允许发送环回流量的应用容器) SID。 用于调试目的。 /// 如果成功,则返回ERROR_SUCCESS,否则返回错误值。 - [DllImport(FirewallAPI, CharSet = CharSet.Unicode, EntryPoint = "NetworkIsolationGetAppContainerConfig", SetLastError = false)] - internal static extern uint NetworkIsolationSetAppContainerConfig(int dwNumPublicAppCs, SID_AND_ATTRIBUTES[] appContainerSids); + [DllImport(FirewallAPI, CharSet = CharSet.Unicode, EntryPoint = "NetworkIsolationSetAppContainerConfig", SetLastError = false)] + internal static extern uint NetworkIsolationSetAppContainerConfig(int dwNumPublicAppCs, [MarshalAs(UnmanagedType.LPArray)] SID_AND_ATTRIBUTES[] appContainerSids); } } diff --git a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_AC_BINARIES.cs b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_AC_BINARIES.cs index 6a51bd6..da93843 100644 --- a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_AC_BINARIES.cs +++ b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_AC_BINARIES.cs @@ -1,10 +1,12 @@ using System; +using System.Runtime.InteropServices; namespace WindowsTools.WindowsAPI.PInvoke.FirewallAPI { /// /// 包含应用容器中运行的应用程序的二进制路径。 /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct INET_FIREWALL_AC_BINARIES { /// diff --git a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_AC_CAPABILITIES.cs b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_AC_CAPABILITIES.cs index 8d64acc..4399a50 100644 --- a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_AC_CAPABILITIES.cs +++ b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_AC_CAPABILITIES.cs @@ -1,10 +1,12 @@ using System; +using System.Runtime.InteropServices; namespace WindowsTools.WindowsAPI.PInvoke.FirewallAPI { /// /// 包含有关应用容器功能的信息。 /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct INET_FIREWALL_AC_CAPABILITIES { /// diff --git a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_APP_CONTAINER.cs b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_APP_CONTAINER.cs index 4c18efc..b01796f 100644 --- a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_APP_CONTAINER.cs +++ b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/INET_FIREWALL_APP_CONTAINER.cs @@ -6,6 +6,7 @@ namespace WindowsTools.WindowsAPI.PInvoke.FirewallAPI /// /// 包含有关特定应用容器的信息。 /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct INET_FIREWALL_APP_CONTAINER { /// diff --git a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/SID_AND_ATTRIBUTES.cs b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/SID_AND_ATTRIBUTES.cs index 10c9b4a..278c23a 100644 --- a/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/SID_AND_ATTRIBUTES.cs +++ b/WindowsTools/WindowsAPI/PInvoke/FirewallAPI/SID_AND_ATTRIBUTES.cs @@ -1,10 +1,12 @@ using System; +using System.Runtime.InteropServices; namespace WindowsTools.WindowsAPI.PInvoke.FirewallAPI { /// /// SID_AND_ATTRIBUTES 结构表示 SID) 及其属性安全标识符。 SID 用于唯一标识用户或组。 /// + [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public struct SID_AND_ATTRIBUTES { /// diff --git a/WindowsToolsPackage/Package.appxmanifest b/WindowsToolsPackage/Package.appxmanifest index 2478b62..823b0b5 100644 --- a/WindowsToolsPackage/Package.appxmanifest +++ b/WindowsToolsPackage/Package.appxmanifest @@ -12,7 +12,7 @@ + Version="2.6.627.0" /> ms-resource:PackageDisplayName diff --git a/WindowsToolsShellExtension/Commands/EnumExplorerCommand.cs b/WindowsToolsShellExtension/Commands/EnumExplorerCommand.cs index 9370353..0595717 100644 --- a/WindowsToolsShellExtension/Commands/EnumExplorerCommand.cs +++ b/WindowsToolsShellExtension/Commands/EnumExplorerCommand.cs @@ -8,23 +8,11 @@ namespace WindowsToolsShellExtension.Commands /// 命令栏的命令枚举接口实现类 /// [GeneratedComClass] - public partial class EnumExplorerCommand : IEnumExplorerCommand + public partial class EnumExplorerCommand(SubExplorerCommand[] explorerCommands) : IEnumExplorerCommand { - private readonly SubExplorerCommand[] subExplorerCommands; + private readonly SubExplorerCommand[] subExplorerCommands = explorerCommands is null ? ([]) : explorerCommands; private uint index; - public EnumExplorerCommand(SubExplorerCommand[] explorerCommands) - { - if (explorerCommands is null) - { - subExplorerCommands = []; - } - else - { - subExplorerCommands = explorerCommands; - } - } - /// /// 目前尚未实现。 /// diff --git a/WindowsToolsShellExtension/Helpers/Root/RegistryHelper.cs b/WindowsToolsShellExtension/Helpers/Root/RegistryHelper.cs index f5be7e2..f28999e 100644 --- a/WindowsToolsShellExtension/Helpers/Root/RegistryHelper.cs +++ b/WindowsToolsShellExtension/Helpers/Root/RegistryHelper.cs @@ -57,14 +57,7 @@ public static T ReadRegistryValue(string rootKey, string key) } // 布尔值以字符串整数类型值存储 - if (typeof(T) == typeof(bool) || typeof(T) == typeof(bool?)) - { - value = (T)(object)BitConverter.ToBoolean(data, 0); - } - else - { - value = (T)(object)BitConverter.ToUInt32(data, 0); - } + value = typeof(T) == typeof(bool) || typeof(T) == typeof(bool?) ? (T)(object)BitConverter.ToBoolean(data, 0) : (T)(object)BitConverter.ToUInt32(data, 0); } // 字符串序列 else if (kind is RegistryValueKind.REG_MULTI_SZ) diff --git a/WindowsToolsShellExtension/Program.cs b/WindowsToolsShellExtension/Program.cs index 53b80c5..a7bcf56 100644 --- a/WindowsToolsShellExtension/Program.cs +++ b/WindowsToolsShellExtension/Program.cs @@ -20,7 +20,7 @@ public class Program public static StrategyBasedComWrappers StrategyBasedComWrappers { get; } = new StrategyBasedComWrappers(); - private readonly static IReadOnlyDictionary> createFunctions = new Dictionary>() + private static readonly IReadOnlyDictionary> createFunctions = new Dictionary>() { [typeof(RootExplorerCommand).GUID] = () => new RootExplorerCommand() }; diff --git a/WindowsToolsShellExtension/Properties/AssemblyInfo.cs b/WindowsToolsShellExtension/Properties/AssemblyInfo.cs index e73a79d..74efb2e 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.6.626.0")] -[assembly: AssemblyInformationalVersion("2.6.626.0")] +[assembly: AssemblyFileVersion("2.6.627.0")] +[assembly: AssemblyInformationalVersion("2.6.627.0")] [assembly: AssemblyProduct("Windows 工具箱 右键菜单扩展")] [assembly: AssemblyTitle("Windows 工具箱 右键菜单扩展")] -[assembly: AssemblyVersion("2.6.626.0")] +[assembly: AssemblyVersion("2.6.627.0")] // 应用程序默认区域性的资源控制器设置 [assembly: NeutralResourcesLanguage("en-us")] diff --git a/WindowsToolsShellExtension/Services/Shell/ShellMenuService.cs b/WindowsToolsShellExtension/Services/Shell/ShellMenuService.cs index 7e58085..f31dcad 100644 --- a/WindowsToolsShellExtension/Services/Shell/ShellMenuService.cs +++ b/WindowsToolsShellExtension/Services/Shell/ShellMenuService.cs @@ -75,14 +75,7 @@ private static unsafe void InitializeRootMenu() RootMenuIconPath = Path.Combine(new string(pathbuffer), @"Assets\WindowsTools.ico"); } - if (useDefaultText.HasValue && useDefaultText is false && !string.IsNullOrEmpty(text)) - { - RootMenuText = text; - } - else - { - RootMenuText = ShellMenu.RootItemTitle; - } + RootMenuText = useDefaultText.HasValue && useDefaultText is false && !string.IsNullOrEmpty(text) ? text : ShellMenu.RootItemTitle; } } }