From 8de82022ef44b0d7a2c20084c495a52f3703a58e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=93=9D=E7=82=B9lilac?= Date: Mon, 16 Nov 2020 17:31:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0WinX=E5=91=BD=E4=BB=A4?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E7=AC=A6=E6=9B=BF=E6=8D=A2=E4=B8=BAPowerShel?= =?UTF-8?q?l=E8=A7=84=E5=88=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ContextMenuManager/App.config | 2 +- ContextMenuManager/AppImage.cs | 2 ++ ContextMenuManager/AppString.cs | 1 + ContextMenuManager/ContextMenuManager.csproj | 2 +- ContextMenuManager/Controls/RegRuleItem.cs | 27 ++++++++++++++----- ContextMenuManager/Controls/ThirdRulesList.cs | 4 +-- ContextMenuManager/Controls/WinXList.cs | 5 +++- .../Resources/Texts/AppLanguageDic.ini | 1 + .../Resources/Texts/ThirdRulesDic.xml | 7 +++-- languages/zh-CN.ini | 1 + 10 files changed, 39 insertions(+), 13 deletions(-) diff --git a/ContextMenuManager/App.config b/ContextMenuManager/App.config index cfd720a..e55d23b 100644 --- a/ContextMenuManager/App.config +++ b/ContextMenuManager/App.config @@ -2,7 +2,7 @@ - + diff --git a/ContextMenuManager/AppImage.cs b/ContextMenuManager/AppImage.cs index 2c3d886..76d00cf 100644 --- a/ContextMenuManager/AppImage.cs +++ b/ContextMenuManager/AppImage.cs @@ -57,6 +57,8 @@ namespace ContextMenuManager public static readonly Image Shield = ResourceIcon.GetIcon("imageres.dll", 73).ToBitmap(); ///资源管理器图标 public static readonly Image Explorer = ResourceIcon.GetIcon("explorer.exe", 0).ToBitmap(); + ///命令提示符图标 + public static readonly Image Cmd= ResourceIcon.GetIcon("cmd.exe", 0).ToBitmap(); ///刷新图标 public static readonly Image Refresh = ResourceIcon.GetIcon("shell32.dll", 238).ToBitmap(); ///自定义文件夹图标 diff --git a/ContextMenuManager/AppString.cs b/ContextMenuManager/AppString.cs index 62bce76..8d55596 100644 --- a/ContextMenuManager/AppString.cs +++ b/ContextMenuManager/AppString.cs @@ -159,6 +159,7 @@ namespace ContextMenuManager public static string RemovableDrive => GetValue("RemovableDrive"); public static string BuildSendtoMenu => GetValue("BuildSendtoMenu"); public static string UseStoreOpenWith => GetValue("UseStoreOpenWith"); + public static string WinXPowerShell => GetValue("WinXPowerShell"); public static string NewItem => GetValue("NewItem"); public static string AddGuidBlockedItem => GetValue("AddGuidBlockedItem"); public static string CurrentExtension => GetValue("CurrentExtension"); diff --git a/ContextMenuManager/ContextMenuManager.csproj b/ContextMenuManager/ContextMenuManager.csproj index 6dc0397..d11d61e 100644 --- a/ContextMenuManager/ContextMenuManager.csproj +++ b/ContextMenuManager/ContextMenuManager.csproj @@ -8,7 +8,7 @@ WinExe ContextMenuManager ContextMenuManager - v3.5 + v4.5 512 false true diff --git a/ContextMenuManager/Controls/RegRuleItem.cs b/ContextMenuManager/Controls/RegRuleItem.cs index 2fe25ff..ebb889b 100644 --- a/ContextMenuManager/Controls/RegRuleItem.cs +++ b/ContextMenuManager/Controls/RegRuleItem.cs @@ -112,6 +112,7 @@ namespace ContextMenuManager.Controls public IFoldGroupItem FoldGroupItem { get; set; } + const string CU_SMWCEA = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"; const string LM_SMWCPE = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer"; const string CU_SMWCPE = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"; const string LM_SMWCE = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer"; @@ -126,7 +127,7 @@ namespace ContextMenuManager.Controls new RegRule(LM_SMWCPE, "NoCustomizeWebView", 0, 1), new RegRule(CU_SMWCPE, "NoCustomizeThisFolder", 0, 1), new RegRule(CU_SMWCPE, "NoCustomizeWebView", 0, 1) - }, + }, ItemInfo = new ItemInfo { Text = AppString.Item.CustomFolder, @@ -141,7 +142,7 @@ namespace ContextMenuManager.Controls Rules = new[] { new RegRule(LM_SMWCPE, "NoNetConnectDisconnect", 0, 1), new RegRule(CU_SMWCPE, "NoNetConnectDisconnect", 0, 1) - }, + }, ItemInfo = new ItemInfo { Text = $"{AppString.Item.MapNetworkDrive} && {AppString.Item.DisconnectNetworkDrive}", @@ -155,7 +156,7 @@ namespace ContextMenuManager.Controls Rules = new[] { new RegRule(LM_SMWCPE, "NoPropertiesRecycleBin", 0, 1), new RegRule(CU_SMWCPE, "NoPropertiesRecycleBin", 0, 1) - }, + }, ItemInfo = new ItemInfo { Text = AppString.Item.RecycleBinProperties, @@ -169,7 +170,7 @@ namespace ContextMenuManager.Controls Rules = new[] { new RegRule(LM_SMWCPE, "NoDrivesInSendToMenu", 0, 1), new RegRule(CU_SMWCPE, "NoDrivesInSendToMenu", 0, 1) - }, + }, ItemInfo = new ItemInfo { Text = AppString.Item.RemovableDrive, @@ -184,7 +185,7 @@ namespace ContextMenuManager.Controls Rules = new[] { new RegRule(LM_SMWCE, "DelaySendToMenuBuild", 0, 1), new RegRule(CU_SMWCE, "DelaySendToMenuBuild", 0, 1) - }, + }, ItemInfo = new ItemInfo { Text = AppString.Item.BuildSendtoMenu, @@ -198,12 +199,26 @@ namespace ContextMenuManager.Controls Rules = new[] { new RegRule(LM_SPMWE, "NoUseStoreOpenWith", 0, 1), new RegRule(CU_SPMWE, "NoUseStoreOpenWith", 0, 1) - }, + }, ItemInfo = new ItemInfo { Text = AppString.Item.UseStoreOpenWith, Image = AppImage.MicrosoftStore } }; + + public static RuleAndInfo WinXPowerShell = new RuleAndInfo + { + Rules = new[] + { + new RegRule(CU_SMWCEA, "DontUsePowerShellOnWinX", 0, 1) + }, + ItemInfo = new ItemInfo + { + Text = AppString.Item.WinXPowerShell, + Image = AppImage.Cmd, + RestartExplorer = true + } + }; } } \ No newline at end of file diff --git a/ContextMenuManager/Controls/ThirdRulesList.cs b/ContextMenuManager/Controls/ThirdRulesList.cs index 0468ec3..894a2cf 100644 --- a/ContextMenuManager/Controls/ThirdRulesList.cs +++ b/ContextMenuManager/Controls/ThirdRulesList.cs @@ -32,8 +32,8 @@ namespace ContextMenuManager.Controls } foreach(XmlElement groupXE in doc1.DocumentElement.ChildNodes) { - if(!GuidInfo.TryGetGuid(groupXE.GetAttribute("Guid"), out Guid guid) - && !groupXE.HasAttribute("Common")) continue; + Guid guid = Guid.Empty; + if(groupXE.HasAttribute("Guid") && !GuidInfo.TryGetGuid(groupXE.GetAttribute("Guid"), out guid)) continue; GroupPathItem groupItem = new GroupPathItem { diff --git a/ContextMenuManager/Controls/WinXList.cs b/ContextMenuManager/Controls/WinXList.cs index a414081..df945c7 100644 --- a/ContextMenuManager/Controls/WinXList.cs +++ b/ContextMenuManager/Controls/WinXList.cs @@ -28,11 +28,14 @@ namespace ContextMenuManager.Controls public void LoadItems() { Version ver = Environment.OSVersion.Version; - if((ver.Major == 10) || (ver.Major == 6 && ver.Minor >= 2)) + bool isWin10= ver.Major == 10; + bool isWin8 = (ver.Major == 6) && (ver.Minor >= 2); + if(isWin10 || isWin8) { this.ClearItems(); DesktopIniReaders.Clear(); Array.ForEach(new DirectoryInfo(WinXPath).GetDirectories(), di => LoadSubDirItems(di)); + if(isWin10) this.AddItem(new RegRuleItem(RegRuleItem.WinXPowerShell) { MarginRight = RegRuleItem.SysMarginRignt }); } } diff --git a/ContextMenuManager/Properties/Resources/Texts/AppLanguageDic.ini b/ContextMenuManager/Properties/Resources/Texts/AppLanguageDic.ini index 485138d..a74b020 100644 --- a/ContextMenuManager/Properties/Resources/Texts/AppLanguageDic.ini +++ b/ContextMenuManager/Properties/Resources/Texts/AppLanguageDic.ini @@ -129,6 +129,7 @@ RecycleBinProperties = 属性(&R) RemovableDrive = 可移动磁盘 BuildSendtoMenu = 快速构建发送到子菜单 UseStoreOpenWith = 在Microsoft Store中查找应用 +WinXPowerShell = Win+X菜单命令提示符替换为PowerShell NewItem = 新建一个菜单项目 AddGuidBlockedItem = 添加GUID锁定项目 CurrentExtension = 你当前选择的文件格式为 diff --git a/ContextMenuManager/Properties/Resources/Texts/ThirdRulesDic.xml b/ContextMenuManager/Properties/Resources/Texts/ThirdRulesDic.xml index 6ee4841..5f85297 100644 --- a/ContextMenuManager/Properties/Resources/Texts/ThirdRulesDic.xml +++ b/ContextMenuManager/Properties/Resources/Texts/ThirdRulesDic.xml @@ -1,11 +1,11 @@ - - + @@ -36,6 +36,9 @@ ValueKind为键值类型,默认键值类型ValueKind为REG_DWORD,为默认 + + + diff --git a/languages/zh-CN.ini b/languages/zh-CN.ini index 485138d..a74b020 100644 --- a/languages/zh-CN.ini +++ b/languages/zh-CN.ini @@ -129,6 +129,7 @@ RecycleBinProperties = 属性(&R) RemovableDrive = 可移动磁盘 BuildSendtoMenu = 快速构建发送到子菜单 UseStoreOpenWith = 在Microsoft Store中查找应用 +WinXPowerShell = Win+X菜单命令提示符替换为PowerShell NewItem = 新建一个菜单项目 AddGuidBlockedItem = 添加GUID锁定项目 CurrentExtension = 你当前选择的文件格式为