修复bug, 优化代码

This commit is contained in:
蓝点lilac
2021-03-10 23:21:52 +08:00
parent 958d2a0576
commit 480b5d6c19
31 changed files with 405 additions and 308 deletions

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v2.0.50727"/></startup>
<supportedRuntime version="v2.0.50727"/>
</startup>
<runtime>
<legacyCorruptedStateExceptionsPolicy enabled="true"/>
<EnableWindowsFormsHighDpiAutoResizing enabled="true"/>

View File

@@ -57,14 +57,15 @@ namespace ContextMenuManager
};
private static readonly IniWriter ConfigWriter = new IniWriter(ConfigIni);
private static string GetGeneralValue(string key) => ConfigWriter.GetValue("General", key);
private static void SetGeneralValue(string key, object value) => ConfigWriter.SetValue("General", key, value);
public static string LanguageIniPath => $@"{LangsDir}\{Language}.ini";
public static string Language
{
get
{
string language = ConfigWriter.GetValue("General", "Language");
string language = GetGeneralValue("Language");
if(language == string.Empty)
{
language = new CultureInfo(GetUserDefaultUILanguage()).Name;
@@ -75,13 +76,13 @@ namespace ContextMenuManager
}
return language;
}
set => ConfigWriter.SetValue("General", "Language", value);
set => SetGeneralValue("Language", value);
}
public static bool AutoBackup
{
get => ConfigWriter.GetValue("General", "AutoBackup") != "0";
set => ConfigWriter.SetValue("General", "AutoBackup", value ? 1 : 0);
get => GetGeneralValue("AutoBackup") != "0";
set => SetGeneralValue("AutoBackup", value ? 1 : 0);
}
public static DateTime LastCheckUpdateTime
@@ -90,7 +91,7 @@ namespace ContextMenuManager
{
try
{
string time = ConfigWriter.GetValue("General", "LastCheckUpdateTime");
string time = GetGeneralValue("LastCheckUpdateTime");
//二进制数据时间不会受系统时间格式影响
return DateTime.FromBinary(Convert.ToInt64(time));
}
@@ -102,60 +103,60 @@ namespace ContextMenuManager
}
set
{
ConfigWriter.SetValue("General", "LastCheckUpdateTime", value.ToBinary());
SetGeneralValue("LastCheckUpdateTime", value.ToBinary());
}
}
public static bool ProtectOpenItem
{
get => ConfigWriter.GetValue("General", "ProtectOpenItem") != "0";
set => ConfigWriter.SetValue("General", "ProtectOpenItem", value ? 1 : 0);
get => GetGeneralValue("ProtectOpenItem") != "0";
set => SetGeneralValue("ProtectOpenItem", value ? 1 : 0);
}
public static string EngineUrl
{
get
{
string url = ConfigWriter.GetValue("General", "EngineUrl");
string url = GetGeneralValue("EngineUrl");
if(url.IsNullOrWhiteSpace()) url = EngineUrls[0];
return url;
}
set
{
ConfigWriter.SetValue("General", "EngineUrl", value);
SetGeneralValue("EngineUrl", value);
}
}
public static bool ShowFilePath
{
get => ConfigWriter.GetValue("General", "ShowFilePath") == "1";
set => ConfigWriter.SetValue("General", "ShowFilePath", value ? 1 : 0);
get => GetGeneralValue("ShowFilePath") == "1";
set => SetGeneralValue("ShowFilePath", value ? 1 : 0);
}
public static bool WinXSortable
{
get => ConfigWriter.GetValue("General", "WinXSortable") == "1";
set => ConfigWriter.SetValue("General", "WinXSortable", value ? 1 : 0);
get => GetGeneralValue("WinXSortable") == "1";
set => SetGeneralValue("WinXSortable", value ? 1 : 0);
}
public static bool OpenMoreRegedit
{
get => ConfigWriter.GetValue("General", "OpenMoreRegedit") == "1";
set => ConfigWriter.SetValue("General", "OpenMoreRegedit", value ? 1 : 0);
get => GetGeneralValue("OpenMoreRegedit") == "1";
set => SetGeneralValue("OpenMoreRegedit", value ? 1 : 0);
}
public static Version Version
{
get
{
Version version = new Version();
try { version = new Version(ConfigWriter.GetValue("General", "Version")); }
Version version = new Version(0, 0, 0, 0);
try { version = new Version(GetGeneralValue("Version")); }
catch { }
return version;
}
set
{
ConfigWriter.SetValue("General", "Version", value);
SetGeneralValue("Version", value);
}
}
}

View File

@@ -35,6 +35,10 @@ namespace ContextMenuManager
public static readonly Image AddSeparator = Resources.AddSeparator.ResizeImage(Scale);
///<summary>打开图标</summary>
public static readonly Image Open = Resources.Open.ResizeImage(Scale);
///<summary>下载图标</summary>
public static readonly Image DownLoad = Resources.DownLoad.ResizeImage(Scale);
///<summary>翻译图标</summary>
public static readonly Image Translate = Resources.Translate.ResizeImage(Scale);
///<summary>上图标</summary>
public static readonly Image Up = Resources.Up.ResizeImage(Scale);
///<summary>下图标</summary>

View File

@@ -6,7 +6,7 @@ namespace ContextMenuManager
public static class AppString
{
public static readonly IniReader UserLanguage = new IniReader(AppConfig.LanguageIniPath);
private static readonly IniReader DefaultLanguage = new IniReader(new StringBuilder(Properties.Resources.AppLanguageDic));
public static readonly IniReader DefaultLanguage = new IniReader(new StringBuilder(Properties.Resources.AppLanguageDic));
private static string GetStringValue(string section, string key)
{
@@ -61,6 +61,7 @@ namespace ContextMenuManager
public static string DirectoryType => GetValue("DirectoryType");
public static string EnhanceMenu => GetValue("EnhanceMenu");
public static string ThirdRules => GetValue("ThirdRules");
public static string OtherAccounts => GetValue("OtherAccounts");
public static string GuidBlocked => GetValue("GuidBlocked");
public static string DragDrop => GetValue("DragDrop");
public static string PublicReferences => GetValue("PublicReferences");
@@ -99,6 +100,7 @@ namespace ContextMenuManager
public static string DirectoryType => GetValue("DirectoryType");
public static string EnhanceMenu => GetValue("EnhanceMenu");
public static string ThirdRules => GetValue("ThirdRules");
public static string OtherAccounts => GetValue("OtherAccounts");
public static string GuidBlocked => GetValue("GuidBlocked");
public static string DragDrop => GetValue("DragDrop");
public static string PublicReferences => GetValue("PublicReferences");
@@ -147,42 +149,6 @@ namespace ContextMenuManager
public static string Save => GetValue("Save");
}
/// <summary>特殊项目文本</summary>
public static class Item
{
private static string GetValue(string key) => GetStringValue("Item", key);
public static string Open => GetValue("Open");
public static string Edit => GetValue("Edit");
public static string Explore => GetValue("Explore");
public static string ExploreOld => GetValue("ExploreOld");
public static string Play => GetValue("Play");
public static string Print => GetValue("Print");
public static string Find => GetValue("Find");
public static string Runas => GetValue("Runas");
public static string CustomFolder => GetValue("CustomFolder");
public static string MapNetworkDrive => GetValue("MapNetworkDrive");
public static string DisconnectNetworkDrive => GetValue("DisconnectNetworkDrive");
public static string RecycleBinProperties => GetValue("RecycleBinProperties");
public static string RemovableDrive => GetValue("RemovableDrive");
public static string BuildSendtoMenu => GetValue("BuildSendtoMenu");
public static string UseStoreOpenWith => GetValue("UseStoreOpenWith");
public static string NewItem => GetValue("NewItem");
public static string AddGuidBlockedItem => GetValue("AddGuidBlockedItem");
public static string SelectExtension => GetValue("SelectExtension");
public static string SelectPerceivedType => GetValue("SelectPerceivedType");
public static string SelectDirectoryType => GetValue("SelectDirectoryType");
public static string CurrentExtension => GetValue("CurrentExtension");
public static string CurrentPerceivedType => GetValue("CurrentPerceivedType");
public static string CurrentDirectoryType => GetValue("CurrentDirectoryType");
public static string EditSubItems => GetValue("EditSubItems");
public static string InvalidItem => GetValue("InvalidItem");
public static string Separator => GetValue("Separator");
public static string LockNewMenu => GetValue("LockNewMenu");
public static string WinXSortable => GetValue("WinXSortable");
public static string ShowFilePath => GetValue("ShowFilePath");
public static string OpenMoreRegedit => GetValue("OpenMoreRegedit");
}
public static class Dialog
{
private static string GetValue(string key) => GetStringValue("Dialog", key);
@@ -215,6 +181,9 @@ namespace ContextMenuManager
public static string AudioDirectory => GetValue("AudioDirectory");
public static string CheckReference => GetValue("CheckReference");
public static string CheckCopy => GetValue("CheckCopy");
public static string SelectExtension => GetValue("SelectExtension");
public static string SelectPerceivedType => GetValue("SelectPerceivedType");
public static string SelectDirectoryType => GetValue("SelectDirectoryType");
public static string SelectSubMenuMode => GetValue("SelectSubMenuMode");
public static string SelectNewItemType => GetValue("SelectNewItemType");
public static string RegistryFile => GetValue("RegistryFile");
@@ -260,11 +229,34 @@ namespace ContextMenuManager
public static class Other
{
private static string GetValue(string key) => GetStringValue("Other", key);
public static string Open => GetValue("Open");
public static string Edit => GetValue("Edit");
public static string Explore => GetValue("Explore");
public static string ExploreOld => GetValue("ExploreOld");
public static string Play => GetValue("Play");
public static string Print => GetValue("Print");
public static string Find => GetValue("Find");
public static string Runas => GetValue("Runas");
public static string CustomFolder => GetValue("CustomFolder");
public static string MapNetworkDrive => GetValue("MapNetworkDrive");
public static string DisconnectNetworkDrive => GetValue("DisconnectNetworkDrive");
public static string RecycleBinProperties => GetValue("RecycleBinProperties");
public static string RemovableDrive => GetValue("RemovableDrive");
public static string BuildSendtoMenu => GetValue("BuildSendtoMenu");
public static string UseStoreOpenWith => GetValue("UseStoreOpenWith");
public static string NewItem => GetValue("NewItem");
public static string AddGuidBlockedItem => GetValue("AddGuidBlockedItem");
public static string CurrentExtension => GetValue("CurrentExtension");
public static string CurrentPerceivedType => GetValue("CurrentPerceivedType");
public static string CurrentDirectoryType => GetValue("CurrentDirectoryType");
public static string EditSubItems => GetValue("EditSubItems");
public static string InvalidItem => GetValue("InvalidItem");
public static string Separator => GetValue("Separator");
public static string LockNewMenu => GetValue("LockNewMenu");
public static string RestartExplorer => GetValue("RestartExplorer");
public static string DictionaryDescription => GetValue("DictionaryDescription");
public static string GuidInfosDictionary => GetValue("GuidInfosDictionary");
public static string Translators => GetValue("Translators");
public static string OtherLanguages => GetValue("OtherLanguages");
public static string AboutApp => GetValue("AboutApp");
public static string Dictionaries => GetValue("Dictionaries");
public static string Donate => GetValue("Donate");
@@ -281,6 +273,9 @@ namespace ContextMenuManager
public static string WebSearchEngine => GetValue("WebSearchEngine");
public static string CustomEngine => GetValue("CustomEngine");
public static string SetCustomEngine => GetValue("SetCustomEngine");
public static string WinXSortable => GetValue("WinXSortable");
public static string ShowFilePath => GetValue("ShowFilePath");
public static string OpenMoreRegedit => GetValue("OpenMoreRegedit");
}
/// <summary>提示文本</summary>
@@ -301,6 +296,7 @@ namespace ContextMenuManager
public static string CheckUpdate => GetValue("CheckUpdate");
public static string LastCheckUpdateTime => GetValue("LastCheckUpdateTime");
public static string OpenLanguagesDir => GetValue("OpenLanguagesDir");
public static string OtherLanguages => GetValue("OtherLanguages");
public static string OpenDictionariesDir => GetValue("OpenDictionariesDir");
public static string ConfigPath => GetValue("ConfigPath");
public static string CommandFiles => GetValue("CommandFiles");

View File

@@ -20,6 +20,8 @@ namespace BluePointLilac.Methods
public static RectangleF DpiZoom(this RectangleF r) => new RectangleF(DpiZoom(r.Location), DpiZoom(r.Size));
public static Padding DpiZoom(this Padding p) => new Padding(DpiZoom(p.Left), DpiZoom(p.Top), DpiZoom(p.Right), DpiZoom(p.Bottom));
public static int DpiZoom(this int num) => (int)(num * DpiScale);
public static float DpiZoom(this float num) => (float)(num * DpiScale);

View File

@@ -31,12 +31,14 @@ namespace BluePointLilac.Methods
}
}
public static void Restart()
public static void Restart(bool isElevated = false, string[] args = null)
{
using(Process process = new Process())
{
process.StartInfo.FileName = Application.ExecutablePath;
process.StartInfo.Arguments = "Restart";
if(args != null) process.StartInfo.Arguments += string.Join(" ", args);
if(isElevated) process.StartInfo.Verb = "Runas";
process.Start();
}
Application.Exit();

View File

@@ -33,7 +33,7 @@
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
@@ -93,6 +93,9 @@
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<PropertyGroup>
<ApplicationManifest>Properties\App.manifest</ApplicationManifest>
</PropertyGroup>
@@ -138,6 +141,9 @@
<Compile Include="Controls\AddGuidDicDialog.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\FileExtensionDialog.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\EnhanceMenusItem.cs">
<SubType>Component</SubType>
</Compile>
@@ -267,6 +273,9 @@
<Compile Include="Controls\ThirdRulesList.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\TranslateDialog.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Controls\UwpModeItem.cs">
<SubType>Component</SubType>
</Compile>
@@ -338,6 +347,8 @@
<None Include="Properties\App.manifest" />
<None Include="Properties\Resources\Texts\AppLanguageDic.ini" />
<None Include="Properties\Resources\Texts\GuidInfosDic.ini" />
<Content Include="Properties\Resources\Images\DownLoad.png" />
<Content Include="Properties\Resources\Images\Translate.png" />
<Content Include="Properties\Resources\Texts\UwpModeItemsDic.xml" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>

View File

@@ -17,6 +17,7 @@ namespace ContextMenuManager.Controls
{
this.Dock = DockStyle.Fill;
this.BackColor = Color.White;
this.AutoScroll = true;
this.Font = new Font(SystemFonts.MenuFont.FontFamily, 10F);
this.Controls.AddRange(new Control[] { lblInfo, picQR, llbDonationList });
llbDonationList.LinkClicked += (sender, e) => ExternalProgram.OpenUrl(DonateListUrl);
@@ -156,7 +157,7 @@ namespace ContextMenuManager.Controls
}
}
sealed class LanguagesBox : Panel
sealed class LanguagesBox : FlowLayoutPanel
{
const string OtherLanguagesUrl = "https://github.com/BluePointLilac/ContextMenuManager/tree/master/languages";
@@ -164,12 +165,14 @@ namespace ContextMenuManager.Controls
{
this.Dock = DockStyle.Fill;
this.Font = new Font(SystemFonts.MenuFont.FontFamily, 10F);
this.Controls.AddRange(new Control[] { cmbLanguages, btnOpenDir, llbOtherLanguages, txtTranslators });
this.OnResize(null);
this.Controls.AddRange(new Control[] { cmbLanguages, btnOpenDir, btnDownLoad, txtTranslators });
cmbLanguages.SelectionChangeCommitted += (sender, e) => ChangeLanguage();
llbOtherLanguages.LinkClicked += (sender, e) => ExternalProgram.OpenUrl(OtherLanguagesUrl);
btnDownLoad.MouseDown += (sender, e) => ExternalProgram.OpenUrl(OtherLanguagesUrl);
btnOpenDir.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(AppConfig.LangsDir);
btnTranslate.MouseDown += (sender, e) => new TranslateDialog().ShowDialog();
MyToolTip.SetToolTip(btnOpenDir, AppString.Tip.OpenLanguagesDir);
MyToolTip.SetToolTip(btnDownLoad, AppString.Tip.OtherLanguages);
this.OnResize(null);
}
readonly ComboBox cmbLanguages = new ComboBox
@@ -178,34 +181,24 @@ namespace ContextMenuManager.Controls
DropDownStyle = ComboBoxStyle.DropDownList
};
readonly LinkLabel llbOtherLanguages = new LinkLabel
{
Text = AppString.Other.OtherLanguages,
AutoSize = true
};
readonly ReadOnlyTextBox txtTranslators = new ReadOnlyTextBox
{
Multiline = true,
ScrollBars = ScrollBars.Vertical
};
readonly PictureButton btnOpenDir = new PictureButton(AppImage.Open);
readonly PictureButton btnDownLoad = new PictureButton(AppImage.DownLoad);
readonly PictureButton btnTranslate = new PictureButton(AppImage.Translate);
readonly List<string> languages = new List<string>();
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
int a = 20.DpiZoom();
txtTranslators.Left = cmbLanguages.Left = cmbLanguages.Top = llbOtherLanguages.Top = a;
btnOpenDir.Left = cmbLanguages.Right + a;
btnOpenDir.Top = cmbLanguages.Top + (cmbLanguages.Height - btnOpenDir.Height) / 2;
txtTranslators.Top = cmbLanguages.Bottom + a;
txtTranslators.Width = this.ClientSize.Width - 2 * a;
txtTranslators.Height = this.ClientSize.Height - txtTranslators.Top - a;
txtTranslators.BackColor = this.BackColor;
llbOtherLanguages.Left = txtTranslators.Right - llbOtherLanguages.Width;
cmbLanguages.Margin = txtTranslators.Margin = btnOpenDir.Margin
= btnDownLoad.Margin = btnTranslate.Margin = new Padding(a, a, 0, 0);
}
public void LoadLanguages()
@@ -243,7 +236,7 @@ namespace ContextMenuManager.Controls
else
{
AppConfig.Language = language;
SingleInstance.Restart();
SingleInstance.Restart(true);
}
}
@@ -301,7 +294,7 @@ namespace ContextMenuManager.Controls
{
DirectoryEx.CopyTo(AppConfig.ConfigDir, newPath);
Directory.Delete(AppConfig.ConfigDir, true);
SingleInstance.Restart();
SingleInstance.Restart(true);
}
};
cmbEngine.SelectionChangeCommitted += (sender, e) =>
@@ -337,7 +330,7 @@ namespace ContextMenuManager.Controls
if(MessageBoxEx.Show(AppString.MessageBox.RestartApp, MessageBoxButtons.OKCancel) == DialogResult.OK)
{
AppConfig.ShowFilePath = chkShowFilePath.Checked;
SingleInstance.Restart();
SingleInstance.Restart(true);
}
else
{
@@ -413,7 +406,7 @@ namespace ContextMenuManager.Controls
readonly MyListItem mliWinXSortable = new MyListItem
{
Text = AppString.Item.WinXSortable,
Text = AppString.Other.WinXSortable,
Visible = WindowsOsVersion.ISAfterOrEqual8,
HasImage = false
};
@@ -421,18 +414,24 @@ namespace ContextMenuManager.Controls
readonly MyListItem mliShowFilePath = new MyListItem
{
Text = AppString.Item.ShowFilePath,
Text = AppString.Other.ShowFilePath,
HasImage = false
};
readonly MyCheckBox chkShowFilePath = new MyCheckBox();
readonly MyListItem mliOpenMoreRegedit = new MyListItem
{
Text = AppString.Item.OpenMoreRegedit,
Text = AppString.Other.OpenMoreRegedit,
HasImage = false
};
readonly MyCheckBox chkOpenMoreRegedit = new MyCheckBox();
protected override void OnVisibleChanged(EventArgs e)
{
base.OnVisibleChanged(e);
this.Enabled = this.Visible;
}
public void LoadItems()
{
this.AddItems(new[] { mliUpdate, mliConfigDir, mliEngine, mliBackup,

View File

@@ -0,0 +1,41 @@
using BluePointLilac.Methods;
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace ContextMenuManager.Controls
{
sealed class FileExtensionDialog : SelectDialog
{
public string Extension
{
get => Selected;
set => Selected = value;
}
public FileExtensionDialog()
{
this.Title = AppString.Dialog.SelectExtension;
this.DropDownStyle = ComboBoxStyle.DropDown;
List<string> items = new List<string>();
foreach(string keyName in Microsoft.Win32.Registry.ClassesRoot.GetSubKeyNames())
{
if(keyName.StartsWith(".")) items.Add(keyName.Substring(1));
}
this.Items = items.ToArray();
}
protected override bool RunDialog(IntPtr hwndOwner)
{
bool flag = base.RunDialog(hwndOwner);
if(flag)
{
string extension = ObjectPath.RemoveIllegalChars(this.Extension);
int index = extension.LastIndexOf('.');
if(index >= 0) this.Extension = extension.Substring(index);
else this.Extension = $".{extension}";
}
return flag;
}
}
}

View File

@@ -35,7 +35,7 @@ namespace ContextMenuManager.Controls
private void AddNewItem()
{
NewItem newItem = new NewItem(AppString.Item.AddGuidBlockedItem);
NewItem newItem = new NewItem(AppString.Other.AddGuidBlockedItem);
this.AddItem(newItem);
newItem.AddNewItem += (sender, e) =>
{

View File

@@ -6,7 +6,7 @@ namespace ContextMenuManager.Controls
{
class NewItem : MyListItem
{
public NewItem() : this(AppString.Item.NewItem) { }
public NewItem() : this(AppString.Other.NewItem) { }
public NewItem(string text)
{

View File

@@ -12,7 +12,7 @@ namespace ContextMenuManager.Controls
{
this.AcceptButton = btnOk;
this.CancelButton = btnCancel;
this.Text = AppString.Item.NewItem;
this.Text = AppString.Other.NewItem;
this.Font = SystemFonts.MenuFont;
this.MaximizeBox = this.MinimizeBox = false;
this.ShowIcon = this.ShowInTaskbar = false;

View File

@@ -160,7 +160,7 @@ namespace ContextMenuManager.Controls
},
ItemInfo = new ItemInfo
{
Text = AppString.Item.CustomFolder,
Text = AppString.Other.CustomFolder,
Image = AppImage.Folder,
Tip = AppString.Tip.CustomFolder,
RestartExplorer = true
@@ -175,7 +175,7 @@ namespace ContextMenuManager.Controls
},
ItemInfo = new ItemInfo
{
Text = $"{AppString.Item.MapNetworkDrive} && {AppString.Item.DisconnectNetworkDrive}",
Text = $"{AppString.Other.MapNetworkDrive} && {AppString.Other.DisconnectNetworkDrive}",
Image = AppImage.NetworkDrive,
RestartExplorer = true
}
@@ -189,7 +189,7 @@ namespace ContextMenuManager.Controls
},
ItemInfo = new ItemInfo
{
Text = AppString.Item.RecycleBinProperties,
Text = AppString.Other.RecycleBinProperties,
Image = AppImage.RecycleBin,
RestartExplorer = true
}
@@ -203,7 +203,7 @@ namespace ContextMenuManager.Controls
},
ItemInfo = new ItemInfo
{
Text = AppString.Item.RemovableDrive,
Text = AppString.Other.RemovableDrive,
Image = AppImage.Drive,
Tip = AppString.Tip.SendToDrive,
RestartExplorer = true
@@ -218,7 +218,7 @@ namespace ContextMenuManager.Controls
},
ItemInfo = new ItemInfo
{
Text = AppString.Item.BuildSendtoMenu,
Text = AppString.Other.BuildSendtoMenu,
Image = AppImage.SendTo,
Tip = AppString.Tip.BuildSendtoMenu
}
@@ -232,7 +232,7 @@ namespace ContextMenuManager.Controls
},
ItemInfo = new ItemInfo
{
Text = AppString.Item.UseStoreOpenWith,
Text = AppString.Other.UseStoreOpenWith,
Image = AppImage.MicrosoftStore
}
};

View File

@@ -1,6 +1,5 @@
using BluePointLilac.Methods;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
@@ -110,38 +109,4 @@ namespace ContextMenuManager.Controls
}
}
}
sealed class FileExtensionDialog : SelectDialog
{
public string Extension
{
get => Selected;
set => Selected = value;
}
public FileExtensionDialog()
{
this.Title = AppString.Item.SelectExtension;
this.DropDownStyle = ComboBoxStyle.DropDown;
List<string> items = new List<string>();
foreach(string keyName in Microsoft.Win32.Registry.ClassesRoot.GetSubKeyNames())
{
if(keyName.StartsWith(".")) items.Add(keyName.Substring(1));
}
this.Items = items.ToArray();
}
protected override bool RunDialog(IntPtr hwndOwner)
{
bool flag = base.RunDialog(hwndOwner);
if(flag)
{
string extension = ObjectPath.RemoveIllegalChars(this.Extension);
int index = extension.LastIndexOf('.');
if(index >= 0) this.Extension = extension.Substring(index);
else this.Extension = $".{extension}";
}
return flag;
}
}
}

View File

@@ -91,10 +91,10 @@ namespace ContextMenuManager.Controls
/// <summary>Shell类型菜单特殊注册表项名默认名称</summary>
private static readonly Dictionary<string, string> DefaultNames
= new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase) {
{"open", AppString.Item.Open }, {"edit", AppString.Item.Edit }, {"print", AppString.Item.Print },
{"find", AppString.Item.Find }, {"play", AppString.Item.Play }, {"runas", AppString.Item.Runas },
{"open", AppString.Other.Open }, {"edit", AppString.Other.Edit }, {"print", AppString.Other.Print },
{"find", AppString.Other.Find }, {"play", AppString.Other.Play }, {"runas", AppString.Other.Runas },
//Win10为“浏览(&X)”Win10之前为“资源管理器(&X)”
{"explore", WindowsOsVersion.IsBefore10 ? AppString.Item.ExploreOld : AppString.Item.Explore }
{"explore", WindowsOsVersion.IsBefore10 ? AppString.Other.ExploreOld : AppString.Other.Explore }
};
/// <summary>菜单项目在菜单中出现的位置</summary>
@@ -274,6 +274,10 @@ namespace ContextMenuManager.Controls
else
{
if(TryProtectOpenItem()) return;
if(WindowsOsVersion.IsAfterOrEqualWin10_1703)
{
Registry.SetValue(RegPath, "HideBasedOnVelocityId", 0x639bc8);
}
if(!IsSubItem)
{
//当LegaryDisable键值作用于文件夹-"在新窗口中打开"时
@@ -284,15 +288,11 @@ namespace ContextMenuManager.Controls
}
Registry.SetValue(RegPath, "ProgrammaticAccessOnly", "");
}
if(WindowsOsVersion.IsAfterOrEqualWin10_1703)
{
Registry.SetValue(RegPath, "HideBasedOnVelocityId", 0x639bc8);
if(ShowAsDisabledIfHidden) DeleteSomeValues();
}
else
{
MessageBoxEx.Show(AppString.MessageBox.CannotHideSubItem);
}
if(ShowAsDisabledIfHidden) DeleteSomeValues();
}
}
catch
@@ -577,7 +577,7 @@ namespace ContextMenuManager.Controls
}
using(ShellSubMenuDialog dlg = new ShellSubMenuDialog())
{
dlg.Text = AppString.Item.EditSubItems.Replace("%s", this.Text);
dlg.Text = AppString.Other.EditSubItems.Replace("%s", this.Text);
dlg.Icon = ResourceIcon.GetIcon(IconPath, IconIndex);
dlg.ShowDialog(this.RegPath);
}

View File

@@ -457,29 +457,29 @@ namespace ContextMenuManager.Controls
case Scenes.CustomExtension:
if(CurrentExtension == null)
{
return AppString.Item.SelectExtension;
return AppString.Dialog.SelectExtension;
}
else
{
return AppString.Item.CurrentExtension.Replace("%s", CurrentExtension);
return AppString.Other.CurrentExtension.Replace("%s", CurrentExtension);
}
case Scenes.PerceivedType:
if(CurrentPerceivedType == null)
{
return AppString.Item.SelectPerceivedType;
return AppString.Dialog.SelectPerceivedType;
}
else
{
return AppString.Item.CurrentPerceivedType.Replace("%s", GetPerceivedTypeName());
return AppString.Other.CurrentPerceivedType.Replace("%s", GetPerceivedTypeName());
}
case Scenes.DirectoryType:
if(CurrentDirectoryType == null)
{
return AppString.Item.SelectDirectoryType;
return AppString.Dialog.SelectDirectoryType;
}
else
{
return AppString.Item.CurrentDirectoryType.Replace("%s", GetDirectoryTypeName());
return AppString.Other.CurrentDirectoryType.Replace("%s", GetDirectoryTypeName());
}
default:
return null;
@@ -501,7 +501,7 @@ namespace ContextMenuManager.Controls
dlg = new SelectDialog
{
Items = PerceivedTypeNames,
Title = AppString.Item.SelectPerceivedType,
Title = AppString.Dialog.SelectPerceivedType,
Selected = GetPerceivedTypeName() ?? PerceivedTypeNames[0]
};
break;
@@ -509,7 +509,7 @@ namespace ContextMenuManager.Controls
dlg = new SelectDialog
{
Items = DirectoryTypeNames,
Title = AppString.Item.SelectDirectoryType,
Title = AppString.Dialog.SelectDirectoryType,
Selected = GetDirectoryTypeName() ?? DirectoryTypeNames[0]
};
break;

View File

@@ -188,7 +188,7 @@ namespace ContextMenuManager.Controls
{
this.Owner = list;
this.Image = AppImage.Lock;
this.Text = AppString.Item.LockNewMenu;
this.Text = AppString.Other.LockNewMenu;
this.SetNoClickEvent();
BtnShowMenu = new MenuButton(this);
ChkVisible = new VisibleCheckBox(this) { Checked = IsLocked };
@@ -276,7 +276,7 @@ namespace ContextMenuManager.Controls
{
public ShellNewSeparator()
{
this.Text = AppString.Item.Separator;
this.Text = AppString.Other.Separator;
this.HasImage = false;
}
}

View File

@@ -326,7 +326,7 @@ namespace ContextMenuManager.Controls
public InvalidItem(PulicMultiItemsList list, string keyName)
{
this.Owner = list;
this.Text = $"{AppString.Item.InvalidItem} {keyName}";
this.Text = $"{AppString.Other.InvalidItem} {keyName}";
this.Image = AppImage.NotFound.ToTransparent();
BtnDelete = new DeleteButton(this);
BtnMoveDown = new MoveButton(this, false);
@@ -558,7 +558,7 @@ namespace ContextMenuManager.Controls
{
public SubSeparatorItem()
{
this.Text = AppString.Item.Separator;
this.Text = AppString.Other.Separator;
this.HasImage = false;
BtnDelete = new DeleteButton(this);
BtnMoveDown = new MoveButton(this, false);

View File

@@ -0,0 +1,56 @@
using BluePointLilac.Methods;
using System;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
namespace ContextMenuManager.Controls
{
sealed class TranslateDialog : CommonDialog
{
public override void Reset() { }
protected override bool RunDialog(IntPtr hwndOwner)
{
using(TranslateForm frm = new TranslateForm())
{
bool flag = frm.ShowDialog() == DialogResult.OK;
return flag;
}
}
sealed class TranslateForm : Form
{
public TranslateForm()
{
this.ShowIcon = this.ShowInTaskbar = false;
this.MaximizeBox = this.MinimizeBox = false;
this.SizeGripStyle = SizeGripStyle.Hide;
this.StartPosition = FormStartPosition.CenterParent;
this.Font = new Font(SystemFonts.MessageBoxFont.FontFamily, 10F);
cmbSections.Width = cmbKeys.Width = 200.DpiZoom();
cmbSections.Left = cmbSections.Top = cmbKeys.Top = 20.DpiZoom();
cmbKeys.Left = cmbSections.Right + 20.DpiZoom();
this.Width = cmbKeys.Right + 20.DpiZoom();
this.Controls.AddRange(new Control[] { cmbSections, cmbKeys });
cmbSections.Items.AddRange(AppString.DefaultLanguage.RootDic.Keys.ToArray());
cmbSections.SelectedIndexChanged += (sender, e) =>
{
cmbKeys.Items.Clear();
cmbKeys.Items.AddRange(AppString.DefaultLanguage.RootDic[cmbSections.Text].Keys.ToArray());
cmbKeys.SelectedIndex = 0;
};
cmbSections.SelectedIndex = 0;
}
readonly ComboBox cmbSections = new ComboBox
{
DropDownStyle = ComboBoxStyle.DropDownList
};
readonly ComboBox cmbKeys = new ComboBox
{
DropDownStyle = ComboBoxStyle.DropDownList
};
}
}
}

View File

@@ -15,11 +15,13 @@ namespace ContextMenuManager
[STAThread]
static void Main(string[] args)
{
bool isRestart = args.Length > 0 && args[0] == "Restart";
if(!isRestart && SingleInstance.IsRunning()) return;
Updater.PeriodicUpdate();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
bool isRestart = args.Length > 0 && args[0] == "Restart";
if(!isRestart && SingleInstance.IsRunning()) return;
Updater.PeriodicUpdate();
Application.Run(new MainForm());
}
}

View File

@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false"/>
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site" />
<defaultAssemblyRequest permissionSetReference="Custom"/>
<PermissionSet class="System.Security.PermissionSet" version="1" Unrestricted="true" ID="Custom" SameSite="site"/>
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">

View File

@@ -164,6 +164,16 @@ namespace ContextMenuManager.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap DownLoad {
get {
object obj = ResourceManager.GetObject("DownLoad", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找类似 &lt;?xml version=&apos;1.0&apos; encoding=&apos;utf-8&apos; ?&gt;
///&lt;!--此文件为常用右键菜单字典,
@@ -347,6 +357,16 @@ namespace ContextMenuManager.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap Translate {
get {
object obj = ResourceManager.GetObject("Translate", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>

View File

@@ -142,6 +142,9 @@
<data name="Donate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>resources\images\donate.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="DownLoad" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>resources\images\download.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="EnhanceMenusDic" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>resources\texts\enhancemenusdic.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
@@ -187,6 +190,9 @@
<data name="ThirdRulesDic" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>resources\texts\thirdrulesdic.xml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="Translate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>resources\images\translate.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TurnOff" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>resources\images\turnoff.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1017 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 B

View File

@@ -46,6 +46,7 @@ DragDrop = 右键拖拽
PublicReferences = 公共引用
GuidBlocked = GUID 锁
IEMenu = IE 右键
AppSetting = 程序设置
AppLanguage = 程序语言
Dictionaries = 程序字典
@@ -121,38 +122,6 @@ RestoreDefault = 还原默认
Edit = 编辑
Save = 保存
[Item]
Open = 打开(&O)
Edit = 编辑(&E)
Explore = 浏览(&X)
ExploreOld = 资源管理器(&X)
Play = 播放(&L)
Print = 打印(&P)
Find = 搜索(&E)...
Runas = 以管理员身份运行(&A)
CustomFolder = 自定义文件夹(&F)...
MapNetworkDrive = 映射网络驱动器(&N)...
DisconnectNetworkDrive = 断开网络驱动器的连接(&C)...
RecycleBinProperties = 属性(&R)
RemovableDrive = 可移动磁盘
BuildSendtoMenu = 快速构建发送到子菜单
UseStoreOpenWith = 在Microsoft Store中查找应用
NewItem = 新建一个菜单项目
AddGuidBlockedItem = 添加GUID锁定项目
LockNewMenu = 锁定新建菜单
EditSubItems = 编辑 "%s" 的子菜单项目
InvalidItem = 无效菜单项目:
Separator = >>>>>> 分割线 <<<<<<
SelectExtension = 请选择一个文件扩展名
SelectPerceivedType = 请选择一个文件感知类型
SelectDirectoryType = 请选择一个目录感知类型
CurrentExtension = 你当前选择的文件扩展名为 %s
CurrentPerceivedType = 你当前选择的文件感知类型为 %s
CurrentDirectoryType = 你当前选择的目录感知类型为 %s
WinXSortable = 启用 WinX 菜单排序功能
ShowFilePath = 状态栏实时显示文件路径
OpenMoreRegedit = 允许注册表编辑器多开
[Dialog]
Ok = 确认
Cancel = 取消
@@ -184,6 +153,9 @@ VideoDirectory = 视频目录
AudioDirectory = 音频目录
CheckReference = 请勾选你想要引用的菜单项目
CheckCopy = 请勾选你想要复制的菜单项目
SelectExtension = 请选择一个文件扩展名
SelectPerceivedType = 请选择一个文件感知类型
SelectDirectoryType = 请选择一个目录感知类型
SelectGroup = 请选择保存分组
SelectNewItemType = 请选择新建菜单类型
SelectSubMenuMode = 该多级菜单子项目数为0, 你有两个选择:\n①该多级菜单的所有子菜单项目私有(推荐),\n②该多级菜单可与其他多级菜单引用相同子项,\n请做出你的选择......
@@ -234,17 +206,45 @@ LockNewMenu = 启用后可阻止第三方程序增加项目\n且可对现有项
CheckUpdate = 程序每月自动检测一次更新 (启动程序时)\n你可手动点击浏览Github、Gitee检查更新
LastCheckUpdateTime = 上次自动更新检查时间:
OpenLanguagesDir = 打开语言文件夹
OtherLanguages = 下载或上传其他语言文件
OpenDictionariesDir = 打开字典文件夹
ConfigPath = 更改配置和数据文件保存路径后,\n会导致部分已启用增强菜单失效,\n可在增强菜单中重新启用一遍
CommandFiles = 此命令依赖配置文件,移动配置文件位置\n会导致此菜单项失效重新启用一遍即可
CreateGroup = 新建一个分组
[Other]
Open = 打开(&O)
Edit = 编辑(&E)
Explore = 浏览(&X)
ExploreOld = 资源管理器(&X)
Play = 播放(&L)
Print = 打印(&P)
Find = 搜索(&E)...
Runas = 以管理员身份运行(&A)
CustomFolder = 自定义文件夹(&F)...
MapNetworkDrive = 映射网络驱动器(&N)...
DisconnectNetworkDrive = 断开网络驱动器的连接(&C)...
RecycleBinProperties = 属性(&R)
RemovableDrive = 可移动磁盘
BuildSendtoMenu = 快速构建发送到子菜单
UseStoreOpenWith = 在Microsoft Store中查找应用
NewItem = 新建一个菜单项目
AddGuidBlockedItem = 添加GUID锁定项目
LockNewMenu = 锁定新建菜单
EditSubItems = 编辑 "%s" 的子菜单项目
InvalidItem = 无效菜单项目:
Separator = >>>>>> 分割线 <<<<<<
CurrentExtension = 你当前选择的文件扩展名为 %s
CurrentPerceivedType = 你当前选择的文件感知类型为 %s
CurrentDirectoryType = 你当前选择的目录感知类型为 %s
WinXSortable = 启用 WinX 菜单排序功能
ShowFilePath = 状态栏实时显示文件路径
OpenMoreRegedit = 允许注册表编辑器多开
RestartExplorer = 当前部分操作需要重启文件资源管理器生效
DictionaryDescription = 字典说明
GuidInfosDictionary = GUID信息
Translators = 翻译贡献者
OtherLanguages = 下载或上传其他语言文件
DonationList = 捐赠名单
ConfigPath = 配置和数据文件保存位置
AppDataDir = AppData 目录

View File

@@ -20,13 +20,13 @@ namespace ContextMenuManager
Version appVersion = new Version(Application.ProductVersion);
//如果上次检测更新时间为一个月以前就进行更新操作
bool flag1 = AppConfig.LastCheckUpdateTime.AddMonths(1).CompareTo(DateTime.Today) < 0;
//如果配置文件中的版本号低于程序版本号也进行更新操作
bool flag2 = appVersion.CompareTo(AppConfig.Version) > 0;
//如果配置文件中的版本号程序版本号不同也进行更新操作
bool flag2 = appVersion.CompareTo(AppConfig.Version) != 0;
if(flag1 || flag2)
{
CheckUpdate();
AppConfig.LastCheckUpdateTime = DateTime.Today;
AppConfig.Version = appVersion;
AppConfig.LastCheckUpdateTime = DateTime.Today;
}
}