Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions ContextMenuManager/BluePointLilac.Methods/ResourceString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,33 @@ public static string GetDirectString(string resStr)
SHLoadIndirectString(resStr, outBuff, 1024, IntPtr.Zero);
return outBuff.ToString();
}

/// <summary>Strips Win32 menu access-key markers so the list matches what Explorer actually renders.</summary>
/// <param name="text">The raw menu text, typically read from the registry.</param>
/// <returns>The input unchanged when the setting is off or no '&amp;' is present; otherwise the text with single '&amp;' removed and '&amp;&amp;' collapsed to a literal '&amp;'.</returns>
/// <remarks>Leaving the setting off preserves the raw registry text for power users who want to see the mnemonic markers.</remarks>
public static string StripMnemonics(string text)
{
if (string.IsNullOrEmpty(text) || !AppConfig.StripMenuMnemonics) return text;
if (text.IndexOf('&') < 0) return text;

var sb = new StringBuilder(text.Length);
for (var i = 0; i < text.Length; i++)
{
if (text[i] == '&')
{
if (i + 1 < text.Length && text[i + 1] == '&')
{
sb.Append('&');
i++;
}
}
else
{
sb.Append(text[i]);
}
}
return sb.ToString();
}
}
}
2 changes: 1 addition & 1 deletion ContextMenuManager/Controls/DetailedEditDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public bool ShowDialog()
public bool RunDialog(MainWindow owner)
{
var dialog = ContentDialogHost.CreateDialog(
AppString.Dialog.DetailedEdit.Replace("%s", GuidInfo.GetText(GroupGuid)),
AppString.Dialog.DetailedEdit.Replace("%s", ResourceString.StripMnemonics(GuidInfo.GetText(GroupGuid))),
owner);

var list = new DetailedEditList
Expand Down
6 changes: 3 additions & 3 deletions ContextMenuManager/Controls/DetailedEditList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public override void LoadItems()
groupItem = new FoldGroupItem(this, groupXN.SelectSingleNode(attribute)?.InnerText, pathType);
foreach (XmlElement textXE in groupXN.SelectNodes("Text"))
{
if (XmlDicHelper.JudgeCulture(textXE)) groupItem.Text = ResourceString.GetDirectString(textXE.GetAttribute("Value"));
if (XmlDicHelper.JudgeCulture(textXE)) groupItem.Text = ResourceString.StripMnemonics(ResourceString.GetDirectString(textXE.GetAttribute("Value")));
}
if (guids.Count > 0)
{
groupItem.Control.Tag = guids;
if (string.IsNullOrWhiteSpace(groupItem.Text)) groupItem.Text = GuidInfo.GetText(guids[0]);
if (string.IsNullOrWhiteSpace(groupItem.Text)) groupItem.Text = ResourceString.StripMnemonics(GuidInfo.GetText(guids[0]));
groupItem.Image = GuidInfo.GetImage(guids[0]);
var filePath = GuidInfo.GetFilePath(guids[0]);
var clsidPath = GuidInfo.GetClsidPath(guids[0]);
Expand Down Expand Up @@ -95,7 +95,7 @@ string GetRuleFullRegPath(string regPath)
// 获取文本、提示文本
foreach (XmlElement textXE in itemXE.SelectNodes("Text"))
{
if (XmlDicHelper.JudgeCulture(textXE)) info.Text = ResourceString.GetDirectString(textXE.GetAttribute("Value"));
if (XmlDicHelper.JudgeCulture(textXE)) info.Text = ResourceString.StripMnemonics(ResourceString.GetDirectString(textXE.GetAttribute("Value")));
}
foreach (XmlElement tipXE in itemXE.SelectNodes("Tip"))
{
Expand Down
10 changes: 5 additions & 5 deletions ContextMenuManager/Controls/EnhanceMenuList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public override void LoadItems()
{
if (XmlDicHelper.JudgeCulture(textXE))
{
text = ResourceString.GetDirectString(textXE.GetAttribute("Value"));
text = ResourceString.StripMnemonics(ResourceString.GetDirectString(textXE.GetAttribute("Value")));
}
}
if (string.IsNullOrEmpty(path) || string.IsNullOrEmpty(text)) continue;
Expand Down Expand Up @@ -72,7 +72,7 @@ private void LoadShellItems(XmlNode shellXN, FoldGroupItem groupItem)
foreach (XmlElement szXE in itemXE.SelectNodes("Value/REG_SZ"))
{
if (!XmlDicHelper.JudgeCulture(szXE)) continue;
if (szXE.HasAttribute("MUIVerb")) item.Text = ResourceString.GetDirectString(szXE.GetAttribute("MUIVerb"));
if (szXE.HasAttribute("MUIVerb")) item.Text = ResourceString.StripMnemonics(ResourceString.GetDirectString(szXE.GetAttribute("MUIVerb")));
if (szXE.HasAttribute("Icon")) item.Image = ResourceIcon.GetIcon(szXE.GetAttribute("Icon"))?.ToBitmap();
else if (szXE.HasAttribute("HasLUAShield")) item.Image = AppImage.Shield;
}
Expand Down Expand Up @@ -101,7 +101,7 @@ private void LoadShellItems(XmlNode shellXN, FoldGroupItem groupItem)
}
}
item.Image ??= AppImage.NotFound;
if (string.IsNullOrWhiteSpace(item.Text)) item.Text = keyName;
if (string.IsNullOrWhiteSpace(item.Text)) item.Text = ResourceString.StripMnemonics(keyName);
var tip = "";
foreach (XmlElement tipXE in itemXE.SelectNodes("Tip"))
{
Expand Down Expand Up @@ -137,10 +137,10 @@ private void LoadShellExItems(XmlNode shellExXN, FoldGroupItem groupItem)
{
if (XmlDicHelper.JudgeCulture(textXE))
{
item.Text = ResourceString.GetDirectString(textXE.InnerText);
item.Text = ResourceString.StripMnemonics(ResourceString.GetDirectString(textXE.InnerText));
}
}
if (string.IsNullOrWhiteSpace(item.Text)) item.Text = GuidInfo.GetText(guid);
if (string.IsNullOrWhiteSpace(item.Text)) item.Text = ResourceString.StripMnemonics(GuidInfo.GetText(guid));
if (string.IsNullOrWhiteSpace(item.DefaultKeyName)) item.DefaultKeyName = guid.ToString("B");
var tip = "";
foreach (XmlElement tipXE in itemXN.SelectNodes("Tip"))
Expand Down
2 changes: 1 addition & 1 deletion ContextMenuManager/Controls/GuidBlockedItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public GuidBlockedItem(GuidBlockedList list, string value) : base(list)
if (list != null) Image = AppImage.SystemFile;
}

Text = ItemText;
Text = ResourceString.StripMnemonics(ItemText);
}

public string Value { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion ContextMenuManager/Controls/IEItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public string RegPath
set
{
regPath = value;
Text = ItemText;
Text = ResourceString.StripMnemonics(ItemText);
if (List != null) Image = ItemImage;
}
}
Expand Down
4 changes: 2 additions & 2 deletions ContextMenuManager/Controls/Interfaces/ITsiGuidItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void AddGuidDic()
{
writer.DeleteSection(section);
GuidInfo.RemoveDic(Item.Guid);
listItem.Text = Item.ItemText;
listItem.Text = ResourceString.StripMnemonics(Item.ItemText);
listItem.Image = GuidInfo.GetImage(Item.Guid);
}
return;
Expand All @@ -117,7 +117,7 @@ private void AddGuidDic()
GuidInfo.RemoveDic(Item.Guid);
writer.SetValue(section, "Text", dlg.ItemText);
writer.SetValue(section, "Icon", dlg.ItemIconLocation);
listItem.Text = dlg.ItemText;
listItem.Text = ResourceString.StripMnemonics(dlg.ItemText);
listItem.Image = dlg.ItemIcon;
}
}
Expand Down
2 changes: 1 addition & 1 deletion ContextMenuManager/Controls/Interfaces/ITsiTextItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public ChangeTextMenuItem(ITsiTextItem item) : base(AppString.Menu.ChangeText)
{
Click += (sender, e) =>
{
var name = ChangeText(item.Text);
var name = ChangeText(item.ItemText ?? item.Text);
if (name != null) item.ItemText = name;
};
}
Expand Down
4 changes: 2 additions & 2 deletions ContextMenuManager/Controls/OpenWithItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public string RegPath
{
regPath = value;
ItemFilePath = ObjectPath.ExtractFilePath(ItemCommand);
Text = ItemText;
Text = ResourceString.StripMnemonics(ItemText);
if (List != null) Image = ItemIcon.ToBitmap();
}
}
Expand All @@ -60,7 +60,7 @@ public string ItemText
set
{
Registry.SetValue(AppPath, "FriendlyAppName", value);
Text = ResourceString.GetDirectString(value);
Text = ResourceString.StripMnemonics(ResourceString.GetDirectString(value));
}
}

Expand Down
2 changes: 1 addition & 1 deletion ContextMenuManager/Controls/RuleItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public RuleItem(MyList list, ItemInfo info) : base(list)
RestartExplorer = info.RestartExplorer;
if (list != null)
{
Text = info.Text;
Text = ResourceString.StripMnemonics(info.Text);
Image = info.Image;
BtnShowMenu = new MenuButton(this);
TsiSearch = new WebSearchMenuItem(this);
Expand Down
4 changes: 2 additions & 2 deletions ContextMenuManager/Controls/SendToItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public string FilePath
{
filePath = value;
if (IsShortcut) ShellLink = new ShellLink(value);
Text = ItemText;
Text = ResourceString.StripMnemonics(ItemText);
if (List != null) Image = ItemImage;
}
}
Expand Down Expand Up @@ -90,7 +90,7 @@ public string ItemText
set
{
DesktopIni.SetLocalizedFileNames(FilePath, value);
Text = ResourceString.GetDirectString(value);
Text = ResourceString.StripMnemonics(ResourceString.GetDirectString(value));
ExplorerRestarter.Show();
}
}
Expand Down
2 changes: 1 addition & 1 deletion ContextMenuManager/Controls/ShellExItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public string RegPath
set
{
regPath = value;
Text = ItemText;
Text = ResourceString.StripMnemonics(ItemText);
if (List != null) Image = GuidInfo.GetImage(Guid);
}
}
Expand Down
4 changes: 2 additions & 2 deletions ContextMenuManager/Controls/ShellItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public string RegPath
set
{
regPath = value;
Text = ItemText;
Text = ResourceString.StripMnemonics(ItemText);
if (List != null)
{
Image = ItemIcon.ToBitmap();
Expand Down Expand Up @@ -275,7 +275,7 @@ public string ItemText
else
{
Registry.SetValue(RegPath, "MUIVerb", value);
Text = ResourceString.GetDirectString(value);
Text = ResourceString.StripMnemonics(ResourceString.GetDirectString(value));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ContextMenuManager/Controls/ShellNewItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public string RegPath
set
{
regPath = value;
Text = ItemText;
Text = ResourceString.StripMnemonics(ItemText);
if (List != null) Image = ItemIcon.ToBitmap();
}
}
Expand Down Expand Up @@ -141,7 +141,7 @@ public string ItemText
{
RegistryEx.DeleteValue(RegPath, "MenuText");
Registry.SetValue(DefaultOpenModePath, "FriendlyTypeName", value);
Text = ResourceString.GetDirectString(value);
Text = ResourceString.StripMnemonics(ResourceString.GetDirectString(value));
}
}

Expand Down
2 changes: 1 addition & 1 deletion ContextMenuManager/Controls/UwpModeItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public UwpModeItem(MyList list, string uwpName, Guid guid) : base(list)
{
Guid = guid;
UwpName = uwpName;
Text = ItemText;
Text = ResourceString.StripMnemonics(ItemText);
if (list != null)
{
InitializeComponents();
Expand Down
4 changes: 2 additions & 2 deletions ContextMenuManager/Controls/WinXItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public string FilePath
{
filePath = value;
ShellLink = new ShellLink(value);
Text = ItemText;
Text = ResourceString.StripMnemonics(ItemText);
if (List != null) Image = ItemImage;
}
}
Expand Down Expand Up @@ -86,7 +86,7 @@ public string ItemText
{
DesktopIni.SetLocalizedFileNames(FilePath, value);
}
Text = ResourceString.GetDirectString(value);
Text = ResourceString.StripMnemonics(ResourceString.GetDirectString(value));
ExplorerRestarter.Show();
}
}
Expand Down
6 changes: 6 additions & 0 deletions ContextMenuManager/Methods/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,12 @@ public static bool HideSysStoreItems
set => SetGeneralValue("HideSysStoreItems", value ? 1 : 0);
}

public static bool StripMenuMnemonics
{
get => GetGeneralValue("StripMenuMnemonics") == "1";
set => SetGeneralValue("StripMenuMnemonics", value ? 1 : 0);
}

public static bool DimInferredIcons
{
get => GetGeneralValue("DimInferredIcons") != "0";
Expand Down
1 change: 1 addition & 0 deletions ContextMenuManager/Methods/AppString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ public static class Other
public static string OpenMoreExplorer { get; set; }
public static string HideDisabledItems { get; set; }
public static string HideSysStoreItems { get; set; }
public static string StripMenuMnemonics { get; set; }
public static string DimInferredIcons { get; set; }
public static string SetPerceivedType { get; set; }
public static string SetDefaultDropEffect { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ CustomEngine = 自定义
SetCustomEngine = 设置搜索引擎 (以 %s 代替搜索关键词)
HideDisabledItems = 隐藏已禁用的菜单项目
HideSysStoreItems = 隐藏公共引用中的系统菜单
StripMenuMnemonics = 隐藏菜单项名称中的快捷键符号(&)
DimInferredIcons = 对推测的图标使用半透明效果
SetPerceivedType = 设置扩展名为 %s 的文件感知类型为
SetDefaultDropEffect = 设置文件对象默认拖拽命令为
Expand Down
25 changes: 23 additions & 2 deletions ContextMenuManager/Views/AppSettingView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@

<Separator x:Name="HideSysStoreSeparator" Margin="0,0,0,16" />

<Grid x:Name="HideSysStoreRow">
<Grid x:Name="HideSysStoreRow" Margin="0,0,0,16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
Expand All @@ -315,7 +315,28 @@
Toggled="HideSysStoreItemsCheckBox_OnChanged" />
</Grid>

<Separator Margin="0,16,0,16" />
<Separator Margin="0,0,0,16" />

<Grid Margin="0,0,0,16">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Margin="0,0,20,0" VerticalAlignment="Center">
<TextBlock x:Name="StripMenuMnemonicsLabel" Style="{StaticResource SettingNameStyle}" />
</StackPanel>
<ui:ToggleSwitch
x:Name="StripMenuMnemonicsCheckBox"
Grid.Column="1"
MinWidth="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
OffContent=""
OnContent=""
Toggled="StripMenuMnemonicsCheckBox_OnChanged" />
</Grid>

<Separator Margin="0,0,0,16" />

<Grid>
<Grid.ColumnDefinitions>
Expand Down
11 changes: 11 additions & 0 deletions ContextMenuManager/Views/AppSettingView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public void RefreshFromConfig()
OpenMoreExplorerCheckBox.IsOn = AppConfig.OpenMoreExplorer;
HideDisabledItemsCheckBox.IsOn = AppConfig.HideDisabledItems;
HideSysStoreItemsCheckBox.IsOn = AppConfig.HideSysStoreItems;
StripMenuMnemonicsCheckBox.IsOn = AppConfig.StripMenuMnemonics;
DimInferredIconsCheckBox.IsOn = AppConfig.DimInferredIcons;

var showHideSysStore = WinOsVersion.Current >= WinOsVersion.Win7;
Expand Down Expand Up @@ -111,6 +112,8 @@ private void LoadLabels()

HideSysStoreItemsLabel.Text = AppString.Other.HideSysStoreItems;

StripMenuMnemonicsLabel.Text = AppString.Other.StripMenuMnemonics;

DimInferredIconsLabel.Text = AppString.Other.DimInferredIcons;

LoadDynamicOptions();
Expand Down Expand Up @@ -285,6 +288,14 @@ private void HideSysStoreItemsCheckBox_OnChanged(object sender, RoutedEventArgs
}
}

private void StripMenuMnemonicsCheckBox_OnChanged(object sender, RoutedEventArgs e)
{
if (!isLoading)
{
AppConfig.StripMenuMnemonics = StripMenuMnemonicsCheckBox.IsOn;
}
}

private void DimInferredIconsCheckBox_OnChanged(object sender, RoutedEventArgs e)
{
if (!isLoading)
Expand Down
1 change: 1 addition & 0 deletions languages/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ CustomEngine = Custom...
SetCustomEngine = Define search engine (use %s instead of search keywords)
HideDisabledItems = Hide disabled items
HideSysStoreItems = Hide system store items
StripMenuMnemonics = Hide access-key markers (&) in menu item names
DimInferredIcons = Dim icons inferred from the item's command
SetPerceivedType = Set %s perceived type...
SetDefaultDropEffect = Set default drop effect
Expand Down
1 change: 1 addition & 0 deletions languages/zh-CN.ini
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ CustomEngine = 自定义
SetCustomEngine = 设置搜索引擎 (以 %s 代替搜索关键词)
HideDisabledItems = 隐藏已禁用的菜单项目
HideSysStoreItems = 隐藏公共引用中的系统菜单
StripMenuMnemonics = 隐藏菜单项名称中的快捷键符号(&)
DimInferredIcons = 对推测的图标使用半透明效果
SetPerceivedType = 设置扩展名为 %s 的文件感知类型为
SetDefaultDropEffect = 设置文件对象默认拖拽命令为
Expand Down
Loading