Skip to content

Commit

Permalink
新增了IE浏览器右键菜单的备份
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack251970 committed Jun 3, 2023
1 parent 6ec6bde commit 4178931
Showing 1 changed file with 45 additions and 14 deletions.
59 changes: 45 additions & 14 deletions ContextMenuManager/Methods/BackupHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public enum Scenes
// 其他规则——第一板块

// 其他规则——第二板块
DragDrop, PublicReferences,
DragDrop, PublicReferences, InternetExplorer,
// 其他规则——第三板块(不予备份)
// 不予备份
// 不予备份的场景
CustomExtension, PerceivedType, DirectoryType, MenuAnalysis, CustomRegPath, CustomExtensionPerceivedType,
};

// 备份项目类型(新增备份类别处3)
public enum BackupItemType
{
ShellItem, ShellExItem, UwpModelItem, VisibleRegRuleItem, ShellNewItem, SendToItem,
OpenWithItem, WinXItem, SelectItem, StoreShellItem
OpenWithItem, WinXItem, SelectItem, StoreShellItem, IEItem
}

// 备份选项
Expand Down Expand Up @@ -84,7 +84,7 @@ sealed class BackupHelper
// 其他规则——第一板块

// 其他规则——第二板块
AppString.SideBar.DragDrop, AppString.SideBar.PublicReferences,
AppString.SideBar.DragDrop, AppString.SideBar.PublicReferences, AppString.SideBar.IEMenu,
};

// 右键菜单恢复场景,包含元数据中的场景
Expand Down Expand Up @@ -187,20 +187,17 @@ private void GetBackupItems(bool backup)
{
switch (currentScene)
{
case Scenes.New:
// 新建
case Scenes.New: // 新建
GetShellNewListBackupItems(backup); break;
case Scenes.SendTo:
// 发送到
case Scenes.SendTo: // 发送到
GetSendToListItems(backup); break;
case Scenes.OpenWith:
// 打开方式
case Scenes.OpenWith: // 打开方式
GetOpenWithListItems(backup); break;
case Scenes.WinX:
// Win+X
case Scenes.WinX: // Win+X
GetWinXListItems(backup); break;
default:
// 位于ShellList.cs内的备份项目
case Scenes.InternetExplorer: // IE浏览器
GetIEItems(backup); break;
default: // 位于ShellList.cs内的备份项目
GetShellListItems(backup); break;
}
}
Expand Down Expand Up @@ -251,6 +248,8 @@ private void BackupRestoreItem(MyListItem item, string keyName, BackupItemType b
((WinXItem)item).ItemVisible = !ifItemInMenu; break;
case BackupItemType.StoreShellItem:
((StoreShellItem)item).ItemVisible = !ifItemInMenu; break;
case BackupItemType.IEItem:
((IEItem)item).ItemVisible = !ifItemInMenu; break;
}
}
}
Expand Down Expand Up @@ -1039,6 +1038,38 @@ private void GetWinXListItems(bool backup)
}
}
}

/*******************************IEList.cs************************************/

private void GetIEItems(bool backup)
{
List<string> names = new List<string>();
using (RegistryKey ieKey = RegistryEx.GetRegistryKey(IEList.IEPath))
{
if (ieKey == null) return;
foreach (string part in IEItem.MeParts)
{
using (RegistryKey meKey = ieKey.OpenSubKey(part))
{
if (meKey == null) continue;
foreach (string keyName in meKey.GetSubKeyNames())
{
if (names.Contains(keyName, StringComparer.OrdinalIgnoreCase)) continue;
using (RegistryKey key = meKey.OpenSubKey(keyName))
{
if (!string.IsNullOrEmpty(key.GetValue("")?.ToString()))
{
IEItem item = new IEItem(key.Name);
bool ifItemInMenu = item.ItemVisible;
BackupRestoreItem(item, keyName, BackupItemType.IEItem, ifItemInMenu, currentScene, backup);
names.Add(keyName);
}
}
}
}
}
}
}
}

public sealed class BackupList
Expand Down

0 comments on commit 4178931

Please sign in to comment.