From a0facd53d34e647b97f7edd34bee48d7913103bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E6=80=A1=E9=A3=9E?= <363301617@qq.com> Date: Thu, 1 Aug 2024 15:51:59 +0800 Subject: [PATCH] Add SecondLevelMenuEditControl Add SecondLevelMenuEditControl --- Description/StudyReferenceCode.md | 1 + WindowsTools/Models/ShellMenuItemModel.cs | 3 +- WindowsTools/Properties/AssemblyInfo.cs | 6 +- WindowsTools/Strings/ShellMenu.Designer.cs | 278 ++++- WindowsTools/Strings/ShellMenu.en-us.resx | 96 +- WindowsTools/Strings/ShellMenu.resx | 96 +- WindowsTools/Strings/ShellMenu.zh-hans.resx | 94 +- WindowsTools/Styles/HyperlinkButton.xaml | 3 +- WindowsTools/Styles/ListView.xaml | 3 +- WindowsTools/Styles/MenuFlyout.xaml | 3 +- .../UI/Backdrop/DesktopAcrylicBackdrop.cs | 1 - WindowsTools/UI/Backdrop/MicaBackdrop.cs | 1 - .../Controls/FirstLevelMenuEditControl.xaml | 1082 +++++++++++++++++ .../FirstLevelMenuEditControl.xaml.cs | 681 +++++++++++ .../Controls/SecondLevelMenuEditControl.xaml | 779 ++++++++++++ .../SecondLevelMenuEditControl.xaml.cs | 573 +++++++++ WindowsTools/Views/Pages/AllToolsPage.xaml.cs | 9 +- WindowsTools/Views/Pages/LoafPage.xaml | 6 +- WindowsTools/Views/Pages/MainPage.xaml.cs | 20 +- WindowsTools/Views/Pages/SettingsPage.xaml | 8 +- WindowsTools/Views/Pages/ShellMenuPage.xaml | 356 +----- .../Views/Pages/ShellMenuPage.xaml.cs | 311 +---- .../PInvoke/User32/POWERBROADCAST_SETTING.cs | 2 +- WindowsToolsPackage/Package.appxmanifest | 2 +- .../WindowsToolsPackage.wapproj | 2 +- .../Properties/AssemblyInfo.cs | 8 +- .../WindowsToolsShellExtension.csproj | 7 +- 27 files changed, 3789 insertions(+), 642 deletions(-) create mode 100644 WindowsTools/UI/Controls/FirstLevelMenuEditControl.xaml create mode 100644 WindowsTools/UI/Controls/FirstLevelMenuEditControl.xaml.cs create mode 100644 WindowsTools/UI/Controls/SecondLevelMenuEditControl.xaml create mode 100644 WindowsTools/UI/Controls/SecondLevelMenuEditControl.xaml.cs diff --git a/Description/StudyReferenceCode.md b/Description/StudyReferenceCode.md index 03cc656..4d6aeb7 100644 --- a/Description/StudyReferenceCode.md +++ b/Description/StudyReferenceCode.md @@ -5,6 +5,7 @@ > * [BITS-Manager](https://github.com/Microsoft/BITS-Manager)  > * [BlueFire.Toolkit.WinUI3](https://github.com/cnbluefire/BlueFire.Toolkit.WinUI3)  +> * [ContextMenuForWindows11](https://github.com/ikas-mc/ContextMenuForWindows11)  > * [DirectN](https://github.com/smourier/DirectN)  > * [DODownloaderDotNet](https://github.com/shishirb-MSFT/DODownloaderDotNet)  > * [ExplorerExtensions.Sample](https://github.com/cnbluefire/ExplorerExtensions.Sample)  diff --git a/WindowsTools/Models/ShellMenuItemModel.cs b/WindowsTools/Models/ShellMenuItemModel.cs index f61fa9f..3e71258 100644 --- a/WindowsTools/Models/ShellMenuItemModel.cs +++ b/WindowsTools/Models/ShellMenuItemModel.cs @@ -1,8 +1,7 @@ using System.ComponentModel; using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Media.Imaging; -namespace Models +namespace WindowsTools.Models { /// /// 扩展菜单项数据模型 diff --git a/WindowsTools/Properties/AssemblyInfo.cs b/WindowsTools/Properties/AssemblyInfo.cs index 7cc404c..88a6c83 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.7.725.0")] -[assembly: AssemblyInformationalVersion("2.7.725.0")] +[assembly: AssemblyFileVersion("2.7.801.0")] +[assembly: AssemblyInformationalVersion("2.7.801.0")] [assembly: AssemblyProduct("Windows 工具箱")] [assembly: AssemblyTitle("Windows 工具箱")] -[assembly: AssemblyVersion("2.7.725.0")] +[assembly: AssemblyVersion("2.7.801.0")] diff --git a/WindowsTools/Strings/ShellMenu.Designer.cs b/WindowsTools/Strings/ShellMenu.Designer.cs index 4a1dd87..81533a5 100644 --- a/WindowsTools/Strings/ShellMenu.Designer.cs +++ b/WindowsTools/Strings/ShellMenu.Designer.cs @@ -69,6 +69,15 @@ public static string AddMenuItem { } } + /// + /// 查找类似 All 的本地化字符串。 + /// + public static string All { + get { + return ResourceManager.GetString("All", resourceCulture); + } + } + /// /// 查找类似 Apply 的本地化字符串。 /// @@ -78,6 +87,15 @@ public static string Apply { } } + /// + /// 查找类似 Background 的本地化字符串。 + /// + public static string Background { + get { + return ResourceManager.GetString("Background", resourceCulture); + } + } + /// /// 查找类似 Clear menu items 的本地化字符串。 /// @@ -123,6 +141,33 @@ public static string DefaultRootText { } } + /// + /// 查找类似 Desktop 的本地化字符串。 + /// + public static string Desktop { + get { + return ResourceManager.GetString("Desktop", resourceCulture); + } + } + + /// + /// 查找类似 Directory 的本地化字符串。 + /// + public static string Directory { + get { + return ResourceManager.GetString("Directory", resourceCulture); + } + } + + /// + /// 查找类似 Drive 的本地化字符串。 + /// + public static string Drive { + get { + return ResourceManager.GetString("Drive", resourceCulture); + } + } + /// /// 查找类似 Edit 的本地化字符串。 /// @@ -142,11 +187,20 @@ public static string EmptyDescription { } /// - /// 查找类似 Icon file(*.ico)|*.ico 的本地化字符串。 + /// 查找类似 The content of the secondary menu is empty 的本地化字符串。 /// - public static string FilterCondition { + public static string EmptySecondLevelMenu { get { - return ResourceManager.GetString("FilterCondition", resourceCulture); + return ResourceManager.GetString("EmptySecondLevelMenu", resourceCulture); + } + } + + /// + /// 查找类似 Extension name 的本地化字符串。 + /// + public static string Extension { + get { + return ResourceManager.GetString("Extension", resourceCulture); } } @@ -159,6 +213,15 @@ public static string FirstLevelMenu { } } + /// + /// 查找类似 Icon file(*.ico)|*.ico 的本地化字符串。 + /// + public static string IconFilterCondition { + get { + return ResourceManager.GetString("IconFilterCondition", resourceCulture); + } + } + /// /// 查找类似 Light theme icon 的本地化字符串。 /// @@ -168,6 +231,69 @@ public static string LightThemeIcon { } } + /// + /// 查找类似 For example: .exe | .jpg | .txt 的本地化字符串。 + /// + public static string MenuFileExtensionFormat { + get { + return ResourceManager.GetString("MenuFileExtensionFormat", resourceCulture); + } + } + + /// + /// 查找类似 Match file type 的本地化字符串。 + /// + public static string MenuFileMatch { + get { + return ResourceManager.GetString("MenuFileMatch", resourceCulture); + } + } + + /// + /// 查找类似 Match format 的本地化字符串。 + /// + public static string MenuFileMatchFormat { + get { + return ResourceManager.GetString("MenuFileMatchFormat", resourceCulture); + } + } + + /// + /// 查找类似 Match rule 的本地化字符串。 + /// + public static string MenuFileMatchRule { + get { + return ResourceManager.GetString("MenuFileMatchRule", resourceCulture); + } + } + + /// + /// 查找类似 For example: WindowsTools.exe | ShellMenu.jpg 的本地化字符串。 + /// + public static string MenuFileNameFormat { + get { + return ResourceManager.GetString("MenuFileNameFormat", resourceCulture); + } + } + + /// + /// 查找类似 For example: [\s\S]+.jpg | [\w\W]*.jpg 的本地化字符串。 + /// + public static string MenuFileNameRegexFormat { + get { + return ResourceManager.GetString("MenuFileNameRegexFormat", resourceCulture); + } + } + + /// + /// 查找类似 Match folder type 的本地化字符串。 + /// + public static string MenuFolderMatch { + get { + return ResourceManager.GetString("MenuFolderMatch", resourceCulture); + } + } + /// /// 查找类似 Menu icon 的本地化字符串。 /// @@ -204,6 +330,24 @@ public static string MenuOrder { } } + /// + /// 查找类似 Menu parameter 的本地化字符串。 + /// + public static string MenuParameter { + get { + return ResourceManager.GetString("MenuParameter", resourceCulture); + } + } + + /// + /// 查找类似 The application parameter is not set 的本地化字符串。 + /// + public static string MenuParameterPHText { + get { + return ResourceManager.GetString("MenuParameterPHText", resourceCulture); + } + } + /// /// 查找类似 Program file path 的本地化字符串。 /// @@ -276,6 +420,51 @@ public static string Modify { } } + /// + /// 查找类似 Move down 的本地化字符串。 + /// + public static string MoveDown { + get { + return ResourceManager.GetString("MoveDown", resourceCulture); + } + } + + /// + /// 查找类似 Move up 的本地化字符串。 + /// + public static string MoveUp { + get { + return ResourceManager.GetString("MoveUp", resourceCulture); + } + } + + /// + /// 查找类似 Name 的本地化字符串。 + /// + public static string Name { + get { + return ResourceManager.GetString("Name", resourceCulture); + } + } + + /// + /// 查找类似 Name (Regex) 的本地化字符串。 + /// + public static string NameRegex { + get { + return ResourceManager.GetString("NameRegex", resourceCulture); + } + } + + /// + /// 查找类似 None 的本地化字符串。 + /// + public static string None { + get { + return ResourceManager.GetString("None", resourceCulture); + } + } + /// /// 查找类似 Operation 的本地化字符串。 /// @@ -321,6 +510,15 @@ public static string PrecautionsContent3 { } } + /// + /// 查找类似 Executable file (*.exe)|*.exe 的本地化字符串。 + /// + public static string ProgramFilterCondition { + get { + return ResourceManager.GetString("ProgramFilterCondition", resourceCulture); + } + } + /// /// 查找类似 Refresh 的本地化字符串。 /// @@ -366,6 +564,15 @@ public static string RootMenuSettings { } } + /// + /// 查找类似 Save 的本地化字符串。 + /// + public static string Save { + get { + return ResourceManager.GetString("Save", resourceCulture); + } + } + /// /// 查找类似 Second level menu 的本地化字符串。 /// @@ -385,7 +592,16 @@ public static string SelectIcon { } /// - /// 查找类似 Whether to enable theme icon 的本地化字符串。 + /// 查找类似 Select program 的本地化字符串。 + /// + public static string SelectProgram { + get { + return ResourceManager.GetString("SelectProgram", resourceCulture); + } + } + + /// + /// 查找类似 Should enable theme icon 的本地化字符串。 /// public static string ShouldEnableThemeIcon { get { @@ -420,6 +636,60 @@ public static string ShouldEnableThemeIconToolTip { } } + /// + /// 查找类似 Should use program icon 的本地化字符串。 + /// + public static string ShouldUseProgramIcon { + get { + return ResourceManager.GetString("ShouldUseProgramIcon", resourceCulture); + } + } + + /// + /// 查找类似 No 的本地化字符串。 + /// + public static string ShouldUseProgramIconOffContent { + get { + return ResourceManager.GetString("ShouldUseProgramIconOffContent", resourceCulture); + } + } + + /// + /// 查找类似 Yes 的本地化字符串。 + /// + public static string ShouldUseProgramIconOnContent { + get { + return ResourceManager.GetString("ShouldUseProgramIconOnContent", resourceCulture); + } + } + + /// + /// 查找类似 Should use second level menu 的本地化字符串。 + /// + public static string ShouldUseSecondLevelMenu { + get { + return ResourceManager.GetString("ShouldUseSecondLevelMenu", resourceCulture); + } + } + + /// + /// 查找类似 No 的本地化字符串。 + /// + public static string ShouldUseSecondLevelMenuOffContent { + get { + return ResourceManager.GetString("ShouldUseSecondLevelMenuOffContent", resourceCulture); + } + } + + /// + /// 查找类似 Yes 的本地化字符串。 + /// + public static string ShouldUseSecondLevelMenuOnContent { + get { + return ResourceManager.GetString("ShouldUseSecondLevelMenuOnContent", resourceCulture); + } + } + /// /// 查找类似 Custom shell menu 的本地化字符串。 /// diff --git a/WindowsTools/Strings/ShellMenu.en-us.resx b/WindowsTools/Strings/ShellMenu.en-us.resx index 479b833..cf0b14c 100644 --- a/WindowsTools/Strings/ShellMenu.en-us.resx +++ b/WindowsTools/Strings/ShellMenu.en-us.resx @@ -120,9 +120,15 @@ Add menu item + + All + Apply + + Background + Clear menu items @@ -138,21 +144,57 @@ Windows tools + + Desktop + + + Directory + + + Drive + Edit There's no menu items - - Icon file(*.ico)|*.ico + + The content of the secondary menu is empty + + + Extension name First level menu + + Icon file(*.ico)|*.ico + Light theme icon + + For example: .exe | .jpg | .txt + + + Match file type + + + Match format + + + Match rule + + + For example: WindowsTools.exe | ShellMenu.jpg + + + For example: [\s\S]+.jpg | [\w\W]*.jpg + + + Match folder type + Menu icon @@ -165,6 +207,12 @@ Menu order + + Menu parameter + + + The application parameter is not set + Program file path @@ -189,6 +237,21 @@ Modify + + Move down + + + Move up + + + Name + + + Name (Regex) + + + None + Operation @@ -204,6 +267,9 @@ 3. It is recommended to avoid too many secondary menus, because this may lead to a long menu loading time, which will cause a deadlock. + + Executable file (*.exe)|*.exe + Refresh @@ -219,14 +285,20 @@ Root menu settings + + Save + Second level menu Select icon + + Select program + - Whether to enable theme icon + Should enable theme icon No @@ -237,6 +309,24 @@ When turned on, you can set menu icon individually for light and dark themes + + Should use program icon + + + No + + + Yes + + + Should use second level menu + + + No + + + Yes + Custom shell menu diff --git a/WindowsTools/Strings/ShellMenu.resx b/WindowsTools/Strings/ShellMenu.resx index 479b833..cf0b14c 100644 --- a/WindowsTools/Strings/ShellMenu.resx +++ b/WindowsTools/Strings/ShellMenu.resx @@ -120,9 +120,15 @@ Add menu item + + All + Apply + + Background + Clear menu items @@ -138,21 +144,57 @@ Windows tools + + Desktop + + + Directory + + + Drive + Edit There's no menu items - - Icon file(*.ico)|*.ico + + The content of the secondary menu is empty + + + Extension name First level menu + + Icon file(*.ico)|*.ico + Light theme icon + + For example: .exe | .jpg | .txt + + + Match file type + + + Match format + + + Match rule + + + For example: WindowsTools.exe | ShellMenu.jpg + + + For example: [\s\S]+.jpg | [\w\W]*.jpg + + + Match folder type + Menu icon @@ -165,6 +207,12 @@ Menu order + + Menu parameter + + + The application parameter is not set + Program file path @@ -189,6 +237,21 @@ Modify + + Move down + + + Move up + + + Name + + + Name (Regex) + + + None + Operation @@ -204,6 +267,9 @@ 3. It is recommended to avoid too many secondary menus, because this may lead to a long menu loading time, which will cause a deadlock. + + Executable file (*.exe)|*.exe + Refresh @@ -219,14 +285,20 @@ Root menu settings + + Save + Second level menu Select icon + + Select program + - Whether to enable theme icon + Should enable theme icon No @@ -237,6 +309,24 @@ When turned on, you can set menu icon individually for light and dark themes + + Should use program icon + + + No + + + Yes + + + Should use second level menu + + + No + + + Yes + Custom shell menu diff --git a/WindowsTools/Strings/ShellMenu.zh-hans.resx b/WindowsTools/Strings/ShellMenu.zh-hans.resx index cc2f51e..42970c1 100644 --- a/WindowsTools/Strings/ShellMenu.zh-hans.resx +++ b/WindowsTools/Strings/ShellMenu.zh-hans.resx @@ -120,9 +120,15 @@ 添加菜单项 + + 所有 + 应用 + + 背景 + 清空菜单项 @@ -138,21 +144,57 @@ Windows 工具箱 + + 桌面 + + + 目录 + + + 驱动器 + 编辑 菜单没有任何内容 - - 图标文件(*.ico)|*.ico + + 二级菜单内容为空 + + + 扩展名称 一级菜单 + + 图标文件(*.ico)|*.ico + 浅色主题图标 + + 例如:.exe | .jpg | .txt + + + 文件匹配类型 + + + 匹配格式 + + + 匹配规则 + + + 例如:WindowsTools.exe | ShellMenu.jpg + + + 例如:[\s\S]+.jpg | [\w\W]*.jpg + + + 文件夹匹配类型 + 菜单图标 @@ -165,6 +207,12 @@ 菜单顺序 + + 菜单参数 + + + 未设置应用参数 + 程序文件路径 @@ -189,6 +237,21 @@ 修改 + + 下移 + + + 上移 + + + 名称 + + + 名称(正则表达式) + + + 不匹配 + 操作 @@ -204,6 +267,9 @@ 3.建议避免过多的二级菜单,因为这可能会导致菜单加载时间过长,从而引发卡顿现象。 + + 可执行文件(*.exe)|*.exe + 刷新 @@ -219,12 +285,18 @@ 根菜单设置 + + 保存 + 二级菜单 选择图标 + + 选择程序 + 是否启用主题图标 @@ -237,6 +309,24 @@ 开启后可以针对明暗主题单独设置菜单图标 + + 是否使用应用程序图标 + + + + + + + + + 是否启用二级菜单 + + + + + + + 自定义扩展菜单 diff --git a/WindowsTools/Styles/HyperlinkButton.xaml b/WindowsTools/Styles/HyperlinkButton.xaml index e9b73f6..426aee0 100644 --- a/WindowsTools/Styles/HyperlinkButton.xaml +++ b/WindowsTools/Styles/HyperlinkButton.xaml @@ -1,4 +1,5 @@ - +