diff --git a/ContextMenuManager/AppConfig.cs b/ContextMenuManager/AppConfig.cs
index df8d526..576d4f8 100644
--- a/ContextMenuManager/AppConfig.cs
+++ b/ContextMenuManager/AppConfig.cs
@@ -3,7 +3,7 @@
using System.IO;
using System.Runtime.InteropServices;
using System.Windows.Forms;
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
namespace ContextMenuManager
{
@@ -11,8 +11,10 @@ static class AppConfig
{
static AppConfig()
{
- CreateDirs();
- DeleteOldFiles();
+ foreach(string dirPath in new[] { ConfigDir, ProgramsDir, BackupDir, LangsDir, DicsDir, WebDicsDir, UserDicsDir })
+ {
+ Directory.CreateDirectory(dirPath);
+ }
}
[DllImport("kernel32.dll")]
@@ -25,6 +27,7 @@ static AppConfig()
public static string ConfigIni = $@"{ConfigDir}\Config.ini";
public static string BackupDir = $@"{ConfigDir}\Backup";
public static string LangsDir = $@"{ConfigDir}\Languages";
+ public static string ProgramsDir = $@"{ConfigDir}\Programs";
public static string DicsDir = $@"{ConfigDir}\Dictionaries";
public static string WebDicsDir = $@"{DicsDir}\Web";
public static string UserDicsDir = $@"{DicsDir}\User";
@@ -34,7 +37,7 @@ static AppConfig()
public static string UserThirdRulesDic = $@"{UserDicsDir}\{ThIRDRULESDICXML}";
public static string WebEnhanceMenusDic = $@"{WebDicsDir}\{ENHANCEMENUSICXML}";
public static string UserEnhanceMenusDic = $@"{UserDicsDir}\{ENHANCEMENUSICXML}";
-
+ public static string HashLnkExePath = $@"{ProgramsDir}\HashLnk.exe";
public const string ZH_CNINI = "zh-CN.ini";
public const string GUIDINFOSDICINI = "GuidInfosDic.ini";
public const string ThIRDRULESDICXML = "ThirdRulesDic.xml";
@@ -120,43 +123,22 @@ public static string EngineUrl
}
}
- private static void CreateDirs()
+ public static bool ShowFilePath
{
- foreach(string dirPath in new[] { ConfigDir, BackupDir, LangsDir, DicsDir, WebDicsDir, UserDicsDir })
- {
- Directory.CreateDirectory(dirPath);
- }
+ get => ConfigWriter.GetValue("General", "ShowFilePath") == "1";
+ set => ConfigWriter.SetValue("General", "ShowFilePath", (value ? 1 : 0).ToString());
}
- private static void DeleteOldFiles()
+ public static bool WinXSortable
{
- DirectoryInfo configDi = new DirectoryInfo(ConfigDir);
- foreach(DirectoryInfo di in configDi.GetDirectories())
- {
- bool isOther = true;
- foreach(string path in new[] { BackupDir, LangsDir, DicsDir })
- {
- if(di.FullName.Equals(path, StringComparison.OrdinalIgnoreCase))
- {
- isOther = false;
- break;
- }
- }
- if(isOther) Directory.Delete(di.FullName);
- }
- foreach(FileInfo fi in configDi.GetFiles())
- {
- bool isOther = true;
- foreach(string path in new[] { ConfigIni })
- {
- if(fi.FullName.Equals(path, StringComparison.OrdinalIgnoreCase))
- {
- isOther = false;
- break;
- }
- }
- if(isOther) File.Delete(fi.FullName);
- }
+ get => ConfigWriter.GetValue("General", "WinXSortable") == "1";
+ set => ConfigWriter.SetValue("General", "WinXSortable", (value ? 1 : 0).ToString());
+ }
+
+ public static bool OpenMoreRegedit
+ {
+ get => ConfigWriter.GetValue("General", "OpenMoreRegedit") == "1";
+ set => ConfigWriter.SetValue("General", "OpenMoreRegedit", (value ? 1 : 0).ToString());
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/AppImage.cs b/ContextMenuManager/AppImage.cs
index 5f8ecd4..7b65660 100644
--- a/ContextMenuManager/AppImage.cs
+++ b/ContextMenuManager/AppImage.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using ContextMenuManager.Properties;
using System.Drawing;
@@ -41,12 +41,12 @@ public static class AppImage
public static readonly Image Down = Up.RotateImage(RotateFlipType.Rotate180FlipNone);
///新建项目图标
public static readonly Image NewItem = Resources.NewItem.ResizeImage(Scale);
- ///分隔线图标
- public static readonly Image Separator = Resources.SeparatorItem.ResizeImage(Scale);
- ///自定义类型图标
- public static readonly Image CustomType = Resources.CustomType.ResizeImage(Scale);
- ///所有文件类型图标
- public static readonly Image Types = Resources.Types.ResizeImage(Scale);
+ ///新建文件夹图标
+ public static readonly Image NewFolder = Resources.NewFolder.ResizeImage(Scale);
+ ///自定义图标
+ public static readonly Image Custom = Resources.Custom.ResizeImage(Scale);
+ ///选择图标
+ public static readonly Image Select = Resources.Select.ResizeImage(Scale);
///Microsoft Store图标
public static readonly Image MicrosoftStore = Resources.MicrosoftStore.ResizeImage(Scale);
///Skype图标
diff --git a/ContextMenuManager/AppString.cs b/ContextMenuManager/AppString.cs
index d93cd38..f36d409 100644
--- a/ContextMenuManager/AppString.cs
+++ b/ContextMenuManager/AppString.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System.Text;
namespace ContextMenuManager
@@ -55,20 +55,16 @@ public static class SideBar
public static string LnkFile => GetValue("LnkFile");
public static string UwpLnk => GetValue("UwpLnk");
public static string ExeFile => GetValue("ExeFile");
- public static string TextFile => GetValue("TextFile");
- public static string DocumentFile => GetValue("DocumentFile");
- public static string ImageFile => GetValue("ImageFile");
- public static string VideoFile => GetValue("VideoFile");
- public static string AudioFile => GetValue("AudioFile");
- public static string ImageDirectory => GetValue("ImageDirectory");
- public static string VideoDirectory => GetValue("VideoDirectory");
- public static string AudioDirectory => GetValue("AudioDirectory");
public static string UnknownType => GetValue("UnknownType");
- public static string CustomType => GetValue("CustomType");
+ public static string CustomExtension => GetValue("CustomExtension");
+ public static string PerceivedType => GetValue("PerceivedType");
+ public static string DirectoryType => GetValue("DirectoryType");
public static string EnhanceMenu => GetValue("EnhanceMenu");
public static string ThirdRules => GetValue("ThirdRules");
public static string GuidBlocked => GetValue("GuidBlocked");
+ public static string DragDrop => GetValue("DragDrop");
public static string PublicReferences => GetValue("PublicReferences");
+ public static string IEMenu => GetValue("IEMenu");
public static string AppSetting => GetValue("AppSetting");
public static string AboutApp => GetValue("AboutApp");
public static string Dictionaries => GetValue("Dictionaries");
@@ -97,23 +93,19 @@ public static class StatusBar
public static string LnkFile => GetValue("LnkFile");
public static string UwpLnk => GetValue("UwpLnk");
public static string ExeFile => GetValue("ExeFile");
- public static string TextFile => GetValue("TextFile");
- public static string DocumentFile => GetValue("DocumentFile");
- public static string ImageFile => GetValue("ImageFile");
- public static string VideoFile => GetValue("VideoFile");
- public static string AudioFile => GetValue("AudioFile");
- public static string ImageDirectory => GetValue("ImageDirectory");
- public static string VideoDirectory => GetValue("VideoDirectory");
- public static string AudioDirectory => GetValue("AudioDirectory");
public static string UnknownType => GetValue("UnknownType");
- public static string CustomType => GetValue("CustomType");
+ public static string CustomExtension => GetValue("CustomExtension");
+ public static string PerceivedType => GetValue("PerceivedType");
+ public static string DirectoryType => GetValue("DirectoryType");
public static string EnhanceMenu => GetValue("EnhanceMenu");
public static string ThirdRules => GetValue("ThirdRules");
public static string GuidBlocked => GetValue("GuidBlocked");
+ public static string DragDrop => GetValue("DragDrop");
public static string PublicReferences => GetValue("PublicReferences");
+ public static string IEMenu => GetValue("IEMenu");
}
- /// 菜单
+ /// 程序内右键菜单
public static class Menu
{
private static string GetValue(string key) => GetStringValue("Menu", key);
@@ -132,9 +124,11 @@ public static class Menu
public static string OnlyInExplorer => GetValue("OnlyInExplorer");
public static string NoWorkingDirectory => GetValue("NoWorkingDirectory");
public static string NeverDefault => GetValue("NeverDefault");
+ public static string ShowAsDisabledIfHidden => GetValue("ShowAsDisabledIfHidden");
public static string Details => GetValue("Details");
public static string WebSearch => GetValue("WebSearch");
public static string ChangeCommand => GetValue("ChangeCommand");
+ public static string RunAsAdministrator => GetValue("RunAsAdministrator");
public static string FileProperties => GetValue("FileProperties");
public static string FileLocation => GetValue("FileLocation");
public static string RegistryLocation => GetValue("RegistryLocation");
@@ -146,6 +140,9 @@ public static class Menu
public static string BlockGuid => GetValue("BlockGuid");
public static string AddGuidDic => GetValue("AddGuidDic");
public static string InitialData => GetValue("InitialData");
+ public static string BeforeSeparator => GetValue("BeforeSeparator");
+ public static string ChangeGroup => GetValue("ChangeGroup");
+ public static string RestoreDefault => GetValue("RestoreDefault");
public static string Edit => GetValue("Edit");
public static string Save => GetValue("Save");
}
@@ -172,12 +169,19 @@ public static class Item
public static string ShareWithSkype => GetValue("ShareWithSkype");
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 SetPerceivedType => GetValue("SetPerceivedType");
+ 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
@@ -187,9 +191,6 @@ public static class Dialog
public static string Cancel => GetValue("Cancel");
public static string Browse => GetValue("Browse");
public static string Program => GetValue("Program");
- public static string NewShellItem => GetValue("NewShellItem");
- public static string NewSendToItem => GetValue("NewSendToItem");
- public static string NewOpenWithItem => GetValue("NewOpenWithItem");
public static string ItemText => GetValue("ItemText");
public static string ItemCommand => GetValue("ItemCommand");
public static string CommandArguments => GetValue("CommandArguments");
@@ -199,14 +200,26 @@ public static class Dialog
public static string MultiMenu => GetValue("MultiMenu");
public static string Public => GetValue("Public");
public static string Private => GetValue("Private");
+ public static string Administrator => GetValue("Administrator");
public static string InputGuid => GetValue("InputGuid");
public static string AddGuidDic => GetValue("AddGuidDic");
public static string DeleteGuidDic => GetValue("DeleteGuidDic");
- public static string SelectExtension => GetValue("SelectExtension");
+ public static string TextFile => GetValue("TextFile");
+ public static string DocumentFile => GetValue("DocumentFile");
+ public static string ImageFile => GetValue("ImageFile");
+ public static string VideoFile => GetValue("VideoFile");
+ public static string AudioFile => GetValue("AudioFile");
+ public static string CompressedFile => GetValue("CompressedFile");
+ public static string SystemFile => GetValue("SystemFile");
+ public static string DocumentDirectory => GetValue("DocumentDirectory");
+ public static string ImageDirectory => GetValue("ImageDirectory");
+ public static string VideoDirectory => GetValue("VideoDirectory");
+ public static string AudioDirectory => GetValue("AudioDirectory");
public static string CheckReference => GetValue("CheckReference");
public static string CheckCopy => GetValue("CheckCopy");
public static string SelectSubMenuMode => GetValue("SelectSubMenuMode");
public static string RegistryFile => GetValue("RegistryFile");
+ public static string SelectGroup => GetValue("SelectGroup");
}
/// 消息框
@@ -218,6 +231,7 @@ public static class MessageBox
public static string StringParsingFailed => GetValue("StringParsingFailed");
public static string TextLengthCannotExceed80 => GetValue("TextLengthCannotExceed80");
public static string ConfirmDeletePermanently => GetValue("ConfirmDeletePermanently");
+ public static string DeleteButCanRestore => GetValue("DeleteButCanRestore");
public static string ConfirmDeleteReference => GetValue("ConfirmDeleteReference");
public static string ConfirmDelete => GetValue("ConfirmDelete");
public static string ConfirmDeleteReferenced => GetValue("ConfirmDeleteReferenced");
@@ -238,6 +252,9 @@ public static class MessageBox
public static string FolderNotExists => GetValue("FolderNotExists");
public static string NoUpdateDetected => GetValue("NoUpdateDetected");
public static string AuthorityProtection => GetValue("AuthorityProtection");
+ public static string WinXSorted => GetValue("WinXSorted");
+ public static string RestoreDefault => GetValue("RestoreDefault");
+ public static string DeleteGroup => GetValue("DeleteGroup");
}
/// 其他文本
@@ -257,9 +274,9 @@ public static class Other
public static string Dictionaries => GetValue("Dictionaries");
public static string Donate => GetValue("Donate");
public static string DonationList => GetValue("DonationList");
- public static string ConfigFile => GetValue("ConfigFile");
- public static string SaveToAppData => GetValue("SaveToAppData");
- public static string SaveToAppDir => GetValue("SaveToAppDir");
+ public static string ConfigPath => GetValue("ConfigPath");
+ public static string AppDataDir => GetValue("AppDataDir");
+ public static string AppDir => GetValue("AppDir");
public static string OpenConfigDir => GetValue("OpenConfigDir");
public static string AutoBackup => GetValue("AutoBackup");
public static string OpenBackupDir => GetValue("OpenBackupDir");
@@ -282,7 +299,6 @@ public static class Tip
public static string EditSubItems => GetValue("EditSubItems");
public static string InvalidItem => GetValue("InvalidItem");
public static string AddSeparator => GetValue("AddSeparator");
- public static string Separator => GetValue("Separator");
public static string AddReference => GetValue("AddReference");
public static string AddFromParentMenu => GetValue("AddFromParentMenu");
public static string DeleteGuidDic => GetValue("DeleteGuidDic");
@@ -291,7 +307,9 @@ public static class Tip
public static string LastCheckUpdateTime => GetValue("LastCheckUpdateTime");
public static string OpenLanguagesDir => GetValue("OpenLanguagesDir");
public static string OpenDictionariesDir => GetValue("OpenDictionariesDir");
- public static string ShareWithSkype => GetValue("ShareWithSkype");
+ public static string ConfigPath => GetValue("ConfigPath");
+ public static string CommandFiles => GetValue("CommandFiles");
+ public static string CreateGroup => GetValue("CreateGroup");
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Controls/IconDialog.cs b/ContextMenuManager/BluePointLilac.Controls/IconDialog.cs
similarity index 96%
rename from ContextMenuManager/BulePointLilac.Controls/IconDialog.cs
rename to ContextMenuManager/BluePointLilac.Controls/IconDialog.cs
index 6f9220f..84db31b 100644
--- a/ContextMenuManager/BulePointLilac.Controls/IconDialog.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/IconDialog.cs
@@ -3,7 +3,7 @@
using System.Text;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
public sealed class IconDialog : CommonDialog
{
diff --git a/ContextMenuManager/BulePointLilac.Controls/InputDialog.cs b/ContextMenuManager/BluePointLilac.Controls/InputDialog.cs
similarity index 97%
rename from ContextMenuManager/BulePointLilac.Controls/InputDialog.cs
rename to ContextMenuManager/BluePointLilac.Controls/InputDialog.cs
index 155dce8..94cb116 100644
--- a/ContextMenuManager/BulePointLilac.Controls/InputDialog.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/InputDialog.cs
@@ -1,10 +1,10 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using ContextMenuManager;
using System;
using System.Drawing;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
public sealed class InputDialog : CommonDialog
{
diff --git a/ContextMenuManager/BulePointLilac.Controls/MyCheckBox.cs b/ContextMenuManager/BluePointLilac.Controls/MyCheckBox.cs
similarity index 88%
rename from ContextMenuManager/BulePointLilac.Controls/MyCheckBox.cs
rename to ContextMenuManager/BluePointLilac.Controls/MyCheckBox.cs
index a2d7b6f..23206b0 100644
--- a/ContextMenuManager/BulePointLilac.Controls/MyCheckBox.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/MyCheckBox.cs
@@ -1,7 +1,7 @@
using ContextMenuManager;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
public class MyCheckBox : PictureBox
{
@@ -18,6 +18,7 @@ public bool Checked
public MyCheckBox()
{
+ this.Checked = false;
this.Cursor = Cursors.Hand;
this.SizeMode = PictureBoxSizeMode.AutoSize;
}
diff --git a/ContextMenuManager/BulePointLilac.Controls/MyListBox.cs b/ContextMenuManager/BluePointLilac.Controls/MyListBox.cs
similarity index 97%
rename from ContextMenuManager/BulePointLilac.Controls/MyListBox.cs
rename to ContextMenuManager/BluePointLilac.Controls/MyListBox.cs
index 7486d55..6f6d7c7 100644
--- a/ContextMenuManager/BulePointLilac.Controls/MyListBox.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/MyListBox.cs
@@ -1,10 +1,10 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
public class MyListBox : Panel
{
@@ -58,12 +58,14 @@ public MyListItem HoveredItem
value.ForeColor = Color.FromArgb(0, 138, 217);
//value.BackColor = Color.FromArgb(200, 230, 250);
value.Focus();
+ HoveredItemChanged?.Invoke(null, null);
}
}
+ public event EventHandler HoveredItemChanged;
+
public void AddItem(MyListItem item)
{
- if(item.Parent == this) return;
item.Parent = this;
item.Width = Owner.Width - item.Margin.Horizontal;
Owner.Resize += (sender, e) => item.Width = Owner.Width - item.Margin.Horizontal;
@@ -136,7 +138,6 @@ public MyListItem()
this.Margin = new Padding(0);
this.ForeColor = Color.FromArgb(80, 80, 80);
this.BackColor = Color.FromArgb(250, 250, 250);
- this.BackgroundImageLayout = ImageLayout.Stretch;
this.Font = SystemFonts.IconTitleFont;
this.Controls.AddRange(new Control[] { lblSeparator, flpControls, lblText, picImage });
flpControls.MouseEnter += (sender, e) => this.OnMouseEnter(null);
@@ -204,7 +205,7 @@ public bool HasImage
};
private readonly Label lblSeparator = new Label
{
- BackColor = Color.FromArgb(200, 200, 200),
+ BackColor = Color.FromArgb(220, 220, 220),
Dock = DockStyle.Bottom,
Height = 1
};
diff --git a/ContextMenuManager/BulePointLilac.Controls/MyMainForm.cs b/ContextMenuManager/BluePointLilac.Controls/MyMainForm.cs
similarity index 94%
rename from ContextMenuManager/BulePointLilac.Controls/MyMainForm.cs
rename to ContextMenuManager/BluePointLilac.Controls/MyMainForm.cs
index 6f01727..6778cc3 100644
--- a/ContextMenuManager/BulePointLilac.Controls/MyMainForm.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/MyMainForm.cs
@@ -1,9 +1,9 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.Drawing;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
public class MyMainForm : Form
{
diff --git a/ContextMenuManager/BulePointLilac.Controls/MySideBar.cs b/ContextMenuManager/BluePointLilac.Controls/MySideBar.cs
similarity index 95%
rename from ContextMenuManager/BulePointLilac.Controls/MySideBar.cs
rename to ContextMenuManager/BluePointLilac.Controls/MySideBar.cs
index 1a5dd2f..a57994c 100644
--- a/ContextMenuManager/BulePointLilac.Controls/MySideBar.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/MySideBar.cs
@@ -1,11 +1,11 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.Drawing;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
- public class MySideBar : Panel
+ public sealed class MySideBar : Panel
{
public MySideBar()
{
@@ -92,7 +92,7 @@ public Color HoveredForeColor
};
readonly Label LblSeparator = new Label
{
- BackColor = Color.FromArgb(200, 200, 200),
+ BackColor = Color.FromArgb(220, 220, 220),
Dock = DockStyle.Right,
Width = 1,
};
@@ -106,7 +106,7 @@ public int GetItemWidth(string str)
/// 绘制所有项目作为底图
private void PaintItems()
{
- this.BackgroundImage = new Bitmap(Width, Height);
+ this.BackgroundImage = new Bitmap(Width, ItemHeight * ItemNames.Length);
using(Graphics g = Graphics.FromImage(BackgroundImage))
{
g.Clear(BackColor);
@@ -132,6 +132,7 @@ private void PaintItems()
/// 刷新选中的项目
private void RefreshItem(Panel panel, int index)
{
+ panel.CreateGraphics().Clear(panel.BackColor);
panel.Top = index < 0 ? -ItemHeight : (TopSpace + index * ItemHeight);
panel.Text = index < 0 ? null : ItemNames[index];
panel.Refresh();
@@ -141,7 +142,6 @@ private void RefreshItem(Panel panel, int index)
private void PaintItem(object sender, PaintEventArgs e)
{
Control ctr = (Control)sender;
- e.Graphics.Clear(ctr.BackColor);
e.Graphics.DrawString(ctr.Text, Font,
new SolidBrush(ctr.ForeColor),
new PointF(HorizontalSpace, VerticalSpace));
diff --git a/ContextMenuManager/BulePointLilac.Controls/MyStatusBar.cs b/ContextMenuManager/BluePointLilac.Controls/MyStatusBar.cs
similarity index 68%
rename from ContextMenuManager/BulePointLilac.Controls/MyStatusBar.cs
rename to ContextMenuManager/BluePointLilac.Controls/MyStatusBar.cs
index 2e10f60..986ef76 100644
--- a/ContextMenuManager/BulePointLilac.Controls/MyStatusBar.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/MyStatusBar.cs
@@ -1,11 +1,11 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.Drawing;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
- public class MyStatusBar : Panel
+ public sealed class MyStatusBar : Panel
{
public static readonly string DefaultText = $"Ver: {new Version(Application.ProductVersion).ToString(2)} {Application.CompanyName}";
@@ -22,17 +22,29 @@ public MyStatusBar()
public new string Text
{
get => base.Text;
- set { base.Text = value; Refresh(); }
+ set
+ {
+ if(base.Text == value) return;
+ base.Text = value; Refresh();
+ }
}
public new Font Font
{
get => base.Font;
- set { base.Font = value; Refresh(); }
+ set
+ {
+ if(base.Font == value) return;
+ base.Font = value; Refresh();
+ }
}
public new Color ForeColor
{
get => base.ForeColor;
- set { base.ForeColor = value; Refresh(); }
+ set
+ {
+ if(base.ForeColor == value) return;
+ base.ForeColor = value; Refresh();
+ }
}
protected override void OnPaint(PaintEventArgs e)
diff --git a/ContextMenuManager/BulePointLilac.Controls/MyToolBar.cs b/ContextMenuManager/BluePointLilac.Controls/MyToolBar.cs
similarity index 86%
rename from ContextMenuManager/BulePointLilac.Controls/MyToolBar.cs
rename to ContextMenuManager/BluePointLilac.Controls/MyToolBar.cs
index 9dfe810..56db5a1 100644
--- a/ContextMenuManager/BulePointLilac.Controls/MyToolBar.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/MyToolBar.cs
@@ -1,11 +1,11 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.Drawing;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
- public class MyToolBar : FlowLayoutPanel
+ public sealed class MyToolBar : FlowLayoutPanel
{
public MyToolBar()
{
@@ -43,7 +43,7 @@ public void AddButton(MyToolBarButton button)
button.Margin = new Padding(12.DpiZoom(), 4.DpiZoom(), 0, 0);
button.MouseDown += (sender, e) =>
{
- if(e.Button == MouseButtons.Left) { SelectedButton = button; button.Cursor = Cursors.Default; }
+ if(button.CanBeSelected) { SelectedButton = button; button.Cursor = Cursors.Default; }
};
button.MouseEnter += (sender, e) =>
{
@@ -61,7 +61,7 @@ public void AddButtons(MyToolBarButton[] buttons)
}
}
- public class MyToolBarButton : Panel
+ public sealed class MyToolBarButton : Panel
{
public MyToolBarButton(Image image, string text)
{
@@ -73,6 +73,7 @@ public MyToolBarButton(Image image, string text)
lblText.Resize += (sender, e) => lblText.Left = (Width - lblText.Width) / 2;
this.Image = image;
this.Text = text;
+ this.CanBeSelected = true;
MyToolTip.SetToolTip(this, text);
lblText.SetEnabled(false);
}
@@ -108,5 +109,11 @@ public float Opacity
get => BackColor.A / 255;
set => BackColor = Color.FromArgb((int)(value * 255), Color.White);
}
+ public bool CanBeSelected { get; set; }
+
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ if(e.Button == MouseButtons.Left) base.OnMouseDown(e);
+ }
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Controls/MyToolTip.cs b/ContextMenuManager/BluePointLilac.Controls/MyToolTip.cs
similarity index 84%
rename from ContextMenuManager/BulePointLilac.Controls/MyToolTip.cs
rename to ContextMenuManager/BluePointLilac.Controls/MyToolTip.cs
index 0317f0d..a45d3e5 100644
--- a/ContextMenuManager/BulePointLilac.Controls/MyToolTip.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/MyToolTip.cs
@@ -1,9 +1,9 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
- public sealed class MyToolTip
+ public static class MyToolTip
{
public static void SetToolTip(Control ctr, string tip)
{
diff --git a/ContextMenuManager/BulePointLilac.Controls/PictureButton.cs b/ContextMenuManager/BluePointLilac.Controls/PictureButton.cs
similarity index 96%
rename from ContextMenuManager/BulePointLilac.Controls/PictureButton.cs
rename to ContextMenuManager/BluePointLilac.Controls/PictureButton.cs
index 6ef5453..578c9c3 100644
--- a/ContextMenuManager/BulePointLilac.Controls/PictureButton.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/PictureButton.cs
@@ -2,7 +2,7 @@
using System.Drawing;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
public class PictureButton : PictureBox
{
diff --git a/ContextMenuManager/BulePointLilac.Controls/ReadOnlyRichTextBox.cs b/ContextMenuManager/BluePointLilac.Controls/ReadOnlyRichTextBox.cs
similarity index 78%
rename from ContextMenuManager/BulePointLilac.Controls/ReadOnlyRichTextBox.cs
rename to ContextMenuManager/BluePointLilac.Controls/ReadOnlyRichTextBox.cs
index a914af4..0cb73af 100644
--- a/ContextMenuManager/BulePointLilac.Controls/ReadOnlyRichTextBox.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/ReadOnlyRichTextBox.cs
@@ -1,10 +1,10 @@
-using System.Diagnostics;
-using System.Drawing;
+using System.Drawing;
using System.Windows.Forms;
+using BluePointLilac.Methods;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
- sealed class ReadOnlyRichTextBox : RichTextBox
+ public sealed class ReadOnlyRichTextBox : RichTextBox
{
public ReadOnlyRichTextBox()
{
@@ -30,7 +30,7 @@ protected override void WndProc(ref Message m)
protected override void OnLinkClicked(LinkClickedEventArgs e)
{
- base.OnLinkClicked(e); Process.Start(e.LinkText);
+ base.OnLinkClicked(e); ExternalProgram.OpenUrl(e.LinkText);
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Controls/ResizbleForm.cs b/ContextMenuManager/BluePointLilac.Controls/ResizbleForm.cs
similarity index 97%
rename from ContextMenuManager/BulePointLilac.Controls/ResizbleForm.cs
rename to ContextMenuManager/BluePointLilac.Controls/ResizbleForm.cs
index f705217..f1dbb39 100644
--- a/ContextMenuManager/BulePointLilac.Controls/ResizbleForm.cs
+++ b/ContextMenuManager/BluePointLilac.Controls/ResizbleForm.cs
@@ -1,10 +1,10 @@
using System;
using System.Windows.Forms;
-namespace BulePointLilac.Controls
+namespace BluePointLilac.Controls
{
/// 限制水平、竖直方向调整大小的窗体
- class ResizbleForm : Form
+ public class ResizbleForm : Form
{
/// 水平方向可调整大小
public bool HorizontalResizable { get; set; } = true;
diff --git a/ContextMenuManager/BulePointLilac.Methods/ControlExtension.cs b/ContextMenuManager/BluePointLilac.Methods/ControlExtension.cs
similarity index 98%
rename from ContextMenuManager/BulePointLilac.Methods/ControlExtension.cs
rename to ContextMenuManager/BluePointLilac.Methods/ControlExtension.cs
index ab5c756..04ad777 100644
--- a/ContextMenuManager/BulePointLilac.Methods/ControlExtension.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/ControlExtension.cs
@@ -2,7 +2,7 @@
using System.Runtime.InteropServices;
using System.Windows.Forms;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class ControlExtension
{
diff --git a/ContextMenuManager/BluePointLilac.Methods/DesktopIni.cs b/ContextMenuManager/BluePointLilac.Methods/DesktopIni.cs
new file mode 100644
index 0000000..0c0c78b
--- /dev/null
+++ b/ContextMenuManager/BluePointLilac.Methods/DesktopIni.cs
@@ -0,0 +1,34 @@
+using System.IO;
+
+namespace BluePointLilac.Methods
+{
+ public static class DesktopIni
+ {
+ private const string LocalizedFileNames = "LocalizedFileNames";
+
+ private static string GetIniPath(string filePath) => $@"{Path.GetDirectoryName(filePath)}\desktop.ini";
+
+ public static void DeleteLocalizedFileNames(string filePath)
+ {
+ IniWriter writer = new IniWriter(GetIniPath(filePath));
+ string fileName = Path.GetFileName(filePath);
+ writer.DeleteKey(LocalizedFileNames, fileName);
+ }
+
+ public static void SetLocalizedFileNames(string filePath, string name)
+ {
+ IniWriter writer = new IniWriter(GetIniPath(filePath));
+ string fileName = Path.GetFileName(filePath);
+ writer.SetValue(LocalizedFileNames, fileName, name);
+ }
+
+ public static string GetLocalizedFileNames(string filePath, bool translate = false)
+ {
+ IniWriter writer = new IniWriter(GetIniPath(filePath));
+ string fileName = Path.GetFileName(filePath);
+ string name = writer.GetValue(LocalizedFileNames, fileName);
+ if(translate) name = ResourceString.GetDirectString(name);
+ return name;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Methods/DirectoryEx.cs b/ContextMenuManager/BluePointLilac.Methods/DirectoryEx.cs
similarity index 95%
rename from ContextMenuManager/BulePointLilac.Methods/DirectoryEx.cs
rename to ContextMenuManager/BluePointLilac.Methods/DirectoryEx.cs
index 02ca7e9..3903c8d 100644
--- a/ContextMenuManager/BulePointLilac.Methods/DirectoryEx.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/DirectoryEx.cs
@@ -1,6 +1,6 @@
using System.IO;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class DirectoryEx
{
diff --git a/ContextMenuManager/BulePointLilac.Methods/EncodingType.cs b/ContextMenuManager/BluePointLilac.Methods/EncodingType.cs
similarity index 81%
rename from ContextMenuManager/BulePointLilac.Methods/EncodingType.cs
rename to ContextMenuManager/BluePointLilac.Methods/EncodingType.cs
index b5564a0..46d7eb3 100644
--- a/ContextMenuManager/BulePointLilac.Methods/EncodingType.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/EncodingType.cs
@@ -1,9 +1,8 @@
using System;
using System.IO;
-using System.Linq;
using System.Text;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
/// 获取文本文件编码类型
/// 代码主要为转载,仅做简单改动
@@ -20,10 +19,6 @@ public static Encoding GetType(string filePath)
return GetType(fs);
}
- static readonly byte[] Unicode = { 0xFF, 0xFE, 0x41 };
- static readonly byte[] UnicodeBIG = { 0xFE, 0xFF, 0x00 };
- static readonly byte[] UTF8 = { 0xEF, 0xBB, 0xBF }; //带BOM
-
/// 通过给定的文件流,判断文件的编码类型
/// 文件流
/// 文件的编码类型
@@ -33,11 +28,11 @@ public static Encoding GetType(FileStream fs)
int.TryParse(fs.Length.ToString(), out int i);
using(BinaryReader reader = new BinaryReader(fs, Encoding.Default))
ss = reader.ReadBytes(i);
- byte[] rs = ss.Take(3).ToArray();
- if((rs == UTF8) || IsUTF8Bytes(ss)) return Encoding.UTF8;
- else if(rs == UnicodeBIG) return Encoding.BigEndianUnicode;
- else if(rs == Unicode) return Encoding.Unicode;
- else return Encoding.Default;
+ if(IsUTF8Bytes(ss)) return Encoding.UTF8;
+ if(ss[0] == 0xEF && ss[1] == 0xBB && ss[2] == 0xBF) return Encoding.UTF8;//带BOM
+ if(ss[0] == 0xFE && ss[1] == 0xFF) return Encoding.BigEndianUnicode; //UTF-16BE
+ if(ss[0] == 0xFF && ss[1] == 0xFE) return Encoding.Unicode; //UTF-16LE
+ return Encoding.Default;
}
/// 判断是否是不带 BOM 的 UTF8 格式
diff --git a/ContextMenuManager/BluePointLilac.Methods/ExternalProgram.cs b/ContextMenuManager/BluePointLilac.Methods/ExternalProgram.cs
new file mode 100644
index 0000000..c63a836
--- /dev/null
+++ b/ContextMenuManager/BluePointLilac.Methods/ExternalProgram.cs
@@ -0,0 +1,177 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading;
+
+namespace BluePointLilac.Methods
+{
+ public static class ExternalProgram
+ {
+ public static void JumpRegEdit(string regPath, string valueName = null, bool moreOpen = false)
+ {
+ IntPtr hMain = FindWindow("RegEdit_RegEdit", null);
+ if(moreOpen || hMain == IntPtr.Zero)
+ {
+ using(Process process = Process.Start("regedit.exe", "-m"))
+ {
+ process.WaitForInputIdle();
+ hMain = process.MainWindowHandle;
+ }
+ }
+
+ IntPtr hTree = FindWindowEx(hMain, IntPtr.Zero, "SysTreeView32", null);
+ IntPtr hList = FindWindowEx(hMain, IntPtr.Zero, "SysListView32", null);
+
+ SetForegroundWindow(hTree);
+ SetFocus(hTree);
+ SendMessage(hTree, WM_KEYDOWN, VK_HOME, null);
+ Thread.Sleep(50);
+ SendMessage(hTree, WM_KEYDOWN, VK_RIGHT, null);
+ foreach(char chr in Encoding.Default.GetBytes(regPath))
+ {
+ if(chr == '\\')
+ {
+ Thread.Sleep(50);
+ SendMessage(hTree, WM_KEYDOWN, VK_RIGHT, null);
+ }
+ else SendMessage(hTree, WM_CHAR, Convert.ToInt16(chr), null);
+ }
+
+ if(!string.IsNullOrEmpty(valueName))
+ {
+ Thread.Sleep(50);
+ SetForegroundWindow(hList);
+ SetFocus(hList);
+ SendMessage(hList, WM_KEYDOWN, VK_HOME, null);
+ foreach(char chr in Encoding.Default.GetBytes(valueName))
+ {
+ SendMessage(hList, WM_CHAR, Convert.ToInt16(chr), null);
+ }
+ }
+ }
+
+ public static void JumpExplorer(string filePath)
+ {
+ using(Process process = new Process())
+ {
+ if(File.Exists(filePath))
+ {
+ process.StartInfo.FileName = "explorer.exe";
+ process.StartInfo.Arguments = $"/select,{filePath}";
+ process.Start();
+ }
+ else if(Directory.Exists(filePath))
+ {
+ process.StartInfo.FileName = filePath;
+ process.Start();
+ }
+ }
+ }
+
+ public static bool ShowPropertiesDialog(string filePath)
+ {
+ SHELLEXECUTEINFO info = new SHELLEXECUTEINFO
+ {
+ lpVerb = "Properties",
+ //lpParameters = "详细信息";//显示选项卡,此处有语言差异
+ lpFile = filePath,
+ nShow = SW_SHOW,
+ fMask = SEE_MASK_INVOKEIDLIST,
+ cbSize = Marshal.SizeOf(typeof(SHELLEXECUTEINFO))
+ };
+ return ShellExecuteEx(ref info);
+ }
+
+ public static void RestartExplorer()
+ {
+ using(Process process = new Process())
+ {
+ process.StartInfo = new ProcessStartInfo
+ {
+ FileName = "taskkill.exe",
+ Arguments = "-f -im explorer.exe",
+ WindowStyle = ProcessWindowStyle.Hidden
+ };
+ process.Start();
+ process.WaitForExit();
+ process.StartInfo = new ProcessStartInfo("explorer.exe");
+ process.Start();
+ }
+ }
+
+ public static void OpenUrl(string url)
+ {
+ //替换网址转义符
+ url = url.Replace("%", "%25").Replace("#", "%23").Replace("&", "%26").Replace("+", "%2B");
+ using(Process process = new Process())
+ {
+ //通过explorer来调用浏览器打开链接,避免管理员权限影响
+ process.StartInfo.FileName = "explorer.exe";
+ process.StartInfo.Arguments = $"\"{url}\"";
+ process.Start();
+ }
+ }
+
+ public static void OpenNotepadWithText(string text)
+ {
+ using(Process process = Process.Start("notepad.exe"))
+ {
+ Thread.Sleep(200);
+ IntPtr handle = FindWindowEx(process.MainWindowHandle, IntPtr.Zero, "Edit", null);
+ SendMessage(handle, WM_SETTEXT, 0, text);
+ }
+ }
+
+ private const int SW_SHOW = 5;
+ private const uint SEE_MASK_INVOKEIDLIST = 12;
+ private const int WM_SETTEXT = 0xC;
+ private const int WM_KEYDOWN = 0x100;
+ private const int WM_CHAR = 0x102;
+ private const int VK_HOME = 0x24;
+ private const int VK_RIGHT = 0x27;
+
+ [DllImport("User32.dll")]
+ private static extern bool SetForegroundWindow(IntPtr hWnd);
+
+ [DllImport("User32.dll")]
+ private static extern bool SetFocus(IntPtr hWnd);
+
+ [DllImport("user32.dll")]
+ private static extern IntPtr FindWindow(string lpszClass, string lpszWindow);
+
+ [DllImport("user32.dll")]
+ private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChild, string lpszClass, string lpszWindow);
+
+ [DllImport("user32.dll")]
+ private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
+ [DllImport("shell32.dll", CharSet = CharSet.Auto)]
+ private static extern bool ShellExecuteEx(ref SHELLEXECUTEINFO lpExecInfo);
+
+ [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
+ private struct SHELLEXECUTEINFO
+ {
+ public int cbSize;
+ public uint fMask;
+ public IntPtr hwnd;
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string lpVerb;
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string lpFile;
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string lpParameters;
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string lpDirectory;
+ public int nShow;
+ public IntPtr hInstApp;
+ public IntPtr lpIDList;
+ [MarshalAs(UnmanagedType.LPTStr)]
+ public string lpClass;
+ public IntPtr hkeyClass;
+ public uint dwHotKey;
+ public IntPtr hIcon;
+ public IntPtr hProcess;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Methods/FileExtension.cs b/ContextMenuManager/BluePointLilac.Methods/FileExtension.cs
similarity index 94%
rename from ContextMenuManager/BulePointLilac.Methods/FileExtension.cs
rename to ContextMenuManager/BluePointLilac.Methods/FileExtension.cs
index fef31a7..962b3cf 100644
--- a/ContextMenuManager/BulePointLilac.Methods/FileExtension.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/FileExtension.cs
@@ -1,6 +1,6 @@
using Microsoft.Win32;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class FileExtension
{
diff --git a/ContextMenuManager/BulePointLilac.Methods/GuidEx.cs b/ContextMenuManager/BluePointLilac.Methods/GuidEx.cs
similarity index 54%
rename from ContextMenuManager/BulePointLilac.Methods/GuidEx.cs
rename to ContextMenuManager/BluePointLilac.Methods/GuidEx.cs
index 619c488..f4fb2fa 100644
--- a/ContextMenuManager/BulePointLilac.Methods/GuidEx.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/GuidEx.cs
@@ -1,22 +1,30 @@
using System;
+using System.Text.RegularExpressions;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
//为兼容.Net Framework 3.5,无法引用Microsoft.CSharp.dll(中的Guid.TryParse)写了这个扩展方法
public static class GuidEx
{
public static bool TryParse(string str, out Guid guid)
{
- try
+ if(IsGuid(str))
{
guid = new Guid(str);
return true;
}
- catch
+ else
{
guid = Guid.Empty;
return false;
}
}
+
+ public static bool IsGuid(string str)
+ {
+ if(string.IsNullOrEmpty(str)) return false;
+ Regex guidRegEx = new Regex(@"[a-fA-F0-9]{8}(\-[a-fA-F0-9]{4}){3}\-[a-fA-F0-9]{12}");
+ return guidRegEx.IsMatch(str);
+ }
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Methods/HighDpi.cs b/ContextMenuManager/BluePointLilac.Methods/HighDpi.cs
similarity index 97%
rename from ContextMenuManager/BulePointLilac.Methods/HighDpi.cs
rename to ContextMenuManager/BluePointLilac.Methods/HighDpi.cs
index 70ba625..085b07d 100644
--- a/ContextMenuManager/BulePointLilac.Methods/HighDpi.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/HighDpi.cs
@@ -2,7 +2,7 @@
using System.Windows;
using System.Windows.Forms;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class HighDpi
{
diff --git a/ContextMenuManager/BulePointLilac.Methods/ImageExtension.cs b/ContextMenuManager/BluePointLilac.Methods/ImageExtension.cs
similarity index 98%
rename from ContextMenuManager/BulePointLilac.Methods/ImageExtension.cs
rename to ContextMenuManager/BluePointLilac.Methods/ImageExtension.cs
index 75da33d..f7f0074 100644
--- a/ContextMenuManager/BulePointLilac.Methods/ImageExtension.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/ImageExtension.cs
@@ -2,7 +2,7 @@
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class ImageExtension
{
diff --git a/ContextMenuManager/BulePointLilac.Methods/IniReader.cs b/ContextMenuManager/BluePointLilac.Methods/IniReader.cs
similarity index 97%
rename from ContextMenuManager/BulePointLilac.Methods/IniReader.cs
rename to ContextMenuManager/BluePointLilac.Methods/IniReader.cs
index db327f5..1a22939 100644
--- a/ContextMenuManager/BulePointLilac.Methods/IniReader.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/IniReader.cs
@@ -4,7 +4,7 @@
using System.Linq;
using System.Text;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public sealed class IniReader
{
@@ -65,6 +65,7 @@ private void ReadLines(List lines)
int k = lines[j].IndexOf('=');
string key = lines[j].Substring(0, k).TrimEnd();
string value = lines[j].Substring(k + 1).TrimStart();
+ if(keyValues.ContainsKey(key)) continue;
keyValues.Add(key, value);
}
}
diff --git a/ContextMenuManager/BulePointLilac.Methods/IniWriter.cs b/ContextMenuManager/BluePointLilac.Methods/IniWriter.cs
similarity index 97%
rename from ContextMenuManager/BulePointLilac.Methods/IniWriter.cs
rename to ContextMenuManager/BluePointLilac.Methods/IniWriter.cs
index 704117f..7a79dcf 100644
--- a/ContextMenuManager/BulePointLilac.Methods/IniWriter.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/IniWriter.cs
@@ -3,7 +3,7 @@
using System.IO;
using System.Text;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public sealed class IniWriter
{
@@ -16,7 +16,7 @@ public IniWriter(string filePath)
}
public string FilePath { get; set; }
- public Encoding Encoding { get; set; } = Encoding.UTF8;
+ public Encoding Encoding { get; set; } = Encoding.Unicode;
public bool DeleteFileWhenEmpty { get; set; }
private List GetLines()
@@ -85,7 +85,7 @@ private void SetValue(string section, string key, ref string value, bool isGetVa
{
if(key != null && value != null)
{
- if(lines.Count > 0) lines.Add(string.Empty);//添加空行
+ lines.Add(string.Empty);//添加空行
//目标section不存在则添加到最后
lines.Add(sectionLine);
lines.Add(keyLine);
diff --git a/ContextMenuManager/BulePointLilac.Methods/MessageBoxEx.cs b/ContextMenuManager/BluePointLilac.Methods/MessageBoxEx.cs
similarity index 92%
rename from ContextMenuManager/BulePointLilac.Methods/MessageBoxEx.cs
rename to ContextMenuManager/BluePointLilac.Methods/MessageBoxEx.cs
index 2adcff6..42aa8c3 100644
--- a/ContextMenuManager/BulePointLilac.Methods/MessageBoxEx.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/MessageBoxEx.cs
@@ -1,7 +1,7 @@
using ContextMenuManager;
using System.Windows.Forms;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class MessageBoxEx
{
diff --git a/ContextMenuManager/BulePointLilac.Methods/ObjectPath.cs b/ContextMenuManager/BluePointLilac.Methods/ObjectPath.cs
similarity index 63%
rename from ContextMenuManager/BulePointLilac.Methods/ObjectPath.cs
rename to ContextMenuManager/BluePointLilac.Methods/ObjectPath.cs
index 281562a..9d24bc9 100644
--- a/ContextMenuManager/BulePointLilac.Methods/ObjectPath.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/ObjectPath.cs
@@ -1,20 +1,18 @@
using Microsoft.Win32;
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
using System.Linq;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
- public class ObjectPath
+ public static class ObjectPath
{
/// 路径类型
public enum PathType { File, Directory, Registry }
- //右键菜单仅支持%SystemRoot%\System32和%SystemRoot%两个环境变量,不考虑其他系统环境变量和用户环境变量,和Win+R命令有区别
- private static readonly string[] EnvironmentDirectorys = { @"%SystemRoot%\System32", @"%SystemRoot%" };
private const string RegAppPath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths";
private const string RegLastPath = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit";
+ private const string ShellExecuteCommand = "mshta vbscript:createobject(\"shell.application\").shellexecute(\"";
private static readonly char[] IllegalChars = { '/', '*', '?', '\"', '<', '>', '|' };
private static readonly List IgnoreCommandParts = new List { "", "%1", "%v" };
@@ -22,26 +20,28 @@ public enum PathType { File, Directory, Registry }
/// 根据文件名获取完整的文件路径
/// fileName为Win+R、注册表等可直接使用的文件名
/// 文件名
- /// 成功提取返回现有文件路径,否则返回值为null
+ /// 成功提取返回true, fullPath为现有文件路径; 否则返回false, fullPath为null
public static bool GetFullFilePath(string fileName, out string fullPath)
{
fullPath = null;
- if(File.Exists(fileName))
- {
- fullPath = fileName;
- return true;
- }
+ if(fileName.IsNullOrWhiteSpace()) return false;
+
foreach(string name in new[] { fileName, $"{fileName}.exe" })
{
- foreach(string dir in EnvironmentDirectorys)
+ //右键菜单仅支持%SystemRoot%\System32和%SystemRoot%两个环境变量,不考虑其他系统环境变量和用户环境变量,和Win+R命令有区别
+ foreach(string dir in new[] { "", @"%SystemRoot%\System32\", @"%SystemRoot%\" })
{
- fullPath = Environment.ExpandEnvironmentVariables($@"{dir}\{name}");
+ fullPath = Environment.ExpandEnvironmentVariables($@"{dir}{name}");
if(File.Exists(fullPath)) return true;
}
- fullPath = Registry.GetValue($@"{RegAppPath}\{name}", "", null)?.ToString();
- if(File.Exists(fullPath)) return true;
+ if(!name.Contains("\\"))
+ {
+ fullPath = Registry.GetValue($@"{RegAppPath}\{name}", "", null)?.ToString();
+ if(File.Exists(fullPath)) return true;
+ }
}
+ fullPath = null;
return false;
}
@@ -54,27 +54,54 @@ public static string ExtractFilePath(string command)
command = Environment.ExpandEnvironmentVariables(command).Replace(@"\\", @"\");
if(File.Exists(command)) return command;
+ if(command.StartsWith(ShellExecuteCommand, StringComparison.OrdinalIgnoreCase))
+ {
+ command = command.Remove(0, ShellExecuteCommand.Length);
+ string[] arr = command.Split(new[] { "\",\"" }, StringSplitOptions.None);
+ if(arr.Length > 0)
+ {
+ string filePath = null;
+ string fileName = arr[0];
+ if(arr.Length > 1)
+ {
+ string arguments = arr[1];
+ filePath = ExtractFilePath(arguments);
+ if(filePath != null) return filePath;
+ }
+ if(GetFullFilePath(fileName, out filePath)) return filePath;
+ }
+ }
+
string[] strs = Array.FindAll(command.Split(IllegalChars), str
=> IgnoreCommandParts.Any(part => !part.Equals(str.Trim()))).Reverse().ToArray();
- foreach(string str in strs)
+ foreach(string str1 in strs)
{
- int index = str.Length;
+ string str2 = str1;
+ int index = -1;
do
{
- string path1 = str.Substring(0, index);
- List paths = new List { path1 };
- if(path1.Contains(",")) paths.Add(path1.Substring(0, path1.LastIndexOf(',')));
+ List paths = new List();
+ string path1 = str2.Substring(index + 1);
+ paths.Add(path1);
+ if(path1.Contains(",")) paths.AddRange(path1.Split(','));
+ if(index > 0)
+ {
+ string path2 = str2.Substring(0, index);
+ paths.Add(path2);
+ if(path2.Contains(",")) paths.AddRange(path2.Split(','));
+ }
foreach(string path in paths)
{
if(GetFullFilePath(path, out string fullPath)) return fullPath;
}
- index = path1.LastIndexOf(' ');
- } while(index != -1);
+ str2 = path1;
+ index = str2.IndexOf(' ');
+ }
+ while(index != -1);
}
return null;
}
-
/// 移除文件或文件夹名称中的非法字符
/// 文件或文件夹名称
/// 返回移除非法字符后的文件或文件夹名称
@@ -84,7 +111,6 @@ public static string RemoveIllegalChars(string fileName)
return fileName.Replace("\\", "").Replace(":", "");
}
-
/// 判断文件或文件夹或注册表项是否存在
/// 文件或文件夹或注册表项路径
/// 路径类型
@@ -108,39 +134,21 @@ public static bool ObjectPathExist(string path, PathType type)
/// 目标路径
/// 路径类型
/// 如果目标路径不存在则返回目标路径,否则返回带序号的新路径
- public static string GetNewPathWithIndex(string oldPath, PathType type)
+ public static string GetNewPathWithIndex(string oldPath, PathType type, int startIndex = -1)
{
string newPath;
string dirPath = type == PathType.Registry ? RegistryEx.GetParentPath(oldPath) : Path.GetDirectoryName(oldPath);
string name = type == PathType.Registry ? RegistryEx.GetKeyName(oldPath) : Path.GetFileNameWithoutExtension(oldPath);
string extension = type == PathType.Registry ? "" : Path.GetExtension(oldPath);
- int index = 0;
do
{
newPath = $@"{dirPath}\{name}";
- if(index > 0) newPath += index;
+ if(startIndex > -1) newPath += startIndex;
newPath += extension;
- index++;
+ startIndex++;
} while(ObjectPathExist(newPath, type));
return newPath;
}
-
- public static void ShowPath(string path, PathType type)
- {
- switch(type)
- {
- case PathType.Directory:
- Process.Start(path);
- break;
- case PathType.File:
- Process.Start("explorer.exe", $" /select,{path}");
- break;
- case PathType.Registry:
- Registry.SetValue(RegLastPath, "LastKey", path);
- Process.Start("regedit.exe", "-m");
- break;
- }
- }
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Methods/RegTrustedInstaller.cs b/ContextMenuManager/BluePointLilac.Methods/RegTrustedInstaller.cs
similarity index 91%
rename from ContextMenuManager/BulePointLilac.Methods/RegTrustedInstaller.cs
rename to ContextMenuManager/BluePointLilac.Methods/RegTrustedInstaller.cs
index f72129b..9bc96ea 100644
--- a/ContextMenuManager/BulePointLilac.Methods/RegTrustedInstaller.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/RegTrustedInstaller.cs
@@ -5,7 +5,7 @@
using System.Security.AccessControl;
using System.Security.Principal;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
/// 获取TrustedInstaller权限注册表项的所有权
/// 代码主要为转载,仅做简单改动
@@ -18,18 +18,21 @@ static class NativeMethod
public const string TakeOwnership = "SeTakeOwnershipPrivilege";
public const string Restore = "SeRestorePrivilege";
+ [StructLayout(LayoutKind.Sequential)]
public struct LUID
{
public int lowPart;
public int highPart;
}
+ [StructLayout(LayoutKind.Sequential)]
public struct LUID_AND_ATTRIBUTES
{
public LUID Luid;
public int Attributes;
}
+ [StructLayout(LayoutKind.Sequential)]
public struct TOKEN_PRIVILEGES
{
public int PrivilegeCount;
@@ -37,6 +40,7 @@ public struct TOKEN_PRIVILEGES
public LUID_AND_ATTRIBUTES[] Privileges;
}
+ [Flags]
public enum PrivilegeAttributes
{
/// 特权被禁用.
@@ -51,6 +55,7 @@ public enum PrivilegeAttributes
UsedForAccess = -2147483648
}
+ [Flags]
public enum TokenAccessRights
{
/// 向进程附加主令牌的权限.
@@ -82,6 +87,7 @@ public enum TokenAccessRights
Execute = AccessTypeMasks.StandardRightsExecute | Impersonate
}
+ [Flags]
private enum AccessTypeMasks
{
Delete = 65536,
@@ -98,14 +104,17 @@ private enum AccessTypeMasks
}
[DllImport("advapi32.dll", SetLastError = true)]
- private static extern bool AdjustTokenPrivileges(IntPtr accessTokenHandle, bool disableAllPrivileges,
- ref TOKEN_PRIVILEGES newState, int bufferLength, ref TOKEN_PRIVILEGES previousState, ref int returnLength);
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool AdjustTokenPrivileges([In] IntPtr accessTokenHandle, [In] bool disableAllPrivileges,
+ [In] ref TOKEN_PRIVILEGES newState, [In] int bufferLength, [In, Out] ref TOKEN_PRIVILEGES previousState, [In, Out] ref int returnLength);
[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
- private static extern bool LookupPrivilegeValue(string systemName, string name, ref LUID luid);
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool LookupPrivilegeValue([In] string systemName, [In] string name, [In, Out] ref LUID luid);
[DllImport("advapi32.dll", SetLastError = true)]
- private static extern bool OpenProcessToken(IntPtr processHandle, TokenAccessRights desiredAccess, ref IntPtr tokenHandle);
+ [return: MarshalAs(UnmanagedType.Bool)]
+ private static extern bool OpenProcessToken([In] IntPtr processHandle, [In] TokenAccessRights desiredAccess, [In, Out] ref IntPtr tokenHandle);
[DllImport("kernel32.dll", SetLastError = true)]
private static extern int GetLastError();
diff --git a/ContextMenuManager/BulePointLilac.Methods/RegistryEx.cs b/ContextMenuManager/BluePointLilac.Methods/RegistryEx.cs
similarity index 96%
rename from ContextMenuManager/BulePointLilac.Methods/RegistryEx.cs
rename to ContextMenuManager/BluePointLilac.Methods/RegistryEx.cs
index ef2d2b7..13b249f 100644
--- a/ContextMenuManager/BulePointLilac.Methods/RegistryEx.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/RegistryEx.cs
@@ -4,7 +4,7 @@
using System.IO;
using System.Security.AccessControl;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class RegistryEx
{
@@ -46,7 +46,6 @@ public static void MoveTo(string srcPath, string dstPath)
public static RegistryKey CreateSubKey(this RegistryKey key, string subKeyName, bool writable)
{
key.CreateSubKey(subKeyName).Close();
- RegTrustedInstaller.TakeRegTreeOwnerShip($@"{key.Name}\{subKeyName}");
return key.OpenSubKey(subKeyName, writable);
}
@@ -142,8 +141,8 @@ public static RegistryKey GetRegistryKey(string regPath, RegistryKeyPermissionCh
public static void Export(string regPath, string filePath)
{
if(File.Exists(filePath)) File.Delete(filePath);
- Process process = Process.Start("regedit.exe", $" /e \"{filePath}\" \"{regPath}\"");
- process.WaitForExit();
+ using(Process process = Process.Start("regedit.exe", $"/e \"{filePath}\" \"{regPath}\""))
+ process.WaitForExit();
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Methods/ResourceIcon.cs b/ContextMenuManager/BluePointLilac.Methods/ResourceIcon.cs
similarity index 99%
rename from ContextMenuManager/BulePointLilac.Methods/ResourceIcon.cs
rename to ContextMenuManager/BluePointLilac.Methods/ResourceIcon.cs
index 8037cf4..0a9f749 100644
--- a/ContextMenuManager/BulePointLilac.Methods/ResourceIcon.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/ResourceIcon.cs
@@ -5,7 +5,7 @@
using System.Runtime.InteropServices;
using System.Windows.Forms;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class ResourceIcon
{
diff --git a/ContextMenuManager/BulePointLilac.Methods/ResourceString.cs b/ContextMenuManager/BluePointLilac.Methods/ResourceString.cs
similarity index 96%
rename from ContextMenuManager/BulePointLilac.Methods/ResourceString.cs
rename to ContextMenuManager/BluePointLilac.Methods/ResourceString.cs
index 309e2d7..df6f664 100644
--- a/ContextMenuManager/BulePointLilac.Methods/ResourceString.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/ResourceString.cs
@@ -2,7 +2,7 @@
using System.Runtime.InteropServices;
using System.Text;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class ResourceString
{
diff --git a/ContextMenuManager/BulePointLilac.Methods/RichTextBoxExtension.cs b/ContextMenuManager/BluePointLilac.Methods/RichTextBoxExtension.cs
similarity index 99%
rename from ContextMenuManager/BulePointLilac.Methods/RichTextBoxExtension.cs
rename to ContextMenuManager/BluePointLilac.Methods/RichTextBoxExtension.cs
index ab16bdf..9436a3c 100644
--- a/ContextMenuManager/BulePointLilac.Methods/RichTextBoxExtension.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/RichTextBoxExtension.cs
@@ -4,7 +4,7 @@
using System.Windows.Forms;
using System.Xml.Linq;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class RichTextBoxExtension
{
diff --git a/ContextMenuManager/BluePointLilac.Methods/SingleInstance.cs b/ContextMenuManager/BluePointLilac.Methods/SingleInstance.cs
new file mode 100644
index 0000000..01b541c
--- /dev/null
+++ b/ContextMenuManager/BluePointLilac.Methods/SingleInstance.cs
@@ -0,0 +1,51 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+
+namespace BluePointLilac.Methods
+{
+ public static class SingleInstance
+ {
+ public static bool IsRunning()
+ {
+ using(Process current = Process.GetCurrentProcess())
+ {
+ string fileName = current.MainModule.FileName;
+ string processName = Path.GetFileNameWithoutExtension(fileName);
+ foreach(Process process in Process.GetProcessesByName(processName))
+ {
+ using(process)
+ {
+ if(process.Id == current.Id) continue;
+ if(process.MainModule.FileName == fileName)
+ {
+ ShowWindowAsync(process.MainWindowHandle, 1);//SW_SHOWNORMAL
+ SetForegroundWindow(process.MainWindowHandle);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
+
+ public static void Restart()
+ {
+ using(Process process = new Process())
+ {
+ process.StartInfo.FileName = Application.ExecutablePath;
+ process.StartInfo.Arguments = "Restart";
+ process.Start();
+ }
+ Application.Exit();
+ }
+
+ [DllImport("User32.dll")]
+ private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
+
+ [DllImport("User32.dll")]
+ private static extern bool SetForegroundWindow(IntPtr hWnd);
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Methods/StringExtension.cs b/ContextMenuManager/BluePointLilac.Methods/StringExtension.cs
similarity index 90%
rename from ContextMenuManager/BulePointLilac.Methods/StringExtension.cs
rename to ContextMenuManager/BluePointLilac.Methods/StringExtension.cs
index a2575ea..166eebe 100644
--- a/ContextMenuManager/BulePointLilac.Methods/StringExtension.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/StringExtension.cs
@@ -1,4 +1,4 @@
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
//为兼容.Net Framework 3.5,无法引用Microsoft.CSharp.dll(中的string.IsNullOrWhiteSpace)写了这个扩展方法
public static class StringExtension
diff --git a/ContextMenuManager/BulePointLilac.Methods/TextBoxExtension.cs b/ContextMenuManager/BluePointLilac.Methods/TextBoxExtension.cs
similarity index 95%
rename from ContextMenuManager/BulePointLilac.Methods/TextBoxExtension.cs
rename to ContextMenuManager/BluePointLilac.Methods/TextBoxExtension.cs
index 00c52b1..40170b3 100644
--- a/ContextMenuManager/BulePointLilac.Methods/TextBoxExtension.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/TextBoxExtension.cs
@@ -1,7 +1,7 @@
using System.Drawing;
using System.Windows.Forms;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
public static class TextBoxExtension
{
diff --git a/ContextMenuManager/BulePointLilac.Methods/WindowsOsVersion.cs b/ContextMenuManager/BluePointLilac.Methods/WindowsOsVersion.cs
similarity index 98%
rename from ContextMenuManager/BulePointLilac.Methods/WindowsOsVersion.cs
rename to ContextMenuManager/BluePointLilac.Methods/WindowsOsVersion.cs
index 19fac75..5795cb4 100644
--- a/ContextMenuManager/BulePointLilac.Methods/WindowsOsVersion.cs
+++ b/ContextMenuManager/BluePointLilac.Methods/WindowsOsVersion.cs
@@ -1,6 +1,6 @@
using System;
-namespace BulePointLilac.Methods
+namespace BluePointLilac.Methods
{
//判断Windows系统版本
public static class WindowsOsVersion
diff --git a/ContextMenuManager/BluePointLilac.Methods/WshShortcut.cs b/ContextMenuManager/BluePointLilac.Methods/WshShortcut.cs
new file mode 100644
index 0000000..4daa4ee
--- /dev/null
+++ b/ContextMenuManager/BluePointLilac.Methods/WshShortcut.cs
@@ -0,0 +1,202 @@
+using System;
+using System.IO;
+using System.Reflection;
+using System.Runtime.InteropServices;
+using System.Runtime.InteropServices.ComTypes;
+using System.Text;
+
+namespace BluePointLilac.Methods
+{
+ //为兼容.Net Framework 3.5无法使用dynamic和Interop.IWshRuntimeLibrary.dll专门写出此类
+ public sealed class WshShortcut : IDisposable
+ {
+ private static readonly Type ShellType = Type.GetTypeFromCLSID(new Guid("72C24DD5-D70A-438B-8A42-98424B88AFB8"));
+ private static readonly object Shell = Activator.CreateInstance(ShellType);
+ private static readonly BindingFlags InvokeMethodFlag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod;
+ private static readonly BindingFlags GetPropertyFlag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty;
+ private static readonly BindingFlags SetPropertyFlag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty;
+
+ private static object CreateShortcut(string lnkPath)
+ {
+ return ShellType.InvokeMember("CreateShortcut", InvokeMethodFlag, null, Shell, new[] { lnkPath });
+ }
+
+ public WshShortcut(string lnkPath)
+ {
+ //只调用CreateShortcut方法时,TargetPath值为null,
+ //其他属性值正常,只有调用一下Save方法才能获取到TargetPath值
+ this.lnkPath = lnkPath;
+ shortcut = CreateShortcut(lnkPath);
+ shortcutType = shortcut.GetType();
+ shellLink = (IShellLinkA)new ShellLink();
+ if(File.Exists(lnkPath))
+ {
+ Save();
+ ((IPersistFile)shellLink).Load(lnkPath, 2);//STGM_READWRITE
+ }
+ }
+
+ private readonly string lnkPath;
+ private readonly object shortcut;
+ private readonly Type shortcutType;
+ private readonly IShellLinkA shellLink;
+
+ public string FullName
+ {
+ get => GetValue("FullName")?.ToString();
+ }
+ public string TargetPath
+ {
+ get => GetValue("TargetPath")?.ToString();
+ set => SetValue("TargetPath", value);
+ }
+ public string Arguments
+ {
+ get => GetValue("Arguments")?.ToString();
+ set => SetValue("Arguments", value);
+ }
+ public string WorkingDirectory
+ {
+ get => GetValue("WorkingDirectory")?.ToString();
+ set => SetValue("WorkingDirectory", value);
+ }
+ public string IconLocation
+ {
+ get => GetValue("IconLocation")?.ToString();
+ set => SetValue("IconLocation", value);
+ }
+ public string Description
+ {
+ get => GetValue("Description")?.ToString();
+ set => SetValue("Description", value);
+ }
+ public string Hotkey
+ {
+ get => GetValue("Hotkey")?.ToString();
+ set => SetValue("Hotkey", value);
+ }
+ public int WindowStyle
+ {
+ get => Convert.ToInt32(GetValue("WindowStyle"));
+ set => SetValue("WindowStyle", value);
+ }
+ public bool RunAsAdministrator
+ {
+ get
+ {
+ ((IShellLinkDataList)shellLink).GetFlags(out ShellLinkDataFlags flags);
+ return (flags & ShellLinkDataFlags.RunasUser) == ShellLinkDataFlags.RunasUser;
+ }
+ set
+ {
+ ((IShellLinkDataList)shellLink).GetFlags(out ShellLinkDataFlags flags);
+ if(value) flags |= ShellLinkDataFlags.RunasUser;
+ else flags &= ~ShellLinkDataFlags.RunasUser;
+ ((IShellLinkDataList)shellLink).SetFlags(flags);
+ ((IPersistFile)shellLink).Save(lnkPath, true);
+ }
+ }
+
+ private object GetValue(string name)
+ {
+ try { return shortcutType.InvokeMember(name, GetPropertyFlag, null, shortcut, null); }
+ catch { return null; }
+ }
+
+ private void SetValue(string name, object value)
+ {
+ shortcutType.InvokeMember(name, SetPropertyFlag, null, shortcut, new[] { value });
+ }
+
+ public void Save()
+ {
+ //存储快捷方式为写入文件行为,如果没有权限会报错
+ shortcutType.InvokeMember("Save", InvokeMethodFlag, null, shortcut, null);
+ }
+
+ public void Dispose()
+ {
+ Marshal.ReleaseComObject(shortcut);
+ Marshal.ReleaseComObject(shellLink);
+ }
+
+ ~WshShortcut() { Dispose(); }
+
+
+ [ComImport]
+ [Guid("00021401-0000-0000-C000-000000000046")]
+ internal class ShellLink { }
+
+ [ComImport]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [Guid("000214EE-0000-0000-C000-000000000046")]
+ public interface IShellLinkA
+ {
+ void GetPath([Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder pszFile, int cchMaxPath, out IntPtr pfd, int fFlags);
+ void GetIDList(out IntPtr ppidl);
+ void SetIDList(IntPtr pidl);
+ void GetDescription([Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder pszName, int cchMaxName);
+ void SetDescription([MarshalAs(UnmanagedType.LPStr)] string pszName);
+ void GetWorkingDirectory([Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder pszDir, int cchMaxPath);
+ void SetWorkingDirectory([MarshalAs(UnmanagedType.LPStr)] string pszDir);
+ void GetArguments([Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder pszArgs, int cchMaxPath);
+ void SetArguments([MarshalAs(UnmanagedType.LPStr)] string pszArgs);
+ void GetHotkey(out short pwHotkey);
+ void SetHotkey(short wHotkey);
+ void GetShowCmd(out int piShowCmd);
+ void SetShowCmd(int iShowCmd);
+ void GetIconLocation([Out, MarshalAs(UnmanagedType.LPStr)] StringBuilder pszIconPath, int cchIconPath, out int piIcon);
+ void SetIconLocation([MarshalAs(UnmanagedType.LPStr)] string pszIconPath, int iIcon);
+ void SetRelativePath([MarshalAs(UnmanagedType.LPStr)] string pszPathRel, int dwReserved);
+ void Resolve(IntPtr hwnd, int fFlags);
+ void SetPath([MarshalAs(UnmanagedType.LPStr)] string pszFile);
+ }
+
+ [ComImport]
+ [Guid("45e2b4ae-b1c3-11d0-b92f-00a0c90312e1")]
+ [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ interface IShellLinkDataList
+ {
+ void AddDataBlock(IntPtr pDataBlock);
+ void CopyDataBlock(uint dwSig, out IntPtr ppDataBlock);
+ void RemoveDataBlock(uint dwSig);
+ void GetFlags(out ShellLinkDataFlags pdwFlags);
+ void SetFlags(ShellLinkDataFlags dwFlags);
+ }
+
+ [Flags] // SHELL_LINK_DATA_FLAGS
+ public enum ShellLinkDataFlags : uint
+ {
+ Default = 0x00000000,
+ HasIdList = 0x00000001,
+ HasLinkInfo = 0x00000002,
+ HasName = 0x00000004,
+ HasRelpath = 0x00000008,
+ HasWorkingdir = 0x00000010,
+ HasArgs = 0x00000020,
+ HasIconLocation = 0x00000040,
+ Unicode = 0x00000080,
+ ForceNoLinkInfo = 0x00000100,
+ HasExpSz = 0x00000200,
+ RunInSeparate = 0x00000400,
+ HasLogo3Id = 0x00000800,
+ HasDarwinId = 0x00001000,
+ RunasUser = 0x00002000,
+ HasExpIconSz = 0x00004000,
+ NoPidlAlias = 0x00008000,
+ ForceUncname = 0x00010000,
+ RunWithShimlayer = 0x00020000,
+ ForceNoLinktrack = 0x00040000,
+ EnableTargetMetadata = 0x00080000,
+ DisableLinkPathTracking = 0x00100000,
+ DisableKnownfolderRelativeTracking = 0x00200000,
+ NoKFAlias = 0x00400000,
+ AllowLinkToLink = 0x00800000,
+ UnaliasOnSave = 0x01000000,
+ PreferEnvironmentPath = 0x02000000,
+ KeepLocalIdListForUncTarget = 0x04000000,
+ Valid = 0x07fff7ff,
+ Reserved = 0x80000000
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Methods/PropertiesDialog.cs b/ContextMenuManager/BulePointLilac.Methods/PropertiesDialog.cs
deleted file mode 100644
index e5ac640..0000000
--- a/ContextMenuManager/BulePointLilac.Methods/PropertiesDialog.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-using System;
-using System.Runtime.InteropServices;
-
-namespace BulePointLilac.Methods
-{
- public static class PropertiesDialog
- {
- public static bool Show(string filePath)
- {
- SHELLEXECUTEINFO info = new SHELLEXECUTEINFO
- {
- lpVerb = "Properties",
- //lpParameters = "详细信息";//显示选项卡,此处有语言差异
- lpFile = filePath,
- nShow = SW_SHOW,
- fMask = SEE_MASK_INVOKEIDLIST,
- cbSize = CbSize
- };
- return ShellExecuteEx(ref info);
- }
-
- private const int SW_SHOW = 5;
-
- private const uint SEE_MASK_INVOKEIDLIST = 12;
-
- private static readonly int CbSize = Marshal.SizeOf(typeof(SHELLEXECUTEINFO));
-
- [DllImport("shell32.dll", CharSet = CharSet.Auto)]
- private static extern bool ShellExecuteEx(ref SHELLEXECUTEINFO lpExecInfo);
-
- [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
- private struct SHELLEXECUTEINFO
- {
- public int cbSize;
- public uint fMask;
- public IntPtr hwnd;
- [MarshalAs(UnmanagedType.LPTStr)]
- public string lpVerb;
- [MarshalAs(UnmanagedType.LPTStr)]
- public string lpFile;
- [MarshalAs(UnmanagedType.LPTStr)]
- public string lpParameters;
- [MarshalAs(UnmanagedType.LPTStr)]
- public string lpDirectory;
- public int nShow;
- public IntPtr hInstApp;
- public IntPtr lpIDList;
- [MarshalAs(UnmanagedType.LPTStr)]
- public string lpClass;
- public IntPtr hkeyClass;
- public uint dwHotKey;
- public IntPtr hIcon;
- public IntPtr hProcess;
- }
- }
-}
\ No newline at end of file
diff --git a/ContextMenuManager/BulePointLilac.Methods/WshShortcut.cs b/ContextMenuManager/BulePointLilac.Methods/WshShortcut.cs
deleted file mode 100644
index 0dbd0e4..0000000
--- a/ContextMenuManager/BulePointLilac.Methods/WshShortcut.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-using System;
-using System.Reflection;
-
-namespace BulePointLilac.Methods
-{
- //为兼容.Net Framework 3.5无法使用dynamic和Interop.IWshRuntimeLibrary.dll专门写出此类
- sealed class WshShortcut
- {
- private static readonly Type ShellType = Type.GetTypeFromProgID("WScript.Shell");
- private static readonly object Shell = Activator.CreateInstance(ShellType);
- private static readonly BindingFlags InvokeMethodFlag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod;
- private static readonly BindingFlags GetPropertyFlag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty;
- private static readonly BindingFlags SetPropertyFlag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty;
-
- private static object CreateShortcut(string lnkPath)
- {
- return ShellType.InvokeMember("CreateShortcut", InvokeMethodFlag, null, Shell, new[] { lnkPath });
- }
-
- private Type ShortcutType;
- private object Shortcut;
-
- private string fullName;
- public string FullName
- {
- get => fullName;
- set => Load(value);
- }
-
- public string TargetPath
- {
- get => GetValue("TargetPath").ToString();
- set => SetValue("TargetPath", value);
- }
- public string Arguments
- {
- get => GetValue("Arguments").ToString();
- set => SetValue("Arguments", value);
- }
- public string WorkingDirectory
- {
- get => GetValue("WorkingDirectory").ToString();
- set => SetValue("WorkingDirectory", value);
- }
- public string IconLocation
- {
- get => GetValue("IconLocation").ToString();
- set => SetValue("IconLocation", value);
- }
- public string Description
- {
- get => GetValue("Description").ToString();
- set => SetValue("Description", value);
- }
- public string Hotkey
- {
- get => GetValue("Hotkey").ToString();
- set => SetValue("Hotkey", value);
- }
- public int WindowStyle
- {
- get => Convert.ToInt32(GetValue("WindowStyle"));
- set => SetValue("WindowStyle", value);
- }
- //public string RelativePath { get; set; }//暂时不知道这是啥
-
- private object GetValue(string name)
- {
- return ShortcutType.InvokeMember(name, GetPropertyFlag, null, Shortcut, null);
- }
-
- private void SetValue(string name, object value)
- {
- ShortcutType.InvokeMember(name, SetPropertyFlag, null, Shortcut, new[] { value });
- }
-
- public void Load(string lnkPath)
- {
- fullName = lnkPath;
- Shortcut = CreateShortcut(lnkPath);
- ShortcutType = Shortcut.GetType();
- Save();
- }
-
- public void Save()
- {
- //存储快捷方式为写入文件行为,如果没有权限会报错
- ShortcutType.InvokeMember("Save", InvokeMethodFlag, null, Shortcut, null);
- }
- }
-}
\ No newline at end of file
diff --git a/ContextMenuManager/ContextMenuManager.csproj b/ContextMenuManager/ContextMenuManager.csproj
index 33ca476..7c73ab0 100644
--- a/ContextMenuManager/ContextMenuManager.csproj
+++ b/ContextMenuManager/ContextMenuManager.csproj
@@ -110,46 +110,67 @@
-
-
+
+
Component
-
+
Form
-
+
+ Component
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Component
-
-
-
-
-
-
-
-
-
-
-
-
+
Component
-
+
Component
-
+
Component
-
+
Component
Component
+
+ Component
+
+
+ Component
+
Component
-
+
+ Component
+
+
+ Component
+
+
+ Component
+
+
Component
@@ -200,9 +221,6 @@
Component
-
- Component
-
Component
@@ -212,16 +230,13 @@
Component
-
- Component
-
Component
Component
-
+
Component
@@ -248,6 +263,9 @@
Component
+
+ Component
+
Component
@@ -257,31 +275,31 @@
Form
-
+
Component
-
+
Component
-
+
Component
-
+
Component
-
+
Form
-
+
Component
-
+
Component
Component
-
+
Component
@@ -290,20 +308,24 @@
Component
-
-
-
-
-
+
+
+
+
-
+
-
-
-
-
+
+
+
+
+
+ True
+ True
+ Resources.resx
+
@@ -314,11 +336,6 @@
Settings.Designer.cs
-
- True
- True
- Resources.resx
-
True
Settings.settings
@@ -339,6 +356,10 @@
+
+
+
+
@@ -346,20 +367,17 @@
-
-
-
diff --git a/ContextMenuManager/Controls/AboutApp.cs b/ContextMenuManager/Controls/AboutApp.cs
index ddf1c06..076f795 100644
--- a/ContextMenuManager/Controls/AboutApp.cs
+++ b/ContextMenuManager/Controls/AboutApp.cs
@@ -1,13 +1,10 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System;
using System.Collections.Generic;
-using System.Diagnostics;
using System.Drawing;
using System.IO;
-using System.Runtime.InteropServices;
using System.Text;
-using System.Threading;
using System.Windows.Forms;
namespace ContextMenuManager.Controls
@@ -22,7 +19,7 @@ public DonateBox()
this.BackColor = Color.White;
this.Font = new Font(SystemFonts.MenuFont.FontFamily, 10F);
this.Controls.AddRange(new Control[] { lblInfo, picQR, llbDonationList });
- llbDonationList.LinkClicked += (sender, e) => Process.Start(DonateListUrl);
+ llbDonationList.LinkClicked += (sender, e) => ExternalProgram.OpenUrl(DonateListUrl);
}
readonly Label lblInfo = new Label
@@ -70,12 +67,12 @@ public DictionariesBox()
boxs[i] = new ReadOnlyRichTextBox { Parent = pages[i] };
if(i > 0) boxs[i].ContextMenuStrip = cms;
}
- items[0].Click += (sender, e) => EditText();
+ items[0].Click += (sender, e) => ExternalProgram.OpenNotepadWithText(GetInitialText());
items[2].Click += (sender, e) => SaveFile();
boxs[0].Controls.Add(btnOpenDir);
btnOpenDir.Top = boxs[0].Height - btnOpenDir.Height;
MyToolTip.SetToolTip(btnOpenDir, AppString.Tip.OpenDictionariesDir);
- btnOpenDir.MouseDown += (sender, e) => Process.Start(AppConfig.DicsDir);
+ btnOpenDir.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(AppConfig.DicsDir);
}
readonly TabPage[] pages = new TabPage[] {
@@ -98,22 +95,6 @@ public DictionariesBox()
new ToolStripMenuItem(AppString.Menu.Save)
};
- [DllImport("user32.dll")]
- private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
-
- [DllImport("user32.dll")]
- private static extern int SendMessage(IntPtr hWnd, int uMsg, int wParam, string lParam);
- const int WM_SETTEXT = 0x000C;
- private void EditText()
- {
- using(Process process = Process.Start("notepad.exe"))
- {
- Thread.Sleep(200);
- IntPtr handle = FindWindowEx(process.MainWindowHandle, IntPtr.Zero, "Edit", null);
- SendMessage(handle, WM_SETTEXT, 0, GetInitialText());
- }
- }
-
private void SaveFile()
{
using(SaveFileDialog dlg = new SaveFileDialog())
@@ -140,7 +121,7 @@ private void SaveFile()
dlg.InitialDirectory = dirPath;
if(dlg.ShowDialog() == DialogResult.OK)
{
- File.WriteAllText(dlg.FileName, GetInitialText(), Encoding.UTF8);
+ File.WriteAllText(dlg.FileName, GetInitialText(), Encoding.Unicode);
}
}
}
@@ -186,8 +167,8 @@ public LanguagesBox()
this.Controls.AddRange(new Control[] { cmbLanguages, btnOpenDir, llbOtherLanguages, txtTranslators });
this.OnResize(null);
cmbLanguages.SelectionChangeCommitted += (sender, e) => ChangeLanguage();
- llbOtherLanguages.LinkClicked += (sender, e) => Process.Start(OtherLanguagesUrl);
- btnOpenDir.MouseDown += (sender, e) => Process.Start(AppConfig.LangsDir);
+ llbOtherLanguages.LinkClicked += (sender, e) => ExternalProgram.OpenUrl(OtherLanguagesUrl);
+ btnOpenDir.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(AppConfig.LangsDir);
MyToolTip.SetToolTip(btnOpenDir, AppString.Tip.OpenLanguagesDir);
}
@@ -237,7 +218,7 @@ public void LoadLanguages()
if(Directory.Exists(AppConfig.LangsDir))
{
languages.Clear();
- foreach(string fileName in Directory.GetFiles(AppConfig.LangsDir,"*.ini"))
+ foreach(string fileName in Directory.GetFiles(AppConfig.LangsDir, "*.ini"))
{
languages.Add(Path.GetFileNameWithoutExtension(fileName));
IniReader reader = new IniReader(fileName);
@@ -264,7 +245,7 @@ private void ChangeLanguage()
else
{
AppConfig.Language = language;
- Application.Restart();
+ SingleInstance.Restart();
}
}
@@ -281,8 +262,8 @@ private int GetSelectIndex()
sealed class AppSettingBox : MyList
{
- private const string GITHUBRELEASES = "https://github.com/BluePointLilac/ContextMenuManager/releases";
- private const string GITEERELEASES = "https://gitee.com/BluePointLilac/ContextMenuManager/releases";
+ private const string GithubUrl = "https://github.com/BluePointLilac/ContextMenuManager/releases";
+ private const string GiteeUrl = "https://gitee.com/BluePointLilac/ContextMenuManager/releases";
public AppSettingBox()
{
@@ -292,16 +273,20 @@ public AppSettingBox()
mliUpdate.AddCtrs(new Control[] { lblGitee, lblGithub, lblUpdate });
mliProtect.AddCtr(chkProtect);
mliEngine.AddCtr(cmbEngine);
+ mliWinXSortable.AddCtr(chkWinXSortable);
+ mliShowFilePath.AddCtr(chkShowFilePath);
+ mliOpenMoreRegedit.AddCtr(chkOpenMoreRegedit);
+ MyToolTip.SetToolTip(cmbConfigDir, AppString.Tip.ConfigPath);
MyToolTip.SetToolTip(btnConfigDir, AppString.Other.OpenConfigDir);
MyToolTip.SetToolTip(btnBackupDir, AppString.Other.OpenBackupDir);
MyToolTip.SetToolTip(lblUpdate, AppString.Tip.CheckUpdate + Environment.NewLine
+ AppString.Tip.LastCheckUpdateTime + AppConfig.LastCheckUpdateTime.ToLongDateString());
- cmbConfigDir.Items.AddRange(new[] { AppString.Other.SaveToAppData, AppString.Other.SaveToAppDir });
+ cmbConfigDir.Items.AddRange(new[] { AppString.Other.AppDataDir, AppString.Other.AppDir });
cmbEngine.Items.AddRange(new[] { "Baidu", "Bing", "Google", "DogeDoge", "Sogou", "360", AppString.Other.CustomEngine });
- btnConfigDir.MouseDown += (sender, e) => Process.Start(AppConfig.ConfigDir);
- btnBackupDir.MouseDown += (sender, e) => Process.Start(AppConfig.BackupDir);
- lblGithub.Click += (sender, e) => Process.Start(GITHUBRELEASES);
- lblGitee.Click += (sender, e) => Process.Start(GITEERELEASES);
+ btnConfigDir.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(AppConfig.ConfigDir);
+ btnBackupDir.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(AppConfig.ConfigDir);
+ lblGithub.Click += (sender, e) => ExternalProgram.OpenUrl(GithubUrl);
+ lblGitee.Click += (sender, e) => ExternalProgram.OpenUrl(GiteeUrl);
lblUpdate.Click += (sender, e) =>
{
if(!Updater.CheckUpdate()) MessageBoxEx.Show(AppString.MessageBox.NoUpdateDetected);
@@ -318,7 +303,7 @@ public AppSettingBox()
{
DirectoryEx.CopyTo(AppConfig.ConfigDir, newPath);
Directory.Delete(AppConfig.ConfigDir, true);
- Application.Restart();
+ SingleInstance.Restart();
}
};
cmbEngine.SelectionChangeCommitted += (sender, e) =>
@@ -346,17 +331,32 @@ public AppSettingBox()
};
chkBackup.MouseDown += (sender, e) => AppConfig.AutoBackup = chkBackup.Checked = !chkBackup.Checked;
chkProtect.MouseDown += (sender, e) => AppConfig.ProtectOpenItem = chkProtect.Checked = !chkProtect.Checked;
+ chkWinXSortable.MouseDown += (sender, e) => AppConfig.WinXSortable = chkWinXSortable.Checked = !chkWinXSortable.Checked;
+ chkOpenMoreRegedit.MouseDown += (sender, e) => AppConfig.OpenMoreRegedit = chkOpenMoreRegedit.Checked = !chkOpenMoreRegedit.Checked;
+ chkShowFilePath.MouseDown += (sender, e) =>
+ {
+ chkShowFilePath.Checked = !chkShowFilePath.Checked;
+ if(MessageBoxEx.Show(AppString.MessageBox.RestartApp, MessageBoxButtons.OKCancel) == DialogResult.OK)
+ {
+ AppConfig.ShowFilePath = chkShowFilePath.Checked;
+ SingleInstance.Restart();
+ }
+ else
+ {
+ chkShowFilePath.Checked = !chkShowFilePath.Checked;
+ }
+ };
}
readonly MyListItem mliConfigDir = new MyListItem
{
- Text = AppString.Other.ConfigFile,
+ Text = AppString.Other.ConfigPath,
HasImage = false
};
readonly ComboBox cmbConfigDir = new ComboBox
{
DropDownStyle = ComboBoxStyle.DropDownList,
- Width = 160.DpiZoom()
+ Width = 120.DpiZoom()
};
readonly PictureButton btnConfigDir = new PictureButton(AppImage.Open);
@@ -410,15 +410,42 @@ public AppSettingBox()
readonly ComboBox cmbEngine = new ComboBox
{
DropDownStyle = ComboBoxStyle.DropDownList,
- Width = 100.DpiZoom()
+ Width = 120.DpiZoom()
};
+ readonly MyListItem mliWinXSortable = new MyListItem
+ {
+ Text = AppString.Item.WinXSortable,
+ Visible = WindowsOsVersion.ISAfterOrEqual8,
+ HasImage = false
+ };
+ readonly MyCheckBox chkWinXSortable = new MyCheckBox();
+
+ readonly MyListItem mliShowFilePath = new MyListItem
+ {
+ Text = AppString.Item.ShowFilePath,
+ HasImage = false
+ };
+ readonly MyCheckBox chkShowFilePath = new MyCheckBox();
+
+ readonly MyListItem mliOpenMoreRegedit = new MyListItem
+ {
+ Text = AppString.Item.OpenMoreRegedit,
+ HasImage = false
+ };
+ readonly MyCheckBox chkOpenMoreRegedit = new MyCheckBox();
+
public void LoadItems()
{
- this.AddItems(new[] { mliUpdate, mliConfigDir, mliBackup, mliProtect, mliEngine });
+ this.AddItems(new[] { mliUpdate, mliConfigDir, mliBackup, mliProtect,
+ mliEngine, mliWinXSortable, mliShowFilePath, mliOpenMoreRegedit });
cmbConfigDir.SelectedIndex = AppConfig.SaveToAppDir ? 1 : 0;
chkBackup.Checked = AppConfig.AutoBackup;
chkProtect.Checked = AppConfig.ProtectOpenItem;
+ chkWinXSortable.Checked = AppConfig.WinXSortable;
+ chkShowFilePath.Checked = AppConfig.ShowFilePath;
+ chkOpenMoreRegedit.Checked = AppConfig.OpenMoreRegedit;
+
string url = AppConfig.EngineUrl;
for(int i = 0; i <= AppConfig.EngineUrls.Length; i++)
{
diff --git a/ContextMenuManager/Controls/AddGuidDicDialog.cs b/ContextMenuManager/Controls/AddGuidDicDialog.cs
index dbe91e0..001f6eb 100644
--- a/ContextMenuManager/Controls/AddGuidDicDialog.cs
+++ b/ContextMenuManager/Controls/AddGuidDicDialog.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System;
using System.Drawing;
using System.Windows.Forms;
diff --git a/ContextMenuManager/Controls/CommandDialog.cs b/ContextMenuManager/Controls/CommandDialog.cs
deleted file mode 100644
index 86751db..0000000
--- a/ContextMenuManager/Controls/CommandDialog.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-
-namespace ContextMenuManager.Controls
-{
- sealed class CommandDialog : CommonDialog
- {
- public string Command { get; set; }
- public string Arguments { get; set; }
-
- public override void Reset() { }
-
- protected override bool RunDialog(IntPtr hwndOwner)
- {
- using(CommandForm frm = new CommandForm())
- {
- frm.Command = this.Command;
- frm.Arguments = this.Arguments;
- bool flag = frm.ShowDialog() == DialogResult.OK;
- if(flag)
- {
- this.Command = frm.Command;
- this.Arguments = frm.Arguments;
- }
- return flag;
- }
- }
-
- sealed class CommandForm : ResizbleForm
- {
- public CommandForm()
- {
- this.AcceptButton = btnOk;
- this.CancelButton = btnCancel;
- this.VerticalResizable = false;
- this.Font = SystemFonts.MessageBoxFont;
- this.Text = AppString.Menu.ChangeCommand;
- this.SizeGripStyle = SizeGripStyle.Hide;
- this.StartPosition = FormStartPosition.CenterParent;
- this.MaximizeBox = MinimizeBox = ShowIcon = ShowInTaskbar = false;
- InitializeComponents();
- }
-
- public string Command
- {
- get => txtCommand.Text;
- set => txtCommand.Text = value;
- }
-
- public string Arguments
- {
- get => txtArguments.Text;
- set => txtArguments.Text = value;
- }
-
- readonly Label lblCommand = new Label
- {
- Text = AppString.Dialog.ItemCommand,
- AutoSize = true
- };
- readonly Label lblArguments = new Label
- {
- Text = AppString.Dialog.CommandArguments,
- AutoSize = true
- };
- readonly TextBox txtCommand = new TextBox();
- readonly TextBox txtArguments = new TextBox();
- readonly Button btnOk = new Button
- {
- DialogResult = DialogResult.OK,
- Text = AppString.Dialog.Ok,
- AutoSize = true
- };
- readonly Button btnCancel = new Button
- {
- DialogResult = DialogResult.Cancel,
- Text = AppString.Dialog.Cancel,
- AutoSize = true
- };
-
- private void InitializeComponents()
- {
- this.Controls.AddRange(new Control[] { lblCommand, lblArguments, txtCommand, txtArguments, btnOk, btnCancel });
- int a = 20.DpiZoom();
- lblArguments.Left = lblCommand.Left = lblCommand.Top = txtCommand.Top = a;
- lblArguments.Top = txtArguments.Top = txtCommand.Bottom + a;
- btnOk.Top = btnCancel.Top = txtArguments.Bottom + a;
- int b = Math.Max(lblCommand.Width, lblArguments.Width) + 3 * a;
- this.ClientSize = new Size(250.DpiZoom() + b, btnOk.Bottom + a);
- btnOk.Anchor = btnCancel.Anchor = AnchorStyles.Right | AnchorStyles.Top;
- btnCancel.Left = this.ClientSize.Width - btnCancel.Width - a;
- btnOk.Left = btnCancel.Left - btnOk.Width - a;
- this.Resize += (sender, e) =>
- {
- txtArguments.Width = txtCommand.Width = this.ClientSize.Width - b;
- txtArguments.Left = txtCommand.Left = btnCancel.Right - txtCommand.Width;
- };
- this.OnResize(null);
- this.MinimumSize = this.Size;
- }
- }
- }
-
-}
diff --git a/ContextMenuManager/Controls/EnhanceMenusItem.cs b/ContextMenuManager/Controls/EnhanceMenusItem.cs
index e902ecb..a69674f 100644
--- a/ContextMenuManager/Controls/EnhanceMenusItem.cs
+++ b/ContextMenuManager/Controls/EnhanceMenusItem.cs
@@ -1,10 +1,12 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using System.Text;
using System.Xml;
namespace ContextMenuManager.Controls
@@ -63,8 +65,16 @@ private static void WriteAttributesValue(XmlNode valueXN, string regPath)
private static void WriteSubKeysValue(XmlElement keyXE, string regPath)
{
if(keyXE == null) return;
- string defaultValue = keyXE.GetAttribute("Default");
- if(!defaultValue.IsNullOrWhiteSpace()) Registry.SetValue(regPath, "", defaultValue);
+ string defaultValue = Environment.ExpandEnvironmentVariables(keyXE.GetAttribute("Default"));
+ if(!defaultValue.IsNullOrWhiteSpace())
+ {
+ Registry.SetValue(regPath, "", defaultValue);
+ }
+ else if(keyXE.Name == "Command")
+ {
+ //按照规则Command节点无默认值则创建文件
+ WriteCommandValue(keyXE, regPath);
+ }
WriteAttributesValue(keyXE.SelectSingleNode("Value"), regPath);
XmlNode subKeyXN = keyXE.SelectSingleNode("SubKey");
@@ -74,6 +84,50 @@ private static void WriteSubKeysValue(XmlElement keyXE, string regPath)
WriteSubKeysValue(xe, $@"{regPath}\{xe.Name}");
}
}
+
+ private static void WriteCommandValue(XmlElement cmdXE, string regPath)
+ {
+ XmlElement fnXE = (XmlElement)cmdXE.SelectSingleNode("FileName");
+ XmlElement argXE = (XmlElement)cmdXE.SelectSingleNode("Arguments");
+ XmlElement seXE = (XmlElement)cmdXE.SelectSingleNode("ShellExecute");
+
+ string command;
+ string fileName = fnXE?.InnerText.Trim();
+ string arguments = argXE?.InnerText.Trim();
+ if(string.IsNullOrEmpty(fileName)) fileName = CreateCommandFile(fnXE);
+ if(string.IsNullOrEmpty(arguments)) arguments = CreateCommandFile(argXE);
+ fileName = Environment.ExpandEnvironmentVariables(fileName);
+ arguments = Environment.ExpandEnvironmentVariables(arguments);
+ if(seXE != null)
+ {
+ string verb = seXE.HasAttribute("Verb") ? seXE.GetAttribute("Verb") : "open";
+ int windowStyle = seXE.HasAttribute("WindowStyle") ? Convert.ToInt32(seXE.GetAttribute("WindowStyle")) : 1;
+ string directory = Environment.ExpandEnvironmentVariables(seXE.GetAttribute("Directory"));
+ command = ShellExecuteDialog.GetCommand(fileName, arguments, verb, windowStyle, directory);
+ }
+ else
+ {
+ command = fileName;
+ if(arguments != string.Empty) command += $" {arguments}";
+ }
+ Registry.SetValue(regPath, "", command);
+ }
+
+ private static string CreateCommandFile(XmlElement xe)
+ {
+ if(xe == null) return string.Empty;
+ XmlElement cfXE = (XmlElement)xe.SelectSingleNode("CreateFile");
+ if(cfXE == null) return string.Empty;
+ string fileName = cfXE.GetAttribute("FileName");
+ string content = cfXE.GetAttribute("Content");
+ string extension = Path.GetExtension(fileName).ToLower();
+ string filePath = $@"{AppConfig.ProgramsDir}\{fileName}";
+ Encoding encoding = Encoding.Unicode;
+ if(extension == ".bat" || extension == ".cmd") encoding = Encoding.Default;
+ if(File.Exists(filePath)) File.Delete(filePath);
+ File.WriteAllText(filePath, content, encoding);
+ return filePath;
+ }
}
sealed class EnhanceShellExItem : MyListItem, IFoldSubItem, IChkVisibleItem
diff --git a/ContextMenuManager/Controls/EnhanceMenusList.cs b/ContextMenuManager/Controls/EnhanceMenusList.cs
index e57efc3..6b68d2d 100644
--- a/ContextMenuManager/Controls/EnhanceMenusList.cs
+++ b/ContextMenuManager/Controls/EnhanceMenusList.cs
@@ -1,10 +1,9 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using System;
using System.Drawing;
using System.IO;
-using System.Text;
using System.Xml;
namespace ContextMenuManager.Controls
@@ -17,71 +16,9 @@ public void LoadItems()
{
foreach(XmlNode xn in ReadXml().DocumentElement.ChildNodes)
{
- string path = null;
- string text = null;
- Image image = null;
- switch(xn.Name)
- {
- case "File":
- path = ShellList.MENUPATH_FILE;
- text = AppString.SideBar.File;
- image = AppImage.File;
- break;
- case "Folder":
- path = ShellList.MENUPATH_FOLDER;
- text = AppString.SideBar.Folder;
- image = AppImage.Folder;
- break;
- case "Directory":
- path = ShellList.MENUPATH_FOLDER;
- text = AppString.SideBar.Directory;
- image = AppImage.Directory;
- break;
- case "Background":
- path = ShellList.MENUPATH_BACKGROUND;
- text = AppString.SideBar.Background;
- image = AppImage.Background;
- break;
- case "Desktop":
- path = ShellList.MENUPATH_DESKTOP;
- //Vista没有桌面右键菜单的独立注册表项
- if(WindowsOsVersion.IsEqualVista) path = ShellList.MENUPATH_BACKGROUND;
- text = AppString.SideBar.Desktop;
- image = AppImage.Desktop;
- break;
- case "Drive":
- path = ShellList.MENUPATH_DRIVE;
- text = AppString.SideBar.Drive;
- image = AppImage.Drive;
- break;
- case "AllObjects":
- path = ShellList.MENUPATH_ALLOBJECTS;
- text = AppString.SideBar.AllObjects;
- image = AppImage.AllObjects;
- break;
- case "Computer":
- path = ShellList.MENUPATH_COMPUTER;
- text = AppString.SideBar.Computer;
- image = AppImage.Computer;
- break;
- case "RecycleBin":
- path = ShellList.MENUPATH_RECYCLEBIN;
- text = AppString.SideBar.RecycleBin;
- image = AppImage.RecycleBin;
- break;
- default:
- XmlElement xe = (XmlElement)xn;
- path = xe.GetAttribute("RegPath");
- text = ResourceString.GetDirectString(xe.GetAttribute("Text"));
- image = ResourceIcon.GetIcon(xe.GetAttribute("Icon"))?.ToBitmap() ?? AppImage.NotFound;
- break;
- }
- if(string.IsNullOrEmpty(path) || string.IsNullOrEmpty(text)) continue;
- GroupPathItem groupItem = new GroupPathItem(path, ObjectPath.PathType.Registry)
- {
- Image = image,
- Text = text,
- };
+
+ GroupPathItem groupItem = GetGroupPathItem(xn);
+ if(groupItem == null) continue;
this.AddItem(groupItem);
XmlElement shellXE = (XmlElement)xn.SelectSingleNode("Shell");
XmlElement shellExXE = (XmlElement)xn.SelectSingleNode("ShellEx");
@@ -94,21 +31,89 @@ public void LoadItems()
catch { }
}
+ private GroupPathItem GetGroupPathItem(XmlNode xn)
+ {
+ string path;
+ string text;
+ Image image;
+ switch(xn.Name)
+ {
+ case "File":
+ path = ShellList.MENUPATH_FILE;
+ text = AppString.SideBar.File;
+ image = AppImage.File;
+ break;
+ case "Folder":
+ path = ShellList.MENUPATH_FOLDER;
+ text = AppString.SideBar.Folder;
+ image = AppImage.Folder;
+ break;
+ case "Directory":
+ path = ShellList.MENUPATH_FOLDER;
+ text = AppString.SideBar.Directory;
+ image = AppImage.Directory;
+ break;
+ case "Background":
+ path = ShellList.MENUPATH_BACKGROUND;
+ text = AppString.SideBar.Background;
+ image = AppImage.Background;
+ break;
+ case "Desktop":
+ path = ShellList.MENUPATH_DESKTOP;
+ //Vista没有桌面右键菜单的独立注册表项
+ if(WindowsOsVersion.IsEqualVista) path = ShellList.MENUPATH_BACKGROUND;
+ text = AppString.SideBar.Desktop;
+ image = AppImage.Desktop;
+ break;
+ case "Drive":
+ path = ShellList.MENUPATH_DRIVE;
+ text = AppString.SideBar.Drive;
+ image = AppImage.Drive;
+ break;
+ case "AllObjects":
+ path = ShellList.MENUPATH_ALLOBJECTS;
+ text = AppString.SideBar.AllObjects;
+ image = AppImage.AllObjects;
+ break;
+ case "Computer":
+ path = ShellList.MENUPATH_COMPUTER;
+ text = AppString.SideBar.Computer;
+ image = AppImage.Computer;
+ break;
+ case "RecycleBin":
+ path = ShellList.MENUPATH_RECYCLEBIN;
+ text = AppString.SideBar.RecycleBin;
+ image = AppImage.RecycleBin;
+ break;
+ default:
+ XmlElement xe = (XmlElement)xn;
+ path = xe.GetAttribute("RegPath");
+ text = ResourceString.GetDirectString(xe.GetAttribute("Text"));
+ if(string.IsNullOrEmpty(path) || string.IsNullOrEmpty(text)) return null;
+ image = ResourceIcon.GetIcon(xe.GetAttribute("Icon"))?.ToBitmap() ?? AppImage.NotFound;
+ break;
+ }
+ GroupPathItem groupItem = new GroupPathItem(path, ObjectPath.PathType.Registry) { Image = image, Text = text };
+ return groupItem;
+ }
+
private XmlDocument ReadXml()
{
XmlDocument doc1 = new XmlDocument();
try
{
- //如果没有网络下载的,则将程序内置的写入
- if(!File.Exists(AppConfig.WebEnhanceMenusDic))
+ if(File.Exists(AppConfig.WebEnhanceMenusDic))
+ {
+ doc1.LoadXml(File.ReadAllText(AppConfig.WebEnhanceMenusDic, EncodingType.GetType(AppConfig.WebEnhanceMenusDic)));
+ }
+ else
{
- File.WriteAllText(AppConfig.WebEnhanceMenusDic, Properties.Resources.EnhanceMenusDic, Encoding.UTF8);
+ doc1.LoadXml(Properties.Resources.EnhanceMenusDic);
}
- doc1.Load(AppConfig.WebEnhanceMenusDic);
if(File.Exists(AppConfig.UserEnhanceMenusDic))
{
XmlDocument doc2 = new XmlDocument();
- doc2.Load(AppConfig.UserEnhanceMenusDic);
+ doc2.LoadXml(File.ReadAllText(AppConfig.UserEnhanceMenusDic, EncodingType.GetType(AppConfig.UserEnhanceMenusDic)));
foreach(XmlNode xn in doc2.DocumentElement.ChildNodes)
{
XmlNode node = doc1.ImportNode(xn, true);
@@ -122,13 +127,13 @@ private XmlDocument ReadXml()
private void LoadShellItems(XmlElement shellXE, GroupPathItem groupItem)
{
- foreach(XmlElement itemXE in shellXE.GetElementsByTagName("Item"))
+ foreach(XmlElement itemXE in shellXE.SelectNodes("Item"))
{
if(!JudgeOSVersion(itemXE)) continue;
+ if(!FileExists(itemXE)) continue;
XmlElement szXE = (XmlElement)itemXE.SelectSingleNode("Value/REG_SZ");
string keyName = itemXE.GetAttribute("KeyName");
if(keyName.IsNullOrWhiteSpace()) continue;
- string regPath = $@"{groupItem.TargetPath}\shell\{keyName}";
EnhanceShellItem item = new EnhanceShellItem()
{
RegPath = $@"{groupItem.TargetPath}\shell\{keyName}",
@@ -140,18 +145,40 @@ private void LoadShellItems(XmlElement shellXE, GroupPathItem groupItem)
item.Text = 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;
+ else
+ {
+ XmlElement cmdXE = (XmlElement)itemXE.SelectSingleNode("SubKey/Command");
+ if(cmdXE != null)
+ {
+ Icon icon = null;
+ if(cmdXE.HasAttribute("Default"))
+ {
+ string filePath = ObjectPath.ExtractFilePath(cmdXE.GetAttribute("Default"));
+ icon = ResourceIcon.GetIcon(filePath);
+ }
+ item.Image = icon?.ToBitmap();
+ icon?.Dispose();
+ }
+ }
}
if(item.Image == null) item.Image = AppImage.NotFound;
if(item.Text.IsNullOrWhiteSpace()) item.Text = keyName;
item.ChkVisible.Checked = item.ItemVisible;
- MyToolTip.SetToolTip(item.ChkVisible, itemXE.GetAttribute("Tip"));
+ string tip = itemXE.GetAttribute("Tip");
+ if(itemXE.GetElementsByTagName("CreateFile").Count > 0)
+ {
+ if(!tip.IsNullOrWhiteSpace()) tip += "\n";
+ tip += AppString.Tip.CommandFiles;
+ if(System.Diagnostics.Debugger.IsAttached) item.ChkVisible.Checked = item.ItemVisible = true;
+ }
+ MyToolTip.SetToolTip(item.ChkVisible, tip);
this.AddItem(item);
}
}
private void LoadShellExItems(XmlElement shellExXE, GroupPathItem groupItem)
{
- foreach(XmlElement itemXE in shellExXE.GetElementsByTagName("Item"))
+ foreach(XmlElement itemXE in shellExXE.SelectNodes("Item"))
{
if(!JudgeOSVersion(itemXE)) continue;
if(!GuidEx.TryParse(itemXE.GetAttribute("Guid"), out Guid guid)) continue;
@@ -174,6 +201,7 @@ private void LoadShellExItems(XmlElement shellExXE, GroupPathItem groupItem)
public static bool JudgeOSVersion(XmlElement itemXE)
{
+ if(System.Diagnostics.Debugger.IsAttached) return true;//调试状态
bool JudgeOne(XmlElement osXE)
{
Version ver = new Version(osXE.InnerText);
@@ -197,11 +225,22 @@ bool JudgeOne(XmlElement osXE)
}
}
- foreach(XmlElement osXE in itemXE.GetElementsByTagName("OSVersion"))
+ foreach(XmlElement osXE in itemXE.SelectNodes("OSVersion"))
{
if(!JudgeOne(osXE)) return false;
}
return true;
}
+
+ private static bool FileExists(XmlElement itemXE)
+ {
+ if(System.Diagnostics.Debugger.IsAttached) return true;//调试状态
+ foreach(XmlElement feXE in itemXE.SelectNodes("FileExists"))
+ {
+ string path = Environment.ExpandEnvironmentVariables(feXE.InnerText);
+ if(!File.Exists(path)) return false;
+ }
+ return true;
+ }
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/ExplorerRestarter.cs b/ContextMenuManager/Controls/ExplorerRestarter.cs
index d94e048..0efaf4a 100644
--- a/ContextMenuManager/Controls/ExplorerRestarter.cs
+++ b/ContextMenuManager/Controls/ExplorerRestarter.cs
@@ -1,7 +1,6 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System;
-using System.Diagnostics;
using System.Windows.Forms;
namespace ContextMenuManager.Controls
@@ -17,8 +16,8 @@ public ExplorerRestarter()
MyToolTip.SetToolTip(BtnRestart, AppString.Tip.RestartExplorer);
this.AddCtr(BtnRestart);
this.CanMoveForm();
- BtnRestart.MouseDown += (sender, e) => { Explorer.ReStart(); this.Visible = false; };
- RestartHandler += (sender, e) => this.Visible = NeedRestart;
+ BtnRestart.MouseDown += (sender, e) => { ExternalProgram.RestartExplorer(); this.Visible = false; };
+ ShowHandler += (sender, e) => this.Visible = true;
}
protected override void OnVisibleChanged(EventArgs e)
@@ -29,38 +28,8 @@ protected override void OnVisibleChanged(EventArgs e)
private readonly PictureButton BtnRestart = new PictureButton(AppImage.RestartExplorer);
- private static event EventHandler RestartHandler;
+ private static event EventHandler ShowHandler;
- private static bool needRestart;
- public static bool NeedRestart
- {
- get => needRestart;
- set
- {
- needRestart = value;
- RestartHandler?.Invoke(null, null);
- }
- }
- }
-
- public static class Explorer
- {
- public static void ReStart()
- {
- using(Process process = new Process())
- {
- process.StartInfo = new ProcessStartInfo
- {
- FileName = "cmd.exe",
- Arguments = "/c taskkill -f -im explorer.exe",
- WindowStyle = ProcessWindowStyle.Hidden,
- UseShellExecute = true
- };
- process.Start();
- process.WaitForExit();
- process.StartInfo.Arguments = "/c explorer";
- process.Start();
- }
- }
+ public new static void Show() { ShowHandler?.Invoke(null, null); }
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/FileExtensionDialog.cs b/ContextMenuManager/Controls/FileExtensionDialog.cs
deleted file mode 100644
index 4396129..0000000
--- a/ContextMenuManager/Controls/FileExtensionDialog.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-using BulePointLilac.Methods;
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-
-namespace ContextMenuManager.Controls
-{
- sealed class FileExtensionDialog : CommonDialog
- {
- public string Extension { get; private set; }
- public override void Reset() { }
-
- protected override bool RunDialog(IntPtr hwndOwner)
- {
- using(FileExtensionForm frm = new FileExtensionForm())
- {
- bool flag = frm.ShowDialog() == DialogResult.OK;
- if(flag) this.Extension = frm.Extension;
- return flag;
- }
- }
-
- sealed class FileExtensionForm : Form
- {
- public FileExtensionForm()
- {
- this.AcceptButton = btnOk;
- this.CancelButton = btnCancel;
- this.Text = AppString.Dialog.SelectExtension;
- this.Font = SystemFonts.MenuFont;
- this.ShowIcon = this.ShowInTaskbar = false;
- this.MaximizeBox = this.MinimizeBox = false;
- this.FormBorderStyle = FormBorderStyle.FixedSingle;
- this.StartPosition = FormStartPosition.CenterParent;
- InitializeComponents();
- LoadExtensions();
- btnOk.Click += (sender, e) =>
- {
- int index = cmbExtension.Text.IndexOf('.');
- if(index >= 0) this.Extension = cmbExtension.Text.Substring(index);
- else this.Extension = $".{cmbExtension.Text}";
- };
- }
-
- public string Extension { get; private set; }
-
- readonly ComboBox cmbExtension = new ComboBox
- {
- AutoCompleteMode = AutoCompleteMode.SuggestAppend,
- AutoCompleteSource = AutoCompleteSource.ListItems,
- DropDownHeight = 294.DpiZoom(),
- ImeMode = ImeMode.Disable
- };
- readonly Button btnOk = new Button
- {
- DialogResult = DialogResult.OK,
- Text = AppString.Dialog.Ok,
- AutoSize = true
- };
- readonly Button btnCancel = new Button
- {
- DialogResult = DialogResult.Cancel,
- Text = AppString.Dialog.Cancel,
- AutoSize = true
- };
-
- private void InitializeComponents()
- {
- this.Controls.AddRange(new Control[] { cmbExtension, btnOk, btnCancel });
- int a = 20.DpiZoom();
- cmbExtension.Left = a;
- cmbExtension.Width = 85.DpiZoom();
- cmbExtension.Top = btnOk.Top = btnCancel.Top = a;
- btnOk.Left = cmbExtension.Right + a;
- btnCancel.Left = btnOk.Right + a;
- this.ClientSize = new Size(btnCancel.Right + a, btnCancel.Bottom + a);
- }
-
- private void LoadExtensions()
- {
- foreach(string extension in Microsoft.Win32.Registry.ClassesRoot.GetSubKeyNames())
- {
- if(!extension.StartsWith(".")) continue;
- cmbExtension.Items.Add(extension.Substring(1));
- }
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/GuidBlockedItem.cs b/ContextMenuManager/Controls/GuidBlockedItem.cs
index 2c94a6f..66e06e5 100644
--- a/ContextMenuManager/Controls/GuidBlockedItem.cs
+++ b/ContextMenuManager/Controls/GuidBlockedItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using System;
using System.Windows.Forms;
@@ -63,7 +63,7 @@ private void InitializeComponents()
public void DeleteMe()
{
Array.ForEach(BlockedPaths, path => { RegistryEx.DeleteValue(path, this.Value); });
- if(!this.Guid.Equals(Guid.Empty)) ExplorerRestarter.NeedRestart = true;
+ if(!this.Guid.Equals(Guid.Empty)) ExplorerRestarter.Show();
this.Dispose();
}
}
diff --git a/ContextMenuManager/Controls/GuidBlockedList.cs b/ContextMenuManager/Controls/GuidBlockedList.cs
index 006d881..e846c7a 100644
--- a/ContextMenuManager/Controls/GuidBlockedList.cs
+++ b/ContextMenuManager/Controls/GuidBlockedList.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
@@ -32,17 +32,9 @@ private void LoadBlockedItems()
private void AddNewItem()
{
- MyListItem newItem = new MyListItem
- {
- Text = AppString.Item.AddGuidBlockedItem,
- Image = AppImage.AddNewItem
- };
- PictureButton btnAddNewItem = new PictureButton(AppImage.AddNewItem);
- newItem.AddCtr(btnAddNewItem);
- newItem.SetNoClickEvent();
+ NewItem newItem = new NewItem(AppString.Item.AddGuidBlockedItem);
this.AddItem(newItem);
- MyToolTip.SetToolTip(btnAddNewItem, newItem.Text);
- btnAddNewItem.MouseDown += (sender, e) =>
+ newItem.AddNewItem += (sender, e) =>
{
using(InputDialog dlg = new InputDialog { Title = AppString.Dialog.InputGuid })
{
@@ -63,7 +55,7 @@ private void AddNewItem()
}
}
this.InsertItem(new GuidBlockedItem(dlg.Text), 1);
- ExplorerRestarter.NeedRestart = true;
+ ExplorerRestarter.Show();
}
else MessageBoxEx.Show(AppString.MessageBox.MalformedGuid);
}
diff --git a/ContextMenuManager/Controls/IEItem.cs b/ContextMenuManager/Controls/IEItem.cs
new file mode 100644
index 0000000..8baf9f5
--- /dev/null
+++ b/ContextMenuManager/Controls/IEItem.cs
@@ -0,0 +1,122 @@
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
+using ContextMenuManager.Controls.Interfaces;
+using Microsoft.Win32;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ContextMenuManager.Controls
+{
+ sealed class IEItem : MyListItem, ITsiRegPathItem, ITsiFilePathItem, ITsiRegDeleteItem, ITsiCommandItem,
+ ITsiWebSearchItem, ITsiTextItem, ITsiRegExportItem, IBtnShowMenuItem, IChkVisibleItem
+ {
+ public static readonly string[] MeParts = { "MenuExt", "-MenuExt" };
+
+ public IEItem(string regPath)
+ {
+ InitializeComponents();
+ this.RegPath = regPath;
+ }
+
+ private string regPath;
+ public string RegPath
+ {
+ get => regPath;
+ set
+ {
+ regPath = value;
+ this.Text = this.ItemText;
+ this.Image = this.ItemImage;
+ ChkVisible.Checked = this.ItemVisible;
+ }
+ }
+ public string ValueName => null;
+ private string KeyName => RegistryEx.GetKeyName(RegPath);
+ private string BackupPath => $@"{IEList.IEPath}\{(ItemVisible ? MeParts[1] : MeParts[0])}\{KeyName}";
+ private string MeKeyName => RegistryEx.GetKeyName(RegistryEx.GetParentPath(RegPath));
+
+ public string ItemText
+ {
+ get => RegistryEx.GetKeyName(RegPath);
+ set
+ {
+ string newPath = $@"{RegistryEx.GetParentPath(RegPath)}\{value.Replace("\\", "")}";
+ string defaultValue = Registry.GetValue(newPath, "", null)?.ToString();
+ if(!defaultValue.IsNullOrWhiteSpace())
+ {
+ MessageBoxEx.Show(AppString.MessageBox.HasBeenAdded);
+ }
+ else
+ {
+ RegistryEx.MoveTo(RegPath, newPath);
+ RegPath = newPath;
+ }
+ }
+ }
+
+ public bool ItemVisible
+ {
+ get => MeKeyName.Equals(MeParts[0], StringComparison.OrdinalIgnoreCase);
+ set
+ {
+ RegistryEx.MoveTo(RegPath, BackupPath);
+ RegPath = BackupPath;
+ }
+ }
+
+ public string ItemCommand
+ {
+ get => Registry.GetValue(RegPath, "", null)?.ToString();
+ set
+ {
+ Registry.SetValue(RegPath, "", value);
+ this.Image = this.ItemImage;
+ }
+ }
+
+ public string SearchText => $@"{AppString.SideBar.IEMenu} {Text}";
+ public string ItemFilePath => ObjectPath.ExtractFilePath(ItemCommand);
+ private Icon ItemIcon => ResourceIcon.GetIcon(ItemFilePath) ?? ResourceIcon.GetExtensionIcon(ItemFilePath);
+ private Image ItemImage => ItemIcon?.ToBitmap() ?? AppImage.NotFound;
+
+ public MenuButton BtnShowMenu { get; set; }
+ public VisibleCheckBox ChkVisible { get; set; }
+ public WebSearchMenuItem TsiSearch { get; set; }
+ public ChangeTextMenuItem TsiChangeText { get; set; }
+ public ChangeCommandMenuItem TsiChangeCommand { get; set; }
+ public FileLocationMenuItem TsiFileLocation { get; set; }
+ public FilePropertiesMenuItem TsiFileProperties { get; set; }
+ public RegLocationMenuItem TsiRegLocation { get; set; }
+ public RegExportMenuItem TsiRegExport { get; set; }
+ public DeleteMeMenuItem TsiDeleteMe { get; set; }
+ readonly ToolStripMenuItem TsiDetails = new ToolStripMenuItem(AppString.Menu.Details);
+
+ private void InitializeComponents()
+ {
+ BtnShowMenu = new MenuButton(this);
+ ChkVisible = new VisibleCheckBox(this);
+ TsiChangeText = new ChangeTextMenuItem(this);
+ TsiChangeCommand = new ChangeCommandMenuItem(this);
+ TsiSearch = new WebSearchMenuItem(this);
+ TsiFileLocation = new FileLocationMenuItem(this);
+ TsiFileProperties = new FilePropertiesMenuItem(this);
+ TsiRegLocation = new RegLocationMenuItem(this);
+ TsiRegExport = new RegExportMenuItem(this);
+ TsiDeleteMe = new DeleteMeMenuItem(this);
+
+ ContextMenuStrip.Items.AddRange(new ToolStripItem[] { TsiChangeText,
+ new ToolStripSeparator(), TsiDetails, new ToolStripSeparator(), TsiDeleteMe });
+
+ TsiDetails.DropDownItems.AddRange(new ToolStripItem[] { TsiSearch, new ToolStripSeparator(),
+ TsiChangeCommand, TsiFileProperties, TsiFileLocation, TsiRegLocation, TsiRegExport});
+ }
+
+ public void DeleteMe()
+ {
+ RegistryEx.DeleteKeyTree(this.RegPath);
+ RegistryEx.DeleteKeyTree(this.BackupPath);
+ this.Dispose();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/IEList.cs b/ContextMenuManager/Controls/IEList.cs
new file mode 100644
index 0000000..9cf269a
--- /dev/null
+++ b/ContextMenuManager/Controls/IEList.cs
@@ -0,0 +1,63 @@
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
+using Microsoft.Win32;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+
+namespace ContextMenuManager.Controls
+{
+ sealed class IEList : MyList
+ {
+ public const string IEPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer";
+
+ public void LoadItems()
+ {
+ AddNewItem();
+ LoadIEItems();
+ }
+
+ private void LoadIEItems()
+ {
+ List names = new List();
+ using(RegistryKey ieKey = RegistryEx.GetRegistryKey(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()))
+ {
+ this.AddItem(new IEItem(key.Name));
+ names.Add(keyName);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void AddNewItem()
+ {
+ NewItem newItem = new NewItem();
+ this.AddItem(newItem);
+ newItem.AddNewItem += (sender, e) =>
+ {
+ using(NewIEDialog dlg = new NewIEDialog())
+ {
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ this.InsertItem(new IEItem(dlg.RegPath), 1);
+ }
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/Interfaces/IBtnDeleteItem.cs b/ContextMenuManager/Controls/Interfaces/IBtnDeleteItem.cs
index 1d5792a..2fb5141 100644
--- a/ContextMenuManager/Controls/Interfaces/IBtnDeleteItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/IBtnDeleteItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System.Windows.Forms;
namespace ContextMenuManager.Controls.Interfaces
diff --git a/ContextMenuManager/Controls/Interfaces/IBtnMoveUpDownItem.cs b/ContextMenuManager/Controls/Interfaces/IBtnMoveUpDownItem.cs
index 39e6f55..6e57319 100644
--- a/ContextMenuManager/Controls/Interfaces/IBtnMoveUpDownItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/IBtnMoveUpDownItem.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Controls;
+using BluePointLilac.Controls;
namespace ContextMenuManager.Controls.Interfaces
{
diff --git a/ContextMenuManager/Controls/Interfaces/IBtnOpenPathItem.cs b/ContextMenuManager/Controls/Interfaces/IBtnOpenPathItem.cs
index 54990bc..0a2637f 100644
--- a/ContextMenuManager/Controls/Interfaces/IBtnOpenPathItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/IBtnOpenPathItem.cs
@@ -1,5 +1,6 @@
-using BulePointLilac.Controls;
-using static BulePointLilac.Methods.ObjectPath;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
+using static BluePointLilac.Methods.ObjectPath;
namespace ContextMenuManager.Controls.Interfaces
{
@@ -15,7 +16,19 @@ sealed class ObjectPathButton : PictureButton
public ObjectPathButton(IBtnOpenPathItem item) : base(AppImage.Open)
{
((MyListItem)item).AddCtr(this);
- this.MouseDown += (sender, e) => ShowPath(item.TargetPath, item.PathType);
+ this.MouseDown += (sender, e) =>
+ {
+ switch(item.PathType)
+ {
+ case PathType.File:
+ case PathType.Directory:
+ ExternalProgram.JumpExplorer(item.TargetPath);
+ break;
+ case PathType.Registry:
+ ExternalProgram.JumpRegEdit(item.TargetPath, null, AppConfig.OpenMoreRegedit);
+ break;
+ }
+ };
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/Interfaces/IBtnShowMenuItem.cs b/ContextMenuManager/Controls/Interfaces/IBtnShowMenuItem.cs
index 52f0a32..73c408d 100644
--- a/ContextMenuManager/Controls/Interfaces/IBtnShowMenuItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/IBtnShowMenuItem.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Controls;
+using BluePointLilac.Controls;
using System.Windows.Forms;
namespace ContextMenuManager.Controls.Interfaces
diff --git a/ContextMenuManager/Controls/Interfaces/IChkVisibleItem.cs b/ContextMenuManager/Controls/Interfaces/IChkVisibleItem.cs
index 516b3e2..8d51d7e 100644
--- a/ContextMenuManager/Controls/Interfaces/IChkVisibleItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/IChkVisibleItem.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Controls;
+using BluePointLilac.Controls;
using System.Windows.Forms;
namespace ContextMenuManager.Controls.Interfaces
diff --git a/ContextMenuManager/Controls/Interfaces/IFoldGroupItem.cs b/ContextMenuManager/Controls/Interfaces/IFoldGroupItem.cs
index c8ea150..5ee460a 100644
--- a/ContextMenuManager/Controls/Interfaces/IFoldGroupItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/IFoldGroupItem.cs
@@ -1,9 +1,10 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
+using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
-using static BulePointLilac.Methods.ObjectPath;
+using static BluePointLilac.Methods.ObjectPath;
namespace ContextMenuManager.Controls.Interfaces
{
@@ -11,6 +12,7 @@ interface IFoldGroupItem
{
FoldButton BtnFold { get; set; }
bool IsFold { get; set; }
+ string Text { get; set; }
}
interface IFoldSubItem
@@ -30,10 +32,12 @@ public bool IsFold
this.BaseImage = ReplaceImage(value);
Control list = ((MyListItem)FoldGroup).Parent;
if(list == null) return;
+ list.SuspendLayout();
foreach(Control ctr in list.Controls)
{
if(ctr is IFoldSubItem item && item.FoldGroupItem == FoldGroup) ctr.Visible = !value;
}
+ list.ResumeLayout();
}
}
@@ -53,7 +57,7 @@ public FoldButton(IFoldGroupItem owner, bool fold = false) : base(ReplaceImage(f
}
}
- sealed class GroupPathItem : MyListItem, IFoldGroupItem, IBtnOpenPathItem
+ class GroupPathItem : MyListItem, IFoldGroupItem, IBtnOpenPathItem
{
public bool IsFold
{
@@ -70,6 +74,10 @@ public GroupPathItem(string targetPath, PathType pathType)
BtnFold = new FoldButton(this);
BtnOpenPath = new ObjectPathButton(this);
this.Font = new Font(base.Font, FontStyle.Bold);
+ if(pathType == PathType.File || pathType == PathType.Directory)
+ {
+ targetPath = Environment.ExpandEnvironmentVariables(targetPath);
+ }
this.TargetPath = targetPath;
this.PathType = pathType;
string tip = null;
@@ -90,7 +98,6 @@ public GroupPathItem(string targetPath, PathType pathType)
break;
}
MyToolTip.SetToolTip(BtnOpenPath, tip);
- this.SetNoClickEvent();
}
public void HideWhenNoSubItem()
@@ -102,5 +109,11 @@ public void HideWhenNoSubItem()
}
if(count == 0) this.Visible = false;
}
+
+ protected override void OnDoubleClick(EventArgs e)
+ {
+ base.OnDoubleClick(e);
+ IsFold = !IsFold;
+ }
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiAdministratorItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiAdministratorItem.cs
new file mode 100644
index 0000000..7a47b78
--- /dev/null
+++ b/ContextMenuManager/Controls/Interfaces/ITsiAdministratorItem.cs
@@ -0,0 +1,46 @@
+using BluePointLilac.Methods;
+using System.IO;
+using System.Windows.Forms;
+
+namespace ContextMenuManager.Controls.Interfaces
+{
+ interface ITsiAdministratorItem
+ {
+ ContextMenuStrip ContextMenuStrip { get; set; }
+ RunAsAdministratorItem TsiAdministrator { get; set; }
+ WshShortcut Shortcut { get; }
+ }
+
+ sealed class RunAsAdministratorItem : ToolStripMenuItem
+ {
+ public RunAsAdministratorItem(ITsiAdministratorItem item) : base(AppString.Menu.RunAsAdministrator)
+ {
+ item.ContextMenuStrip.Opening += (sender, e) =>
+ {
+ if(item.Shortcut == null)
+ {
+ this.Enabled = false;
+ return;
+ }
+ string filePath = item.Shortcut.TargetPath;
+ string extension = Path.GetExtension(filePath)?.ToLower();
+ switch(extension)
+ {
+ case ".exe":
+ case ".bat":
+ case ".cmd":
+ this.Enabled = true;
+ break;
+ default:
+ this.Enabled = false;
+ break;
+ }
+ this.Checked = item.Shortcut.RunAsAdministrator;
+ };
+ this.Click += (sender, e) =>
+ {
+ item.Shortcut.RunAsAdministrator = !this.Checked;
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiCommandItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiCommandItem.cs
index dbfc3ec..503fe88 100644
--- a/ContextMenuManager/Controls/Interfaces/ITsiCommandItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/ITsiCommandItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System.Windows.Forms;
namespace ContextMenuManager.Controls.Interfaces
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiDeleteItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiDeleteItem.cs
index f6c9ef7..e824455 100644
--- a/ContextMenuManager/Controls/Interfaces/ITsiDeleteItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/ITsiDeleteItem.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.IO;
using System.Windows.Forms;
@@ -13,7 +13,7 @@ interface ITsiDeleteItem
interface ITsiRegDeleteItem : ITsiDeleteItem
{
- string ItemText { get; }
+ string Text { get; }
string RegPath { get; }
}
@@ -23,20 +23,19 @@ public DeleteMeMenuItem(ITsiDeleteItem item) : base(AppString.Menu.Delete)
{
this.Click += (sender, e) =>
{
- if(MessageBoxEx.Show(AppString.MessageBox.ConfirmDeletePermanently,
- MessageBoxButtons.YesNo) == DialogResult.Yes)
+ if(item is ITsiRegDeleteItem regItem && AppConfig.AutoBackup)
{
- if(item is ITsiRegDeleteItem regItem && AppConfig.AutoBackup)
- {
- string date = DateTime.Today.ToString("yyyy-MM-dd");
- string fileName = ObjectPath.RemoveIllegalChars(regItem.ItemText);
- string filePath = $@"{AppConfig.BackupDir}\{date}\{fileName}.reg";
- filePath = ObjectPath.GetNewPathWithIndex(filePath, ObjectPath.PathType.File);
- Directory.CreateDirectory(Path.GetDirectoryName(filePath));
- RegistryEx.Export(regItem.RegPath, filePath);
- }
- item.DeleteMe();
+ if(MessageBoxEx.Show(AppString.MessageBox.DeleteButCanRestore,
+ MessageBoxButtons.YesNo) != DialogResult.Yes) return;
+ string date = DateTime.Today.ToString("yyyy-MM-dd");
+ string time = DateTime.Now.ToString("HH.mm.ss");
+ string filePath = $@"{AppConfig.BackupDir}\{date}\{regItem.Text}-{time}.reg";
+ Directory.CreateDirectory(Path.GetDirectoryName(filePath));
+ RegistryEx.Export(regItem.RegPath, filePath);
}
+ else if(MessageBoxEx.Show(AppString.MessageBox.ConfirmDeletePermanently,
+ MessageBoxButtons.YesNo) != DialogResult.Yes) return;
+ item.DeleteMe();
};
}
}
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiFilePathItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiFilePathItem.cs
index c5e89ff..fbf0c0b 100644
--- a/ContextMenuManager/Controls/Interfaces/ITsiFilePathItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/ITsiFilePathItem.cs
@@ -1,7 +1,6 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System.IO;
using System.Windows.Forms;
-using static BulePointLilac.Methods.ObjectPath;
namespace ContextMenuManager.Controls.Interfaces
{
@@ -17,15 +16,9 @@ sealed class FileLocationMenuItem : ToolStripMenuItem
{
public FileLocationMenuItem(ITsiFilePathItem item) : base(AppString.Menu.FileLocation)
{
- bool FileExists() => File.Exists(item.ItemFilePath);
- bool DirExists() => Directory.Exists(item.ItemFilePath);
- item.ContextMenuStrip.Opening += (sender, e)
- => this.Visible = FileExists() || DirExists();
- this.Click += (sender, e) =>
- {
- if(FileExists()) ShowPath(item.ItemFilePath, PathType.File);
- else if(DirExists()) ShowPath(item.ItemFilePath, PathType.Directory);
- };
+ item.ContextMenuStrip.Opening += (sender, e) =>
+ this.Visible = File.Exists(item.ItemFilePath) || Directory.Exists(item.ItemFilePath);
+ this.Click += (sender, e) => ExternalProgram.JumpExplorer(item.ItemFilePath);
}
}
@@ -35,7 +28,7 @@ public FilePropertiesMenuItem(ITsiFilePathItem item) : base(AppString.Menu.FileP
{
item.ContextMenuStrip.Opening += (sender, e)
=> this.Visible = File.Exists(item.ItemFilePath) || Directory.Exists(item.ItemFilePath);
- this.Click += (sender, e) => PropertiesDialog.Show(item.ItemFilePath);
+ this.Click += (sender, e) => ExternalProgram.ShowPropertiesDialog(item.ItemFilePath);
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiIconItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiIconItem.cs
index 93ba40d..651b478 100644
--- a/ContextMenuManager/Controls/Interfaces/ITsiIconItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/ITsiIconItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System.Drawing;
using System.Windows.Forms;
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiRegExportItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiRegExportItem.cs
index 64484a6..d8961bc 100644
--- a/ContextMenuManager/Controls/Interfaces/ITsiRegExportItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/ITsiRegExportItem.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.IO;
using System.Windows.Forms;
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiRegPathItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiRegPathItem.cs
index c969cca..01bd228 100644
--- a/ContextMenuManager/Controls/Interfaces/ITsiRegPathItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/ITsiRegPathItem.cs
@@ -1,22 +1,21 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System.Windows.Forms;
-using static BulePointLilac.Methods.ObjectPath;
namespace ContextMenuManager.Controls.Interfaces
{
interface ITsiRegPathItem
{
- string RegPath { get; set; }
+ string RegPath { get; }
+ string ValueName { get; }
ContextMenuStrip ContextMenuStrip { get; set; }
RegLocationMenuItem TsiRegLocation { get; set; }
}
sealed class RegLocationMenuItem : ToolStripMenuItem
{
-
public RegLocationMenuItem(ITsiRegPathItem item) : base(AppString.Menu.RegistryLocation)
{
- this.Click += (sender, e) => ShowPath(item.RegPath, PathType.Registry);
+ this.Click += (sender, e) => ExternalProgram.JumpRegEdit(item.RegPath, item.ValueName, AppConfig.OpenMoreRegedit);
item.ContextMenuStrip.Opening += (sender, e) =>
{
using(var key = RegistryEx.GetRegistryKey(item.RegPath))
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiShortcutCommandItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiShortcutCommandItem.cs
new file mode 100644
index 0000000..6957951
--- /dev/null
+++ b/ContextMenuManager/Controls/Interfaces/ITsiShortcutCommandItem.cs
@@ -0,0 +1,138 @@
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ContextMenuManager.Controls.Interfaces
+{
+ interface ITsiShortcutCommandItem
+ {
+ WshShortcut Shortcut { get; }
+ ShortcutCommandMenuItem TsiChangeCommand { get; set; }
+ ContextMenuStrip ContextMenuStrip { get; set; }
+ }
+
+ sealed class ShortcutCommandMenuItem : ToolStripMenuItem
+ {
+ public ShortcutCommandMenuItem(ITsiShortcutCommandItem item) : base(AppString.Menu.ChangeCommand)
+ {
+ item.ContextMenuStrip.Opening += (sender, e) =>
+ {
+ this.Visible = !string.IsNullOrEmpty(item.Shortcut?.TargetPath);
+ };
+ }
+
+ public bool ChangeCommand(WshShortcut shortcut)
+ {
+ using(CommandDialog dlg = new CommandDialog())
+ {
+ dlg.Command = shortcut.TargetPath;
+ dlg.Arguments = shortcut.Arguments;
+ if(dlg.ShowDialog() != DialogResult.OK) return false;
+ shortcut.TargetPath = dlg.Command;
+ shortcut.Arguments = dlg.Arguments;
+ shortcut.Save();
+ return true;
+ }
+ }
+
+ sealed class CommandDialog : CommonDialog
+ {
+ public string Command { get; set; }
+ public string Arguments { get; set; }
+
+ public override void Reset() { }
+
+ protected override bool RunDialog(IntPtr hwndOwner)
+ {
+ using(CommandForm frm = new CommandForm())
+ {
+ frm.Command = this.Command;
+ frm.Arguments = this.Arguments;
+ bool flag = frm.ShowDialog() == DialogResult.OK;
+ if(flag)
+ {
+ this.Command = frm.Command;
+ this.Arguments = frm.Arguments;
+ }
+ return flag;
+ }
+ }
+
+ sealed class CommandForm : ResizbleForm
+ {
+ public CommandForm()
+ {
+ this.AcceptButton = btnOk;
+ this.CancelButton = btnCancel;
+ this.VerticalResizable = false;
+ this.Font = SystemFonts.MessageBoxFont;
+ this.Text = AppString.Menu.ChangeCommand;
+ this.SizeGripStyle = SizeGripStyle.Hide;
+ this.StartPosition = FormStartPosition.CenterParent;
+ this.MaximizeBox = MinimizeBox = ShowIcon = ShowInTaskbar = false;
+ InitializeComponents();
+ }
+
+ public string Command
+ {
+ get => txtCommand.Text;
+ set => txtCommand.Text = value;
+ }
+
+ public string Arguments
+ {
+ get => txtArguments.Text;
+ set => txtArguments.Text = value;
+ }
+
+ readonly Label lblCommand = new Label
+ {
+ Text = AppString.Dialog.ItemCommand,
+ AutoSize = true
+ };
+ readonly Label lblArguments = new Label
+ {
+ Text = AppString.Dialog.CommandArguments,
+ AutoSize = true
+ };
+ readonly TextBox txtCommand = new TextBox();
+ readonly TextBox txtArguments = new TextBox();
+ readonly Button btnOk = new Button
+ {
+ DialogResult = DialogResult.OK,
+ Text = AppString.Dialog.Ok,
+ AutoSize = true
+ };
+ readonly Button btnCancel = new Button
+ {
+ DialogResult = DialogResult.Cancel,
+ Text = AppString.Dialog.Cancel,
+ AutoSize = true
+ };
+
+ private void InitializeComponents()
+ {
+ this.Controls.AddRange(new Control[] { lblCommand, lblArguments, txtCommand, txtArguments, btnOk, btnCancel });
+ int a = 20.DpiZoom();
+ lblArguments.Left = lblCommand.Left = lblCommand.Top = txtCommand.Top = a;
+ lblArguments.Top = txtArguments.Top = txtCommand.Bottom + a;
+ btnOk.Top = btnCancel.Top = txtArguments.Bottom + a;
+ int b = Math.Max(lblCommand.Width, lblArguments.Width) + 3 * a;
+ this.ClientSize = new Size(250.DpiZoom() + b, btnOk.Bottom + a);
+ btnOk.Anchor = btnCancel.Anchor = AnchorStyles.Right | AnchorStyles.Top;
+ btnCancel.Left = this.ClientSize.Width - btnCancel.Width - a;
+ btnOk.Left = btnCancel.Left - btnOk.Width - a;
+ this.Resize += (sender, e) =>
+ {
+ txtArguments.Width = txtCommand.Width = this.ClientSize.Width - b;
+ txtArguments.Left = txtCommand.Left = btnCancel.Right - txtCommand.Width;
+ };
+ this.OnResize(null);
+ this.MinimumSize = this.Size;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiTextItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiTextItem.cs
index daee3dc..5c5e8a6 100644
--- a/ContextMenuManager/Controls/Interfaces/ITsiTextItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/ITsiTextItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System.Windows.Forms;
namespace ContextMenuManager.Controls.Interfaces
diff --git a/ContextMenuManager/Controls/Interfaces/ITsiWebSearchItem.cs b/ContextMenuManager/Controls/Interfaces/ITsiWebSearchItem.cs
index 3f7b1e5..5011b4e 100644
--- a/ContextMenuManager/Controls/Interfaces/ITsiWebSearchItem.cs
+++ b/ContextMenuManager/Controls/Interfaces/ITsiWebSearchItem.cs
@@ -1,4 +1,4 @@
-using System.Diagnostics;
+using BluePointLilac.Methods;
using System.Windows.Forms;
namespace ContextMenuManager.Controls.Interfaces
@@ -13,14 +13,11 @@ sealed class WebSearchMenuItem : ToolStripMenuItem
{
public WebSearchMenuItem(ITsiWebSearchItem item) : base(AppString.Menu.WebSearch)
{
- this.Click += (sender, e) => WebSearch(item.SearchText);
- }
-
- public static void WebSearch(string text)
- {
- //替换网址转义符
- text = text.Replace("%", "%25").Replace("#", "%23").Replace("&", "%26").Replace("+", "%2B");
- Process.Start(AppConfig.EngineUrl.Replace("%s", text));
+ this.Click += (sender, e) =>
+ {
+ string url = AppConfig.EngineUrl.Replace("%s", item.SearchText);
+ ExternalProgram.OpenUrl(url);
+ };
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/LockNewItem.cs b/ContextMenuManager/Controls/LockNewItem.cs
deleted file mode 100644
index 8d939b1..0000000
--- a/ContextMenuManager/Controls/LockNewItem.cs
+++ /dev/null
@@ -1,103 +0,0 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
-using ContextMenuManager.Controls.Interfaces;
-using Microsoft.Win32;
-using System;
-using System.Security.AccessControl;
-using System.Security.Principal;
-using System.Windows.Forms;
-
-namespace ContextMenuManager.Controls
-{
- sealed class LockNewItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem, ITsiWebSearchItem
- {
- public LockNewItem(ShellNewList list)
- {
- this.Owner = list;
- this.Image = AppImage.Lock;
- this.Text = AppString.Item.LockNewMenu;
- this.SetNoClickEvent();
- BtnShowMenu = new MenuButton(this);
- ChkVisible = new VisibleCheckBox(this) { Checked = IsLocked() };
- MyToolTip.SetToolTip(ChkVisible, AppString.Tip.LockNewMenu);
- TsiSearch = new WebSearchMenuItem(this);
- this.ContextMenuStrip = new ContextMenuStrip();
- this.ContextMenuStrip.Items.Add(TsiSearch);
- }
-
- public MenuButton BtnShowMenu { get; set; }
- public WebSearchMenuItem TsiSearch { get; set; }
- public VisibleCheckBox ChkVisible { get; set; }
- public ShellNewList Owner { get; private set; }
-
- public bool ItemVisible
- {
- get => IsLocked();
- set
- {
- if(value) Owner.WriteRegistry();
- else UnLock();
- foreach(Control ctr in Owner.Controls)
- {
- if(ctr.GetType() == typeof(ShellNewItem))
- {
- ShellNewItem item = (ShellNewItem)ctr;
- if(item.CanSort)
- {
- item.BtnMoveDown.Visible = item.BtnMoveUp.Visible = value;
- }
- }
- }
- }
- }
-
- public string SearchText => Text;
-
-
- public static bool IsLocked()
- {
- using(RegistryKey key = RegistryEx.GetRegistryKey(ShellNewList.ShellNewPath))
- {
- RegistrySecurity rs = key.GetAccessControl();
- foreach(RegistryAccessRule rar in rs.GetAccessRules(true, true, typeof(NTAccount)))
- {
- if(rar.AccessControlType.ToString().Equals("Deny", StringComparison.OrdinalIgnoreCase))
- {
- if(rar.IdentityReference.ToString().Equals("Everyone", StringComparison.OrdinalIgnoreCase)) return true;
- }
- }
- }
- return false;
- }
-
- public static void Lock()
- {
- using(RegistryKey key = RegistryEx.GetRegistryKey(ShellNewList.ShellNewPath, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.ChangePermissions))
- {
- RegistrySecurity rs = new RegistrySecurity();
- RegistryAccessRule rar = new RegistryAccessRule("Everyone", RegistryRights.Delete | RegistryRights.WriteKey, AccessControlType.Deny);
- rs.AddAccessRule(rar);
- key.SetAccessControl(rs);
- }
- }
-
- public static void UnLock()
- {
- using(RegistryKey key = RegistryEx.GetRegistryKey(ShellNewList.ShellNewPath, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.ChangePermissions))
- {
- RegistrySecurity rs = key.GetAccessControl();
- foreach(RegistryAccessRule rar in rs.GetAccessRules(true, true, typeof(NTAccount)))
- {
- if(rar.AccessControlType.ToString().Equals("Deny", StringComparison.OrdinalIgnoreCase))
- {
- if(rar.IdentityReference.ToString().Equals("Everyone", StringComparison.OrdinalIgnoreCase))
- {
- rs.RemoveAccessRule(rar);
- }
- }
- }
- key.SetAccessControl(rs);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/NewIEDialog.cs b/ContextMenuManager/Controls/NewIEDialog.cs
new file mode 100644
index 0000000..fcb39b5
--- /dev/null
+++ b/ContextMenuManager/Controls/NewIEDialog.cs
@@ -0,0 +1,64 @@
+using BluePointLilac.Methods;
+using System;
+using System.IO;
+using System.Windows.Forms;
+
+namespace ContextMenuManager.Controls
+{
+ sealed class NewIEDialog : CommonDialog
+ {
+ public string RegPath { get; private set; }
+ public override void Reset() { }
+
+ protected override bool RunDialog(IntPtr hwndOwner)
+ {
+ using(NewIEForm frm = new NewIEForm())
+ {
+ bool flag = frm.ShowDialog() == DialogResult.OK;
+ if(flag) this.RegPath = frm.RegPath;
+ return flag;
+ }
+ }
+
+ sealed class NewIEForm : NewItemForm
+ {
+ public string RegPath { get; set; }
+
+ protected override void InitializeComponents()
+ {
+ base.InitializeComponents();
+ btnOk.Click += (sender, e) =>
+ {
+ if(ItemText.IsNullOrWhiteSpace())
+ {
+ MessageBoxEx.Show(AppString.MessageBox.TextCannotBeEmpty);
+ return;
+ }
+ if(ItemCommand.IsNullOrWhiteSpace())
+ {
+ MessageBoxEx.Show(AppString.MessageBox.CommandCannotBeEmpty);
+ return;
+ }
+ AddNewItem();
+ DialogResult = DialogResult.OK;
+ };
+
+ btnBrowse.Click += (sender, e) =>
+ {
+ using(OpenFileDialog dlg = new OpenFileDialog())
+ {
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ this.ItemFilePath = dlg.FileName;
+ this.ItemText = Path.GetFileNameWithoutExtension(dlg.FileName);
+ }
+ };
+ }
+
+ private void AddNewItem()
+ {
+ this.RegPath = $@"{IEList.IEPath}\{IEItem.MeParts[0]}\{ItemText.Replace("\\", "")}";
+ Microsoft.Win32.Registry.SetValue(RegPath, "", ItemCommand);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/NewItem.cs b/ContextMenuManager/Controls/NewItem.cs
index 027f81e..039747d 100644
--- a/ContextMenuManager/Controls/NewItem.cs
+++ b/ContextMenuManager/Controls/NewItem.cs
@@ -1,19 +1,22 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System;
namespace ContextMenuManager.Controls
{
class NewItem : MyListItem
{
- public NewItem()
+ public NewItem() : this(AppString.Item.NewItem) { }
+
+ public NewItem(string text)
{
+ this.Text = text;
this.Image = AppImage.NewItem;
- this.Text = AppString.Item.NewItem;
this.SetNoClickEvent();
this.AddCtr(BtnAddNewItem);
- MyToolTip.SetToolTip(BtnAddNewItem, AppString.Item.NewItem);
+ MyToolTip.SetToolTip(BtnAddNewItem, text);
BtnAddNewItem.MouseDown += (sender, e) => AddNewItem?.Invoke(null, null);
+
}
public event EventHandler AddNewItem;
readonly PictureButton BtnAddNewItem = new PictureButton(AppImage.AddNewItem);
diff --git a/ContextMenuManager/Controls/NewItemForm.cs b/ContextMenuManager/Controls/NewItemForm.cs
index 16e1543..fb65fee 100644
--- a/ContextMenuManager/Controls/NewItemForm.cs
+++ b/ContextMenuManager/Controls/NewItemForm.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System;
using System.Drawing;
using System.Windows.Forms;
@@ -12,6 +12,7 @@ public NewItemForm()
{
this.AcceptButton = btnOk;
this.CancelButton = btnCancel;
+ this.Text = AppString.Item.NewItem;
this.Font = SystemFonts.MenuFont;
this.MaximizeBox = this.MinimizeBox = false;
this.ShowIcon = this.ShowInTaskbar = false;
@@ -22,15 +23,16 @@ public NewItemForm()
}
public string ItemText { get => txtText.Text; set => txtText.Text = value; }
- public string Command { get => txtCommand.Text; set => txtCommand.Text = value; }
+ public string ItemFilePath { get => txtFilePath.Text; set => txtFilePath.Text = value; }
public string Arguments { get => txtArguments.Text; set => txtArguments.Text = value; }
- public string FullCommand
+ public string ItemCommand
{
get
{
- if(Arguments.IsNullOrWhiteSpace()) return Command;
- else if(Command.IsNullOrWhiteSpace()) return Arguments;
- else return $"\"{Command}\" \"{Arguments}\"";
+ if(Arguments.IsNullOrWhiteSpace()) return ItemFilePath;
+ if(ItemFilePath.IsNullOrWhiteSpace()) return Arguments;
+ if(Arguments.StartsWith("\"") && Arguments.EndsWith("\"")) return $"\"{ItemFilePath}\" {Arguments}";
+ return $"\"{ItemFilePath}\" \"{Arguments}\"";
}
}
@@ -50,7 +52,7 @@ public string FullCommand
AutoSize = true
};
protected readonly TextBox txtText = new TextBox();
- protected readonly TextBox txtCommand = new TextBox();
+ protected readonly TextBox txtFilePath = new TextBox();
protected readonly TextBox txtArguments = new TextBox();
protected readonly Button btnBrowse = new Button
{
@@ -74,12 +76,12 @@ public string FullCommand
protected virtual void InitializeComponents()
{
this.Controls.AddRange(new Control[] { lblText, lblCommand, lblArguments,
- txtText, txtCommand, txtArguments, btnBrowse, btnOk, btnCancel });
+ txtText, txtFilePath, txtArguments, btnBrowse, btnOk, btnCancel });
int a = 20.DpiZoom();
btnBrowse.Anchor = btnOk.Anchor = btnCancel.Anchor = AnchorStyles.Right | AnchorStyles.Top;
txtText.Top = lblText.Top = lblText.Left = lblCommand.Left = lblArguments.Left = a;
- btnBrowse.Top = txtCommand.Top = lblCommand.Top = txtText.Bottom + a;
- lblArguments.Top = txtArguments.Top = txtCommand.Bottom + a;
+ btnBrowse.Top = txtFilePath.Top = lblCommand.Top = txtText.Bottom + a;
+ lblArguments.Top = txtArguments.Top = txtFilePath.Bottom + a;
btnOk.Top = btnCancel.Top = txtArguments.Bottom + a;
btnCancel.Left = btnBrowse.Left = this.ClientSize.Width - btnCancel.Width - a;
btnOk.Left = btnCancel.Left - btnOk.Width - a;
@@ -88,8 +90,8 @@ protected virtual void InitializeComponents()
this.MinimumSize = this.Size;
this.Resize += (sender, e) =>
{
- txtText.Width = txtCommand.Width = txtArguments.Width = this.ClientSize.Width - b;
- txtText.Left = txtCommand.Left = txtArguments.Left = btnBrowse.Left - txtCommand.Width - a;
+ txtText.Width = txtFilePath.Width = txtArguments.Width = this.ClientSize.Width - b;
+ txtText.Left = txtFilePath.Left = txtArguments.Left = btnBrowse.Left - txtFilePath.Width - a;
LastSize = this.Size;
};
if(LastSize != null) this.Size = LastSize;
diff --git a/ContextMenuManager/Controls/NewSendToDialog.cs b/ContextMenuManager/Controls/NewLnkFileDialog.cs
similarity index 51%
rename from ContextMenuManager/Controls/NewSendToDialog.cs
rename to ContextMenuManager/Controls/NewLnkFileDialog.cs
index baecfa2..54ed9ee 100644
--- a/ContextMenuManager/Controls/NewSendToDialog.cs
+++ b/ContextMenuManager/Controls/NewLnkFileDialog.cs
@@ -1,28 +1,37 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.IO;
using System.Windows.Forms;
namespace ContextMenuManager.Controls
{
- sealed class NewSendToDialog : CommonDialog
+ sealed class NewLnkFileDialog : CommonDialog
{
- public string FilePath { get; private set; }
+ public string ItemText { get; set; }
+ public string ItemFilePath { get; set; }
+ public string Arguments { get; set; }
+ public string FileFilter { get; set; }
public override void Reset() { }
protected override bool RunDialog(IntPtr hwndOwner)
{
- using(NewSendToForm frm = new NewSendToForm())
+ using(NewLnkForm frm = new NewLnkForm())
{
+ frm.FileFilter = this.FileFilter;
bool flag = frm.ShowDialog() == DialogResult.OK;
- if(flag) this.FilePath = frm.FilePath;
+ if(flag)
+ {
+ this.ItemText = frm.ItemText;
+ this.ItemFilePath = frm.ItemFilePath;
+ this.Arguments = frm.Arguments;
+ }
return flag;
}
}
- sealed class NewSendToForm : NewItemForm
+ sealed class NewLnkForm : NewItemForm
{
- public string FilePath { get; set; }
+ public string FileFilter { get; set; }
readonly RadioButton rdoFile = new RadioButton
{
@@ -39,7 +48,6 @@ sealed class NewSendToForm : NewItemForm
protected override void InitializeComponents()
{
base.InitializeComponents();
- this.Text = AppString.Dialog.NewSendToItem;
this.Controls.AddRange(new Control[] { rdoFile, rdoFolder });
rdoFile.Top = rdoFolder.Top = btnOk.Top;
rdoFile.Left = lblCommand.Left;
@@ -56,25 +64,34 @@ protected override void InitializeComponents()
if(ItemText.IsNullOrWhiteSpace())
{
MessageBoxEx.Show(AppString.MessageBox.TextCannotBeEmpty);
- return;
}
- if(Command.IsNullOrWhiteSpace())
+ else if(ItemFilePath.IsNullOrWhiteSpace())
{
MessageBoxEx.Show(AppString.MessageBox.CommandCannotBeEmpty);
- return;
}
- if(rdoFile.Checked && !ObjectPath.GetFullFilePath(Command, out _))
+ else if(rdoFile.Checked && !ObjectPath.GetFullFilePath(ItemFilePath, out _))
{
MessageBoxEx.Show(AppString.MessageBox.FileNotExists);
- return;
}
- if(rdoFolder.Checked && !Directory.Exists(Command))
+ else if(rdoFolder.Checked && !Directory.Exists(ItemFilePath))
{
MessageBoxEx.Show(AppString.MessageBox.FolderNotExists);
- return;
}
- AddNewItem();
- DialogResult = DialogResult.OK;
+ else DialogResult = DialogResult.OK;
+ };
+
+ txtFilePath.TextChanged += (sender, e) =>
+ {
+ if(Path.GetExtension(ItemFilePath).ToLower() == ".lnk")
+ {
+ using(WshShortcut shortcut = new WshShortcut(ItemFilePath))
+ {
+ if(File.Exists(shortcut.TargetPath))
+ {
+ ItemFilePath = shortcut.TargetPath;
+ }
+ }
+ }
};
}
@@ -82,10 +99,23 @@ private void BrowseFile()
{
using(OpenFileDialog dlg = new OpenFileDialog())
{
- dlg.Filter = $"{AppString.Dialog.Program}|*.exe;*.bat;*.cmd;*.vbs;*.vbe;*.jse;*.wsf";
+ dlg.Filter = this.FileFilter;
+ //取消获取lnk目标路径,可选中UWP快捷方式
+ dlg.DereferenceLinks = false;
if(dlg.ShowDialog() == DialogResult.OK)
{
- Command = dlg.FileName;
+ ItemFilePath = dlg.FileName;
+ string extension = Path.GetExtension(dlg.FileName).ToLower();
+ if(extension == ".lnk")
+ {
+ using(WshShortcut shortcut = new WshShortcut(dlg.FileName))
+ {
+ if(File.Exists(shortcut.TargetPath))
+ {
+ ItemFilePath = shortcut.TargetPath;
+ }
+ }
+ }
ItemText = Path.GetFileNameWithoutExtension(dlg.FileName);
}
}
@@ -95,30 +125,15 @@ private void BrowseFolder()
{
using(FolderBrowserDialog dlg = new FolderBrowserDialog())
{
- if(Directory.Exists(Command)) dlg.SelectedPath = Command;
+ if(Directory.Exists(ItemFilePath)) dlg.SelectedPath = ItemFilePath;
else dlg.SelectedPath = Application.StartupPath;
if(dlg.ShowDialog() == DialogResult.OK)
{
- Command = dlg.SelectedPath;
- ItemText = new DirectoryInfo(dlg.SelectedPath).Name;
+ ItemFilePath = dlg.SelectedPath;
+ ItemText = Path.GetFileNameWithoutExtension(dlg.SelectedPath);
}
}
}
-
- private void AddNewItem()
- {
- FilePath = $@"{SendToList.SendToPath}\{ObjectPath.RemoveIllegalChars(ItemText)}.lnk";
- FilePath = ObjectPath.GetNewPathWithIndex(FilePath, ObjectPath.PathType.File);
- WshShortcut shortcut = new WshShortcut
- {
- FullName = FilePath,
- TargetPath = Command,
- WorkingDirectory = Path.GetDirectoryName(Command),
- Arguments = Arguments
- };
- shortcut.Save();
- SendToList.DesktopIniWriter.SetValue("LocalizedFileNames", Path.GetFileName(FilePath), ItemText);
- }
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/NewOpenWithDialog.cs b/ContextMenuManager/Controls/NewOpenWithDialog.cs
index ab57186..9de58a1 100644
--- a/ContextMenuManager/Controls/NewOpenWithDialog.cs
+++ b/ContextMenuManager/Controls/NewOpenWithDialog.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.Diagnostics;
using System.IO;
@@ -26,12 +26,13 @@ sealed class NewOpenWithForm : NewItemForm
public string RegPath { get; private set; }
private string FilePath;
- private string AppRegPath;
+ private string FileName => Path.GetFileName(FilePath);
+ private string AppRegPath => $@"HKEY_CLASSES_ROOT\Applications\{FileName}";
+ private string CommandPath => $@"{AppRegPath}\shell\open\command";
protected override void InitializeComponents()
{
base.InitializeComponents();
- this.Text = AppString.Dialog.NewOpenWithItem;
btnBrowse.Click += (sender, e) => BrowseFile();
btnOk.Click += (sender, e) =>
{
@@ -40,17 +41,26 @@ protected override void InitializeComponents()
MessageBoxEx.Show(AppString.MessageBox.TextCannotBeEmpty);
return;
}
- if(FullCommand.IsNullOrWhiteSpace())
+ if(ItemCommand.IsNullOrWhiteSpace())
{
MessageBoxEx.Show(AppString.MessageBox.CommandCannotBeEmpty);
return;
}
- FilePath = ObjectPath.ExtractFilePath(Command);
- AppRegPath = $@"HKEY_CLASSES_ROOT\Applications\{Path.GetFileName(FilePath)}";
- if(FilePath == null || RegistryEx.GetRegistryKey(AppRegPath) != null)
+ FilePath = ObjectPath.ExtractFilePath(base.ItemFilePath);
+ using(var key = RegistryEx.GetRegistryKey(CommandPath))
{
- MessageBoxEx.Show(AppString.MessageBox.UnsupportedFilename);
- return;
+ string path = ObjectPath.ExtractFilePath(key?.GetValue("")?.ToString());
+ string name = Path.GetFileName(path);
+ if(FilePath != null && FilePath.Equals(path, StringComparison.OrdinalIgnoreCase))
+ {
+ MessageBoxEx.Show(AppString.MessageBox.HasBeenAdded);
+ return;
+ }
+ if(FileName == null || FileName.Equals(name, StringComparison.OrdinalIgnoreCase))
+ {
+ MessageBoxEx.Show(AppString.MessageBox.UnsupportedFilename);
+ return;
+ }
}
AddNewItem();
this.DialogResult = DialogResult.OK;
@@ -64,8 +74,8 @@ private void BrowseFile()
dlg.Filter = $"{AppString.Dialog.Program}|*.exe";
if(dlg.ShowDialog() == DialogResult.OK)
{
- Command = dlg.FileName;
- Arguments = "%1";
+ base.ItemFilePath = dlg.FileName;
+ Arguments = "\"%1\"";
ItemText = FileVersionInfo.GetVersionInfo(dlg.FileName).FileDescription;
}
}
@@ -76,11 +86,11 @@ private void AddNewItem()
using(var key = RegistryEx.GetRegistryKey(AppRegPath, true, true))
{
key.SetValue("FriendlyAppName", ItemText);
- using(var cmdKey = key.CreateSubKey(@"shell\open\command", true))
- {
- cmdKey.SetValue("", FullCommand);
- RegPath = cmdKey.Name;
- }
+ }
+ using(var cmdKey = RegistryEx.GetRegistryKey(CommandPath, true, true))
+ {
+ cmdKey.SetValue("", ItemCommand);
+ RegPath = cmdKey.Name;
}
}
}
diff --git a/ContextMenuManager/Controls/NewShellDialog.cs b/ContextMenuManager/Controls/NewShellDialog.cs
index de0fa57..66d4461 100644
--- a/ContextMenuManager/Controls/NewShellDialog.cs
+++ b/ContextMenuManager/Controls/NewShellDialog.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
using System.IO;
using System.Windows.Forms;
@@ -45,12 +45,11 @@ sealed class NewShellForm : NewItemForm
Text = AppString.Dialog.MultiMenu,
AutoSize = true
};
+ readonly ShellExecuteCheckBox chkSE = new ShellExecuteCheckBox();
static readonly string[] DirScenePaths = {
ShellList.MENUPATH_DIRECTORY,
- ShellList.MENUPATH_DIRECTORY_IMAGE,
- ShellList.MENUPATH_DIRECTORY_VIDEO,
- ShellList.MENUPATH_DIRECTORY_AUDIO
+ $@"{ShellList.SYSFILEASSPATH}\Directory."
};
static readonly string[] FileObjectsScenePaths = {
ShellList.MENUPATH_FILE,
@@ -58,19 +57,19 @@ sealed class NewShellForm : NewItemForm
ShellList.MENUPATH_ALLOBJECTS,
ShellList.SYSFILEASSPATH,
ShellList.MENUPATH_UNKNOWN,
- ShellList.MENUPATH_LNKFILE,
- ShellList.MENUPATH_EXEFILE,
ShellList.MENUPATH_UWPLNK
};
protected override void InitializeComponents()
{
base.InitializeComponents();
- this.Text = AppString.Dialog.NewShellItem;
- this.Controls.AddRange(new[] { rdoSingle, rdoMulti });
+ this.Controls.AddRange(new Control[] { rdoSingle, rdoMulti, chkSE });
rdoSingle.Top = rdoMulti.Top = btnOk.Top;
rdoSingle.Left = lblCommand.Left;
rdoMulti.Left = rdoSingle.Right + 20.DpiZoom();
+ chkSE.Top = txtArguments.Top + (txtArguments.Height - chkSE.Height) / 2;
+ this.Resize += (sender, e) => chkSE.Left = txtArguments.Right + 20.DpiZoom();
+ this.OnResize(null);
rdoMulti.CheckedChanged += (sender, e) =>
{
@@ -80,8 +79,8 @@ protected override void InitializeComponents()
rdoSingle.Checked = true;
return;
}
- lblCommand.Enabled = txtCommand.Enabled = lblArguments.Enabled
- = txtArguments.Enabled = btnBrowse.Enabled = !rdoMulti.Checked;
+ lblCommand.Enabled = txtFilePath.Enabled = lblArguments.Enabled
+ = txtArguments.Enabled = btnBrowse.Enabled = chkSE.Enabled = !rdoMulti.Checked;
};
btnBrowse.Click += (sender, e) => BrowseFile();
@@ -104,19 +103,36 @@ private void BrowseFile()
{
using(OpenFileDialog dlg = new OpenFileDialog())
{
- dlg.Filter = $"{AppString.Dialog.Program}|*.exe;*.bat;*.cmd;*.pif;*.com";
+ dlg.Filter = $"{AppString.Dialog.Program}|*.exe;*.bat;*.cmd;*.pif;*.com;*.vbs;*.vbe;*.js;*.jse;*.wsf";
if(dlg.ShowDialog() != DialogResult.OK) return;
- Command = dlg.FileName;
ItemText = Path.GetFileNameWithoutExtension(dlg.FileName);
+ string extension = Path.GetExtension(dlg.FileName).ToLower();
+ switch(extension)
+ {
+ case ".vbs":
+ case ".vbe":
+ case ".js":
+ case ".jse":
+ case ".wsf":
+ ItemFilePath = "wscript.exe";
+ Arguments = dlg.FileName;
+ break;
+ default:
+ ItemFilePath = dlg.FileName;
+ break;
+ }
if(Array.FindIndex(DirScenePaths, path
- => ScenePath.Equals(path, StringComparison.OrdinalIgnoreCase)) != -1)
+ => ScenePath.StartsWith(path, StringComparison.OrdinalIgnoreCase)) != -1)
{
- Arguments = "%V";//自动加目录后缀
+ if(!Arguments.IsNullOrWhiteSpace()) Arguments += " ";
+ if(ScenePath != ShellList.MENUPATH_BACKGROUND)
+ Arguments += "\"%V\"";//自动加目录后缀
}
else if(Array.FindIndex(FileObjectsScenePaths, path
=> ScenePath.StartsWith(path, StringComparison.OrdinalIgnoreCase)) != -1)
{
- Arguments += "%1";//自动加文件对象后缀
+ if(!Arguments.IsNullOrWhiteSpace()) Arguments += " ";
+ Arguments += "\"%1\"";//自动加文件对象后缀
}
}
}
@@ -126,7 +142,7 @@ private void AddNewItem()
using(var shellKey = RegistryEx.GetRegistryKey(ShellPath, true, true))
{
string keyName = "Item";
- NewItemRegPath = ObjectPath.GetNewPathWithIndex($@"{ShellPath}\{keyName}", ObjectPath.PathType.Registry);
+ NewItemRegPath = ObjectPath.GetNewPathWithIndex($@"{ShellPath}\{keyName}", ObjectPath.PathType.Registry, 0);
keyName = RegistryEx.GetKeyName(NewItemRegPath);
using(var key = shellKey.CreateSubKey(keyName, true))
@@ -136,8 +152,13 @@ private void AddNewItem()
key.SetValue("SubCommands", "");
else
{
- if(!FullCommand.IsNullOrWhiteSpace())
- key.CreateSubKey("command", true).SetValue("", FullCommand);
+ if(!ItemCommand.IsNullOrWhiteSpace())
+ {
+ string command;
+ if(!chkSE.Checked) command = ItemCommand;
+ else command = ShellExecuteDialog.GetCommand(ItemFilePath, Arguments, chkSE.Verb, chkSE.WindowStyle);
+ key.CreateSubKey("command", true).SetValue("", command);
+ }
}
}
}
diff --git a/ContextMenuManager/Controls/OpenWithItem.cs b/ContextMenuManager/Controls/OpenWithItem.cs
index f75cd0f..bcfabd3 100644
--- a/ContextMenuManager/Controls/OpenWithItem.cs
+++ b/ContextMenuManager/Controls/OpenWithItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using Microsoft.Win32;
using System;
@@ -33,8 +33,9 @@ public string RegPath
ChkVisible.Checked = this.ItemVisible;
}
}
-
- private string AppPath => RegistryEx.GetParentPath(RegistryEx.GetParentPath(RegistryEx.GetParentPath(RegPath)));
+ public string ValueName => null;
+ private string ShellPath => RegistryEx.GetParentPath(RegPath);
+ private string AppPath => RegistryEx.GetParentPath(RegistryEx.GetParentPath(ShellPath));
private bool NameEquals => RegistryEx.GetKeyName(AppPath).Equals(Path.GetFileName(ItemFilePath), StringComparison.OrdinalIgnoreCase);
private Icon ItemIcon => Icon.ExtractAssociatedIcon(ItemFilePath);
@@ -123,6 +124,10 @@ private void InitializeComponents()
public void DeleteMe()
{
RegistryEx.DeleteKeyTree(this.RegPath);
+ using(RegistryKey key = RegistryEx.GetRegistryKey(ShellPath))
+ {
+ if(key.GetSubKeyNames().Length == 0) RegistryEx.DeleteKeyTree(this.AppPath);
+ }
this.Dispose();
}
}
diff --git a/ContextMenuManager/Controls/OpenWithList.cs b/ContextMenuManager/Controls/OpenWithList.cs
index 8d91282..131b287 100644
--- a/ContextMenuManager/Controls/OpenWithList.cs
+++ b/ContextMenuManager/Controls/OpenWithList.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
@@ -12,10 +12,10 @@ sealed class OpenWithList : MyList
{
public void LoadItems()
{
- this.LoadCommonItems();
+ this.LoadOpenWithItems();
this.SortItemByText();
this.AddNewItem();
- RegRuleItem storeItem = new RegRuleItem(RegRuleItem.UseStoreOpenWith)
+ VisibleRegRuleItem storeItem = new VisibleRegRuleItem(VisibleRegRuleItem.UseStoreOpenWith)
{
//Win8、Win8.1、Win10才有在应用商店中查找应用
Visible = WindowsOsVersion.ISAfterOrEqual8
@@ -23,7 +23,7 @@ public void LoadItems()
this.InsertItem(storeItem, 1);
}
- private void LoadCommonItems()
+ private void LoadOpenWithItems()
{
using(RegistryKey appKey = Registry.ClassesRoot.OpenSubKey("Applications"))
{
diff --git a/ContextMenuManager/Controls/RegRuleItem.cs b/ContextMenuManager/Controls/RegRuleItem.cs
deleted file mode 100644
index a0450a4..0000000
--- a/ContextMenuManager/Controls/RegRuleItem.cs
+++ /dev/null
@@ -1,230 +0,0 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
-using ContextMenuManager.Controls.Interfaces;
-using Microsoft.Win32;
-using System.Drawing;
-using System.Windows.Forms;
-
-namespace ContextMenuManager.Controls
-{
- sealed class RegRuleItem : MyListItem, IChkVisibleItem, IFoldSubItem, IBtnShowMenuItem, ITsiWebSearchItem
- {
- public struct RegRule
- {
- public string RegPath { get; set; }
- public string ValueName { get; set; }
- public RegistryValueKind ValueKind { get; set; }
- public object TurnOnValue { get; set; }
- public object TurnOffValue { get; set; }
- public RegRule(string regPath, string valueName, object turnOnValue,
- object turnOffValue, RegistryValueKind valueKind = RegistryValueKind.DWord)
- {
- this.RegPath = regPath; this.ValueName = valueName;
- this.TurnOnValue = turnOnValue; this.TurnOffValue = turnOffValue;
- this.ValueKind = valueKind;
- }
- }
-
- public struct ItemInfo
- {
- public string Text { get; set; }
- public Image Image { get; set; }
- public string Tip { get; set; }
- public bool RestartExplorer { get; set; }
- }
-
- public struct RuleAndInfo
- {
- public RegRule[] Rules { get; set; }
- public ItemInfo ItemInfo { get; set; }
- }
-
- private RegRuleItem(ItemInfo info)
- {
- this.Text = info.Text;
- this.Image = info.Image;
- this.RestartExplorer = info.RestartExplorer;
- BtnShowMenu = new MenuButton(this);
- ChkVisible = new VisibleCheckBox(this);
- MyToolTip.SetToolTip(ChkVisible, info.Tip);
- TsiSearch = new WebSearchMenuItem(this);
- this.ContextMenuStrip = new ContextMenuStrip();
- this.ContextMenuStrip.Items.Add(TsiSearch);
- }
-
- public RegRuleItem(RegRule[] rules, ItemInfo info)
- : this(info) { this.Rules = rules; }
-
- public RegRuleItem(RegRule rule, ItemInfo info)
- : this(info) { this.Rules = new[] { rule }; }
-
- public RegRuleItem(RuleAndInfo ruleAndInfo)
- : this(ruleAndInfo.Rules, ruleAndInfo.ItemInfo) { }
-
- private RegRule[] _Rules;
- public RegRule[] Rules
- {
- get => _Rules;
- set
- {
- _Rules = value;
- ChkVisible.Checked = ItemVisible;
- }
- }
-
- public VisibleCheckBox ChkVisible { get; set; }
- public bool RestartExplorer { get; set; }
-
- public bool ItemVisible
- {
- get
- {
- foreach(RegRule rule in Rules)
- {
- using(RegistryKey key = RegistryEx.GetRegistryKey(rule.RegPath))
- {
- if(key?.GetValue(rule.ValueName) == null) continue;
- if(key.GetValueKind(rule.ValueName) != rule.ValueKind) continue;
- if(key.GetValue(rule.ValueName).ToString().ToLower()
- == rule.TurnOffValue.ToString().ToLower()) return false;
- }
- }
- return true;
- }
- set
- {
- foreach(RegRule rule in Rules)
- {
- object data = value ? rule.TurnOnValue : rule.TurnOffValue;
- if(data != null)
- {
- Registry.SetValue(rule.RegPath, rule.ValueName, data, rule.ValueKind);
- }
- else
- {
- RegistryEx.DeleteValue(rule.RegPath, rule.ValueName);
- }
- }
- if(RestartExplorer) ExplorerRestarter.NeedRestart = true;
- }
- }
-
- public IFoldGroupItem FoldGroupItem { get; set; }
- public WebSearchMenuItem TsiSearch { get; set; }
- public MenuButton BtnShowMenu { get; set; }
-
- public string SearchText => Text;
-
- 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";
- const string CU_SMWCE = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer";
- const string LM_SPMWE = @"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Explorer";
- const string CU_SPMWE = @"HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer";
- public const string SkypeGuidStr = "{776dbc8d-7347-478c-8d71-791e12ef49d8}";
-
- public static RuleAndInfo CustomFolder = new RuleAndInfo
- {
- Rules = new[] {
- new RegRule(LM_SMWCPE, "NoCustomizeThisFolder", 0, 1),
- 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,
- Image = AppImage.Folder,
- Tip = AppString.Tip.CustomFolder,
- RestartExplorer = true
- }
- };
-
- public static RuleAndInfo NetworkDrive = new RuleAndInfo
- {
- 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}",
- Image = AppImage.NetworkDrive,
- RestartExplorer = true
- }
- };
-
- public static RuleAndInfo RecycleBinProperties = new RuleAndInfo
- {
- Rules = new[] {
- new RegRule(LM_SMWCPE, "NoPropertiesRecycleBin", 0, 1),
- new RegRule(CU_SMWCPE, "NoPropertiesRecycleBin", 0, 1)
- },
- ItemInfo = new ItemInfo
- {
- Text = AppString.Item.RecycleBinProperties,
- Image = AppImage.RecycleBin,
- RestartExplorer = true
- }
- };
-
- public static RuleAndInfo SendToDrive = new RuleAndInfo
- {
- Rules = new[] {
- new RegRule(LM_SMWCPE, "NoDrivesInSendToMenu", 0, 1),
- new RegRule(CU_SMWCPE, "NoDrivesInSendToMenu", 0, 1)
- },
- ItemInfo = new ItemInfo
- {
- Text = AppString.Item.RemovableDrive,
- Image = AppImage.Drive,
- Tip = AppString.Tip.SendToDrive,
- RestartExplorer = true
- }
- };
-
- public static RuleAndInfo DeferBuildSendTo = new RuleAndInfo
- {
- Rules = new[] {
- new RegRule(LM_SMWCE, "DelaySendToMenuBuild", 0, 1),
- new RegRule(CU_SMWCE, "DelaySendToMenuBuild", 0, 1)
- },
- ItemInfo = new ItemInfo
- {
- Text = AppString.Item.BuildSendtoMenu,
- Image = AppImage.SendTo,
- Tip = AppString.Tip.BuildSendtoMenu
- }
- };
-
- public static RuleAndInfo UseStoreOpenWith = new RuleAndInfo
- {
- 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 ShareWithSkype = new RuleAndInfo
- {
- Rules = new[]
- {
- new RegRule(GuidBlockedItem.HKLMBLOCKED, SkypeGuidStr, null, "", RegistryValueKind.String),
- new RegRule(GuidBlockedItem.HKCUBLOCKED, SkypeGuidStr, null, "", RegistryValueKind.String)
- },
- ItemInfo = new ItemInfo
- {
- Text = AppString.Item.ShareWithSkype,
- Tip = AppString.Tip.ShareWithSkype,
- Image = AppImage.Skype,
- RestartExplorer = true
- }
- };
- }
-}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/RuleItem.cs b/ContextMenuManager/Controls/RuleItem.cs
new file mode 100644
index 0000000..1a0130c
--- /dev/null
+++ b/ContextMenuManager/Controls/RuleItem.cs
@@ -0,0 +1,498 @@
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
+using ContextMenuManager.Controls.Interfaces;
+using Microsoft.Win32;
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ContextMenuManager.Controls
+{
+ class RuleItem : MyListItem, IFoldSubItem, IBtnShowMenuItem, ITsiWebSearchItem
+ {
+ public RuleItem(ItemInfo info)
+ {
+ this.Text = info.Text;
+ this.Image = info.Image;
+ this.RestartExplorer = info.RestartExplorer;
+ BtnShowMenu = new MenuButton(this);
+ TsiSearch = new WebSearchMenuItem(this);
+ this.ContextMenuStrip = new ContextMenuStrip();
+ this.ContextMenuStrip.Items.Add(TsiSearch);
+ }
+
+ public IFoldGroupItem FoldGroupItem { get; set; }
+ public WebSearchMenuItem TsiSearch { get; set; }
+ public MenuButton BtnShowMenu { get; set; }
+
+ public bool RestartExplorer { get; set; }
+
+ public string SearchText
+ {
+ get
+ {
+ if(this.FoldGroupItem == null) return this.Text;
+ else return $"{FoldGroupItem.Text} {this.Text}";
+ }
+ }
+ }
+
+ public struct ItemInfo
+ {
+ public string Text { get; set; }
+ public Image Image { get; set; }
+ public string Tip { get; set; }
+ public bool RestartExplorer { get; set; }
+ }
+
+ sealed class VisibleRegRuleItem : RuleItem, IChkVisibleItem, ITsiRegPathItem
+ {
+ public struct RegRule
+ {
+ public string RegPath { get; set; }
+ public string ValueName { get; set; }
+ public RegistryValueKind ValueKind { get; set; }
+ public object TurnOnValue { get; set; }
+ public object TurnOffValue { get; set; }
+ public RegRule(string regPath, string valueName, object turnOnValue,
+ object turnOffValue, RegistryValueKind valueKind = RegistryValueKind.DWord)
+ {
+ this.RegPath = regPath; this.ValueName = valueName;
+ this.TurnOnValue = turnOnValue; this.TurnOffValue = turnOffValue;
+ this.ValueKind = valueKind;
+ }
+ }
+
+ public struct RuleAndInfo
+ {
+ public RegRule[] Rules { get; set; }
+ public ItemInfo ItemInfo { get; set; }
+ }
+
+ private VisibleRegRuleItem(ItemInfo info) : base(info)
+ {
+ ChkVisible = new VisibleCheckBox(this);
+ MyToolTip.SetToolTip(ChkVisible, info.Tip);
+ TsiRegLocation = new RegLocationMenuItem(this);
+ this.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { new ToolStripSeparator(), TsiRegLocation });
+ }
+
+ public VisibleRegRuleItem(RegRule[] rules, ItemInfo info)
+ : this(info) { this.Rules = rules; }
+
+ public VisibleRegRuleItem(RegRule rule, ItemInfo info)
+ : this(info) { this.Rules = new[] { rule }; }
+
+ public VisibleRegRuleItem(RuleAndInfo ruleAndInfo)
+ : this(ruleAndInfo.Rules, ruleAndInfo.ItemInfo) { }
+
+ private RegRule[] _Rules;
+ public RegRule[] Rules
+ {
+ get => _Rules;
+ set
+ {
+ _Rules = value;
+ ChkVisible.Checked = ItemVisible;
+ }
+ }
+
+ public VisibleCheckBox ChkVisible { get; set; }
+ public RegLocationMenuItem TsiRegLocation { get; set; }
+
+ public bool ItemVisible
+ {
+ get
+ {
+ for(int i = 0; i < Rules.Length; i++)
+ {
+ RegRule rule = Rules[i];
+ using(RegistryKey key = RegistryEx.GetRegistryKey(rule.RegPath))
+ {
+ string value = key?.GetValue(rule.ValueName)?.ToString().ToLower();
+ string turnOnValue = rule.TurnOnValue?.ToString().ToLower();
+ string turnOffValue = rule.TurnOffValue?.ToString().ToLower();
+ if(value == null || key.GetValueKind(rule.ValueName) != rule.ValueKind)
+ {
+ if(i < Rules.Length - 1) continue;
+ }
+ if(value == turnOnValue) return true;
+ if(value == turnOffValue) return false;
+ }
+ }
+ return true;
+ }
+ set
+ {
+ foreach(RegRule rule in Rules)
+ {
+ object data = value ? rule.TurnOnValue : rule.TurnOffValue;
+ if(data != null)
+ {
+ Registry.SetValue(rule.RegPath, rule.ValueName, data, rule.ValueKind);
+ }
+ else
+ {
+ RegistryEx.DeleteValue(rule.RegPath, rule.ValueName);
+ }
+ }
+ if(RestartExplorer) ExplorerRestarter.Show();
+ }
+ }
+
+ public string RegPath => Rules[0].RegPath;
+ public string ValueName => Rules[0].ValueName;
+
+ 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";
+ const string CU_SMWCE = @"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer";
+ const string LM_SPMWE = @"HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Explorer";
+ const string CU_SPMWE = @"HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows\Explorer";
+ public const string SkypeGuid = "{776dbc8d-7347-478c-8d71-791e12ef49d8}";
+
+ public static RuleAndInfo CustomFolder = new RuleAndInfo
+ {
+ Rules = new[] {
+ new RegRule(LM_SMWCPE, "NoCustomizeThisFolder", null, 1),
+ new RegRule(LM_SMWCPE, "NoCustomizeWebView", null, 1),
+ new RegRule(CU_SMWCPE, "NoCustomizeThisFolder", null, 1),
+ new RegRule(CU_SMWCPE, "NoCustomizeWebView", null, 1)
+ },
+ ItemInfo = new ItemInfo
+ {
+ Text = AppString.Item.CustomFolder,
+ Image = AppImage.Folder,
+ Tip = AppString.Tip.CustomFolder,
+ RestartExplorer = true
+ }
+ };
+
+ public static RuleAndInfo NetworkDrive = new RuleAndInfo
+ {
+ Rules = new[] {
+ new RegRule(LM_SMWCPE, "NoNetConnectDisconnect", null, 1),
+ new RegRule(CU_SMWCPE, "NoNetConnectDisconnect", null, 1)
+ },
+ ItemInfo = new ItemInfo
+ {
+ Text = $"{AppString.Item.MapNetworkDrive} && {AppString.Item.DisconnectNetworkDrive}",
+ Image = AppImage.NetworkDrive,
+ RestartExplorer = true
+ }
+ };
+
+ public static RuleAndInfo RecycleBinProperties = new RuleAndInfo
+ {
+ Rules = new[] {
+ new RegRule(LM_SMWCPE, "NoPropertiesRecycleBin", null, 1),
+ new RegRule(CU_SMWCPE, "NoPropertiesRecycleBin", null, 1)
+ },
+ ItemInfo = new ItemInfo
+ {
+ Text = AppString.Item.RecycleBinProperties,
+ Image = AppImage.RecycleBin,
+ RestartExplorer = true
+ }
+ };
+
+ public static RuleAndInfo SendToDrive = new RuleAndInfo
+ {
+ Rules = new[] {
+ new RegRule(LM_SMWCPE, "NoDrivesInSendToMenu", null, 1),
+ new RegRule(CU_SMWCPE, "NoDrivesInSendToMenu", null, 1)
+ },
+ ItemInfo = new ItemInfo
+ {
+ Text = AppString.Item.RemovableDrive,
+ Image = AppImage.Drive,
+ Tip = AppString.Tip.SendToDrive,
+ RestartExplorer = true
+ }
+ };
+
+ public static RuleAndInfo DeferBuildSendTo = new RuleAndInfo
+ {
+ Rules = new[] {
+ new RegRule(LM_SMWCE, "DelaySendToMenuBuild", null, 1),
+ new RegRule(CU_SMWCE, "DelaySendToMenuBuild", null, 1)
+ },
+ ItemInfo = new ItemInfo
+ {
+ Text = AppString.Item.BuildSendtoMenu,
+ Image = AppImage.SendTo,
+ Tip = AppString.Tip.BuildSendtoMenu
+ }
+ };
+
+ public static RuleAndInfo UseStoreOpenWith = new RuleAndInfo
+ {
+ Rules = new[] {
+ new RegRule(LM_SPMWE, "NoUseStoreOpenWith", null, 1),
+ new RegRule(CU_SPMWE, "NoUseStoreOpenWith", null, 1)
+ },
+ ItemInfo = new ItemInfo
+ {
+ Text = AppString.Item.UseStoreOpenWith,
+ Image = AppImage.MicrosoftStore
+ }
+ };
+
+ public static RuleAndInfo ShareWithSkype = new RuleAndInfo
+ {
+ Rules = new[]
+ {
+ new RegRule(GuidBlockedItem.HKLMBLOCKED, SkypeGuid, null, "", RegistryValueKind.String),
+ new RegRule(GuidBlockedItem.HKCUBLOCKED, SkypeGuid, null, "", RegistryValueKind.String)
+ },
+ ItemInfo = new ItemInfo
+ {
+ Text = AppString.Item.ShareWithSkype,
+ Image = AppImage.Skype,
+ RestartExplorer = true
+ }
+ };
+ }
+
+ sealed class NumberRegRuleItem : RuleItem, ITsiRegPathItem
+ {
+ public struct RegRule
+ {
+ public string RegPath { get; set; }
+ public string ValueName { get; set; }
+ public RegistryValueKind ValueKind { get; set; }
+ public int MaxValue { get; set; }
+ public int MinValue { get; set; }
+ public int DefaultValue { get; set; }
+ }
+
+ readonly NumericUpDown NudValue = new NumericUpDown
+ {
+ Font = new Font(SystemFonts.MenuFont.FontFamily, 12F),
+ TextAlign = HorizontalAlignment.Center,
+ Width = 80.DpiZoom()
+ };
+ public RegLocationMenuItem TsiRegLocation { get; set; }
+
+ public NumberRegRuleItem(RegRule rule, ItemInfo info) : base(info)
+ {
+ this.AddCtr(NudValue);
+ MyToolTip.SetToolTip(NudValue, info.Tip);
+ TsiRegLocation = new RegLocationMenuItem(this);
+ this.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { new ToolStripSeparator(), TsiRegLocation });
+ this.Rule = rule;
+ NudValue.Maximum = rule.MaxValue;
+ NudValue.Minimum = rule.MinValue;
+ NudValue.ValueChanged += (sender, e) =>
+ {
+ if(NudValue.Value == Rule.DefaultValue) NudValue.ForeColor = Color.Red;
+ else NudValue.ForeColor = Color.Black;
+ this.ItemValue = (int)NudValue.Value;
+ };
+ NudValue.Value = ItemValue;
+ }
+
+ public string RegPath => Rule.RegPath;
+ public string ValueName => Rule.ValueName;
+ public RegRule Rule { get; set; }
+
+ public int ItemValue
+ {
+ get
+ {
+ object value = Registry.GetValue(Rule.RegPath, Rule.ValueName, null);
+ if(value == null) return Rule.DefaultValue;
+ int num = Convert.ToInt32(value);
+ if(num > Rule.MaxValue) return Rule.MaxValue;
+ if(num < Rule.MinValue) return Rule.MinValue;
+ else return num;
+ }
+ set
+ {
+ Registry.SetValue(Rule.RegPath, Rule.ValueName, value, Rule.ValueKind);
+ }
+ }
+ }
+
+ sealed class StringRegRuleItem : RuleItem, ITsiRegPathItem
+ {
+ public struct RegRule
+ {
+ public string RegPath { get; set; }
+ public string ValueName { get; set; }
+ }
+
+ readonly Label LblValue = new Label
+ {
+ Font = new Font(SystemFonts.MenuFont.FontFamily, 12F),
+ BorderStyle = BorderStyle.FixedSingle,
+ AutoSize = true
+ };
+
+ public RegLocationMenuItem TsiRegLocation { get; set; }
+
+ public StringRegRuleItem(RegRule rule, ItemInfo info) : base(info)
+ {
+ this.AddCtr(LblValue);
+ MyToolTip.SetToolTip(LblValue, info.Tip);
+ TsiRegLocation = new RegLocationMenuItem(this);
+ this.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { new ToolStripSeparator(), TsiRegLocation });
+ this.Rule = rule;
+ LblValue.Text = ItemValue;
+ LblValue.MouseDown += (sender, e) =>
+ {
+ using(InputDialog dlg = new InputDialog())
+ {
+ dlg.Title = AppString.Menu.ChangeText;
+ dlg.Text = ItemValue;
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ ItemValue = LblValue.Text = dlg.Text;
+ }
+ };
+ LblValue.TextChanged += (sender, e) => ItemValue = LblValue.Text;
+ }
+
+ public string RegPath => Rule.RegPath;
+ public string ValueName => Rule.ValueName;
+ public RegRule Rule { get; set; }
+
+ public string ItemValue
+ {
+ get => Registry.GetValue(Rule.RegPath, Rule.ValueName, null)?.ToString();
+ set => Registry.SetValue(Rule.RegPath, Rule.ValueName, value);
+ }
+ }
+
+ sealed class VisbleIniRuleItem : RuleItem, IChkVisibleItem
+ {
+ public struct IniRule
+ {
+ public string IniPath { get; set; }
+ public string Section { get; set; }
+ public string KeyName { get; set; }
+ public string TurnOnValue { get; set; }
+ public string TurnOffValue { get; set; }
+ }
+
+ public VisbleIniRuleItem(IniRule rule, ItemInfo info) : base(info)
+ {
+ this.Rule = rule;
+ this.IniWriter = new IniWriter(rule.IniPath);
+ ChkVisible = new VisibleCheckBox(this) { Checked = ItemVisible };
+ MyToolTip.SetToolTip(ChkVisible, info.Tip);
+ }
+
+ public IniRule Rule { get; set; }
+ public IniWriter IniWriter { get; set; }
+ public VisibleCheckBox ChkVisible { get; set; }
+ public bool ItemVisible
+ {
+ get => IniWriter.GetValue(Rule.Section, Rule.KeyName) == Rule.TurnOnValue;
+ set => IniWriter.SetValue(Rule.Section, Rule.KeyName, value ? Rule.TurnOnValue : Rule.TurnOffValue);
+ }
+ }
+
+ sealed class NumberIniRuleItem : RuleItem
+ {
+ public struct IniRule
+ {
+ public string IniPath { get; set; }
+ public string Section { get; set; }
+ public string KeyName { get; set; }
+ public int MaxValue { get; set; }
+ public int MinValue { get; set; }
+ public int DefaultValue { get; set; }
+ }
+
+ public NumberIniRuleItem(IniRule rule, ItemInfo info) : base(info)
+ {
+ this.AddCtr(NudValue);
+ this.Rule = rule;
+ this.IniWriter = new IniWriter(rule.IniPath);
+ MyToolTip.SetToolTip(NudValue, info.Tip);
+ NudValue.Maximum = rule.MaxValue;
+ NudValue.Minimum = rule.MinValue;
+ NudValue.ValueChanged += (sender, e) =>
+ {
+ if(NudValue.Value == Rule.DefaultValue) NudValue.ForeColor = Color.Red;
+ else NudValue.ForeColor = Color.Black;
+ this.ItemValue = (int)NudValue.Value;
+ };
+ NudValue.Value = ItemValue;
+ }
+
+ public IniRule Rule { get; set; }
+ public IniWriter IniWriter { get; set; }
+
+ readonly NumericUpDown NudValue = new NumericUpDown
+ {
+ Font = new Font(SystemFonts.MenuFont.FontFamily, 12F),
+ TextAlign = HorizontalAlignment.Center,
+ Width = 80.DpiZoom()
+ };
+
+ public int ItemValue
+ {
+ get
+ {
+ string value = IniWriter.GetValue(Rule.Section, Rule.KeyName);
+ if(value.IsNullOrWhiteSpace()) return Rule.DefaultValue;
+ int num = Convert.ToInt32(value);
+ if(num > Rule.MaxValue) return Rule.MaxValue;
+ if(num < Rule.MinValue) return Rule.MinValue;
+ else return num;
+ }
+ set
+ {
+ IniWriter.SetValue(Rule.Section, Rule.KeyName, value.ToString());
+ }
+ }
+ }
+
+ sealed class StringIniRuleItem : RuleItem
+ {
+ public struct IniRule
+ {
+ public string IniPath { get; set; }
+ public string Secation { get; set; }
+ public string KeyName { get; set; }
+ }
+
+
+ readonly Label LblValue = new Label
+ {
+ Font = new Font(SystemFonts.MenuFont.FontFamily, 12F),
+ BorderStyle = BorderStyle.FixedSingle,
+ AutoSize = true
+ };
+
+ public StringIniRuleItem(IniRule rule, ItemInfo info) : base(info)
+ {
+ this.Rule = rule;
+ this.IniWriter = new IniWriter(rule.IniPath);
+ this.AddCtr(LblValue);
+ MyToolTip.SetToolTip(LblValue, info.Tip);
+ LblValue.Text = ItemValue;
+ LblValue.MouseDown += (sender, e) =>
+ {
+ using(InputDialog dlg = new InputDialog())
+ {
+ dlg.Title = AppString.Menu.ChangeText;
+ dlg.Text = ItemValue;
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ ItemValue = LblValue.Text = dlg.Text;
+ }
+ };
+ LblValue.TextChanged += (sender, e) => ItemValue = LblValue.Text;
+ }
+
+ public IniRule Rule { get; set; }
+ public IniWriter IniWriter { get; set; }
+
+ public string ItemValue
+ {
+ get => IniWriter.GetValue(Rule.Secation, Rule.KeyName);
+ set => IniWriter.SetValue(Rule.Secation, Rule.KeyName, value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/SelectDialog.cs b/ContextMenuManager/Controls/SelectDialog.cs
new file mode 100644
index 0000000..ea83194
--- /dev/null
+++ b/ContextMenuManager/Controls/SelectDialog.cs
@@ -0,0 +1,147 @@
+using BluePointLilac.Methods;
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Windows.Forms;
+
+namespace ContextMenuManager.Controls
+{
+ class SelectDialog : CommonDialog
+ {
+ public string Title { get; set; }
+ public string Selected { get; set; }
+ public int SelectedIndex { get; private set; }
+ public string[] Items { get; set; }
+ public ComboBoxStyle DropDownStyle { get; set; } = ComboBoxStyle.DropDownList;
+
+ public override void Reset() { }
+
+ protected override bool RunDialog(IntPtr hwndOwner)
+ {
+ using(SelectForm frm = new SelectForm())
+ {
+ frm.Text = this.Title;
+ frm.Items = this.Items;
+ frm.Selected = this.Selected;
+ frm.DropDownStyle = this.DropDownStyle;
+ bool flag = frm.ShowDialog() == DialogResult.OK;
+ if(flag)
+ {
+ this.Selected = frm.Selected;
+ this.SelectedIndex = frm.SelectedIndex;
+ }
+ return flag;
+ }
+ }
+
+ sealed class SelectForm : Form
+ {
+ public SelectForm()
+ {
+ this.AcceptButton = btnOk;
+ this.CancelButton = btnCancel;
+ this.Font = SystemFonts.MenuFont;
+ this.ShowIcon = this.ShowInTaskbar = false;
+ this.MaximizeBox = this.MinimizeBox = false;
+ this.FormBorderStyle = FormBorderStyle.FixedSingle;
+ this.StartPosition = FormStartPosition.CenterParent;
+ this.InitializeComponents();
+ }
+
+ public string Selected
+ {
+ get => cmbItems.Text;
+ set => cmbItems.Text = value;
+ }
+
+ public string[] Items
+ {
+ get
+ {
+ string[] value = new string[cmbItems.Items.Count];
+ cmbItems.Items.CopyTo(value, 0);
+ return value;
+ }
+ set
+ {
+ cmbItems.Items.Clear();
+ cmbItems.Items.AddRange(value);
+ }
+ }
+
+ public ComboBoxStyle DropDownStyle
+ {
+ get => cmbItems.DropDownStyle;
+ set => cmbItems.DropDownStyle = value;
+ }
+
+ public int SelectedIndex => cmbItems.SelectedIndex;
+
+ readonly Button btnOk = new Button
+ {
+ DialogResult = DialogResult.OK,
+ Text = AppString.Dialog.Ok,
+ AutoSize = true
+ };
+ readonly Button btnCancel = new Button
+ {
+ DialogResult = DialogResult.Cancel,
+ Text = AppString.Dialog.Cancel,
+ AutoSize = true
+ };
+ readonly ComboBox cmbItems = new ComboBox
+ {
+ AutoCompleteMode = AutoCompleteMode.SuggestAppend,
+ AutoCompleteSource = AutoCompleteSource.ListItems,
+ DropDownHeight = 294.DpiZoom(),
+ ImeMode = ImeMode.Disable
+ };
+
+ private void InitializeComponents()
+ {
+ this.Controls.AddRange(new Control[] { cmbItems, btnOk, btnCancel });
+ int a = 20.DpiZoom();
+ cmbItems.Left = a;
+ cmbItems.Width = 85.DpiZoom();
+ cmbItems.Top = btnOk.Top = btnCancel.Top = a;
+ btnOk.Left = cmbItems.Right + a;
+ btnCancel.Left = btnOk.Right + a;
+ this.ClientSize = new Size(btnCancel.Right + a, btnCancel.Bottom + a);
+ }
+ }
+ }
+
+ sealed class FileExtensionDialog : SelectDialog
+ {
+ public string Extension
+ {
+ get => Selected;
+ set => Selected = value;
+ }
+
+ public FileExtensionDialog()
+ {
+ this.Title = AppString.Item.SelectExtension;
+ this.DropDownStyle = ComboBoxStyle.DropDown;
+ List items = new List();
+ 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;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/SendToItem.cs b/ContextMenuManager/Controls/SendToItem.cs
index c7589cc..bc76d0c 100644
--- a/ContextMenuManager/Controls/SendToItem.cs
+++ b/ContextMenuManager/Controls/SendToItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using Microsoft.Win32;
using System.Drawing;
@@ -8,8 +8,8 @@
namespace ContextMenuManager.Controls
{
- sealed class SendToItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem, ITsiTextItem,
- ITsiIconItem, ITsiWebSearchItem, ITsiFilePathItem, ITsiDeleteItem
+ sealed class SendToItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem, ITsiTextItem, ITsiAdministratorItem,
+ ITsiIconItem, ITsiWebSearchItem, ITsiFilePathItem, ITsiDeleteItem, ITsiShortcutCommandItem
{
public SendToItem(string filePath)
{
@@ -24,15 +24,14 @@ public string FilePath
set
{
filePath = value;
- if(IsShortcut) this.Shortcut.FullName = value;
+ if(IsShortcut) this.Shortcut = new WshShortcut(value);
this.Text = this.ItemText;
this.Image = this.ItemIcon.ToBitmap();
ChkVisible.Checked = this.ItemVisible;
}
}
- private WshShortcut Shortcut = new WshShortcut();
- private string FileName => Path.GetFileName(FilePath);
+ public WshShortcut Shortcut { get; private set; }
private string FileExtension => Path.GetExtension(FilePath);
private bool IsShortcut => FileExtension.ToLower() == ".lnk";
public string SearchText => $"{AppString.SideBar.SendTo} {Text}";
@@ -41,13 +40,25 @@ public string ItemFilePath
{
get
{
- if(IsShortcut) return Shortcut.TargetPath;
+ string path = null;
+ if(IsShortcut) path = Shortcut.TargetPath;
else
{
- string guidPath = Registry.ClassesRoot.OpenSubKey(FileExtension)?.GetValue("")?.ToString();
- if(string.IsNullOrEmpty(guidPath)) return null;
- else return Registry.ClassesRoot.OpenSubKey($@"{guidPath}\InProcServer32")?.GetValue("")?.ToString();
+ using(RegistryKey root = Registry.ClassesRoot)
+ using(RegistryKey extKey = root.OpenSubKey(FileExtension))
+ {
+ string guidPath = extKey?.GetValue("")?.ToString();
+ if(!string.IsNullOrEmpty(guidPath))
+ {
+ using(RegistryKey ipsKey = root.OpenSubKey($@"{guidPath}\InProcServer32"))
+ {
+ path = ipsKey?.GetValue("")?.ToString();
+ }
+ }
+ }
}
+ if(!File.Exists(path) && !Directory.Exists(path)) path = FilePath;
+ return path;
}
}
@@ -67,17 +78,16 @@ public string ItemText
{
get
{
- string name = SendToList.DesktopIniReader.GetValue("LocalizedFileNames", FileName);
- name = ResourceString.GetDirectString(name);
+ string name = DesktopIni.GetLocalizedFileNames(FilePath, true);
if(name == string.Empty) name = Path.GetFileNameWithoutExtension(FilePath);
if(name == string.Empty) name = FileExtension;
return name;
}
set
{
- SendToList.DesktopIniWriter.SetValue("LocalizedFileNames", FileName, value);
+ DesktopIni.SetLocalizedFileNames(FilePath, value);
this.Text = ResourceString.GetDirectString(value);
- ExplorerRestarter.NeedRestart = true;
+ ExplorerRestarter.Show();
}
}
@@ -87,12 +97,14 @@ public Icon ItemIcon
{
Icon icon = ResourceIcon.GetIcon(IconLocation, out string iconPath, out int iconIndex);
IconPath = iconPath; IconIndex = iconIndex;
- if(icon == null && IsShortcut)
+ if(icon != null) return icon;
+ if(IsShortcut)
{
- if(File.Exists(Shortcut.TargetPath)) icon = Icon.ExtractAssociatedIcon(Shortcut.TargetPath);
- else if(Directory.Exists(Shortcut.TargetPath)) icon = ResourceIcon.GetFolderIcon(Shortcut.TargetPath);
+ string path = ItemFilePath;
+ if(File.Exists(path)) icon = ResourceIcon.GetExtensionIcon(path);
+ else if(Directory.Exists(path)) icon = ResourceIcon.GetFolderIcon(path);
}
- icon = icon ?? ResourceIcon.GetExtensionIcon(FileExtension);
+ else icon = ResourceIcon.GetExtensionIcon(FileExtension);
return icon;
}
}
@@ -105,7 +117,7 @@ public string IconLocation
if(IsShortcut)
{
location = Shortcut.IconLocation;
- if(location.StartsWith(",")) location = $"{Shortcut.TargetPath}{location}";
+ if(location==",0") location = Shortcut.TargetPath;
}
else
{
@@ -128,7 +140,7 @@ public string IconLocation
{
if(IsShortcut)
{
- Shortcut.IconLocation = value;
+ Shortcut.IconLocation = $"{this.IconPath},{this.IconIndex}";
Shortcut.Save();
}
else
@@ -142,7 +154,7 @@ public string IconLocation
string regPath = $@"{root.Name}\{guidPath}\DefaultIcon";
RegTrustedInstaller.TakeRegTreeOwnerShip(regPath);
Registry.SetValue(regPath, "", value);
- ExplorerRestarter.NeedRestart = true;
+ ExplorerRestarter.Show();
}
}
}
@@ -160,8 +172,10 @@ public string IconLocation
public FilePropertiesMenuItem TsiFileProperties { get; set; }
public FileLocationMenuItem TsiFileLocation { get; set; }
public DeleteMeMenuItem TsiDeleteMe { get; set; }
+ public ShortcutCommandMenuItem TsiChangeCommand { get; set; }
+ public RunAsAdministratorItem TsiAdministrator { get; set; }
+
readonly ToolStripMenuItem TsiDetails = new ToolStripMenuItem(AppString.Menu.Details);
- readonly ToolStripMenuItem TsiChangeCommand = new ToolStripMenuItem(AppString.Menu.ChangeCommand);
private void InitializeComponents()
{
@@ -169,40 +183,36 @@ private void InitializeComponents()
ChkVisible = new VisibleCheckBox(this);
TsiChangeText = new ChangeTextMenuItem(this);
TsiChangeIcon = new ChangeIconMenuItem(this);
+ TsiChangeCommand = new ShortcutCommandMenuItem(this);
+ TsiAdministrator = new RunAsAdministratorItem(this);
TsiSearch = new WebSearchMenuItem(this);
TsiFileLocation = new FileLocationMenuItem(this);
TsiFileProperties = new FilePropertiesMenuItem(this);
TsiDeleteMe = new DeleteMeMenuItem(this);
ContextMenuStrip.Items.AddRange(new ToolStripItem[] { TsiChangeText, new ToolStripSeparator(),
- TsiChangeIcon, new ToolStripSeparator(), TsiDetails, new ToolStripSeparator(), TsiDeleteMe });
+ TsiChangeIcon, new ToolStripSeparator(), TsiAdministrator, new ToolStripSeparator(),
+ TsiDetails, new ToolStripSeparator(), TsiDeleteMe });
TsiDetails.DropDownItems.AddRange(new ToolStripItem[] { TsiSearch, new ToolStripSeparator(),
TsiChangeCommand, TsiFileProperties, TsiFileLocation });
ContextMenuStrip.Opening += (sender, e) => TsiChangeCommand.Visible = IsShortcut;
- TsiChangeCommand.Click += (sender, e) => ChangeCommand();
-
- }
-
- private void ChangeCommand()
- {
- using(CommandDialog dlg = new CommandDialog())
+ TsiChangeCommand.Click += (sender, e) =>
{
- dlg.Command = Shortcut.TargetPath;
- dlg.Arguments = Shortcut.Arguments;
- if(dlg.ShowDialog() != DialogResult.OK) return;
- Shortcut.TargetPath = dlg.Command;
- Shortcut.Arguments = dlg.Arguments;
- Shortcut.Save();
- }
+ if(TsiChangeCommand.ChangeCommand(Shortcut))
+ {
+ Image = ItemIcon.ToBitmap();
+ }
+ };
}
public void DeleteMe()
{
File.Delete(this.FilePath);
- SendToList.DesktopIniWriter.DeleteKey("LocalizedFileNames", FileName);
+ DesktopIni.DeleteLocalizedFileNames(FilePath);
+ this.Shortcut.Dispose();
this.Dispose();
}
}
diff --git a/ContextMenuManager/Controls/SendToList.cs b/ContextMenuManager/Controls/SendToList.cs
index a56aa26..9b2ab69 100644
--- a/ContextMenuManager/Controls/SendToList.cs
+++ b/ContextMenuManager/Controls/SendToList.cs
@@ -1,7 +1,6 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System;
-using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
@@ -10,23 +9,19 @@ namespace ContextMenuManager.Controls
sealed class SendToList : MyList
{
public static readonly string SendToPath = Environment.ExpandEnvironmentVariables(@"%AppData%\Microsoft\Windows\SendTo");
- public static readonly string DesktopIniPath = $@"{SendToPath}\desktop.ini";
- public static IniWriter DesktopIniWriter = new IniWriter(DesktopIniPath);
- public static IniReader DesktopIniReader;
public void LoadItems()
{
- DesktopIniReader = new IniReader(DesktopIniPath);
- Array.ForEach(new DirectoryInfo(SendToPath).GetFiles(), fi =>
+ Array.ForEach(Directory.GetFiles(SendToPath), path =>
{
- if(fi.Name.ToLower() != "desktop.ini")
- this.AddItem(new SendToItem(fi.FullName));
+ if(Path.GetFileName(path).ToLower() != "desktop.ini")
+ this.AddItem(new SendToItem(path));
});
this.SortItemByText();
this.AddNewItem();
this.AddDirItem();
- this.AddItem(new RegRuleItem(RegRuleItem.SendToDrive));
- this.AddItem(new RegRuleItem(RegRuleItem.DeferBuildSendTo));
+ this.AddItem(new VisibleRegRuleItem(VisibleRegRuleItem.SendToDrive));
+ this.AddItem(new VisibleRegRuleItem(VisibleRegRuleItem.DeferBuildSendTo));
}
private void AddNewItem()
@@ -35,10 +30,21 @@ private void AddNewItem()
this.InsertItem(newItem, 0);
newItem.AddNewItem += (sender, e) =>
{
- using(NewSendToDialog dlg = new NewSendToDialog())
+ using(NewLnkFileDialog dlg = new NewLnkFileDialog())
{
- if(dlg.ShowDialog() == DialogResult.OK)
- this.InsertItem(new SendToItem(dlg.FilePath), 2);
+ dlg.FileFilter = $"{AppString.Dialog.Program}|*.exe;*.bat;*.cmd;*.vbs;*.vbe;*.js;*.jse;*.wsf";
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ string lnkPath = $@"{SendToPath}\{ObjectPath.RemoveIllegalChars(dlg.ItemText)}.lnk";
+ lnkPath = ObjectPath.GetNewPathWithIndex(lnkPath, ObjectPath.PathType.File);
+ using(WshShortcut shortcut = new WshShortcut(lnkPath))
+ {
+ shortcut.TargetPath = dlg.ItemFilePath;
+ shortcut.WorkingDirectory = Path.GetDirectoryName(dlg.ItemFilePath);
+ shortcut.Arguments = dlg.Arguments;
+ shortcut.Save();
+ }
+ DesktopIni.SetLocalizedFileNames(lnkPath, dlg.ItemText);
+ this.InsertItem(new SendToItem(lnkPath), 2);
}
};
}
@@ -52,7 +58,7 @@ private void AddDirItem()
};
PictureButton btnPath = new PictureButton(AppImage.Open);
MyToolTip.SetToolTip(btnPath, AppString.Menu.FileLocation);
- btnPath.MouseDown += (sender, e) => Process.Start(SendToPath);
+ btnPath.MouseDown += (sender, e) => ExternalProgram.JumpExplorer(SendToPath);
item.AddCtr(btnPath);
item.SetNoClickEvent();
this.InsertItem(item, 1);
diff --git a/ContextMenuManager/Controls/ShellExItem.cs b/ContextMenuManager/Controls/ShellExItem.cs
index 58cadf7..f037882 100644
--- a/ContextMenuManager/Controls/ShellExItem.cs
+++ b/ContextMenuManager/Controls/ShellExItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using Microsoft.Win32;
using System;
@@ -8,15 +8,16 @@
namespace ContextMenuManager.Controls
{
- sealed class ShellExItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem,
+ sealed class ShellExItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem, IFoldSubItem,
ITsiWebSearchItem, ITsiFilePathItem, ITsiRegPathItem, ITsiRegDeleteItem, ITsiRegExportItem
{
- public static Dictionary GetPathAndGuids(string shellExPath)
+ public static Dictionary GetPathAndGuids(string shellExPath, bool isDragDrop = false)
{
Dictionary dic = new Dictionary();
- foreach(string cmhPart in CmhParts)
+ string[] parts = isDragDrop ? DdhParts : CmhParts;
+ foreach(string part in parts)
{
- using(RegistryKey cmKey = RegistryEx.GetRegistryKey($@"{shellExPath}\{cmhPart}"))
+ using(RegistryKey cmKey = RegistryEx.GetRegistryKey($@"{shellExPath}\{part}"))
{
if(cmKey == null) continue;
foreach(string keyName in cmKey.GetSubKeyNames())
@@ -34,6 +35,7 @@ sealed class ShellExItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem,
return dic;
}
+ public static readonly string[] DdhParts = { "DragDropHandlers", "-DragDropHandlers" };
public static readonly string[] CmhParts = { "ContextMenuHandlers", "-ContextMenuHandlers" };
private const string LnkOpenGuid = "00021401-0000-0000-c000-000000000046";
@@ -57,26 +59,39 @@ public string RegPath
}
}
+ public string ValueName => DefaultValue;
public Guid Guid { get; set; }
public string SearchText => Text;
public string ItemFilePath => GuidInfo.GetFilePath(Guid);
private string KeyName => RegistryEx.GetKeyName(RegPath);
- private string ShellExPath => RegistryEx.GetParentPath(RegistryEx.GetParentPath(RegPath));
- private string CmhKeyName => RegistryEx.GetKeyName(RegistryEx.GetParentPath(RegPath));
+ private string ParentPath => RegistryEx.GetParentPath(RegPath);
+ private string ShellExPath => RegistryEx.GetParentPath(ParentPath);
+ private string ParentKeyName => RegistryEx.GetKeyName(ParentPath);
private string DefaultValue => Registry.GetValue(RegPath, "", null)?.ToString();
public string ItemText => GuidInfo.GetText(Guid) ?? ((Guid.ToString("B") == KeyName) ? DefaultValue : KeyName);
- private string BackupPath => $@"{ShellExPath}\{(ItemVisible ? CmhParts[1] : CmhParts[0])}\{KeyName}";
private GuidInfo.IconLocation IconLocation => GuidInfo.GetIconLocation(this.Guid);
private bool IsOpenLnkItem => Guid.ToString() == LnkOpenGuid;
- private bool TryProtectOpenItem => IsOpenLnkItem && AppConfig.ProtectOpenItem && MessageBoxEx.Show
- (AppString.MessageBox.PromptIsOpenItem, MessageBoxButtons.YesNo) != DialogResult.Yes;
+ public bool IsDragDropItem => ParentKeyName.EndsWith(DdhParts[0], StringComparison.OrdinalIgnoreCase);
+
+ private string BackupPath
+ {
+ get
+ {
+ string[] parts = IsDragDropItem ? DdhParts : CmhParts;
+ return $@"{ShellExPath}\{(ItemVisible ? parts[1] : parts[0])}\{KeyName}";
+ }
+ }
public bool ItemVisible
{
- get => CmhKeyName.Equals(CmhParts[0], StringComparison.OrdinalIgnoreCase);
+ get
+ {
+ string[] parts = IsDragDropItem ? DdhParts : CmhParts;
+ return ParentKeyName.Equals(parts[0], StringComparison.OrdinalIgnoreCase);
+ }
set
{
- if(!value && TryProtectOpenItem) return;
+ if(!value && TryProtectOpenItem()) return;
try
{
RegistryEx.MoveTo(RegPath, BackupPath);
@@ -98,6 +113,7 @@ public bool ItemVisible
public RegLocationMenuItem TsiRegLocation { get; set; }
public DeleteMeMenuItem TsiDeleteMe { get; set; }
public RegExportMenuItem TsiRegExport { get; set; }
+ public IFoldGroupItem FoldGroupItem { get; set; }
readonly ToolStripMenuItem TsiDetails = new ToolStripMenuItem(AppString.Menu.Details);
readonly ToolStripMenuItem TsiHandleGuid = new ToolStripMenuItem(AppString.Menu.HandleGuid);
@@ -151,7 +167,7 @@ private void BlockGuid()
Registry.SetValue(path, this.Guid.ToString("B"), string.Empty);
}
}
- ExplorerRestarter.NeedRestart = true;
+ ExplorerRestarter.Show();
}
private void AddGuidDic()
@@ -240,6 +256,13 @@ private void RefreshMenuItem()
}
}
+ private bool TryProtectOpenItem()
+ {
+ if(!IsOpenLnkItem) return false;
+ if(!AppConfig.ProtectOpenItem) return false;
+ return MessageBoxEx.Show(AppString.MessageBox.PromptIsOpenItem, MessageBoxButtons.YesNo) != DialogResult.Yes;
+ }
+
public void DeleteMe()
{
try
diff --git a/ContextMenuManager/Controls/ShellExecuteDialog.cs b/ContextMenuManager/Controls/ShellExecuteDialog.cs
new file mode 100644
index 0000000..aaf6525
--- /dev/null
+++ b/ContextMenuManager/Controls/ShellExecuteDialog.cs
@@ -0,0 +1,162 @@
+using BluePointLilac.Methods;
+using System;
+using System.Drawing;
+using System.IO;
+using System.Windows.Forms;
+
+namespace ContextMenuManager.Controls
+{
+ sealed class ShellExecuteDialog : CommonDialog
+ {
+ public string Verb { get; set; }
+ public int WindowStyle { get; set; }
+ public override void Reset() { }
+
+ protected override bool RunDialog(IntPtr hwndOwner)
+ {
+ using(ShellExecuteForm frm = new ShellExecuteForm())
+ {
+ bool flag = frm.ShowDialog() == DialogResult.OK;
+ if(flag)
+ {
+ this.Verb = frm.Verb;
+ this.WindowStyle = frm.WindowStyle;
+ }
+ return flag;
+ }
+ }
+
+ public static string GetCommand(string fileName, string arguments, string verb, int windowStyle, string directory = null)
+ {
+ arguments = arguments.Replace("\"", "\"\"");
+ if(directory == null)
+ {
+ ObjectPath.GetFullFilePath(fileName, out string filePath);
+ directory = Path.GetDirectoryName(filePath);
+ }
+ return "mshta vbscript:createobject(\"shell.application\").shellexecute" +
+ $"(\"{fileName}\",\"{arguments}\",\"{directory}\",\"{verb}\",{windowStyle})(close)";
+ }
+
+ sealed class ShellExecuteForm : Form
+ {
+ private const string ApiInfoUrl = "https://docs.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea";
+ private static readonly string[] Verbs = new[] { "open", "runas", "edit", "print", "find", "explore" };
+ public ShellExecuteForm()
+ {
+ this.Text = "ShellExecute";
+ this.Font = SystemFonts.MenuFont;
+ this.FormBorderStyle = FormBorderStyle.FixedSingle;
+ this.StartPosition = FormStartPosition.CenterParent;
+ this.ShowIcon = ShowInTaskbar = MaximizeBox = MinimizeBox = false;
+ this.HelpButton = true;
+ this.HelpButtonClicked += (sender, e) => ExternalProgram.OpenUrl(ApiInfoUrl);
+ this.InitializeComponents();
+ }
+ public string Verb { get; set; }
+ public int WindowStyle { get; set; }
+
+ readonly RadioButton[] rdoVerbs = new RadioButton[6];
+ readonly GroupBox grpVerb = new GroupBox { Text = "Verb" };
+ readonly Label lblStyle = new Label
+ {
+ Text = "WindowStyle",
+ AutoSize = true
+ };
+ readonly NumericUpDown nudStyle = new NumericUpDown
+ {
+ TextAlign = HorizontalAlignment.Center,
+ Width = 80.DpiZoom(),
+ Maximum = 10,
+ Minimum = 0,
+ Value = 1
+ };
+ readonly Button btnOk = new Button
+ {
+ Text = AppString.Dialog.Ok,
+ DialogResult = DialogResult.OK,
+ AutoSize = true
+ };
+ readonly Button btnCancel = new Button
+ {
+ Text = AppString.Dialog.Cancel,
+ DialogResult = DialogResult.Cancel,
+ AutoSize = true
+ };
+
+ private void InitializeComponents()
+ {
+ this.Controls.AddRange(new Control[] { grpVerb, lblStyle, nudStyle, btnOk, btnCancel });
+ int a = 10.DpiZoom();
+ int b = 2 * a;
+ for(int i = 0; i < 6; i++)
+ {
+ rdoVerbs[i] = new RadioButton
+ {
+ Text = Verbs[i],
+ AutoSize = true,
+ Parent = grpVerb,
+ Location = new Point(a, b + a)
+ };
+ if(i > 0) rdoVerbs[i].Left += rdoVerbs[i - 1].Right;
+ }
+ rdoVerbs[0].Checked = true;
+ grpVerb.Width = rdoVerbs[5].Right + a;
+ grpVerb.Height = rdoVerbs[5].Bottom + b;
+ lblStyle.Left = grpVerb.Left = grpVerb.Top = b;
+ btnOk.Top = btnCancel.Top = lblStyle.Top = nudStyle.Top = grpVerb.Bottom + b;
+ nudStyle.Left = lblStyle.Right + b;
+ btnCancel.Left = grpVerb.Right - btnCancel.Width;
+ btnOk.Left = btnCancel.Left - btnOk.Width - b;
+ this.ClientSize = new Size(btnCancel.Right + b, btnCancel.Bottom + b);
+ btnOk.Click += (sender, e) =>
+ {
+ for(int i = 0; i < 6; i++)
+ {
+ if(rdoVerbs[i].Checked)
+ {
+ this.Verb = rdoVerbs[i].Text;
+ break;
+ }
+ }
+ this.WindowStyle = (int)nudStyle.Value;
+ };
+ }
+ }
+ }
+
+ sealed class ShellExecuteCheckBox : CheckBox
+ {
+ public ShellExecuteCheckBox()
+ {
+ this.Text = "ShellExecute";
+ this.AutoSize = true;
+ this.Font = new Font(SystemFonts.DialogFont.FontFamily, 8F);
+ }
+
+ public string Verb { get; set; }
+ public int WindowStyle { get; set; }
+
+ readonly ToolTip ttpInfo = new ToolTip();
+
+ protected override void OnClick(EventArgs e)
+ {
+ if(this.Checked)
+ {
+ this.Checked = false;
+ ttpInfo.RemoveAll();
+ }
+ else
+ {
+ using(ShellExecuteDialog dlg = new ShellExecuteDialog())
+ {
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ this.Verb = dlg.Verb;
+ this.WindowStyle = dlg.WindowStyle;
+ this.Checked = true;
+ ttpInfo.SetToolTip(this, $"Verb = {Verb}\nWindowStyle = {WindowStyle}");
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/ShellItem.cs b/ContextMenuManager/Controls/ShellItem.cs
index c2bcca7..58ca6a3 100644
--- a/ContextMenuManager/Controls/ShellItem.cs
+++ b/ContextMenuManager/Controls/ShellItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using Microsoft.Win32;
using System;
@@ -16,6 +16,8 @@ class ShellItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem, ITsiTextItem, I
/// Shell公共引用子菜单注册表项路径
public const string CommandStorePath = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell";
+ private const string OpenInNewWindowPath = @"HKEY_CLASSES_ROOT\Folder\shell\opennewwindow";
+
/// 系统原有Shell公共子菜单项名
public static readonly string[] SysStoreItemNames = { "Windows.aboutWindows", "Windows.AddColumns",
"Windows.AddDevice", "Windows.AddMediaServer", "Windows.AddNetworkLocation", "Windows.AddPrinter",
@@ -119,18 +121,28 @@ public string RegPath
}
}
+ public string ValueName => null;
public string SearchText => Text;
private string CommandPath => $@"{RegPath}\command";
public string KeyName => RegistryEx.GetKeyName(RegPath);
- private bool IsMultiItem => Registry.GetValue(RegPath, "SubCommands", null) != null;
protected virtual bool IsSubItem => false;
private bool IsOpenItem => KeyName.ToLower() == "open";
- private bool TryProtectOpenItem => IsOpenItem && AppConfig.ProtectOpenItem && MessageBoxEx.Show(AppString.MessageBox.PromptIsOpenItem,
- MessageBoxButtons.YesNo) != DialogResult.Yes;
public string ItemFilePath => GuidInfo.GetFilePath(Guid) ?? ObjectPath.ExtractFilePath(ItemCommand);
private bool HasIcon => !IconLocation.IsNullOrWhiteSpace() || HasLUAShield;
+ private bool IsMultiItem
+ {
+ get
+ {
+ object value = Registry.GetValue(RegPath, "SubCommands", null);
+ if(value != null) return true;
+ value = Registry.GetValue(RegPath, "ExtendedSubCommandsKey", null);
+ if(!string.IsNullOrEmpty(value?.ToString())) return true;
+ return false;
+ }
+ }
+
private bool OnlyInExplorer
{
get => Registry.GetValue(RegPath, "OnlyInBrowserWindow", null) != null;
@@ -138,7 +150,7 @@ private bool OnlyInExplorer
{
if(value)
{
- if(TryProtectOpenItem) return;
+ if(TryProtectOpenItem()) return;
Registry.SetValue(RegPath, "OnlyInBrowserWindow", "");
}
else RegistryEx.DeleteValue(RegPath, "OnlyInBrowserWindow");
@@ -152,7 +164,7 @@ private bool OnlyWithShift
{
if(value)
{
- if(TryProtectOpenItem) return;
+ if(TryProtectOpenItem()) return;
Registry.SetValue(RegPath, "Extended", "");
}
else RegistryEx.DeleteValue(RegPath, "Extended");
@@ -179,6 +191,16 @@ private bool NeverDefault
}
}
+ private bool ShowAsDisabledIfHidden
+ {
+ get => Registry.GetValue(RegPath, "ShowAsDisabledIfHidden", null) != null;
+ set
+ {
+ if(value) Registry.SetValue(RegPath, "ShowAsDisabledIfHidden", "");
+ else RegistryEx.DeleteValue(RegPath, "ShowAsDisabledIfHidden");
+ }
+ }
+
private Positions ItemPosition
{
get
@@ -234,24 +256,38 @@ public bool ItemVisible
{
try
{
- if(value)
+ void DeleteSomeValues()
{
- RegistryEx.DeleteValue(RegPath, "CommandFlags");
- RegistryEx.DeleteValue(RegPath, "HideBasedOnVelocityId");
RegistryEx.DeleteValue(RegPath, "LegacyDisable");
RegistryEx.DeleteValue(RegPath, "ProgrammaticAccessOnly");
+ if(WindowsOsVersion.IsAfterVista && Convert.ToInt32(Registry.GetValue(RegPath, "CommandFlags", 0)) % 16 >= 8)
+ {
+ RegistryEx.DeleteValue(RegPath, "CommandFlags");
+ }
+ };
+
+ if(value)
+ {
+ RegistryEx.DeleteValue(RegPath, "HideBasedOnVelocityId");
+ DeleteSomeValues();
}
else
{
- if(TryProtectOpenItem) return;
+ if(TryProtectOpenItem()) return;
if(!IsSubItem)
{
- Registry.SetValue(RegPath, "LegacyDisable", string.Empty);
- Registry.SetValue(RegPath, "ProgrammaticAccessOnly", string.Empty);
+ //当LegaryDisable键值作用于文件夹-"在新窗口中打开"时
+ //会导致点击任务栏explorer图标和 Win+E 快捷键错误访问
+ if(!RegPath.StartsWith(OpenInNewWindowPath, StringComparison.OrdinalIgnoreCase))
+ {
+ Registry.SetValue(RegPath, "LegacyDisable", "");
+ }
+ Registry.SetValue(RegPath, "ProgrammaticAccessOnly", "");
}
- else if(WindowsOsVersion.IsAfterOrEqualWin10_1703)
+ if(WindowsOsVersion.IsAfterOrEqualWin10_1703)
{
Registry.SetValue(RegPath, "HideBasedOnVelocityId", 0x639bc8);
+ if(ShowAsDisabledIfHidden) DeleteSomeValues();
}
else
{
@@ -307,7 +343,7 @@ public string ItemCommand
}
set
{
- if(TryProtectOpenItem) return;
+ if(TryProtectOpenItem()) return;
Registry.SetValue(CommandPath, "", value);
if(!this.HasIcon) this.Image = this.ItemIcon.ToBitmap().ToTransparent();
}
@@ -365,7 +401,11 @@ private Guid Guid
get
{
string value = Registry.GetValue(CommandPath, "DelegateExecute", null)?.ToString();
- GuidEx.TryParse(value, out Guid guid);
+ if(!GuidEx.TryParse(value, out Guid guid))
+ {
+ value = Registry.GetValue($@"{RegPath}\DropTarget", "CLSID", null)?.ToString();
+ GuidEx.TryParse(value, out guid);
+ }
return guid;
}
}
@@ -382,6 +422,7 @@ private Guid Guid
public DeleteMeMenuItem TsiDeleteMe { get; set; }
public RegExportMenuItem TsiRegExport { get; set; }
+ protected readonly PictureButton BtnSubItems = new PictureButton(AppImage.SubItems);
protected readonly ToolStripMenuItem TsiOtherAttributes = new ToolStripMenuItem(AppString.Menu.OtherAttributes);
readonly ToolStripMenuItem TsiItemIcon = new ToolStripMenuItem(AppString.Menu.ItemIcon);
readonly ToolStripMenuItem TsiDeleteIcon = new ToolStripMenuItem(AppString.Menu.DeleteIcon);
@@ -395,7 +436,7 @@ private Guid Guid
readonly ToolStripMenuItem TsiNoWorkDir = new ToolStripMenuItem(AppString.Menu.NoWorkingDirectory);
readonly ToolStripMenuItem TsiNeverDefault = new ToolStripMenuItem(AppString.Menu.NeverDefault);
readonly ToolStripMenuItem TsiDetails = new ToolStripMenuItem(AppString.Menu.Details);
- protected readonly PictureButton BtnSubItems = new PictureButton(AppImage.SubItems);
+ readonly ToolStripMenuItem TsiShowAsDisabled = new ToolStripMenuItem(AppString.Menu.ShowAsDisabledIfHidden);
private void InitializeComponents()
{
@@ -418,7 +459,8 @@ private void InitializeComponents()
TsiPosition.DropDownItems.AddRange(new ToolStripItem[] { TsiDefault, TsiSetTop, TsiSetBottom });
- TsiOtherAttributes.DropDownItems.AddRange(new ToolStripItem[] { TsiOnlyWithShift, TsiOnlyInExplorer, TsiNoWorkDir, TsiNeverDefault });
+ TsiOtherAttributes.DropDownItems.AddRange(new ToolStripItem[] { TsiOnlyWithShift, TsiOnlyInExplorer,
+ TsiNoWorkDir, TsiNeverDefault, TsiShowAsDisabled });
TsiDetails.DropDownItems.AddRange(new ToolStripItem[] { TsiSearch, new ToolStripSeparator(),
TsiChangeCommand, TsiFileProperties, TsiFileLocation, TsiRegLocation, TsiRegExport});
@@ -431,6 +473,7 @@ private void InitializeComponents()
TsiOnlyWithShift.Click += (sender, e) => this.OnlyWithShift = !TsiOnlyWithShift.Checked;
TsiNoWorkDir.Click += (sender, e) => this.NoWorkingDirectory = !TsiNoWorkDir.Checked;
TsiNeverDefault.Click += (sender, e) => this.NeverDefault = !TsiNeverDefault.Checked;
+ TsiShowAsDisabled.Click += (sender, e) => SetDisabled(!TsiShowAsDisabled.Checked);
ContextMenuStrip.Opening += (sender, e) => RefreshMenuItem();
BtnSubItems.MouseDown += (sender, e) => ShowSubItems();
TsiShieldIcon.Click += (sender, e) => UseShieldIcon();
@@ -448,19 +491,34 @@ private void DeleteIcon()
private void UseShieldIcon()
{
bool flag = this.HasLUAShield = TsiShieldIcon.Checked = !TsiShieldIcon.Checked;
- if(flag && IconLocation == null)
+ if(IconLocation == null)
{
- this.Image = AppImage.Shield;
- this.IconPath = "imageres.dll";
- this.IconIndex = -78;
+ if(flag)
+ {
+ this.Image = AppImage.Shield;
+ this.IconPath = "imageres.dll";
+ this.IconIndex = -78;
+ }
+ else
+ {
+ this.Image = this.Image.ToTransparent();
+ }
}
}
+ private void SetDisabled(bool flag)
+ {
+ this.ShowAsDisabledIfHidden = flag;
+ if(!ItemVisible && flag) ItemVisible = false;
+ }
+
private void RefreshMenuItem()
{
TsiOnlyWithShift.Visible = !IsSubItem;
TsiDeleteMe.Enabled = !(IsOpenItem && AppConfig.ProtectOpenItem);
TsiNoWorkDir.Checked = this.NoWorkingDirectory;
+ TsiShowAsDisabled.Visible = WindowsOsVersion.IsAfterOrEqualWin10_1703;
+ TsiShowAsDisabled.Checked = this.ShowAsDisabledIfHidden;
TsiChangeCommand.Visible = !IsMultiItem && Guid.Equals(Guid.Empty);
if(!this.IsSubItem) TsiOnlyWithShift.Checked = this.OnlyWithShift;
@@ -525,6 +583,13 @@ private void ShowSubItems()
}
}
+ private bool TryProtectOpenItem()
+ {
+ if(!IsOpenItem) return false;
+ if(!AppConfig.ProtectOpenItem) return false;
+ return MessageBoxEx.Show(AppString.MessageBox.PromptIsOpenItem, MessageBoxButtons.YesNo) != DialogResult.Yes;
+ }
+
public virtual void DeleteMe()
{
try
diff --git a/ContextMenuManager/Controls/ShellList.cs b/ContextMenuManager/Controls/ShellList.cs
index 285b957..910f5fc 100644
--- a/ContextMenuManager/Controls/ShellList.cs
+++ b/ContextMenuManager/Controls/ShellList.cs
@@ -1,11 +1,11 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
+using ContextMenuManager.Controls.Interfaces;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
-using System.Threading;
using System.Windows.Forms;
namespace ContextMenuManager.Controls
@@ -24,49 +24,76 @@ sealed class ShellList : MyList
public const string MENUPATH_LIBRARY = @"HKEY_CLASSES_ROOT\LibraryFolder";//库
public const string MENUPATH_LIBRARY_BACKGROUND = @"HKEY_CLASSES_ROOT\LibraryFolder\Background";//库背景
public const string MENUPATH_LIBRARY_USER = @"HKEY_CLASSES_ROOT\UserLibraryFolder";//用户库
- public const string MENUPATH_LNKFILE = @"HKEY_CLASSES_ROOT\lnkfile";//快捷方式
- public const string MENUPATH_EXEFILE = @"HKEY_CLASSES_ROOT\exefile";//可执行文件
- public const string MENUPATH_SYSLNKFILE = @"HKEY_CLASSES_ROOT\SystemFileAssociations\.lnk";//快捷方式
- public const string MENUPATH_SYSEXEFILE = @"HKEY_CLASSES_ROOT\SystemFileAssociations\.exe";//可执行文件
public const string MENUPATH_UWPLNK = @"HKEY_CLASSES_ROOT\Launcher.ImmersiveApplication";//UWP快捷方式
public const string MENUPATH_UNKNOWN = @"HKEY_CLASSES_ROOT\Unknown";//未知格式
- public const string MENUPATH_TEXT = @"HKEY_CLASSES_ROOT\SystemFileAssociations\text";//通用文本文件
- public const string MENUPATH_DOCUMENT = @"HKEY_CLASSES_ROOT\SystemFileAssociations\document";//通用文档文件
- public const string MENUPATH_IMAGE = @"HKEY_CLASSES_ROOT\SystemFileAssociations\image";//通用图像文件
- public const string MENUPATH_VIDEO = @"HKEY_CLASSES_ROOT\SystemFileAssociations\video";//通用视频文件
- public const string MENUPATH_AUDIO = @"HKEY_CLASSES_ROOT\SystemFileAssociations\audio";//通用音频文件
- public const string MENUPATH_DIRECTORY_IMAGE = @"HKEY_CLASSES_ROOT\SystemFileAssociations\Directory.Image";//通用图像文件目录
- public const string MENUPATH_DIRECTORY_VIDEO = @"HKEY_CLASSES_ROOT\SystemFileAssociations\Directory.Video";//通用视频文件目录
- public const string MENUPATH_DIRECTORY_AUDIO = @"HKEY_CLASSES_ROOT\SystemFileAssociations\Directory.Audio";//通用音频文件目录
public const string SYSFILEASSPATH = @"HKEY_CLASSES_ROOT\SystemFileAssociations";//系统扩展名注册表父项路径
public enum Scenes
{
- File, Folder, Directory, Background, Desktop, Drive, AllObjects, Computer, RecycleBin,
- Library, LnkFile, UwpLnk, ExeFile, TextFile, DocumentFile, ImageFile, VideoFile, AudioFile,
- ImageDirectory, VideoDirectory, AudioDirectory, UnknownType, CustomType, CommandStore
+ File, Folder, Directory, Background, Desktop, Drive, AllObjects, Computer, RecycleBin, Library,
+ LnkFile, UwpLnk, ExeFile, UnknownType, CustomExtension, PerceivedType, DirectoryType, CommandStore, DragDrop
}
- private Scenes scene;
- public Scenes Scene
+ private static readonly string[] DirectoryTypes = { "Document", "Image", "Video", "Audio" };
+ private static readonly string[] PerceivedTypes = { "Text", "Document", "Image", "Video", "Audio", "Compressed", "System" };
+ private static readonly string[] DirectoryTypeNames =
{
- get => scene;
- set { scene = value; LoadItems(); }
+ AppString.Dialog.DocumentDirectory, AppString.Dialog.ImageDirectory,
+ AppString.Dialog.VideoDirectory, AppString.Dialog.AudioDirectory
+ };
+ private static readonly string[] PerceivedTypeNames =
+ {
+ AppString.Dialog.TextFile, AppString.Dialog.DocumentFile, AppString.Dialog.ImageFile, AppString.Dialog.VideoFile,
+ AppString.Dialog.AudioFile, AppString.Dialog.CompressedFile, AppString.Dialog.SystemFile
+ };
+
+ private static string GetDirectoryTypeName()
+ {
+ if(CurrentDirectoryType != null)
+ {
+ for(int i = 0; i < DirectoryTypes.Length; i++)
+ {
+ if(CurrentDirectoryType.Equals(DirectoryTypes[i], StringComparison.OrdinalIgnoreCase))
+ {
+ return DirectoryTypeNames[i];
+ }
+ }
+ }
+ return null;
}
+ private static string GetPerceivedTypeName()
+ {
+ if(CurrentPerceivedType != null)
+ {
+ for(int i = 0; i < PerceivedTypes.Length; i++)
+ {
+ if(CurrentPerceivedType.Equals(PerceivedTypes[i], StringComparison.OrdinalIgnoreCase))
+ {
+ return PerceivedTypeNames[i];
+ }
+ }
+ }
+ return null;
+ }
+
+ private static string CurrentExtension = null;
+ private static string CurrentDirectoryType = null;
+ private static string CurrentPerceivedType = null;
+
private static string GetShellPath(string scenePath) => $@"{scenePath}\shell";
private static string GetShellExPath(string scenePath) => $@"{scenePath}\shellEx";
+ private static string GetSysAssExtPath(string typeName) => typeName != null ? $@"{SYSFILEASSPATH}\{typeName}" : null;
+ private static string GetOpenModePath(string extension) => extension != null ? $@"HKEY_CLASSES_ROOT\{FileExtension.GetOpenMode(extension)}" : null;
+
+ public Scenes Scene { get; set; }
public ShellList()
{
- TypeItem.ExtensionChanged += (sender, e) =>
- {
- this.ClearItems();
- this.Scene = Scenes.CustomType;
- };
+ SelectItem.SelectedChanged += (sender, e) => { this.ClearItems(); this.LoadItems(); };
}
- private void LoadItems()
+ public void LoadItems()
{
string scenePath = null;
switch(Scene)
@@ -96,79 +123,82 @@ private void LoadItems()
if(WindowsOsVersion.IsEqualVista) return;
scenePath = MENUPATH_LIBRARY; break;
case Scenes.LnkFile:
- scenePath = MENUPATH_LNKFILE; break;
+ scenePath = GetSysAssExtPath(".lnk"); break;
case Scenes.UwpLnk:
//Win8之前没有Uwp
if(WindowsOsVersion.IsBefore8) return;
scenePath = MENUPATH_UWPLNK; break;
case Scenes.ExeFile:
- scenePath = MENUPATH_EXEFILE; break;
- case Scenes.TextFile:
- scenePath = MENUPATH_TEXT; break;
- case Scenes.DocumentFile:
- scenePath = MENUPATH_DOCUMENT; break;
- case Scenes.ImageFile:
- scenePath = MENUPATH_IMAGE; break;
- case Scenes.VideoFile:
- scenePath = MENUPATH_VIDEO; break;
- case Scenes.AudioFile:
- scenePath = MENUPATH_AUDIO; break;
- case Scenes.ImageDirectory:
- scenePath = MENUPATH_DIRECTORY_IMAGE; break;
- case Scenes.VideoDirectory:
- scenePath = MENUPATH_DIRECTORY_VIDEO; break;
- case Scenes.AudioDirectory:
- scenePath = MENUPATH_DIRECTORY_AUDIO; break;
+ scenePath = GetSysAssExtPath(".exe"); break;
case Scenes.UnknownType:
scenePath = MENUPATH_UNKNOWN; break;
- case Scenes.CustomType:
- scenePath = TypeItem.SysAssExtPath; break;
+ case Scenes.CustomExtension:
+ scenePath = GetSysAssExtPath(CurrentExtension); break;
+ case Scenes.PerceivedType:
+ scenePath = GetSysAssExtPath(CurrentPerceivedType); break;
+ case Scenes.DirectoryType:
+ if(CurrentDirectoryType == null) scenePath = null;
+ else scenePath = GetSysAssExtPath($"Directory.{CurrentDirectoryType}"); break;
case Scenes.CommandStore:
//Vista系统没有这一项
if(WindowsOsVersion.IsEqualVista) return;
this.AddNewItem(RegistryEx.GetParentPath(ShellItem.CommandStorePath));
- this.LoadCommandStoreItems();
+ this.LoadStoreItems();
+ return;
+ case Scenes.DragDrop:
+ this.AddNewItem(MENUPATH_FOLDER);
+ this.LoadShellExItems(GetShellExPath(MENUPATH_FOLDER));
+ this.LoadShellExItems(GetShellExPath(MENUPATH_DIRECTORY));
+ this.LoadShellExItems(GetShellExPath(MENUPATH_DRIVE));
+ this.LoadShellExItems(GetShellExPath(MENUPATH_ALLOBJECTS));
return;
}
this.AddNewItem(scenePath);
this.LoadItems(scenePath);
-
- switch(scene)
+ switch(Scene)
{
case Scenes.File:
- if(WindowsOsVersion.ISAfterOrEqual10)
- this.AddItem(new RegRuleItem(RegRuleItem.ShareWithSkype));
+ bool flag = WindowsOsVersion.ISAfterOrEqual10;
+ if(flag)
+ {
+ using(RegistryKey key = RegistryEx.GetRegistryKey(@"HKEY_CLASSES_ROOT\PackagedCom\Package"))
+ {
+ flag = key != null && key.GetSubKeyNames().ToList().Any(name => name.StartsWith("Microsoft.SkypeApp", StringComparison.OrdinalIgnoreCase));
+ }
+ }
+ if(flag) this.AddItem(new VisibleRegRuleItem(VisibleRegRuleItem.ShareWithSkype));
break;
case Scenes.Background:
- this.AddItem(new RegRuleItem(RegRuleItem.CustomFolder));
+ this.AddItem(new VisibleRegRuleItem(VisibleRegRuleItem.CustomFolder));
break;
case Scenes.Computer:
- this.AddItem(new RegRuleItem(RegRuleItem.NetworkDrive));
+ this.AddItem(new VisibleRegRuleItem(VisibleRegRuleItem.NetworkDrive));
break;
case Scenes.RecycleBin:
- this.AddItem(new RegRuleItem(RegRuleItem.RecycleBinProperties));
+ this.AddItem(new VisibleRegRuleItem(VisibleRegRuleItem.RecycleBinProperties));
break;
case Scenes.Library:
this.LoadItems(MENUPATH_LIBRARY_BACKGROUND);
this.LoadItems(MENUPATH_LIBRARY_USER);
break;
case Scenes.LnkFile:
- this.LoadItems(MENUPATH_SYSLNKFILE);
+ this.LoadItems(GetOpenModePath(".lnk"));
break;
case Scenes.ExeFile:
- this.LoadItems(MENUPATH_SYSEXEFILE);
+ this.LoadItems(GetOpenModePath(".exe"));
break;
- case Scenes.CustomType:
- this.InsertItem(new TypeItem(), 0);
- this.InsertItem(new PerceptionItem(), 1);
- this.LoadItems(TypeItem.AssExtPath);
+ case Scenes.CustomExtension:
+ case Scenes.PerceivedType:
+ case Scenes.DirectoryType:
+ this.InsertItem(new SelectItem(Scene), 0);
+ if(Scene == Scenes.CustomExtension) this.LoadItems(GetOpenModePath(CurrentExtension));
break;
}
}
private void LoadItems(string scenePath)
{
- if(this.Scene == Scenes.CustomType && TypeItem.Extension == null) return;
+ if(scenePath == null) return;
RegTrustedInstaller.TakeRegKeyOwnerShip(scenePath);
this.LoadShellItems(GetShellPath(scenePath));
this.LoadShellExItems(GetShellExPath(scenePath));
@@ -193,142 +223,293 @@ private void LoadShellExItems(string shellExPath)
using(RegistryKey shellExKey = RegistryEx.GetRegistryKey(shellExPath))
{
if(shellExKey == null) return;
+ bool isDragDrop = Scene == Scenes.DragDrop;
RegTrustedInstaller.TakeRegTreeOwnerShip(shellExKey.Name);
- Dictionary dic = ShellExItem.GetPathAndGuids(shellExPath);
+ Dictionary dic = ShellExItem.GetPathAndGuids(shellExPath, isDragDrop);
+ GroupPathItem groupItem = null;
+ if(isDragDrop)
+ {
+ groupItem = GetDragDropGroupItem(shellExPath);
+ this.AddItem(groupItem);
+ }
foreach(string path in dic.Keys)
{
string keyName = RegistryEx.GetKeyName(path);
if(!names.Contains(keyName))
{
- this.AddItem(new ShellExItem(dic[path], path));
+ ShellExItem item = new ShellExItem(dic[path], path);
+ if(groupItem != null) item.FoldGroupItem = groupItem;
+ this.AddItem(item);
names.Add(keyName);
}
}
+ if(groupItem != null) groupItem.IsFold = true;
}
}
+ private GroupPathItem GetDragDropGroupItem(string shellExPath)
+ {
+ string text = null;
+ Image image = null;
+ string path = shellExPath.Substring(0, shellExPath.LastIndexOf('\\'));
+ switch(path)
+ {
+ case MENUPATH_FOLDER:
+ text = AppString.SideBar.Folder;
+ image = AppImage.Folder;
+ break;
+ case MENUPATH_DIRECTORY:
+ text = AppString.SideBar.Directory;
+ image = AppImage.Directory;
+ break;
+ case MENUPATH_DRIVE:
+ text = AppString.SideBar.Drive;
+ image = AppImage.Drive;
+ break;
+ case MENUPATH_ALLOBJECTS:
+ text = AppString.SideBar.AllObjects;
+ image = AppImage.AllObjects;
+ break;
+ }
+ return new GroupPathItem(shellExPath, ObjectPath.PathType.Registry) { Text = text, Image = image };
+ }
+
private void AddNewItem(string scenePath)
{
- string shellPath = GetShellPath(scenePath);
- NewItem newItem = new NewItem();
+ NewItem newItem = new NewItem { Visible = scenePath != null };
this.AddItem(newItem);
- if(this.Scene == Scenes.CustomType)
+ newItem.AddNewItem += (sender, e) =>
+ {
+ bool isShell;
+ if(Scene == Scenes.DragDrop) isShell = false;
+ else
+ {
+ using(SelectDialog dlg = new SelectDialog())
+ {
+ dlg.Items = new[] { "Shell", "ShellEx" };
+ dlg.Title = "请选择新建菜单类型";
+ dlg.Selected = dlg.Items[0];
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ isShell = dlg.SelectedIndex == 0;
+ }
+ }
+ if(isShell) this.AddNewShellItem(scenePath);
+ else this.AddNewShellExItem(scenePath);
+ };
+ }
+
+ private void AddNewShellItem(string scenePath)
+ {
+ string shellPath = GetShellPath(scenePath);
+ using(NewShellDialog dlg = new NewShellDialog())
{
- newItem.Visible = TypeItem.Extension != null;
- TypeItem.ExtensionChanged += (sender, e) => newItem.Visible = TypeItem.Extension != null;
+ dlg.ScenePath = scenePath;
+ dlg.ShellPath = shellPath;
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ for(int i = 0; i < this.Controls.Count; i++)
+ {
+ if(this.Controls[i] is NewItem)
+ {
+ this.InsertItem(new ShellItem(dlg.NewItemRegPath), i + 1);
+ break;
+ }
+ }
}
- newItem.AddNewItem += (sender, e) =>
+ }
+
+ private void AddNewShellExItem(string scenePath)
+ {
+ bool isDragDrop = Scene == Scenes.DragDrop;
+ using(InputDialog dlg1 = new InputDialog { Title = AppString.Dialog.InputGuid })
{
- using(NewShellDialog dlg = new NewShellDialog
+ if(GuidEx.TryParse(Clipboard.GetText(), out Guid guid)) dlg1.Text = guid.ToString();
+ if(dlg1.ShowDialog() != DialogResult.OK) return;
+ if(GuidEx.TryParse(dlg1.Text, out guid))
{
- ScenePath = scenePath,
- ShellPath = shellPath
- })
+ if(isDragDrop)
+ {
+ using(SelectDialog dlg2 = new SelectDialog())
+ {
+ dlg2.Title = AppString.Dialog.SelectGroup;
+ dlg2.Items = new[] { AppString.SideBar.Folder, AppString.SideBar.Directory,
+ AppString.SideBar.Drive, AppString.SideBar.AllObjects };
+ dlg2.Selected = dlg2.Items[0];
+ if(dlg2.ShowDialog() != DialogResult.OK) return;
+ switch(dlg2.SelectedIndex)
+ {
+ case 0:
+ scenePath = MENUPATH_FOLDER; break;
+ case 1:
+ scenePath = MENUPATH_DIRECTORY; break;
+ case 2:
+ scenePath = MENUPATH_DRIVE; break;
+ case 3:
+ scenePath = MENUPATH_ALLOBJECTS; break;
+ }
+ }
+ }
+ string shellExPath = GetShellExPath(scenePath);
+ if(ShellExItem.GetPathAndGuids(shellExPath, isDragDrop).Values.Contains(guid))
+ {
+ MessageBoxEx.Show(AppString.MessageBox.HasBeenAdded);
+ }
+ else
+ {
+ string part = isDragDrop ? ShellExItem.DdhParts[0] : ShellExItem.CmhParts[0];
+ string regPath = $@"{shellExPath}\{part}\{guid:B}";
+ Registry.SetValue(regPath, "", guid.ToString("B"));
+ ShellExItem item = new ShellExItem(guid, regPath);
+ for(int i = 0; i < this.Controls.Count; i++)
+ {
+ if(isDragDrop)
+ {
+ if(this.Controls[i] is GroupPathItem groupItem)
+ {
+ if(groupItem.TargetPath.Equals(shellExPath, StringComparison.OrdinalIgnoreCase))
+ {
+ this.InsertItem(item, i + 1);
+ item.FoldGroupItem = groupItem;
+ item.Visible = !groupItem.IsFold;
+ break;
+ }
+ }
+ }
+ else
+ {
+ if(this.Controls[i] is NewItem)
+ {
+ this.InsertItem(item, i + 1);
+ break;
+ }
+ }
+ }
+ }
+ }
+ else
{
- if(dlg.ShowDialog() == DialogResult.OK)
- this.InsertItem(new ShellItem(dlg.NewItemRegPath), GetItemIndex(newItem) + 1);
+ MessageBoxEx.Show(AppString.MessageBox.MalformedGuid);
}
- };
+ }
}
- private void LoadCommandStoreItems()
+ ///“其他规则”-“公共引用”
+ private void LoadStoreItems()
{
using(var shellKey = RegistryEx.GetRegistryKey(ShellItem.CommandStorePath))
{
Array.ForEach(Array.FindAll(shellKey.GetSubKeyNames(), itemName =>
!ShellItem.SysStoreItemNames.Contains(itemName, StringComparer.OrdinalIgnoreCase)), itemName =>
{
- this.AddItem(new ShellItem($@"{ShellItem.CommandStorePath}\{itemName}"));
+ this.AddItem(new StoreShellItem($@"{ShellItem.CommandStorePath}\{itemName}", true, false));
});
}
}
- sealed class TypeItem : MyListItem
+ sealed class SelectItem : MyListItem
{
- static string extension;
- public static string Extension
+ static string selected;
+ public static string Selected
{
- get => extension;
+ get => selected;
set
{
- extension = value;
- ExtensionChanged?.Invoke(null, null);
+ selected = value;
+ SelectedChanged?.Invoke(null, null);
}
}
- public static string SysAssExtPath => Extension == null ? null : $@"{SYSFILEASSPATH}\{Extension}";
- public static string AssExtPath => Extension == null ? null : $@"HKEY_CLASSES_ROOT\{FileExtension.GetOpenMode(Extension)}";
- public static string ExtensionPath => $@"HKEY_CLASSES_ROOT\{Extension}";
-
- public static event EventHandler ExtensionChanged;
+ public static event EventHandler SelectedChanged;
- readonly PictureButton BtnType = new PictureButton(AppImage.Types);
+ readonly PictureButton BtnSelect = new PictureButton(AppImage.Select);
- public TypeItem()
+ public SelectItem(Scenes scene)
{
- this.GetText();
- this.Image = AppImage.CustomType;
- this.AddCtr(BtnType);
this.SetNoClickEvent();
- BtnType.MouseDown += (sender, e) =>
- {
- using(FileExtensionDialog dlg = new FileExtensionDialog())
- if(dlg.ShowDialog() == DialogResult.OK) Extension = dlg.Extension;
- };
- ExtensionChanged += (sender, e) => this.GetText();
+ this.Image = AppImage.Custom;
+ this.Text = this.GetText(scene);
+ this.AddCtr(BtnSelect);
+ BtnSelect.MouseDown += (sender, e) => Select(scene);
}
- private void GetText()
+ private string GetText(Scenes scene)
{
- if(Extension == null)
- {
- this.Text = AppString.Dialog.SelectExtension;
- }
- else
+ switch(scene)
{
- this.Text = $"{AppString.Item.CurrentExtension}{Extension}";
+ case Scenes.CustomExtension:
+ if(CurrentExtension == null)
+ {
+ return AppString.Item.SelectExtension;
+ }
+ else
+ {
+ return AppString.Item.CurrentExtension.Replace("%s", CurrentExtension);
+ }
+ case Scenes.PerceivedType:
+ if(CurrentPerceivedType == null)
+ {
+ return AppString.Item.SelectPerceivedType;
+ }
+ else
+ {
+ return AppString.Item.CurrentPerceivedType.Replace("%s", GetPerceivedTypeName());
+ }
+ case Scenes.DirectoryType:
+ if(CurrentDirectoryType == null)
+ {
+ return AppString.Item.SelectDirectoryType;
+ }
+ else
+ {
+ return AppString.Item.CurrentDirectoryType.Replace("%s", GetDirectoryTypeName());
+ }
+ default:
+ return null;
}
}
- }
-
- sealed class PerceptionItem : MyListItem
- {
- private static readonly string[] PerceptionTypes = { "Text", "Image", "Video", "Audio", "System", "Compressed" };
-
- public PerceptionItem()
- {
- this.Image = ResourceIcon.GetExtensionIcon(TypeItem.Extension)?.ToBitmap() ?? AppImage.NotFound;
- this.Text = AppString.Item.SetPerceivedType;
- this.Visible = TypeItem.Extension != null;
- this.AddCtr(cmbType);
- cmbType.Text = Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(PerceivedType ?? string.Empty);
- cmbType.Items.AddRange(PerceptionTypes);
- cmbType.TextChanged += (sneder, e) => PerceivedType = cmbType.Text;
- TypeItem.ExtensionChanged += (sender, e) => this.Visible = TypeItem.Extension != null;
- }
- private static string PerceivedType
+ private void Select(Scenes scene)
{
- get => Registry.GetValue(TypeItem.ExtensionPath, "PerceivedType", null)?.ToString();
- set
+ SelectDialog dlg;
+ switch(scene)
{
- if(value.IsNullOrWhiteSpace())
- {
- RegistryEx.DeleteValue(TypeItem.ExtensionPath, "PerceivedType");
- }
- else
- {
- Registry.SetValue(TypeItem.ExtensionPath, "PerceivedType", value);
- }
+ case Scenes.CustomExtension:
+ dlg = new FileExtensionDialog
+ {
+ Selected = CurrentExtension?.Substring(1)
+ };
+ break;
+ case Scenes.PerceivedType:
+ dlg = new SelectDialog
+ {
+ Items = PerceivedTypeNames,
+ Title = AppString.Item.SelectPerceivedType,
+ Selected = GetPerceivedTypeName() ?? PerceivedTypeNames[0]
+ };
+ break;
+ case Scenes.DirectoryType:
+ dlg = new SelectDialog
+ {
+ Items = DirectoryTypeNames,
+ Title = AppString.Item.SelectDirectoryType,
+ Selected = GetDirectoryTypeName() ?? DirectoryTypeNames[0]
+ };
+ break;
+ default: return;
+ }
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ switch(scene)
+ {
+ case Scenes.CustomExtension:
+ Selected = CurrentExtension = dlg.Selected;
+ break;
+ case Scenes.PerceivedType:
+ Selected = CurrentPerceivedType = PerceivedTypes[dlg.SelectedIndex];
+ break;
+ case Scenes.DirectoryType:
+ Selected = CurrentDirectoryType = DirectoryTypes[dlg.SelectedIndex];
+ break;
}
}
-
- readonly ComboBox cmbType = new ComboBox
- {
- Font = new Font(SystemFonts.MenuFont.FontFamily, 10F),
- ImeMode = ImeMode.Disable,
- Width = 100.DpiZoom()
- };
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/ShellNewItem.cs b/ContextMenuManager/Controls/ShellNewItem.cs
index 8ed08fa..08ae20c 100644
--- a/ContextMenuManager/Controls/ShellNewItem.cs
+++ b/ContextMenuManager/Controls/ShellNewItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using Microsoft.Win32;
using System;
@@ -19,7 +19,9 @@ sealed class ShellNewItem : MyListItem, IChkVisibleItem, ITsiTextItem, IBtnShowM
ITsiIconItem, ITsiWebSearchItem, ITsiFilePathItem, ITsiRegPathItem, ITsiRegDeleteItem, ITsiRegExportItem, ITsiCommandItem
{
public static readonly string[] SnParts = { "ShellNew", "-ShellNew" };
- public static readonly string[] UnableSortExtensions = { ".library-ms", ".lnk", "Folder" };
+ public static readonly string[] UnableSortExtensions = { "Folder", ".library-ms" };
+ public static readonly string[] DefaultBeforeSeparatorExtensions = { "Folder", ".library-ms", ".lnk" };
+ public static readonly string[] EffectValueNames = { "NullFile", "Data", "FileName", "Directory", "Command" };
private static readonly string[] UnableEditDataValues = { "Directory", "FileName", "Handler", "Command" };
private static readonly string[] UnableChangeCommandValues = { "Data", "Directory", "FileName", "Handler" };
@@ -28,7 +30,7 @@ public ShellNewItem(ShellNewList list, string regPath)
this.Owner = list;
InitializeComponents();
this.RegPath = regPath;
- BtnMoveUp.Visible = BtnMoveDown.Visible = this.CanSort && LockNewItem.IsLocked();
+ SetSortabled(ShellNewLockItem.IsLocked);
}
private string regPath;
@@ -44,6 +46,7 @@ public string RegPath
}
}
+ public string ValueName => null;
public string SearchText => $"{AppString.SideBar.New} {Text}";
public string Extension => RegPath.Split('\\')[1];
private string SnKeyName => RegistryEx.GetKeyName(RegPath);
@@ -54,10 +57,12 @@ public string RegPath
private string OpenModePath => $@"{HKCR}\{OpenMode}";//关联打开方式注册表路径
private string DefaultOpenMode => Registry.GetValue($@"{HKCR}\{Extension}", "", null)?.ToString();//默认关联打开方式
private string DefaultOpenModePath => $@"{HKCR}\{DefaultOpenMode}";//默认关联打开方式注册表路径
+ private string ConfigPath => $@"{RegPath}\Config";
+ public bool CanSort => !UnableSortExtensions.Contains(Extension, StringComparer.OrdinalIgnoreCase);//能够排序的
private bool CanEditData => UnableEditDataValues.All(value => Registry.GetValue(RegPath, value, null) == null);//能够编辑初始数据的
private bool CanChangeCommand => UnableChangeCommandValues.All(value => Registry.GetValue(RegPath, value, null) == null);//能够更改菜单命令的
- public bool CanSort => !UnableSortExtensions.Contains(Extension, StringComparer.OrdinalIgnoreCase);//能够排序的
+ private bool DefaultBeforeSeparator => DefaultBeforeSeparatorExtensions.Contains(Extension, StringComparer.OrdinalIgnoreCase);//默认显示在分割线上不可更改的
public string ItemFilePath
{
@@ -169,6 +174,34 @@ public string ItemCommand
}
}
+ public bool BeforeSeparator
+ {
+ get
+ {
+ if(DefaultBeforeSeparator) return true;
+ else return Registry.GetValue(ConfigPath, "BeforeSeparator", null) != null;
+ }
+ set
+ {
+ if(value)
+ {
+ Registry.SetValue(ConfigPath, "BeforeSeparator", "");
+ }
+ else
+ {
+ using(RegistryKey snkey = RegistryEx.GetRegistryKey(RegPath, true))
+ using(RegistryKey ckey = snkey.OpenSubKey("Config", true))
+ {
+ ckey.DeleteValue("BeforeSeparator");
+ if(ckey.GetValueNames().Length == 0 && ckey.GetSubKeyNames().Length == 0)
+ {
+ snkey.DeleteSubKey("Config");
+ }
+ }
+ }
+ }
+ }
+
public ShellNewList Owner { get; private set; }
public MoveButton BtnMoveUp { get; set; }
public MoveButton BtnMoveDown { get; set; }
@@ -185,6 +218,8 @@ public string ItemCommand
public ChangeCommandMenuItem TsiChangeCommand { get; set; }
readonly ToolStripMenuItem TsiDetails = new ToolStripMenuItem(AppString.Menu.Details);
+ readonly ToolStripMenuItem TsiOtherAttributes = new ToolStripMenuItem(AppString.Menu.OtherAttributes);
+ readonly ToolStripMenuItem TsiBeforeSeparator = new ToolStripMenuItem(AppString.Menu.BeforeSeparator);
readonly ToolStripMenuItem TsiEditData = new ToolStripMenuItem(AppString.Menu.InitialData);
private void InitializeComponents()
@@ -205,18 +240,24 @@ private void InitializeComponents()
TsiChangeCommand.CommandCanBeEmpty = true;
ContextMenuStrip.Items.AddRange(new ToolStripItem[] {TsiChangeText,
- new ToolStripSeparator(), TsiChangeIcon, new ToolStripSeparator(),
- TsiDetails, new ToolStripSeparator(), TsiDeleteMe });
+ new ToolStripSeparator(), TsiChangeIcon, new ToolStripSeparator(), TsiOtherAttributes,
+ new ToolStripSeparator(), TsiDetails, new ToolStripSeparator(), TsiDeleteMe });
- TsiDetails.DropDownItems.AddRange(new ToolStripItem[] { TsiSearch, new ToolStripSeparator(),
- TsiEditData,TsiChangeCommand, TsiFileProperties, TsiFileLocation, TsiRegLocation, TsiRegExport });
+ TsiOtherAttributes.DropDownItems.AddRange(new[] { TsiBeforeSeparator, TsiEditData });
+
+ TsiDetails.DropDownItems.AddRange(new ToolStripItem[] { TsiSearch,
+ new ToolStripSeparator(), TsiChangeCommand, TsiFileProperties,
+ TsiFileLocation, TsiRegLocation, TsiRegExport });
- TsiEditData.Click += (sender, e) => EditInitialData();
ContextMenuStrip.Opening += (sender, e) =>
{
TsiEditData.Visible = CanEditData;
TsiChangeCommand.Visible = CanChangeCommand;
+ TsiBeforeSeparator.Enabled = !DefaultBeforeSeparator;
+ TsiBeforeSeparator.Checked = BeforeSeparator;
};
+ TsiEditData.Click += (sender, e) => EditInitialData();
+ TsiBeforeSeparator.Click += (sender, e) => MoveWithSeparator(!TsiBeforeSeparator.Checked);
BtnMoveUp.MouseDown += (sender, e) => Owner.MoveItem(this, true);
BtnMoveDown.MouseDown += (sender, e) => Owner.MoveItem(this, false);
}
@@ -235,12 +276,26 @@ private void EditInitialData()
}
}
+ public void SetSortabled(bool isLocked)
+ {
+ BtnMoveDown.Visible = BtnMoveUp.Visible = isLocked && CanSort;
+ }
+
+ private void MoveWithSeparator(bool isBefore)
+ {
+ BeforeSeparator = isBefore;
+ ShellNewList list = (ShellNewList)this.Parent;
+ int index = list.GetItemIndex(list.Separator);
+ list.SetItemIndex(this, index);
+ if(ShellNewLockItem.IsLocked) list.SaveSorting();
+ }
+
public void DeleteMe()
{
RegistryEx.DeleteKeyTree(this.RegPath);
RegistryEx.DeleteKeyTree(this.BackupPath);
this.Dispose();
- if(LockNewItem.IsLocked()) Owner.WriteRegistry();
+ if(ShellNewLockItem.IsLocked) Owner.SaveSorting();
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/ShellNewList.cs b/ContextMenuManager/Controls/ShellNewList.cs
index f9a0e4b..c732acc 100644
--- a/ContextMenuManager/Controls/ShellNewList.cs
+++ b/ContextMenuManager/Controls/ShellNewList.cs
@@ -1,9 +1,12 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
+using ContextMenuManager.Controls.Interfaces;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Security.AccessControl;
+using System.Security.Principal;
using System.Windows.Forms;
namespace ContextMenuManager.Controls
@@ -11,13 +14,16 @@ namespace ContextMenuManager.Controls
sealed class ShellNewList : MyList
{
public const string ShellNewPath = @"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\ShellNew";
- private static readonly string[] ValueNames = { "NullFile", "Data", "FileName", "Directory", "Command" };
+
+ public ShellNewSeparator Separator;
public void LoadItems()
{
this.AddNewItem();
- this.AddItem(new LockNewItem(this));
- if(LockNewItem.IsLocked()) this.LoadLockItems();
+ this.AddItem(new ShellNewLockItem(this));
+ Separator = new ShellNewSeparator();
+ this.AddItem(Separator);
+ if(ShellNewLockItem.IsLocked) this.LoadLockItems();
else this.LoadUnlockItems();
}
@@ -44,11 +50,10 @@ private void LoadItems(List extensions)
{
foreach(string extension in ShellNewItem.UnableSortExtensions)
{
- string str = extensions.Find(ext => ext.Equals(extension, StringComparison.OrdinalIgnoreCase));
- if(str != null)
+ if(extensions.Contains(extension, StringComparer.OrdinalIgnoreCase))
{
- extensions.Remove(str);
- extensions.Insert(0, str);
+ extensions.Remove(extension);
+ extensions.Insert(0, extension);
}
}
using(RegistryKey root = Registry.ClassesRoot)
@@ -57,7 +62,7 @@ private void LoadItems(List extensions)
{
using(RegistryKey extKey = root.OpenSubKey(extension))
{
- string defalutOpenMode = extKey.GetValue("")?.ToString();
+ string defalutOpenMode = extKey?.GetValue("")?.ToString();
if(string.IsNullOrEmpty(defalutOpenMode)) continue;
using(RegistryKey openModeKey = root.OpenSubKey(defalutOpenMode))
{
@@ -75,9 +80,18 @@ private void LoadItems(List extensions)
if(tKey != null) snPart = $@"{defalutOpenMode}\{snPart}";
using(RegistryKey snKey = extKey.OpenSubKey(snPart))
{
- if(ValueNames.Any(valueName => snKey?.GetValue(valueName) != null))
+ if(ShellNewItem.EffectValueNames.Any(valueName => snKey?.GetValue(valueName) != null))
{
- this.AddItem(new ShellNewItem(this, snKey.Name));
+ ShellNewItem item = new ShellNewItem(this, snKey.Name);
+ if(item.BeforeSeparator)
+ {
+ int index2 = this.GetItemIndex(Separator);
+ this.InsertItem(item, index2);
+ }
+ else
+ {
+ this.AddItem(item);
+ }
break;
}
}
@@ -88,45 +102,32 @@ private void LoadItems(List extensions)
}
}
- public void MoveItem(ShellNewItem item, bool isUp)
+ public void MoveItem(ShellNewItem shellNewItem, bool isUp)
{
- int index = this.GetItemIndex(item);
- int firstIndex = 0;
- for(int i = 0; i < this.Controls.Count; i++)
- {
- Control ctr = this.Controls[i];
- if(ctr.GetType() == typeof(ShellNewItem) && ((ShellNewItem)ctr).CanSort)
- {
- firstIndex = i; break;
- }
- }
- if(isUp)
- {
- if(index > firstIndex)
- {
- this.SetItemIndex(item, index - 1);
- }
- }
- else
+ int index = this.GetItemIndex(shellNewItem);
+ index += isUp ? -1 : 1;
+ if(index == this.Controls.Count) return;
+ Control ctr = this.Controls[index];
+ if(ctr is ShellNewItem item && item.CanSort)
{
- if(index < this.Controls.Count - 1)
- {
- this.SetItemIndex(item, index + 1);
- }
+ this.SetItemIndex(shellNewItem, index);
+ this.SaveSorting();
}
- this.WriteRegistry();
}
- public void WriteRegistry()
+ public void SaveSorting()
{
List extensions = new List();
for(int i = 2; i < this.Controls.Count; i++)
{
- extensions.Add(((ShellNewItem)Controls[i]).Extension);
+ if(Controls[i] is ShellNewItem item)
+ {
+ extensions.Add(item.Extension);
+ }
}
- LockNewItem.UnLock();
+ ShellNewLockItem.UnLock();
Registry.SetValue(ShellNewPath, "Classes", extensions.ToArray());
- LockNewItem.Lock();
+ ShellNewLockItem.Lock();
}
private void AddNewItem()
@@ -147,9 +148,9 @@ private void AddNewItem()
}
foreach(Control ctr in this.Controls)
{
- if(ctr.GetType() == typeof(ShellNewItem))
+ if(ctr is ShellNewItem item)
{
- if(((ShellNewItem)ctr).Extension.Equals(extension, StringComparison.OrdinalIgnoreCase))
+ if(item.Extension.Equals(extension, StringComparison.OrdinalIgnoreCase))
{
MessageBoxEx.Show(AppString.MessageBox.HasBeenAdded);
return;
@@ -174,10 +175,109 @@ private void AddNewItem()
{
item.ItemText = $"{extension.Substring(1)} file";
}
- if(LockNewItem.IsLocked()) this.WriteRegistry();
+ if(ShellNewLockItem.IsLocked) this.SaveSorting();
}
}
};
}
}
+
+ sealed class ShellNewLockItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem, ITsiWebSearchItem
+ {
+ public ShellNewLockItem(ShellNewList list)
+ {
+ this.Owner = list;
+ this.Image = AppImage.Lock;
+ this.Text = AppString.Item.LockNewMenu;
+ this.SetNoClickEvent();
+ BtnShowMenu = new MenuButton(this);
+ ChkVisible = new VisibleCheckBox(this) { Checked = IsLocked };
+ MyToolTip.SetToolTip(ChkVisible, AppString.Tip.LockNewMenu);
+ TsiSearch = new WebSearchMenuItem(this);
+ this.ContextMenuStrip = new ContextMenuStrip();
+ this.ContextMenuStrip.Items.Add(TsiSearch);
+ }
+
+ public MenuButton BtnShowMenu { get; set; }
+ public WebSearchMenuItem TsiSearch { get; set; }
+ public VisibleCheckBox ChkVisible { get; set; }
+ public ShellNewList Owner { get; private set; }
+
+ public bool ItemVisible
+ {
+ get => IsLocked;
+ set
+ {
+ if(value) Owner.SaveSorting();
+ else UnLock();
+ foreach(Control ctr in Owner.Controls)
+ {
+ if(ctr is ShellNewItem item)
+ {
+ item.SetSortabled(value);
+ }
+ }
+ }
+ }
+
+ public string SearchText => Text;
+
+ public static bool IsLocked
+ {
+ get
+ {
+ using(RegistryKey key = RegistryEx.GetRegistryKey(ShellNewList.ShellNewPath))
+ {
+ RegistrySecurity rs = key.GetAccessControl();
+ foreach(RegistryAccessRule rar in rs.GetAccessRules(true, true, typeof(NTAccount)))
+ {
+ if(rar.AccessControlType.ToString().Equals("Deny", StringComparison.OrdinalIgnoreCase))
+ {
+ if(rar.IdentityReference.ToString().Equals("Everyone", StringComparison.OrdinalIgnoreCase)) return true;
+ }
+ }
+ }
+ return false;
+ }
+ }
+
+ public static void Lock()
+ {
+ using(RegistryKey key = RegistryEx.GetRegistryKey(ShellNewList.ShellNewPath, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.ChangePermissions))
+ {
+ RegistrySecurity rs = new RegistrySecurity();
+ RegistryAccessRule rar = new RegistryAccessRule("Everyone", RegistryRights.Delete | RegistryRights.WriteKey, AccessControlType.Deny);
+ rs.AddAccessRule(rar);
+ key.SetAccessControl(rs);
+ }
+ }
+
+ public static void UnLock()
+ {
+ using(RegistryKey key = RegistryEx.GetRegistryKey(ShellNewList.ShellNewPath, RegistryKeyPermissionCheck.ReadWriteSubTree, RegistryRights.ChangePermissions))
+ {
+ RegistrySecurity rs = key.GetAccessControl();
+ foreach(RegistryAccessRule rar in rs.GetAccessRules(true, true, typeof(NTAccount)))
+ {
+ if(rar.AccessControlType.ToString().Equals("Deny", StringComparison.OrdinalIgnoreCase))
+ {
+ if(rar.IdentityReference.ToString().Equals("Everyone", StringComparison.OrdinalIgnoreCase))
+ {
+ rs.RemoveAccessRule(rar);
+ }
+ }
+ }
+ key.SetAccessControl(rs);
+ }
+ }
+ }
+
+ sealed class ShellNewSeparator : MyListItem
+ {
+ public ShellNewSeparator()
+ {
+ this.Text = AppString.Item.Separator;
+ this.HasImage = false;
+ }
+ }
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/ShellStoreDialog.cs b/ContextMenuManager/Controls/ShellStoreDialog.cs
index 68cf709..ced93af 100644
--- a/ContextMenuManager/Controls/ShellStoreDialog.cs
+++ b/ContextMenuManager/Controls/ShellStoreDialog.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System;
using System.Collections.Generic;
using System.Drawing;
@@ -110,27 +110,30 @@ private void GetSelectedItems()
foreach(StoreShellItem item in list.Controls)
if(item.IsSelected) SelectedKeyNames.Add(item.KeyName);
}
+ }
+ }
- sealed class StoreShellItem : ShellItem
+ sealed class StoreShellItem : ShellItem
+ {
+ public StoreShellItem(string regPath, bool isPublic, bool isSelect = true) : base(regPath)
+ {
+ this.IsPublic = isPublic;
+ if(isSelect)
{
- public StoreShellItem(string regPath, bool isPublic) : base(regPath)
- {
- this.IsPublic = isPublic;
- this.AddCtr(chkSelected);
- ChkVisible.Visible = BtnSubItems.Visible = false;
- RegTrustedInstaller.TakeRegTreeOwnerShip(regPath);
- }
- public bool IsSelected => chkSelected.Checked;
- public bool IsPublic { get; set; }
- readonly CheckBox chkSelected = new CheckBox { AutoSize = true };
-
- public override void DeleteMe()
- {
- if(IsPublic && MessageBoxEx.Show(AppString.MessageBox.ConfirmDeleteReferenced,
- MessageBoxButtons.YesNo) != DialogResult.Yes) return;
- base.DeleteMe();
- }
+ this.AddCtr(chkSelected, 40.DpiZoom());
+ ChkVisible.Visible = BtnShowMenu.Visible = BtnSubItems.Visible = false;
}
+ RegTrustedInstaller.TakeRegTreeOwnerShip(regPath);
+ }
+ public bool IsSelected => chkSelected.Checked;
+ public bool IsPublic { get; set; }
+ readonly CheckBox chkSelected = new CheckBox { AutoSize = true };
+
+ public override void DeleteMe()
+ {
+ if(IsPublic && MessageBoxEx.Show(AppString.MessageBox.ConfirmDeleteReferenced,
+ MessageBoxButtons.YesNo) != DialogResult.Yes) return;
+ base.DeleteMe();
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/ShellSubMenuDialog.cs b/ContextMenuManager/Controls/ShellSubMenuDialog.cs
index ad28da7..8d1f8a5 100644
--- a/ContextMenuManager/Controls/ShellSubMenuDialog.cs
+++ b/ContextMenuManager/Controls/ShellSubMenuDialog.cs
@@ -1,9 +1,10 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using System;
using System.Collections.Generic;
using System.Drawing;
+using System.IO;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
@@ -34,23 +35,26 @@ sealed class ShellSubMenuForm : Form
{
public ShellSubMenuForm()
{
- this.ShowInTaskbar = this.MinimizeBox = this.MaximizeBox = false;
this.StartPosition = FormStartPosition.CenterParent;
- this.MinimumSize = this.Size = new Size(646, 389).DpiZoom();
- this.Controls.Add(MlbSubItems);
+ this.ShowInTaskbar = this.MaximizeBox = this.MinimizeBox = false;
+ this.MinimumSize = this.Size = new Size(646, 369).DpiZoom();
+ this.Controls.AddRange(new Control[] { MlbSubItems, StatusBar });
this.OnResize(null);
}
/// 子菜单的父菜单的注册表路径
public string ParentPath { get; set; }
readonly MyListBox MlbSubItems = new MyListBox { Dock = DockStyle.Fill };
+ readonly MyStatusBar StatusBar = new MyStatusBar();
+ private MyList LstSubItems;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
bool isPublic = true;
string value = GetValue(ParentPath, "SubCommands", null)?.ToString();
- if(value.IsNullOrWhiteSpace())
+ if(value == null) isPublic = false;
+ else if(value.IsNullOrWhiteSpace())
{
using(var shellKey = RegistryEx.GetRegistryKey($@"{ParentPath}\shell"))
{
@@ -75,14 +79,27 @@ protected override void OnLoad(EventArgs e)
}
if(isPublic)
{
- new PulicMultiItemsList(MlbSubItems).LoadItems(ParentPath);
+ LstSubItems = new PulicMultiItemsList(MlbSubItems);
+ ((PulicMultiItemsList)LstSubItems).LoadItems(ParentPath);
this.Text += $"({AppString.Dialog.Public})";
}
else
{
- new PrivateMultiItemsList(MlbSubItems).LoadItems(ParentPath);
+ LstSubItems = new PrivateMultiItemsList(MlbSubItems);
+ ((PrivateMultiItemsList)LstSubItems).LoadItems(ParentPath);
this.Text += $"({AppString.Dialog.Private})";
}
+ LstSubItems.HoveredItemChanged += (sender, a) =>
+ {
+ if(!AppConfig.ShowFilePath) return;
+ MyListItem item = LstSubItems.HoveredItem;
+ if(item is ITsiFilePathItem pathItem)
+ {
+ string path = pathItem.ItemFilePath;
+ if(File.Exists(path)) { StatusBar.Text = path; return; }
+ }
+ StatusBar.Text = item.Text;
+ };
}
sealed class SubMenuModeForm : Form
@@ -193,7 +210,7 @@ private void AddNewItem()
{
if(dlg.ShowDialog() != DialogResult.OK) return;
SubKeyNames.Add(dlg.NewItemKeyName);
- WriteRegistry();
+ SaveSorting();
this.AddItem(new SubShellItem(this, dlg.NewItemKeyName));
}
}
@@ -210,9 +227,10 @@ private void AddReference()
if(dlg.ShowDialog() != DialogResult.OK) return;
dlg.SelectedKeyNames.ForEach(keyName =>
{
+ if(!SubShellTypeItem.CanAddMore(this)) return;
this.AddItem(new SubShellItem(this, keyName));
this.SubKeyNames.Add(keyName);
- WriteRegistry();
+ SaveSorting();
});
}
}
@@ -220,11 +238,11 @@ private void AddReference()
private void AddSeparator()
{
this.SubKeyNames.Add("|");
- WriteRegistry();
+ SaveSorting();
this.AddItem(new SeparatorItem(this));
}
- private void WriteRegistry()
+ private void SaveSorting()
{
SetValue(ParentPath, "SubCommands", string.Join(";", SubKeyNames.ToArray()));
}
@@ -248,7 +266,7 @@ private void MoveItem(MyListItem item, bool isUp)
this.SubKeyNames.Reverse(index - 1, 2);
}
}
- this.WriteRegistry();
+ this.SaveSorting();
}
private void DeleteItem(MyListItem item)
@@ -257,7 +275,7 @@ private void DeleteItem(MyListItem item)
this.Controls.Remove(item);
this.Controls[index - 1].Focus();
this.SubKeyNames.RemoveAt(index - 1);
- this.WriteRegistry();
+ this.SaveSorting();
item.Dispose();
}
@@ -317,6 +335,7 @@ public InvalidItem(PulicMultiItemsList list, string keyName)
BtnMoveDown.MouseDown += (sender, e) => Owner.MoveItem(this, false);
MyToolTip.SetToolTip(this, AppString.Tip.InvalidItem);
MyToolTip.SetToolTip(BtnDelete, AppString.Menu.Delete);
+ this.SetNoClickEvent();
}
public DeleteButton BtnDelete { get; set; }
@@ -347,7 +366,7 @@ public PrivateMultiItemsList(MyListBox owner) : base(owner)
/// 父菜单的注册表路径
public string ParentPath { get; set; }
/// 子菜单的Shell项注册表路径
- private string ShellPath => $@"{ParentPath}\shell";
+ private string ShellPath { get; set; }
/// 父菜单的Shell项注册表路径
private string ParentShellPath => RegistryEx.GetParentPath(ParentPath);
/// 菜单所处环境注册表路径
@@ -358,6 +377,15 @@ public PrivateMultiItemsList(MyListBox owner) : base(owner)
public void LoadItems(string parentPath)
{
this.ParentPath = parentPath;
+ string sckValue = GetValue(parentPath, "ExtendedSubCommandsKey", null)?.ToString();
+ if(!sckValue.IsNullOrWhiteSpace())
+ {
+ this.ShellPath = $@"HKEY_CLASSES_ROOT\{sckValue}\shell";
+ }
+ else
+ {
+ this.ShellPath = $@"{parentPath}\shell";
+ }
using(var shellKey = RegistryEx.GetRegistryKey(ShellPath))
{
if(shellKey == null) return;
@@ -420,8 +448,9 @@ private void AddFromParentMenu()
if(dlg.ShowDialog() != DialogResult.OK) return;
dlg.SelectedKeyNames.ForEach(keyName =>
{
+ if(!SubShellTypeItem.CanAddMore(this)) return;
string srcPath = $@"{dlg.ShellPath}\{keyName}";
- string dstPath = ObjectPath.GetNewPathWithIndex($@"{this.ShellPath}\{keyName}", ObjectPath.PathType.Registry);
+ string dstPath = ObjectPath.GetNewPathWithIndex($@"{ShellPath}\{keyName}", ObjectPath.PathType.Registry);
RegistryEx.CopyTo(srcPath, dstPath);
this.AddItem(new SubShellItem(this, dstPath));
@@ -530,12 +559,12 @@ class SubSeparatorItem : MyListItem, IBtnDeleteItem, IBtnMoveUpDownItem
public SubSeparatorItem()
{
this.Text = AppString.Item.Separator;
- this.Image = AppImage.Separator;
+ this.HasImage = false;
BtnDelete = new DeleteButton(this);
BtnMoveDown = new MoveButton(this, false);
BtnMoveUp = new MoveButton(this, true);
- MyToolTip.SetToolTip(this, AppString.Tip.Separator);
MyToolTip.SetToolTip(BtnDelete, AppString.Menu.Delete);
+ this.SetNoClickEvent();
}
public DeleteButton BtnDelete { get; set; }
diff --git a/ContextMenuManager/Controls/ThirdRulesList.cs b/ContextMenuManager/Controls/ThirdRulesList.cs
index 15e01a6..aa5a6a5 100644
--- a/ContextMenuManager/Controls/ThirdRulesList.cs
+++ b/ContextMenuManager/Controls/ThirdRulesList.cs
@@ -1,10 +1,9 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using Microsoft.Win32;
using System;
using System.IO;
-using System.Text;
using System.Xml;
namespace ContextMenuManager.Controls
@@ -27,42 +26,136 @@ public void LoadItems()
else continue;
}
- GroupPathItem groupItem = new GroupPathItem(groupXE.GetAttribute("RegPath"), ObjectPath.PathType.Registry)
+ GroupPathItem groupItem;
+ bool isIniGroup = groupXE.HasAttribute("IsIniGroup");
+ string attribute = isIniGroup ? "FilePath" : "RegPath";
+ ObjectPath.PathType pathType = isIniGroup ? ObjectPath.PathType.File : ObjectPath.PathType.Registry;
+ groupItem = new GroupPathItem(groupXE.GetAttribute(attribute), pathType)
{
Text = groupXE.GetAttribute("Text"),
- Image = GuidInfo.GetImage(guid),
+ Image = GuidInfo.GetImage(guid)
};
if(groupItem.Text.IsNullOrWhiteSpace()) groupItem.Text = GuidInfo.GetText(guid);
this.AddItem(groupItem);
+ string GetRuleFullRegPath(string regPath)
+ {
+ if(string.IsNullOrEmpty(regPath)) regPath = groupItem.TargetPath;
+ else if(regPath.StartsWith("\\")) regPath = groupItem.TargetPath + regPath;
+ return regPath;
+ };
+
foreach(XmlElement itemXE in groupXE.ChildNodes)
{
if(!EnhanceMenusList.JudgeOSVersion(itemXE)) continue;
- RegRuleItem.ItemInfo itemInfo = new RegRuleItem.ItemInfo
+ RuleItem ruleItem;
+ ItemInfo info = new ItemInfo
{
Text = itemXE.GetAttribute("Text"),
Tip = itemXE.GetAttribute("Tip"),
RestartExplorer = itemXE.HasAttribute("RestartExplorer"),
};
+ int defaultValue = 0, maxValue = 0, minValue = 0;
+ if(itemXE.HasAttribute("IsNumberItem"))
+ {
+ XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
+ defaultValue = ruleXE.HasAttribute("Default") ? Convert.ToInt32(ruleXE.GetAttribute("Default")) : 0;
+ maxValue = ruleXE.HasAttribute("Max") ? Convert.ToInt32(ruleXE.GetAttribute("Max")) : int.MaxValue;
+ minValue = ruleXE.HasAttribute("Min") ? Convert.ToInt32(ruleXE.GetAttribute("Min")) : int.MinValue;
+ }
- XmlNodeList ruleXNList = itemXE.GetElementsByTagName("Rule");//Rules
- RegRuleItem.RegRule[] rules = new RegRuleItem.RegRule[ruleXNList.Count];
- for(int i = 0; i < ruleXNList.Count; i++)
+ if(isIniGroup)
{
- XmlElement ruleXE = (XmlElement)ruleXNList[i];
- rules[i] = new RegRuleItem.RegRule
+ XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
+ string iniPath = ruleXE.GetAttribute("FilePath");
+ if(iniPath.IsNullOrWhiteSpace()) iniPath = groupItem.TargetPath;
+ string section = ruleXE.GetAttribute("Section");
+ string keyName = ruleXE.GetAttribute("KeyName");
+ if(itemXE.HasAttribute("IsNumberItem"))
+ {
+ var rule = new NumberIniRuleItem.IniRule
+ {
+ IniPath = iniPath,
+ Section = section,
+ KeyName = keyName,
+ DefaultValue = defaultValue,
+ MaxValue = maxValue,
+ MinValue = maxValue
+ };
+ ruleItem = new NumberIniRuleItem(rule, info);
+ }
+ else if(itemXE.HasAttribute("IsStringItem"))
+ {
+ var rule = new StringIniRuleItem.IniRule
+ {
+ IniPath = iniPath,
+ Secation = section,
+ KeyName = keyName
+ };
+ ruleItem = new StringIniRuleItem(rule, info);
+ }
+ else
{
- RegPath = ruleXE.GetAttribute("RegPath"),
- ValueName = ruleXE.GetAttribute("ValueName"),
- TurnOnValue = ruleXE.GetAttribute("On"),
- TurnOffValue = ruleXE.GetAttribute("Off"),
- ValueKind = GetValueKind(ruleXE.GetAttribute("ValueKind"))
- };
- if(string.IsNullOrEmpty(rules[i].RegPath)) rules[i].RegPath = groupItem.TargetPath;
- else if(rules[i].RegPath.StartsWith("\\")) rules[i].RegPath = groupItem.TargetPath + rules[i].RegPath;
+ var rule = new VisbleIniRuleItem.IniRule
+ {
+ IniPath = iniPath,
+ Section = section,
+ KeyName = keyName,
+ TurnOnValue = ruleXE.HasAttribute("On") ? ruleXE.GetAttribute("On") : null,
+ TurnOffValue = ruleXE.HasAttribute("Off") ? ruleXE.GetAttribute("Off") : null,
+ };
+ ruleItem = new VisbleIniRuleItem(rule, info);
+ }
}
- this.AddItem(new RegRuleItem(rules, itemInfo) { FoldGroupItem = groupItem, HasImage = false });
+ else
+ {
+ if(itemXE.HasAttribute("IsNumberItem"))
+ {
+ XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
+ var rule = new NumberRegRuleItem.RegRule
+ {
+ RegPath = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
+ ValueName = ruleXE.GetAttribute("ValueName"),
+ ValueKind = GetValueKind(ruleXE.GetAttribute("ValueKind")),
+ DefaultValue = defaultValue,
+ MaxValue = maxValue,
+ MinValue = minValue
+ };
+ ruleItem = new NumberRegRuleItem(rule, info);
+ }
+ else if(itemXE.HasAttribute("IsStringItem"))
+ {
+ XmlElement ruleXE = (XmlElement)itemXE.SelectSingleNode("Rule");
+ var rule = new StringRegRuleItem.RegRule
+ {
+ RegPath = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
+ ValueName = ruleXE.GetAttribute("ValueName"),
+ };
+ ruleItem = new StringRegRuleItem(rule, info);
+ }
+ else
+ {
+ XmlNodeList ruleXNList = itemXE.SelectNodes("Rule");
+ var rules = new VisibleRegRuleItem.RegRule[ruleXNList.Count];
+ for(int i = 0; i < ruleXNList.Count; i++)
+ {
+ XmlElement ruleXE = (XmlElement)ruleXNList[i];
+ rules[i] = new VisibleRegRuleItem.RegRule
+ {
+ RegPath = GetRuleFullRegPath(ruleXE.GetAttribute("RegPath")),
+ ValueName = ruleXE.GetAttribute("ValueName"),
+ ValueKind = GetValueKind(ruleXE.GetAttribute("ValueKind")),
+ TurnOnValue = ruleXE.HasAttribute("On") ? ruleXE.GetAttribute("On") : null,
+ TurnOffValue = ruleXE.HasAttribute("Off") ? ruleXE.GetAttribute("Off") : null,
+ };
+ }
+ ruleItem = new VisibleRegRuleItem(rules, info);
+ }
+ }
+ this.AddItem(ruleItem);
+ ruleItem.HasImage = false;
+ ruleItem.FoldGroupItem = groupItem;
}
groupItem.IsFold = true;
groupItem.HideWhenNoSubItem();
@@ -76,15 +169,18 @@ private XmlDocument ReadXml()
XmlDocument doc1 = new XmlDocument();
try
{
- if(!File.Exists(AppConfig.WebThirdRulesDic))
+ if(File.Exists(AppConfig.WebThirdRulesDic))
+ {
+ doc1.LoadXml(File.ReadAllText(AppConfig.WebThirdRulesDic, EncodingType.GetType(AppConfig.WebThirdRulesDic)));
+ }
+ else
{
- File.WriteAllText(AppConfig.WebThirdRulesDic, Properties.Resources.ThirdRulesDic, Encoding.UTF8);
+ doc1.LoadXml(Properties.Resources.ThirdRulesDic);
}
- doc1.Load(AppConfig.WebThirdRulesDic);
if(File.Exists(AppConfig.UserThirdRulesDic))
{
XmlDocument doc2 = new XmlDocument();
- doc2.Load(AppConfig.UserThirdRulesDic);
+ doc2.LoadXml(File.ReadAllText(AppConfig.UserThirdRulesDic, EncodingType.GetType(AppConfig.UserThirdRulesDic)));
foreach(XmlNode xn in doc2.DocumentElement.ChildNodes)
{
XmlNode node = doc1.ImportNode(xn, true);
diff --git a/ContextMenuManager/Controls/WinXGroupItem.cs b/ContextMenuManager/Controls/WinXGroupItem.cs
new file mode 100644
index 0000000..e9779a2
--- /dev/null
+++ b/ContextMenuManager/Controls/WinXGroupItem.cs
@@ -0,0 +1,111 @@
+using BluePointLilac.Methods;
+using ContextMenuManager.Controls.Interfaces;
+using System.IO;
+using System.Windows.Forms;
+
+namespace ContextMenuManager.Controls
+{
+ sealed class WinXGroupItem : GroupPathItem, IChkVisibleItem, ITsiDeleteItem, ITsiTextItem
+ {
+ public WinXGroupItem(string groupPath) : base(groupPath, ObjectPath.PathType.Directory)
+ {
+ InitializeComponents();
+ this.TargetPath = groupPath;
+ }
+
+ public new string TargetPath
+ {
+ get => base.TargetPath;
+ set
+ {
+ base.TargetPath = value;
+ this.Text = Path.GetFileNameWithoutExtension(value);
+ this.Image = ResourceIcon.GetFolderIcon(value).ToBitmap();
+ ChkVisible.Checked = this.ItemVisible;
+ }
+ }
+
+ public bool ItemVisible
+ {
+ get => (File.GetAttributes(TargetPath) & FileAttributes.Hidden) != FileAttributes.Hidden;
+ set
+ {
+ FileAttributes attributes = File.GetAttributes(TargetPath);
+ if(value) attributes &= ~FileAttributes.Hidden;
+ else attributes |= FileAttributes.Hidden;
+ File.SetAttributes(TargetPath, attributes);
+ if(Directory.GetFiles(TargetPath).Length > 0) ExplorerRestarter.Show();
+ }
+ }
+
+ public string ItemText
+ {
+ get => Path.GetFileNameWithoutExtension(TargetPath);
+ set
+ {
+ string newPath = $@"{WinXList.WinXPath}\{ObjectPath.RemoveIllegalChars(value)}";
+ Directory.Move(TargetPath, newPath);
+ this.TargetPath = newPath;
+ ExplorerRestarter.Show();
+ }
+ }
+
+ public VisibleCheckBox ChkVisible { get; set; }
+ public DeleteMeMenuItem TsiDeleteMe { get; set; }
+ public ChangeTextMenuItem TsiChangeText { get; set; }
+ readonly ToolStripMenuItem TsiRestoreDefault = new ToolStripMenuItem(AppString.Menu.RestoreDefault);
+
+ private string DefaultGroupPath => $@"{WinXList.DefaultWinXPath}\{ItemText}";
+
+ private void InitializeComponents()
+ {
+ ChkVisible = new VisibleCheckBox(this);
+ this.SetCtrIndex(ChkVisible, 1);
+ TsiDeleteMe = new DeleteMeMenuItem(this);
+ TsiChangeText = new ChangeTextMenuItem(this);
+ this.ContextMenuStrip = new ContextMenuStrip();
+ this.ContextMenuStrip.Items.AddRange(new ToolStripItem[] { TsiChangeText,
+ new ToolStripSeparator(), TsiRestoreDefault, new ToolStripSeparator(), TsiDeleteMe });
+ this.ContextMenuStrip.Opening += (sender, e) => TsiRestoreDefault.Enabled = Directory.Exists(DefaultGroupPath);
+ TsiRestoreDefault.Click += (sender, e) => RestoreDefault();
+ }
+
+ private void RestoreDefault()
+ {
+ if(MessageBoxEx.Show(AppString.MessageBox.RestoreDefault, MessageBoxButtons.OKCancel) == DialogResult.OK)
+ {
+ File.SetAttributes(TargetPath, File.GetAttributes(DefaultGroupPath));
+ string[] paths = Directory.GetFiles(TargetPath);
+ foreach(string path in paths)
+ {
+ File.Delete(path);
+ }
+ paths = Directory.GetFiles(DefaultGroupPath);
+ foreach(string path in paths)
+ {
+ File.Copy(path, $@"{TargetPath}\{Path.GetFileName(path)}");
+ }
+ WinXList list = (WinXList)this.Parent;
+ list.ClearItems();
+ list.LoadItems();
+ ExplorerRestarter.Show();
+ }
+ }
+
+ public void DeleteMe()
+ {
+ bool flag = Directory.GetFiles(TargetPath, "*.lnk").Length > 0;
+ if(flag && MessageBoxEx.Show(AppString.MessageBox.DeleteGroup, MessageBoxButtons.OKCancel) != DialogResult.OK) return;
+ File.SetAttributes(TargetPath, FileAttributes.Normal);
+ Directory.Delete(TargetPath, true);
+ if(flag)
+ {
+ WinXList list = (WinXList)this.Parent;
+ list.ClearItems();
+ list.LoadItems();
+ ExplorerRestarter.Show();
+ }
+ else this.Dispose();
+ }
+ }
+}
\ No newline at end of file
diff --git a/ContextMenuManager/Controls/WinXItem.cs b/ContextMenuManager/Controls/WinXItem.cs
index 87e1390..0a46aad 100644
--- a/ContextMenuManager/Controls/WinXItem.cs
+++ b/ContextMenuManager/Controls/WinXItem.cs
@@ -1,5 +1,5 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls.Interfaces;
using System.Drawing;
using System.IO;
@@ -7,8 +7,8 @@
namespace ContextMenuManager.Controls
{
- sealed class WinXItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem,
- ITsiTextItem, ITsiWebSearchItem, ITsiFilePathItem, ITsiDeleteItem, IFoldSubItem
+ sealed class WinXItem : MyListItem, IChkVisibleItem, IBtnShowMenuItem, IBtnMoveUpDownItem, ITsiAdministratorItem,
+ ITsiTextItem, ITsiWebSearchItem, ITsiFilePathItem, ITsiDeleteItem, IFoldSubItem, ITsiShortcutCommandItem
{
public WinXItem(string filePath, IFoldGroupItem group)
{
@@ -24,7 +24,7 @@ public string FilePath
set
{
filePath = value;
- this.Shortcut.FullName = value;
+ this.Shortcut = new WshShortcut(value);
this.Text = this.ItemText;
this.Image = this.ItemIcon.ToBitmap();
ChkVisible.Checked = this.ItemVisible;
@@ -35,8 +35,8 @@ public string ItemText
{
get
{
- string name = Shortcut.Description.Trim();
- if(name == string.Empty) name = WinXList.GetItemText(FilePath);
+ string name = Shortcut.Description?.Trim();
+ if(name.IsNullOrWhiteSpace()) name = DesktopIni.GetLocalizedFileNames(FilePath, true);
if(name == string.Empty) name = Path.GetFileNameWithoutExtension(FilePath);
return name;
}
@@ -45,7 +45,7 @@ public string ItemText
Shortcut.Description = value;
Shortcut.Save();
this.Text = ResourceString.GetDirectString(value);
- ExplorerRestarter.NeedRestart = true;
+ ExplorerRestarter.Show();
}
}
@@ -58,33 +58,39 @@ public bool ItemVisible
if(value) attributes &= ~FileAttributes.Hidden;
else attributes |= FileAttributes.Hidden;
File.SetAttributes(FilePath, attributes);
- ExplorerRestarter.NeedRestart = true;
+ ExplorerRestarter.Show();
}
}
- private string IconLocation
+ public Icon ItemIcon
{
get
{
- if(Shortcut.IconLocation.StartsWith(","))
- Shortcut.IconLocation = $"{Shortcut.TargetPath}{Shortcut.IconLocation}";
- return Shortcut.IconLocation;
+ Icon icon = ResourceIcon.GetIcon(Shortcut.IconLocation);
+ if(icon == null)
+ {
+ string path = ItemFilePath;
+ if(File.Exists(path)) icon = ResourceIcon.GetExtensionIcon(path);
+ else if(Directory.Exists(path)) icon = ResourceIcon.GetFolderIcon(path);
+ }
+ return icon;
}
}
- private WshShortcut Shortcut = new WshShortcut();
- private Icon ItemIcon => ResourceIcon.GetIcon(IconLocation) ?? Icon.ExtractAssociatedIcon(Shortcut.TargetPath);
- public string SearchText => $"{AppString.SideBar.WinX} {Text}";
-
public string ItemFilePath
{
get
{
- if(File.Exists(Shortcut.TargetPath)) return Shortcut.TargetPath;
- else return FilePath;
+ string path = Shortcut.TargetPath;
+ if(!File.Exists(path) && !Directory.Exists(path)) path = FilePath;
+ return path;
}
}
+ public WshShortcut Shortcut { get; private set; }
+ public string SearchText => $"{AppString.SideBar.WinX} {Text}";
+ private string FileName => Path.GetFileName(FilePath);
+
public IFoldGroupItem FoldGroupItem { get; set; }
public VisibleCheckBox ChkVisible { get; set; }
public MenuButton BtnShowMenu { get; set; }
@@ -92,29 +98,129 @@ public string ItemFilePath
public WebSearchMenuItem TsiSearch { get; set; }
public FilePropertiesMenuItem TsiFileProperties { get; set; }
public FileLocationMenuItem TsiFileLocation { get; set; }
+ public ShortcutCommandMenuItem TsiChangeCommand { get; set; }
+ public RunAsAdministratorItem TsiAdministrator { get; set; }
public DeleteMeMenuItem TsiDeleteMe { get; set; }
+ public MoveButton BtnMoveUp { get; set; }
+ public MoveButton BtnMoveDown { get; set; }
+
readonly ToolStripMenuItem TsiDetails = new ToolStripMenuItem(AppString.Menu.Details);
+ readonly ToolStripMenuItem TsiChangeGroup = new ToolStripMenuItem(AppString.Menu.ChangeGroup);
+
private void InitializeComponents()
{
BtnShowMenu = new MenuButton(this);
ChkVisible = new VisibleCheckBox(this);
+ BtnMoveDown = new MoveButton(this, false);
+ BtnMoveUp = new MoveButton(this, true);
TsiChangeText = new ChangeTextMenuItem(this);
+ TsiChangeCommand = new ShortcutCommandMenuItem(this);
+ TsiAdministrator = new RunAsAdministratorItem(this);
TsiSearch = new WebSearchMenuItem(this);
TsiFileLocation = new FileLocationMenuItem(this);
TsiFileProperties = new FilePropertiesMenuItem(this);
TsiDeleteMe = new DeleteMeMenuItem(this);
- ContextMenuStrip.Items.AddRange(new ToolStripItem[] { TsiChangeText,
- new ToolStripSeparator(), TsiDetails, new ToolStripSeparator(), TsiDeleteMe });
+ ContextMenuStrip.Items.AddRange(new ToolStripItem[] { TsiChangeText, new ToolStripSeparator(),
+ TsiChangeGroup, new ToolStripSeparator(), TsiAdministrator, new ToolStripSeparator(),
+ TsiDetails, new ToolStripSeparator(), TsiDeleteMe });
TsiDetails.DropDownItems.AddRange(new ToolStripItem[] { TsiSearch,
- new ToolStripSeparator(), TsiFileProperties, TsiFileLocation });
+ new ToolStripSeparator(), TsiChangeCommand, TsiFileProperties, TsiFileLocation });
+
+ TsiChangeGroup.Click += (sender, e) => ChangeGroup();
+ BtnMoveDown.MouseDown += (sender, e) => MoveItem(false);
+ BtnMoveUp.MouseDown += (sender, e) => MoveItem(true);
+ TsiAdministrator.Click += (sender, e) => {
+ WinXList.HashLnk(this.FilePath);
+ ExplorerRestarter.Show();
+ };
+ TsiChangeCommand.Click += (sender, e) =>
+ {
+ if(TsiChangeCommand.ChangeCommand(Shortcut))
+ {
+ Image = ItemIcon.ToBitmap();
+ WinXList.HashLnk(this.FilePath);
+ }
+ };
+ }
+
+ private void ChangeGroup()
+ {
+ using(SelectDialog dlg = new SelectDialog())
+ {
+ dlg.Title = AppString.Dialog.SelectGroup;
+ dlg.Items = WinXList.GetGroupNames();
+ dlg.Selected = this.FoldGroupItem.Text;
+ if(dlg.ShowDialog() != DialogResult.OK) return;
+ if(dlg.Selected == this.FoldGroupItem.Text) return;
+ string dirPath = $@"{WinXList.WinXPath}\{dlg.Selected}";
+ int count = Directory.GetFiles(dirPath, "*.lnk").Length;
+ string num = (count + 1).ToString().PadLeft(2, '0');
+ string partName = this.FileName;
+ int index = partName.IndexOf(" - ");
+ if(index > 0) partName = partName.Substring(index + 3);
+ string lnkPath = $@"{dirPath}\{num} - {partName}";
+ lnkPath = ObjectPath.GetNewPathWithIndex(lnkPath, ObjectPath.PathType.File);
+ string text = DesktopIni.GetLocalizedFileNames(FilePath);
+ DesktopIni.DeleteLocalizedFileNames(FilePath);
+ if(text != string.Empty) DesktopIni.SetLocalizedFileNames(lnkPath, text);
+ File.Move(FilePath, lnkPath);
+ this.FilePath = lnkPath;
+ WinXList list = (WinXList)this.Parent;
+ list.Controls.Remove(this);
+ for(int i = 0; i < list.Controls.Count; i++)
+ {
+ if(list.Controls[i] is WinXGroupItem groupItem && groupItem.Text == dlg.Selected)
+ {
+ list.Controls.Add(this);
+ list.SetItemIndex(this, i + 1);
+ this.Visible = !groupItem.IsFold;
+ this.FoldGroupItem = groupItem;
+ break;
+ }
+ }
+ ExplorerRestarter.Show();
+ }
+ }
+
+ private void MoveItem(bool isUp)
+ {
+ WinXList list = (WinXList)this.Parent;
+ int index = list.Controls.GetChildIndex(this);
+ if(index == list.Controls.Count - 1) return;
+ index += isUp ? -1 : 1;
+ Control ctr = list.Controls[index];
+ if(ctr is WinXGroupItem) return;
+ WinXItem item = (WinXItem)ctr;
+ string name1 = DesktopIni.GetLocalizedFileNames(this.FilePath);
+ string name2 = DesktopIni.GetLocalizedFileNames(item.FilePath);
+ DesktopIni.DeleteLocalizedFileNames(this.FilePath);
+ DesktopIni.DeleteLocalizedFileNames(item.FilePath);
+ string fileName1 = $@"{item.FileName.Substring(0, 2)}{this.FileName.Substring(2)}";
+ string fileName2 = $@"{this.FileName.Substring(0, 2)}{item.FileName.Substring(2)}";
+ string dirPath = Path.GetDirectoryName(this.FilePath);
+ string path1 = $@"{dirPath}\{fileName1}";
+ string path2 = $@"{dirPath}\{fileName2}";
+ path1 = ObjectPath.GetNewPathWithIndex(path1, ObjectPath.PathType.File);
+ path2 = ObjectPath.GetNewPathWithIndex(path2, ObjectPath.PathType.File);
+ File.Move(this.FilePath, path1);
+ File.Move(item.FilePath, path2);
+ if(name1 != string.Empty) DesktopIni.SetLocalizedFileNames(path1, name1);
+ if(name1 != string.Empty) DesktopIni.SetLocalizedFileNames(path2, name2);
+ this.FilePath = path1;
+ item.FilePath = path2;
+ list.SetItemIndex(this, index);
+ ExplorerRestarter.Show();
}
public void DeleteMe()
{
- File.Delete(this.FilePath);
+ File.Delete(FilePath);
+ DesktopIni.DeleteLocalizedFileNames(FilePath);
+ ExplorerRestarter.Show();
+ this.Shortcut.Dispose();
this.Dispose();
}
}
diff --git a/ContextMenuManager/Controls/WinXList.cs b/ContextMenuManager/Controls/WinXList.cs
index bf211e8..e7ad425 100644
--- a/ContextMenuManager/Controls/WinXList.cs
+++ b/ContextMenuManager/Controls/WinXList.cs
@@ -1,53 +1,202 @@
-using BulePointLilac.Controls;
-using BulePointLilac.Methods;
-using ContextMenuManager.Controls.Interfaces;
+using BluePointLilac.Controls;
+using BluePointLilac.Methods;
using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
+using System.Text;
+using System.Windows.Forms;
namespace ContextMenuManager.Controls
{
sealed class WinXList : MyList
{
public static readonly string WinXPath = Environment.ExpandEnvironmentVariables(@"%LocalAppData%\Microsoft\Windows\WinX");
- private static readonly Dictionary DesktopIniReaders = new Dictionary();
+ public static readonly string DefaultWinXPath = Environment.ExpandEnvironmentVariables(@"%HOMEDRIVE%\Users\Default\AppData\Local\Microsoft\Windows\WinX");
- public static string GetItemText(string filePath)
+ public void LoadItems()
{
- string dirPath = Path.GetDirectoryName(filePath);
- string fileName = Path.GetFileName(filePath);
- if(DesktopIniReaders.TryGetValue(dirPath, out IniReader reader))
+ if(WindowsOsVersion.ISAfterOrEqual8)
{
- string name = reader.GetValue("LocalizedFileNames", fileName);
- name = ResourceString.GetDirectString(name);
- return name;
+ this.AddNewItem();
+ this.LoadWinXItems();
}
- else return string.Empty;
}
- public void LoadItems()
+ private void LoadWinXItems()
{
- if(WindowsOsVersion.ISAfterOrEqual8)
+ string[] dirPaths = Directory.GetDirectories(WinXPath);
+ Array.Reverse(dirPaths);
+ bool sortable = AppConfig.WinXSortable;
+ bool sorted = false;
+ foreach(string dirPath in dirPaths)
+ {
+ WinXGroupItem groupItem = new WinXGroupItem(dirPath);
+ this.AddItem(groupItem);
+ string[] lnkPaths;
+ if(sortable)
+ {
+ lnkPaths = GetSortedPaths(dirPath, out bool flag);
+ if(flag) sorted = true;
+ }
+ else
+ {
+ lnkPaths = Directory.GetFiles(dirPath, "*.lnk");
+ Array.Reverse(lnkPaths);
+ }
+ foreach(string path in lnkPaths)
+ {
+ WinXItem winXItem = new WinXItem(path, groupItem);
+ winXItem.BtnMoveDown.Visible = winXItem.BtnMoveUp.Visible = sortable;
+ this.AddItem(winXItem);
+ }
+ groupItem.IsFold = true;
+ }
+ if(sorted)
{
- DesktopIniReaders.Clear();
- Array.ForEach(new DirectoryInfo(WinXPath).GetDirectories(), di => LoadSubDirItems(di));
+ ExplorerRestarter.Show();
+ MessageBoxEx.Show(AppString.MessageBox.WinXSorted);
}
}
- private void LoadSubDirItems(DirectoryInfo di)
+ private void AddNewItem()
{
- GroupPathItem groupItem = new GroupPathItem(di.FullName, ObjectPath.PathType.Directory)
+ NewItem newItem = new NewItem();
+ this.AddItem(newItem);
+ PictureButton btnCreateDir = new PictureButton(AppImage.NewFolder);
+ MyToolTip.SetToolTip(btnCreateDir, AppString.Tip.CreateGroup);
+ newItem.AddCtr(btnCreateDir);
+ btnCreateDir.MouseDown += (sender, e) => CreateNewGroup();
+ newItem.AddNewItem += (sender, e) =>
{
- Text = Path.GetFileNameWithoutExtension(di.FullName),
- Image = ResourceIcon.GetFolderIcon(di.FullName).ToBitmap()
+ using(NewLnkFileDialog dlg1 = new NewLnkFileDialog())
+ {
+ if(dlg1.ShowDialog() != DialogResult.OK) return;
+ using(SelectDialog dlg2 = new SelectDialog())
+ {
+ dlg2.Title = AppString.Dialog.SelectGroup;
+ dlg2.Items = GetGroupNames();
+ dlg2.Selected = dlg2.Items[0];
+ if(dlg2.ShowDialog() != DialogResult.OK) return;
+ string dirPath = $@"{WinXPath}\{dlg2.Selected}";
+ string extension = Path.GetExtension(dlg1.ItemFilePath).ToLower();
+ string fileName = Path.GetFileNameWithoutExtension(dlg1.ItemFilePath);
+ int count = Directory.GetFiles(dirPath, "*.lnk").Length;
+ string index = (count + 1).ToString().PadLeft(2, '0');
+ string lnkName = $"{index} - {fileName}.lnk";
+ string lnkPath = $@"{dirPath}\{lnkName}";
+ WshShortcut shortcut;
+ if(extension == ".lnk")
+ {
+ File.Copy(dlg1.ItemFilePath, lnkPath);
+ shortcut = new WshShortcut(lnkPath);
+ }
+ else
+ {
+ shortcut = new WshShortcut(lnkPath)
+ {
+ TargetPath = dlg1.ItemFilePath,
+ Arguments = dlg1.Arguments,
+ WorkingDirectory = Path.GetDirectoryName(dlg1.ItemFilePath)
+ };
+ }
+ shortcut.Description = dlg1.ItemText;
+ shortcut.Save();
+ shortcut.Dispose();
+ DesktopIni.SetLocalizedFileNames(lnkPath, dlg1.ItemText);
+ HashLnk(lnkPath);
+ foreach(MyListItem ctr in this.Controls)
+ {
+ if(ctr is WinXGroupItem groupItem && groupItem.Text == dlg2.Selected)
+ {
+ WinXItem item = new WinXItem(lnkPath, groupItem) { Visible = !groupItem.IsFold };
+ item.BtnMoveDown.Visible = item.BtnMoveUp.Visible = AppConfig.WinXSortable;
+ this.InsertItem(item, this.GetItemIndex(groupItem) + 1);
+ break;
+ }
+ }
+ ExplorerRestarter.Show();
+ }
+ }
};
- this.AddItem(groupItem);
- string iniPath = $@"{di.FullName}\desktop.ini";
- DesktopIniReaders.Add(di.FullName, new IniReader(iniPath));
- Array.ForEach(di.GetFiles(), fi =>
+ }
+
+ private void CreateNewGroup()
+ {
+ string dirPath = ObjectPath.GetNewPathWithIndex($@"{WinXPath}\Group", ObjectPath.PathType.Directory, 1);
+ Directory.CreateDirectory(dirPath);
+ string iniPath = $@"{dirPath}\desktop.ini";
+ File.WriteAllText(iniPath, string.Empty, Encoding.Unicode);
+ File.SetAttributes(dirPath, File.GetAttributes(dirPath) | FileAttributes.ReadOnly);
+ File.SetAttributes(iniPath, File.GetAttributes(iniPath) | FileAttributes.Hidden | FileAttributes.System);
+ this.InsertItem(new WinXGroupItem(dirPath), 1);
+ }
+
+ public static void HashLnk(string lnkPath)
+ {
+ using(FileStream fs = new FileStream(AppConfig.HashLnkExePath, FileMode.OpenOrCreate))
{
- if(fi.Extension.ToLower() == ".lnk") this.AddItem(new WinXItem(fi.FullName, groupItem));
- });
+ byte[] buffer;
+ //Any CPU编译条件下,64bit操作系统IntPtr.Size = 8
+ if(IntPtr.Size == 8 && !lnkPath.StartsWith(Environment.ExpandEnvironmentVariables("%ProgramFiles(x86)%")))
+ {
+ buffer = Properties.Resources.HashLnk_64;
+ }
+ else
+ {
+ buffer = Properties.Resources.HashLnk_32;
+ }
+ fs.Write(buffer, 0, buffer.Length);
+ }
+
+ using(Process process = new Process())
+ {
+ process.StartInfo = new ProcessStartInfo
+ {
+ FileName = AppConfig.HashLnkExePath,
+ Arguments = $"\"{lnkPath}\"",
+ UseShellExecute = false,
+ CreateNoWindow = true,
+ WindowStyle = ProcessWindowStyle.Hidden
+ };
+ process.Start();
+ process.WaitForExit();
+ }
+ }
+
+ public static string[] GetGroupNames()
+ {
+ List items = new List();
+ DirectoryInfo winxDi = new DirectoryInfo(WinXPath);
+ Array.ForEach(winxDi.GetDirectories(), di => items.Add(di.Name));
+ items.Reverse();
+ return items.ToArray();
+ }
+
+ private static string[] GetSortedPaths(string groupPath, out bool sorted)
+ {
+ sorted = false;
+ List sortedPaths = new List();
+ string[] paths = Directory.GetFiles(groupPath, "*.lnk");
+ for(int i = paths.Length - 1; i >= 0; i--)
+ {
+ string srcPath = paths[i];
+ string name = Path.GetFileName(srcPath);
+ int index = name.IndexOf(" - ");
+ if(index >= 2 && int.TryParse(name.Substring(0, index), out int num) && num == i + 1)
+ {
+ sortedPaths.Add(srcPath); continue;
+ }
+ string dstPath = $@"{groupPath}\{(i + 1).ToString().PadLeft(2, '0')} - {name.Substring(index + 3)}";
+ dstPath = ObjectPath.GetNewPathWithIndex(dstPath, ObjectPath.PathType.File);
+ string value = DesktopIni.GetLocalizedFileNames(srcPath);
+ DesktopIni.DeleteLocalizedFileNames(srcPath);
+ if(value != string.Empty) DesktopIni.SetLocalizedFileNames(dstPath, value);
+ File.Move(srcPath, dstPath);
+ sortedPaths.Add(dstPath);
+ sorted = true;
+ }
+ return sortedPaths.ToArray();
}
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/GuidInfo.cs b/ContextMenuManager/GuidInfo.cs
index e7b5d91..dd3b3bb 100644
--- a/ContextMenuManager/GuidInfo.cs
+++ b/ContextMenuManager/GuidInfo.cs
@@ -1,4 +1,4 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using ContextMenuManager.Controls;
using Microsoft.Win32;
using System;
@@ -27,7 +27,7 @@ public struct IconLocation
static GuidInfo()
{
//将Skype添加到字典
- Guid skypeGuid = new Guid(RegRuleItem.SkypeGuidStr);
+ Guid skypeGuid = new Guid(VisibleRegRuleItem.SkypeGuid);
FilePathDic.Add(skypeGuid, null);
ItemTextDic.Add(skypeGuid, AppString.Item.ShareWithSkype);
ItemImageDic.Add(skypeGuid, AppImage.Skype);
diff --git a/ContextMenuManager/MainForm.cs b/ContextMenuManager/MainForm.cs
index 84d4cc5..d1ab8df 100644
--- a/ContextMenuManager/MainForm.cs
+++ b/ContextMenuManager/MainForm.cs
@@ -1,7 +1,9 @@
-using BulePointLilac.Controls;
+using BluePointLilac.Controls;
using ContextMenuManager.Controls;
+using ContextMenuManager.Controls.Interfaces;
using System;
using System.Drawing;
+using System.IO;
using System.Linq;
using System.Windows.Forms;
@@ -16,21 +18,22 @@ public MainForm()
this.ForeColor = Color.FromArgb(80, 80, 80);
this.Controls.Add(new ExplorerRestarter());
appSettingBox.Owner = shellList.Owner = shellNewList.Owner = sendToList.Owner = openWithList.Owner
- = winXList.Owner = guidBlockedList.Owner = enhanceMenusList.Owner = thirdRuleList.Owner = MainBody;
+ = winXList.Owner = guidBlockedList.Owner = enhanceMenusList.Owner = thirdRuleList.Owner = iEList.Owner = MainBody;
donateBox.Parent = aboutMeBox.Parent = dictionariesBox.Parent = languagesBox.Parent = MainBody;
SideBar.SelectIndexChanged += (sender, e) => SwitchItem();
SideBar.HoverIndexChanged += (sender, e) => ShowItemInfo();
ToolBar.SelectedButtonChanged += (sender, e) => SwitchTab();
- ((RefreshButton)ToolBarButtons[3]).ClickMe += (sender, e) => SideBar.SelectIndex = SideBar.SelectIndex;
+ ToolBarButtons[3].MouseDown += (sender, e) => SwitchItem();
ToolBar.AddButtons(ToolBarButtons);
ToolBar.SelectedIndex = 0;
+ if(AppConfig.ShowFilePath) ShowFilePath();
}
readonly MyToolBarButton[] ToolBarButtons = new MyToolBarButton[] {
new MyToolBarButton(AppImage.Home, AppString.ToolBar.Home),//主页
new MyToolBarButton(AppImage.Type, AppString.ToolBar.Type),//文件类型
new MyToolBarButton(AppImage.Star, AppString.ToolBar.Rule),//其他规则
- new RefreshButton(),//刷新
+ new MyToolBarButton(AppImage.Refresh,AppString.ToolBar.Refresh){ CanBeSelected = false },//刷新
new MyToolBarButton(AppImage.About, AppString.ToolBar.About)//关于
};
readonly ShellList shellList = new ShellList();
@@ -41,6 +44,7 @@ public MainForm()
readonly GuidBlockedList guidBlockedList = new GuidBlockedList();
readonly EnhanceMenusList enhanceMenusList = new EnhanceMenusList();
readonly ThirdRulesList thirdRuleList = new ThirdRulesList();
+ readonly IEList iEList = new IEList();
readonly ReadOnlyRichTextBox aboutMeBox = new ReadOnlyRichTextBox
{
Text = AppString.Other.AboutApp
@@ -92,51 +96,43 @@ public MainForm()
AppString.SideBar.UwpLnk,
AppString.SideBar.ExeFile,
null,
- AppString.SideBar.TextFile,
- AppString.SideBar.DocumentFile,
- AppString.SideBar.ImageFile,
- AppString.SideBar.VideoFile,
- AppString.SideBar.AudioFile,
- AppString.SideBar.ImageDirectory,
- AppString.SideBar.VideoDirectory,
- AppString.SideBar.AudioDirectory,
+ AppString.SideBar.CustomExtension,
+ AppString.SideBar.PerceivedType,
+ AppString.SideBar.DirectoryType,
null,
- AppString.SideBar.UnknownType,
- null,
- AppString.SideBar.CustomType
+ AppString.SideBar.UnknownType
};
static readonly string[] TypeItemInfos = {
AppString.StatusBar.LnkFile,
AppString.StatusBar.UwpLnk,
AppString.StatusBar.ExeFile,
null,
- AppString.StatusBar.TextFile,
- AppString.StatusBar.DocumentFile,
- AppString.StatusBar.ImageFile,
- AppString.StatusBar.VideoFile,
- AppString.StatusBar.AudioFile,
- AppString.StatusBar.ImageDirectory,
- AppString.StatusBar.VideoDirectory,
- AppString.StatusBar.AudioDirectory,
- null,
- AppString.StatusBar.UnknownType,
+ AppString.StatusBar.CustomExtension,
+ AppString.StatusBar.PerceivedType,
+ AppString.StatusBar.DirectoryType,
null,
- AppString.StatusBar.CustomType
+ AppString.StatusBar.UnknownType
};
static readonly string[] OtherRuleItems = {
AppString.SideBar.EnhanceMenu,
AppString.SideBar.ThirdRules,
null,
+ AppString.SideBar.DragDrop,
AppString.SideBar.PublicReferences,
- AppString.SideBar.GuidBlocked
+ AppString.SideBar.GuidBlocked,
+ null,
+ AppString.SideBar.IEMenu
};
static readonly string[] OtherRuleItemInfos = {
AppString.StatusBar.EnhanceMenu,
AppString.StatusBar.ThirdRules,
null,
+ AppString.StatusBar.DragDrop,
AppString.StatusBar.PublicReferences,
- AppString.StatusBar.GuidBlocked
+ AppString.StatusBar.GuidBlocked,
+ null,
+ AppString.StatusBar.IEMenu
};
static readonly string[] AboutItems = {
@@ -167,18 +163,11 @@ public MainForm()
ShellList.Scenes.UwpLnk,
ShellList.Scenes.ExeFile,
null,
- ShellList.Scenes.TextFile,
- ShellList.Scenes.DocumentFile,
- ShellList.Scenes.ImageFile,
- ShellList.Scenes.VideoFile,
- ShellList.Scenes.AudioFile,
- ShellList.Scenes.ImageDirectory,
- ShellList.Scenes.VideoDirectory,
- ShellList.Scenes.AudioDirectory,
- null,
- ShellList.Scenes.UnknownType,
+ ShellList.Scenes.CustomExtension,
+ ShellList.Scenes.PerceivedType,
+ ShellList.Scenes.DirectoryType,
null,
- ShellList.Scenes.CustomType
+ ShellList.Scenes.UnknownType
};
private void HideAllParts()
@@ -245,6 +234,27 @@ private void ShowItemInfo()
StatusBar.Text = MyStatusBar.DefaultText;
}
+ private void ShowFilePath()
+ {
+ foreach(MyList list in new MyList[] { shellList, shellNewList, sendToList, openWithList, winXList, guidBlockedList, iEList })
+ {
+ list.HoveredItemChanged += (sender, e) =>
+ {
+ MyListItem item = list.HoveredItem;
+ if(item is ITsiFilePathItem pathItem)
+ {
+ string path = pathItem.ItemFilePath;
+ if(File.Exists(path)) { StatusBar.Text = path; return; }
+ }
+ if(item is GuidBlockedItem guidItem)
+ {
+ StatusBar.Text = guidItem.Value; return;
+ }
+ StatusBar.Text = item.Text;
+ };
+ }
+ }
+
private void SwitchGeneralItem()
{
switch(SideBar.SelectIndex)
@@ -261,6 +271,7 @@ private void SwitchGeneralItem()
if(SideBar.SelectIndex <= 9)
{
shellList.Scene = GeneralShellScenes[SideBar.SelectIndex];
+ shellList.LoadItems();
shellList.Visible = true;
}
break;
@@ -270,6 +281,7 @@ private void SwitchGeneralItem()
private void SwitchTypeItem()
{
shellList.Scene = (ShellList.Scenes)TypeShellScenes[SideBar.SelectIndex];
+ shellList.LoadItems();
shellList.Visible = true;
}
@@ -282,9 +294,13 @@ private void SwitchOtherRuleItem()
case 1:
thirdRuleList.LoadItems(); thirdRuleList.Visible = true; break;
case 3:
- shellList.Scene = ShellList.Scenes.CommandStore; shellList.Visible = true; break;
+ shellList.Scene = ShellList.Scenes.DragDrop; shellList.LoadItems(); shellList.Visible = true; break;
case 4:
+ shellList.Scene = ShellList.Scenes.CommandStore; shellList.LoadItems(); shellList.Visible = true; break;
+ case 5:
guidBlockedList.LoadItems(); guidBlockedList.Visible = true; break;
+ case 7:
+ iEList.LoadItems(); iEList.Visible = true; break;
}
}
@@ -320,17 +336,5 @@ private void SetSideBarWidth()
Array.ForEach(strs, str => maxWidth = Math.Max(maxWidth, SideBar.GetItemWidth(str)));
SideBar.Width = maxWidth;
}
-
- sealed class RefreshButton : MyToolBarButton
- {
- public RefreshButton() : base(AppImage.Refresh, AppString.ToolBar.Refresh) { }
-
- public EventHandler ClickMe;
-
- protected override void OnMouseDown(MouseEventArgs e)
- {
- ClickMe?.Invoke(null, null);
- }
- }
}
}
\ No newline at end of file
diff --git a/ContextMenuManager/Program.cs b/ContextMenuManager/Program.cs
index 1503daa..eadefc4 100644
--- a/ContextMenuManager/Program.cs
+++ b/ContextMenuManager/Program.cs
@@ -1,4 +1,5 @@
-using System;
+using BluePointLilac.Methods;
+using System;
using System.Windows.Forms;
namespace ContextMenuManager
@@ -12,8 +13,10 @@ namespace ContextMenuManager
static class Program
{
[STAThread]
- static void Main()
+ 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);
diff --git a/ContextMenuManager/Properties/AssemblyInfo.cs b/ContextMenuManager/Properties/AssemblyInfo.cs
index 3403601..4a9241f 100644
--- a/ContextMenuManager/Properties/AssemblyInfo.cs
+++ b/ContextMenuManager/Properties/AssemblyInfo.cs
@@ -6,10 +6,10 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("蓝点llilac")]
[assembly: AssemblyProduct("Windows右键管理")]
-[assembly: AssemblyCopyright("Copyright @ 2020 蓝点lilac")]
+[assembly: AssemblyCopyright("Copyright @ 2020-2021 蓝点lilac")]
[assembly: AssemblyTrademark("蓝点llilac")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("35190ec1-2515-488d-a2e9-825d6ff67aa2")]
-[assembly: AssemblyVersion("2.2.0.0")]
-[assembly: AssemblyFileVersion("2.2.0.0")]
\ No newline at end of file
+[assembly: AssemblyVersion("3.0.0.0")]
+[assembly: AssemblyFileVersion("3.0.0.0")]
\ No newline at end of file
diff --git a/ContextMenuManager/Properties/Resources.Designer.cs b/ContextMenuManager/Properties/Resources.Designer.cs
index 64c5d54..deaee76 100644
--- a/ContextMenuManager/Properties/Resources.Designer.cs
+++ b/ContextMenuManager/Properties/Resources.Designer.cs
@@ -19,7 +19,7 @@ namespace ContextMenuManager.Properties {
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
@@ -47,8 +47,8 @@ internal class Resources {
}
///
- /// 重写当前线程的 CurrentUICulture 属性
- /// 重写当前线程的 CurrentUICulture 属性。
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
///
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
@@ -101,10 +101,10 @@ internal class Resources {
}
///
- /// 查找类似 ;此文件为ContextMenuManager程序的显示文本字典
- ///;如果你想要帮助作者为此程序添加其他语言字典, 可以修改此文本并保存在.\config\languages文件夹内,
- ///;比如美国英语字典保存为en-US.ini, 并给[General]\Language赋值 en-US English
- ///;可以在Github或Gitee上Fork该项目并提交申请给我,或者直接发送文件到邮箱1617859183@qq.com
+ /// 查找类似 ;此文件为 ContextMenuManager Windows右键管理程序 的显示文本字典
+ ///;翻译:可帮助作者为此程序提供翻译并提交到Github,以下内容中等号右侧内容替换为翻译文本,
+ ///;General-Translator为翻译贡献者,General-Language为语言名称,如en-US 美国英语
+ ///;翻译文件保存在Config\languages目录中,文件名保存为en-US.ini
///;翻译说明:暂时不翻译的值保留为空即可,字典内赋值换行请使用\n进行转义
///
///[General]
@@ -125,7 +125,8 @@ internal class Resources {
///Directory = 目录
///Background = 目录背景
///Desktop = 桌面背景
- ///Drive = 磁盘 [字符串的其余部分被截断]"; 的本地化字符串。
+ ///Drive = 磁盘分区
+ ///AllObjects [字符串的其余部分被截断]"; 的本地化字符串。
///
internal static string AppLanguageDic {
get {
@@ -136,9 +137,9 @@ internal class Resources {
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
- internal static System.Drawing.Bitmap CustomType {
+ internal static System.Drawing.Bitmap Custom {
get {
- object obj = ResourceManager.GetObject("CustomType", resourceCulture);
+ object obj = ResourceManager.GetObject("Custom", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@@ -167,16 +168,14 @@ internal class Resources {
/// 查找类似 <?xml version='1.0' encoding='utf-8' ?>
///<!--此文件为常用右键菜单字典,
///Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开始, 子元素Value表示该项的注册表键值,目前仅支持REG_SZ、REG_DWORD、REG_EXPAND_SZ的键值类型,
- ///子元素SubKey的所有子元素是该项的子项,项名即为元素名; 每一Item项和SubKey的所有子元素的属性Default为该注册表项默认值,不放在Value\REG_SZ元素里面是为了防止与可能存在的键名为Default的键产生冲突-->
+ ///子元素SubKey的所有子元素是该项的子项,项名即为元素名; 每一Item项和SubKey的所有子元素的属性Default为该注册表项默认值,不放在Value\REG_SZ元素里面是为了防止与可能存在的键名为Default的键产生冲突
+ ///由于Shell项太过复杂,程序只根据注册表项名判断存在即启用,故同一场景下不允许有相同KeyName属性的Shell项目,ShellEx项只要Guid符合则为启用-->
///<Data>
/// <File>
/// <Shell>
- /// <Item KeyName='CopyAsPath' Tip='系统原生菜单项需按住Shift显示,
此项可以直接显示'>
+ /// <Item KeyName='CopyContent' Tip='不需打开文件直接复制文件文本内容
非UTF-16 LE(或带BOM)编码会乱码'>
/// <Value>
- /// <REG_SZ MUIVerb='复制文件路径' Icon='imageres.dll,-5302'/>
- /// </Value>
- /// <SubKey>
- /// [字符串的其余部分被截断]"; 的本地化字符串。
+ /// <REG [字符串的其余部分被截断]"; 的本地化字符串。
///
internal static string EnhanceMenusDic {
get {
@@ -213,6 +212,26 @@ internal class Resources {
}
}
+ ///
+ /// 查找 System.Byte[] 类型的本地化资源。
+ ///
+ internal static byte[] HashLnk_32 {
+ get {
+ object obj = ResourceManager.GetObject("HashLnk_32", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Byte[] 类型的本地化资源。
+ ///
+ internal static byte[] HashLnk_64 {
+ get {
+ object obj = ResourceManager.GetObject("HashLnk_64", resourceCulture);
+ return ((byte[])(obj));
+ }
+ }
+
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
@@ -233,6 +252,16 @@ internal class Resources {
}
}
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap NewFolder {
+ get {
+ object obj = ResourceManager.GetObject("NewFolder", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
@@ -266,9 +295,9 @@ internal class Resources {
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
- internal static System.Drawing.Bitmap SeparatorItem {
+ internal static System.Drawing.Bitmap Select {
get {
- object obj = ResourceManager.GetObject("SeparatorItem", resourceCulture);
+ object obj = ResourceManager.GetObject("Select", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
@@ -314,13 +343,13 @@ internal class Resources {
}
///
- /// 查找类似 <?xml version="1.0" encoding="utf-8" ?>
+ /// 查找类似 <?xml version='1.0' encoding='utf-8' ?>
///<!--每个程序为一个Group,Text为Group项显示文本,Guid用于判断用户是否安装此程序并决定是否显示该Group,不设置Guid则为常驻菜单,RegPath为程序相关注册表主路径;
///其相关菜单项目设置作为一个Item子元素,Item的Text为该Item项显示文本,Tip属性为鼠标悬浮在开关上时的提示信息,需要重启资源管理器生效则添加属性RestartExplorer;
- ///Item的子元素Rule为相关注册表内容,RegPath省略则默认为Group主路径,以\开头则为Group主路径的子项路径;ValueName为相关键名,On为启用键值,Off为禁用键值;
- ///每个Item可能受多个注册表Rule影响,按照顺序进行键值判定;程序优先判定为On,即只要所有Rule不匹配Off键值就判定为On,键值类型不符时也判定为On;
- ///ValueKind为键值类型,默认键值类型ValueKind为REG_DWORD,为默认值时可省略,目前仅支持REG_SZ、REG_DWORD、REG_EXPAND_SZ的键值类型-->
- ///< [字符串的其余部分被截断]"; 的本地化字符串。
+ ///Item的子元素Rule为相关注册表内容,RegPath省略则默认为Group主路径,以\开头则为Group主路径的子项路径;
+ ///ValueName为相关键名,On为启用键值,Off为禁用键值;不设置On或Off属性时,其值为null,对应注册表键值不存在;
+ ///每个Item可能受多个注册表Rule影响,按照顺序进行键值判定;判定规则:当有多条规则时,前面的规则注册表键值匹配On则为On,匹配Off则为Off,并终止判断,都不匹配时继续往下判断,若所有规则都不匹配则为On
+ ///ValueKind为键值类型,默认键值类型ValueKind为REG_D [字符串的其余部分被截断]"; 的本地化字符串。
///
internal static string ThirdRulesDic {
get {
@@ -358,16 +387,6 @@ internal class Resources {
}
}
- ///
- /// 查找 System.Drawing.Bitmap 类型的本地化资源。
- ///
- internal static System.Drawing.Bitmap Types {
- get {
- object obj = ResourceManager.GetObject("Types", resourceCulture);
- return ((System.Drawing.Bitmap)(obj));
- }
- }
-
///
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
///
diff --git a/ContextMenuManager/Properties/Resources.resx b/ContextMenuManager/Properties/Resources.resx
index 7c15821..a560078 100644
--- a/ContextMenuManager/Properties/Resources.resx
+++ b/ContextMenuManager/Properties/Resources.resx
@@ -133,8 +133,8 @@
resources\texts\applanguagedic.ini;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
-
- resources\images\customtype.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ resources\images\custom.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
resources\images\delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -148,12 +148,21 @@
resources\texts\guidinfosdic.ini;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8
+
+ resources\hashlnk\hashlnk_32.exe;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ resources\hashlnk\hashlnk_64.exe;System.Byte[], mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
resources\images\home.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
resources\images\microsoftstore.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ resources\images\newfolder.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
resources\images\newitem.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -163,8 +172,8 @@
resources\images\refresh.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- resources\images\separatoritem.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+ resources\images\select.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
resources\images\setting.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
@@ -190,9 +199,6 @@
resources\images\type.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
- resources\images\types.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
-
resources\images\up.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
diff --git a/ContextMenuManager/Properties/Resources/HashLnk/HashLnk_32.exe b/ContextMenuManager/Properties/Resources/HashLnk/HashLnk_32.exe
new file mode 100644
index 0000000..fa2cc31
Binary files /dev/null and b/ContextMenuManager/Properties/Resources/HashLnk/HashLnk_32.exe differ
diff --git a/ContextMenuManager/Properties/Resources/HashLnk/HashLnk_64.exe b/ContextMenuManager/Properties/Resources/HashLnk/HashLnk_64.exe
new file mode 100644
index 0000000..12479de
Binary files /dev/null and b/ContextMenuManager/Properties/Resources/HashLnk/HashLnk_64.exe differ
diff --git a/ContextMenuManager/Properties/Resources/Images/CustomType.png b/ContextMenuManager/Properties/Resources/Images/Custom.png
similarity index 100%
rename from ContextMenuManager/Properties/Resources/Images/CustomType.png
rename to ContextMenuManager/Properties/Resources/Images/Custom.png
diff --git a/ContextMenuManager/Properties/Resources/Images/NewFolder.png b/ContextMenuManager/Properties/Resources/Images/NewFolder.png
new file mode 100644
index 0000000..7debb44
Binary files /dev/null and b/ContextMenuManager/Properties/Resources/Images/NewFolder.png differ
diff --git a/ContextMenuManager/Properties/Resources/Images/Types.png b/ContextMenuManager/Properties/Resources/Images/Select.png
similarity index 100%
rename from ContextMenuManager/Properties/Resources/Images/Types.png
rename to ContextMenuManager/Properties/Resources/Images/Select.png
diff --git a/ContextMenuManager/Properties/Resources/Images/SeparatorItem.png b/ContextMenuManager/Properties/Resources/Images/SeparatorItem.png
deleted file mode 100644
index 9a5da3a..0000000
Binary files a/ContextMenuManager/Properties/Resources/Images/SeparatorItem.png and /dev/null differ
diff --git a/ContextMenuManager/Properties/Resources/Texts/AppLanguageDic.ini b/ContextMenuManager/Properties/Resources/Texts/AppLanguageDic.ini
index e670027..818abca 100644
--- a/ContextMenuManager/Properties/Resources/Texts/AppLanguageDic.ini
+++ b/ContextMenuManager/Properties/Resources/Texts/AppLanguageDic.ini
@@ -1,7 +1,7 @@
-;此文件为ContextMenuManager程序的显示文本字典
-;如果你想要帮助作者为此程序添加其他语言字典, 可以修改此文本并保存在.\config\languages文件夹内,
-;比如美国英语字典保存为en-US.ini, 并给[General]\Language赋值 en-US English
-;可以在Github或Gitee上Fork该项目并提交申请给我,或者直接发送文件到邮箱1617859183@qq.com
+;此文件为 ContextMenuManager Windows右键管理程序 的显示文本字典
+;翻译:可帮助作者为此程序提供翻译并提交到Github,以下内容中等号右侧内容替换为翻译文本,
+;General-Translator为翻译贡献者,General-Language为语言名称,如en-US 美国英语
+;翻译文件保存在Config\languages目录中,文件名保存为en-US.ini
;翻译说明:暂时不翻译的值保留为空即可,字典内赋值换行请使用\n进行转义
[General]
@@ -35,22 +35,17 @@ WinX = Win+X
LnkFile = lnk文件
UwpLnk = uwp lnk
ExeFile = exe文件
-TextFile = 文本文件
-DocumentFile = 文档文件
-ImageFile = 图像文件
-VideoFile = 视频文件
-AudioFile = 音频文件
-ImageDirectory = 图像目录
-VideoDirectory = 视频目录
-AudioDirectory = 音频目录
UnknownType = 未知格式
-CustomType = 自选格式
+CustomExtension = 自选格式
+PerceivedType = 感知类型
+DirectoryType = 目录类型
EnhanceMenu = 增强菜单
ThirdRules = 三方规则
+DragDrop = 右键拖拽
PublicReferences = 公共引用
GuidBlocked = GUID 锁
-
+IEMenu = IE 右键
AppSetting = 程序设置
AppLanguage = 程序语言
Dictionaries = 程序字典
@@ -71,29 +66,25 @@ Library = 所有库和库目录背景的右键菜单
New = 所有目录背景和桌面背景的右键 "新建" 的菜单项目
SendTo = 所有文件系统对象的右键 "发送到" 的菜单项目
OpenWith = 所有文件右键 "打开方式" 的菜单项目
-WinX = Win8~Win10 "开始" 按钮的右键Win+X菜单项目
+WinX = Win8~Win10 "开始" 按钮的右键 Win+X 菜单项目
-LnkFile = 所有快捷方式的右键菜单
+LnkFile = 所有LNK快捷方式的右键菜单
UwpLnk = Win8~Win10 UWP应用快捷方式的右键菜单
ExeFile = 所有EXE可执行文件的右键菜单
-TextFile = 通用文本格式 (感知类型为Text) 文件的右键菜单
-DocumentFile = 通用文档格式 (感知类型为Document) 文件的右键菜单
-ImageFile = 通用图像格式 (感知类型为Image) 文件的右键菜单
-VideoFile = 通用视频格式 (感知类型为Video) 文件的右键菜单
-AudioFile = 通用音频格式 (感知类型为Audio) 文件的右键菜单
-ImageDirectory = 通用图像文件目录的右键菜单
-VideoDirectory = 通用视频文件目录的右键菜单
-AudioDirectory = 通用音频文件目录的右键菜单
UnknownType = 所有未关联打开方式的格式文件的右键菜单
-CustomType = 自定义指定格式文件的右键菜单
+CustomExtension = 自定义指定格式文件的右键菜单
+PerceivedType = 自定义指定文件感知类型的右键菜单
+DirectoryType = 自定义指定目录感知类型的右键菜单
EnhanceMenu = 添加一些有用的菜单项
ThirdRules = 程序字典内收录的部分第三方程序内部菜单设置规则
+DragDrop = 右键拖拽文件时的菜单项目
PublicReferences = 编辑用户添加的公共引用的Shell类型子菜单项目
-GuidBlocked = 适用于部分顽固的依赖GUID(部分GUID无效)的ShellEx类型项目
+GuidBlocked = 适用于隐藏部分顽固的依赖GUID的ShellEx类型项目
+IEMenu = Internet Explorer 网页的右键菜单
[Menu]
-ChangeText = 更改名称
+ChangeText = 更改文本
ItemIcon = 菜单图标
ChangeIcon = 更改图标
ShieldIcon = 盾牌图标
@@ -107,10 +98,12 @@ OtherAttributes = 其他属性
OnlyWithShift = 仅在按住 Shift 键后显示
OnlyInExplorer = 仅在 Explorer 窗口显示
NoWorkingDirectory = 不使用右键所处目录信息
-NeverDefault = 从不作为左键默认执行命令
+NeverDefault = 从不用作左键默认执行命令
+ShowAsDisabledIfHidden = 被禁用时灰色显示不隐藏
Details = 详细信息
WebSearch = 网页搜索
ChangeCommand = 更改命令
+RunAsAdministrator = 提升权限
FileProperties = 文件属性
FileLocation = 文件位置
RegistryLocation = 注册表位置
@@ -121,7 +114,10 @@ HandleGuid = 处理guid
CopyGuid = 复制guid
BlockGuid = 锁定guid
AddGuidDic = 添加字典
-InitialData = 初始数据
+InitialData = 编辑文件初始数据
+BeforeSeparator = 显示在分割线上方
+ChangeGroup = 更换分组
+RestoreDefault = 还原默认
Edit = 编辑
Save = 保存
@@ -145,11 +141,18 @@ ShareWithSkype = 使用 Skype 共享
NewItem = 新建一个菜单项目
AddGuidBlockedItem = 添加GUID锁定项目
LockNewMenu = 锁定新建菜单
-CurrentExtension = 你当前选择的文件格式为
-SetPerceivedType = 设置文件格式感知类型
EditSubItems = 编辑 "%s" 的子菜单项目
InvalidItem = 无效菜单项目:
-Separator = ●●●●●●●●●●●●●●●●●●
+Separator = >>>>>> 分割线 <<<<<<
+SelectExtension = 请选择一个文件扩展名
+SelectPerceivedType = 请选择一个文件感知类型
+SelectDirectoryType = 请选择一个目录感知类型
+CurrentExtension = 你当前选择的文件扩展名为 %s
+CurrentPerceivedType = 你当前选择的文件感知类型为 %s
+CurrentDirectoryType = 你当前选择的目录感知类型为 %s
+WinXSortable = 启用 WinX 菜单排序功能
+ShowFilePath = 状态栏实时显示文件路径
+OpenMoreRegedit = 允许注册表编辑器多开
[Dialog]
Ok = 确认
@@ -157,9 +160,6 @@ Cancel = 取消
Browse = 浏览
Program = 程序
RegistryFile = 注册表文件
-NewShellItem = 新建Shell类型右键菜单项目
-NewSendToItem = 新建发送到子菜单项目
-NewOpenWithItem = 新建打开方式菜单项目
ItemText = 菜单文本
ItemCommand = 菜单命令
CommandArguments = 命令参数
@@ -172,9 +172,20 @@ Private = 私有
InputGuid = 输入Guid
AddGuidDic = 添加Guid本地字典
DeleteGuidDic = 删除
-SelectExtension = 请选择一个文件扩展名
+TextFile = 文本文件
+DocumentFile = 文档文件
+ImageFile = 图像文件
+VideoFile = 视频文件
+AudioFile = 音频文件
+CompressedFile = 压缩文件
+SystemFile = 系统文件
+DocumentDirectory = 文档目录
+ImageDirectory = 图像目录
+VideoDirectory = 视频目录
+AudioDirectory = 音频目录
CheckReference = 请勾选你想要引用的菜单项目
CheckCopy = 请勾选你想要复制的菜单项目
+SelectGroup = 请选择保存分组
SelectSubMenuMode = 该多级菜单子项目数为0, 你有两个选择:\n①该多级菜单的所有子菜单项目私有(推荐),\n②该多级菜单可与其他多级菜单引用相同子项,\n请做出你的选择......
[MessageBox]
@@ -183,10 +194,11 @@ CommandCannotBeEmpty = 菜单命令不能为空!
StringParsingFailed = 本地化字符串解析失败!
TextLengthCannotExceed80 = 菜单文本过长, 长度不允许超过80!
ConfirmDeletePermanently = 确认是否永久删除此项?\n此操作无法还原,请谨慎操作!
+DeleteButCanRestore = 确认删除此菜单的注册表项目?\n由于启用了自动备份(默认启用),\n删除后可在备份文件夹中还原。
ConfirmDeleteReference = 确认是否移除对该项目的引用?
ConfirmDelete = 确认是否删除该项?
-ConfirmDeleteReferenced = 确认是否永久删除此项?\n所有引用此项的项目都会失效,请谨慎操作!
-CannotAddNewItem = 系统限制子菜单最大项目数为16,\n无法再进行添加!
+ConfirmDeleteReferenced = 确认是否删除此项?\n所有引用此项的项目都会失效,请谨慎操作!
+CannotAddNewItem = 系统限制子菜单数目最多为16,\n无法添加更多的子菜单项目!
VistaUnsupportedMulti = Vista系统不支持多级菜单!
CannotHideSubItem = 你的系统版本太低,不支持隐藏子级菜单!
UnsupportedFilename = 不支持的文件名,\n可能已经存在相同文件名的菜单项目!
@@ -203,6 +215,9 @@ FileNotExists = 文件不存在!
FolderNotExists = 文件夹不存在!
NoUpdateDetected = 未检测到程序更新,\n但已为你更新网络字典文件。
AuthorityProtection = 此菜单注册表项目可能受安全软件保护,\n无法对其进行禁用删除和其他个性化修改。
+WinXSorted = 为优化排序功能已对部分项目重新编号,\n需要重启文件资源管理器应用效果
+RestoreDefault = 确认还原为默认菜单项目?
+DeleteGroup = 确认永久删除此组及组内所有菜单项目?
[Tip]
RestartExplorer = 重启Explorer会使桌面闪烁片刻, 正常现象无需担心,\n或者你也可以稍后重启或注销计算机使你的操作生效
@@ -214,14 +229,15 @@ EditSubItems = 编辑子菜单项目
AddReference = 从公共引用项目中添加引用
AddFromParentMenu = 从母菜单中复制项目
AddSeparator = 添加分隔线
-Separator = 项目分隔线
DeleteGuidDic = 删除用户自行添加的该项的本地Guid字典
LockNewMenu = 启用后可阻止第三方程序增加项目\n且可对现有项目排序(关闭后复原)
CheckUpdate = 程序每月自动检测一次更新 (启动程序时)\n你可手动点击浏览Github、Gitee检查更新
LastCheckUpdateTime = 上次自动更新检查时间:
OpenLanguagesDir = 打开语言文件夹
OpenDictionariesDir = 打开字典文件夹
-ShareWithSkype = 仅当用户电脑安装了 Skype 应用后有此项目
+ConfigPath = 更改配置和数据文件保存路径后,\n会导致部分已启用增强菜单失效,\n可在增强菜单中重新启用一遍
+CommandFiles = 此命令依赖配置文件,移动配置文件位置\n会导致此菜单项失效,重新启用一遍即可
+CreateGroup = 新建一个分组
[Other]
RestartExplorer = 当前部分操作需要重启文件资源管理器生效
@@ -233,9 +249,9 @@ CommonItemsDictionary = 常用菜单
Translators = 翻译贡献者
OtherLanguages = 下载或上传其他语言文件
DonationList = 捐赠名单
-ConfigFile = 配置和数据文件
-SaveToAppData = 保存到 AppData 目录
-SaveToAppDir = 保存到程序所在目录
+ConfigPath = 配置和数据文件保存位置
+AppDataDir = AppData 目录
+AppDir = 程序所在目录
OpenConfigDir = 打开配置文件所在目录
AutoBackup = 删除菜单时自动备份注册表
OpenBackupDir = 打开备份文件夹
@@ -244,10 +260,10 @@ ImmediatelyCheckUpdate = 立即检查
ProtectOpenItem = 保护 "打开" 菜单项目
WebSearchEngine = 网页搜索使用的搜索引擎
CustomEngine = 自定义
-SetCustomEngine = 设定搜索引擎 (以 %s 代替搜索关键字)
+SetCustomEngine = 设定搜索引擎 (以 %s 代替搜索关键词)
-AboutApp = 【主要功能】\n 1.管理常见位置右键菜单\n 2.自定义添加右键菜单\n\n【兼容性能】\n 1.适用于Win7、8、8.1、10、Vista\n 2.适用于 x64、x32 CPU 操作系统\n 3.适配高分屏,最佳缩放比为150%\n\n【代码开源】\n 1.代码语言:C Sharp, Winform程序\n 2.Github仓库:https://github.com/BluePointLilac/ContextMenuManager \n 3.Gitee仓库:https://gitee.com/BluePointLilac/ContextMenuManager \n 4.使用本程序的源代码请遵守MIT开源协议\n\n【联系作者】\n 1.程序由我个人独立开发,当然也要感谢萌研社 @坑晨 平时的答疑解惑,能力有限,\n 难免出现一些Bug,欢迎大家反馈Bug和提出建议\n 2.个人B站ID:蓝点lilac https://space.bilibili.com/34492771 (欢迎大家关注我!)\n 3.个人邮箱:1617859183@qq.com\n\n【程序图标】\n 1.程序主图标来自 https://www.easyicon.net/1208132-mouse_icon.html \n 2.程序使用到的按钮图标主要来自 https://www.iconfont.cn/ \n\n【程序更新】\n 1.程序有检查更新功能,除了更新程序本身还会更新字典,下载完成后直接覆盖原文件即可\n 2.由于Github Raw被墙,Gitee Raw有每月次数访问上限,程序设置为每月检测一次更新,\n 大家也可以自己浏览Github Releases栏或Gitee 发行版栏检查是否有更新 \n\n【温馨提示】\n 1.一些特殊菜单项可能会受到其他因素影响导致不会显示在右键菜单中,\n 但是按照程序使用的通用规则在此程序中仍会显示为启用,这是正常的现象。\n 2.每个右键管理程序禁用菜单方法可能不同, 建议不要同时使用多个右键菜单管理程序,\n 大部分程序使用简单暴力的备份-删除法, 此程序尽可能使用了系统提供的键值进行隐藏操作,\n 若之前使用过其他程序禁用菜单项,请先使用对应程序还原, 不然可能无法在此程序中看到它。\n 3.此程序不用于清理未卸载干净的程序,但可帮助你定位菜单项相关注册表和文件位置,\n 你可根据相关内容进行你的操作,如果你是一个电脑小白,建议只碰启用\禁用开关。
+AboutApp = 【主要功能】\n 1.管理常见位置右键菜单\n 2.自定义添加右键菜单\n\n【兼容性能】\n 1.适用于Win7、8、8.1、10、Vista\n 2.适用于 x64、x32 CPU 操作系统\n 3.适配高分屏,最佳缩放比为150%\n\n【代码开源】\n 1.代码语言:C Sharp, Winform 程序\n 2.Github 仓库: https://github.com/BluePointLilac/ContextMenuManager \n 3.Gitee 仓库: https://gitee.com/BluePointLilac/ContextMenuManager \n\n【联系作者】\n 1.程序由我个人独立开发,当然也要感谢萌研社 @坑晨 平时的答疑解惑,能力有限,\n 难免出现一些Bug,欢迎大家反馈Bug和提出建议\n 2.个人B站: https://space.bilibili.com/34492771 (欢迎大家关注我!)\n 3.QQ邮箱: 1617859183@qq.com\n\n【资源引用】\n 1.程序主图标来自: https://www.easyicon.net/1208132-mouse_icon.html \n 2.程序按钮图标主要来自阿里巴巴矢量图标库: https://www.iconfont.cn/ \n 3.WinX HashLnk (Rafael Rivera): https://github.com/riverar/hashlnk \n\n【程序更新】\n 1.程序有检查更新功能,除了更新程序本身还会更新字典,下载完成后直接覆盖原文件即可\n 2.由于Github Raw被墙,Gitee Raw有每月次数访问上限,程序设置为每月检测一次更新,\n 大家也可以自己浏览Github Releases栏或Gitee 发行版栏检查是否有更新 \n\n【温馨提示】\n 1.一些特殊菜单项可能会受到其他因素影响导致不会显示在右键菜单中,\n 但是按照程序使用的通用规则在此程序中仍会显示为启用,这是正常的现象。\n 2.每个右键管理程序禁用菜单方法可能不同, 建议不要同时使用多个右键菜单管理程序,\n 大部分程序使用简单暴力的备份-删除法, 此程序尽可能使用了系统提供的键值进行隐藏操作,\n 若之前使用过其他程序禁用菜单项,请先使用对应程序还原, 不然可能无法在此程序中看到它。\n 3.此程序不用于清理未卸载干净的程序,但可帮助你定位菜单项相关注册表和文件位置,\n 你可根据相关内容进行你的操作,如果你是一个电脑小白,建议只碰启用\禁用开关。
-Dictionaries = 【字典说明】\n 此程序拥有几个字典文件, 每份字典又有用户字典和网络字典\n 如果想为此程序添加字典可右键保存字典文件, 并按照文件内相关说明进行添加\n 可将你的用户字典发送到我的邮箱或提交到Github为此项目做出你的贡献\n 右侧选项卡中为原始字典内容, 你可以切换选项卡进行查看\n\n【字典内容】\n 1.程序显示文本语言字典 (languages目录)\n 2.ShellEx菜单项GUID文本图标字典 (GuidInfosDic.ini)\n 3.第三方程序菜单内部设置字典 (ThirdRulesDic.xml)\n 4.增强菜单项目字典 (EnhanceMenusDic.xml)
+Dictionaries = 【字典说明】\n 此程序拥有几个字典文件, 每份字典又有用户字典和网络字典\n 如果想为此程序添加字典可右键保存文件, 并按照文件内说明进行添加\n 可将你的字典发送到我的邮箱或提交到Github为此项目做出你的贡献\n 右侧选项卡中为原始字典内容, 你可以切换选项卡进行查看\n\n【字典内容】\n 1.程序显示文本语言字典 (Languages目录)\n 2.ShellEx菜单项GUID文本图标字典 (GuidInfosDic.ini)\n 3.第三方程序菜单内部设置字典 (ThirdRulesDic.xml)\n 4.增强菜单项目字典 (EnhanceMenusDic.xml)
Donate = 此程序完全免费,如果你觉得这个软件对你有所帮助, 你可以通过扫描\n下方二维码(微信、支付宝、腾讯QQ)进行捐赠, 金额请随意, 谢谢支持!\n也期待你在Github或者Gitee上为此程序项目点亮Star (这对我很重要!)
\ No newline at end of file
diff --git a/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml b/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
index 70a785a..e47c4a8 100644
--- a/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
+++ b/ContextMenuManager/Properties/Resources/Texts/EnhanceMenusDic.xml
@@ -1,18 +1,11 @@
+子元素SubKey的所有子元素是该项的子项,项名即为元素名; 每一Item项和SubKey的所有子元素的属性Default为该注册表项默认值,不放在Value\REG_SZ元素里面是为了防止与可能存在的键名为Default的键产生冲突
+由于Shell项太过复杂,程序只根据注册表项名判断存在即启用,故同一场景下不允许有相同KeyName属性的Shell项目,ShellEx项只要Guid符合则为启用-->
- -
-
-
-
-
-
-
-
-
@@ -22,21 +15,21 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
- 6.2
-
+
-
-
-
-
+
+
+ takeown.exe
+ /f "%1" /a
+
-
6.3
-
+
@@ -45,31 +38,17 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
-
- -
-
-
-
-
-
-
-
-
-
-
- -
- 6.2
+
-
-
+
-
-
-
-
+
+
+ takeown.exe
+ /f "%v" /a /r /d y
@@ -81,7 +60,8 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
6.1
-
+
@@ -102,21 +82,101 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
6.2
-
+
-
6.2
-
+
+ -
+ 6.2
+
+
+
+
+
+ wscript.exe
+
+
+
+
+
+
+ -
+ 6.2
+
+
+
+
+
+ wscript.exe
+
+
+
+
+
+
+ -
+
+
+
+
+
+ wscript.exe
+
+
+
+
+
+
-
-
+
+
+ cmd.exe
+ /s /k pushd "%v"
+
-
@@ -130,7 +190,8 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
+
+
@@ -138,22 +199,23 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
-
+
-
+
-
-
+
-
+
-
6.1
+ %SystemRoot%\System32\tskill.exe
@@ -161,12 +223,33 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
+ -
+
+
+
+
+
+ wscript.exe
+
+
+
+
+
+
-
-
+
-
@@ -175,7 +258,7 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
+
-
@@ -187,6 +270,81 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
6.3
@@ -196,13 +354,182 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
- -
+
-
- 10.0
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 10.0.17763
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+ 10.0
+
+
+
+
+
+
+
+
+
+
+
+
+ wscript.exe
+
+
+
+
+
+
+
+
+
+
+
+
+ wscript.exe
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+ wscript.exe
+
+
+
+
+
+
+ -
+
+
-
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
@@ -222,10 +549,62 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
-
+
+ -
+
+
+
+
+
+ Wscript.exe
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ Wscript.exe
+
+
+
+
+
+
@@ -235,17 +614,78 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
6.2
-
+
+
+
+ -
+
+
+
+
+
- -
+
-
6.2
-
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -255,6 +695,151 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+ %SystemRoot%\System32\gpedit.msc
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ notepad.exe
+ "%systemroot%\system32\drivers\etc\hosts"
+
+
+
+ -
+
+
+
+
+
+
+
+ -
+
+ 10.0
+
+
+
+
+ wscript.exe
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+ wscript.exe
+
+
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
@@ -262,7 +847,7 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
+
@@ -275,7 +860,7 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
+
@@ -288,7 +873,11 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
+
+
+ regsvr32.exe
+ "%1"
+
-
@@ -296,7 +885,11 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
+
+
+ regsvr32.exe
+ /u "%1"
+
@@ -309,7 +902,11 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
+
+
+ regsvr32.exe
+ "%1"
+
-
@@ -317,7 +914,11 @@ Tip属性为鼠标悬浮在开关上时的提示信息,从每个Item节点开
-
+
+
+ regsvr32.exe
+ /u "%1"
+
diff --git a/ContextMenuManager/Properties/Resources/Texts/GuidInfosDic.ini b/ContextMenuManager/Properties/Resources/Texts/GuidInfosDic.ini
index 6cc27e0..7c51859 100644
--- a/ContextMenuManager/Properties/Resources/Texts/GuidInfosDic.ini
+++ b/ContextMenuManager/Properties/Resources/Texts/GuidInfosDic.ini
@@ -132,6 +132,8 @@ Icon=shell32.dll,-254
;全部解压缩(&T)...
[b8cdcb65-b1bf-4b42-9428-1dfdb7ee92af]
Text=@shell32.dll,-37514
+[bd472f60-27fa-11cf-b8b4-444553540000]
+Text=提取(&E)...
;复制到文件夹(&F)...
[c2fbb630-2971-11d1-a18c-00c04fd75d13]
Text=@*,-30304
@@ -140,8 +142,9 @@ Icon=imageres.dll,-5304
[c2fbb631-2971-11d1-a18c-00c04fd75d13]
Text=@*,-30305
Icon=imageres.dll,-5303
+;窗口转换程序
[3080f90e-d7ad-11d9-bd98-0000947b0257]
-Text=窗口转换程序
+Text=@shell32.dll,-12715
Icon=imageres.dll
;----------------显卡------------------
@@ -157,8 +160,11 @@ Icon=nvcpl.dll
[9B5F5829-A529-4B12-814A-E81BCB8D93FC]
Text=英特尔® 显卡设置
Icon=.\igfxEM.exe
+[3ab1675a-ccff-11d2-8b20-00a0c93cb1f4]
+Text=Intel 显卡
[5E2121EE-0300-11D4-8D3B-444553540000]
Text=AMD 显卡
+Icon=.\RadeonSettings.exe
;----------------压缩------------------
[5B69A6B4-393B-459C-8EBB-214237A9E7AC]
@@ -259,8 +265,8 @@ Text=清理垃圾(电脑管家)
Text=使用 360杀毒 扫描
Icon=.\msdev.exe
[7C0F6D57-E799-4C8A-A319-8E2B4D724CF0]
-Text=360解除占用 && 强力删除
-Icon=.\360FileUnlock.exe
+Text=360安全卫士
+Icon=..\360Safe.exe
[5E19C0CE-C02C-46c2-98C3-A2E12EDE0E17]
Text=360强力卸载 && 桌面助手
Icon=.\SoftMgr.exe
@@ -271,10 +277,13 @@ Icon=.\2345MPCSafe.exe
Text=使用2345软件管家卸载软件
Icon=..\..\2345SoftMgr.exe
[DDEA5705-1BB0-4C03-AC1E-8FF9716A0D51]
-Text=金山毒霸(64位)扫描 && 文件粉碎
+Text=金山毒霸(64位)
Icon=.\kismain.exe
[D21D88E8-4123-48BA-B0B1-3FDBE4AE5FA4]
-Text=金山毒霸(32位)扫描 && 文件粉碎
+Text=金山毒霸(32位)
+Icon=.\kismain.exe
+[367f6ae2-6809-4bed-b09b-228893fb33dd]
+Text=金山毒霸
Icon=.\kismain.exe
[758c684b-4d10-4bc1-90da-6bebf0b4e0b4]
Text=使用联想电脑管家进行扫描
@@ -304,7 +313,9 @@ Icon=.\uiStub.exe
Text=Norton File Shredder
[1c7593cb-c1cc-4ba7-be52-8eea47f9cb1d]
Text=使用瑞星杀毒
-
+[0bb81440-5f42-4480-a5f7-770a6f439fc8]
+Text=IObit Malware Fighter
+Icon=*,3
;----------------传输------------------
[53D2405C-48AB-4C8A-8F59-CE0610F13BBC]
Text=通过QQ发送到
@@ -370,6 +381,9 @@ Text=Huawei Share
[9c5397bb-07be-4e38-98ba-395f94045091]
Text=福昕PDF编辑器
Icon=..\FoxitPhantom.exe
+[27be7b9d-935f-325c-9a05-63557d69f4f9]
+Text=万兴PDF专家
+Icon=..\PDFExpert.exe
[a6595cd1-bf77-430a-a452-18696685f7c7]
Text=Adobe Acrobat
Icon=..\Acrobat\Acrobat.exe
@@ -439,6 +453,13 @@ Text=图片工厂(&F)
Text=调整图片大小(PowerToys)
[5c6a637c-9780-4d0f-a379-4732edcce7c3]
Text=网易云音乐
+[1F77B17B-F531-44DB-ACA4-76ABB5010A28]
+Text=AIMP
+Icon=..\AIMP.exe
+[8e7861bb-3a13-40a1-af25-633458757201]
+Text=QQ影音
+[7a1884a3-f647-49be-b93c-8ffaf4a1f1bf]
+Text=使用PP视频播放
;----------------美化------------------
[CF444751-60FC-48B8-AC0F-363063EB2A9E]
@@ -457,6 +478,12 @@ Icon=.\StartIsBackCfg.exe
[6a451c0a-9597-4915-bcce-6e859bc996b2]
Text=Pin to Start (Start10)
Icon=.\Start10.exe
+[af8fa9c9-9907-463e-bdc3-4cc1200d6310]
+Text=Start Menu 8
+Icon=*,2
+[07451604-fbe4-4475-9dd6-261b7b619417]
+Text=电脑管家经典开始菜单
+Icon=.\QMStart.exe
[2d5ad9eb-31bc-48f7-a438-28f363632c73]
Text=开启布丁桌面
Icon=.\PDLanuncher.exe
@@ -481,6 +508,9 @@ Icon=.\uedit64.exe
[51eee242-ad87-11d3-9c1e-0090278bbd99]
Text=Vim
Icon=..\vim.exe
+[ed90173a-3b4c-4e7e-b9cf-79714425d4b5]
+Text=PSPad Editor
+Icon=.\PSPad.exe
[A3777921-CFD3-4A6B-89BF-08E6B95716E8]
Text=格式工厂(&F)
Icon=.\FormatFactory.exe
@@ -531,6 +561,9 @@ Text=FileLocator Pro
Text=显示隐藏文件+扩展名
[c1b2c38f-3dca-4e3d-bc34-d5b87b636543]
Text=FileMenu Tools
+[189f1e63-33a7-404b-b2f6-8c76a452cc54]
+Text=Smart Defrag
+Icon=*,2
[4380c993-0c43-4e02-9a7a-0d40b6ea7590]
Text=Defraggler
Icon=.\Defraggler.exe
@@ -545,4 +578,17 @@ Text=Locale Emulator
Icon=.\LEGUI.exe
[0a479751-02bc-11d3-a855-0004ac2568aa]
Text=NTFS文件连接扩展配置工具
-Icon=.\LSEConfig.exe
\ No newline at end of file
+Icon=.\LSEConfig.exe
+[fdf253ac-1724-4853-be34-c2dbc18fb5ca]
+Text=Copywhiz
+Icon=.\Copywhiz.exe
+[6c467336-8281-4e60-8204-430ced96822d]
+Text=共享文件夹同步
+[6fa85dad-ac32-4d74-9cba-6a1c038f9a56]
+Text=文档加密/解密
+[ef479680-ea35-4ea9-b093-7114f3e3e0da]
+Text=Directory Lister
+Icon=.\DirListerPro.exe
+[8e57c449-7891-49bb-80e5-ddac375f8ac8]
+Text=使用微表格打开
+Icon=.\microexcel.exe
\ No newline at end of file
diff --git a/ContextMenuManager/Properties/Resources/Texts/ThirdRulesDic.xml b/ContextMenuManager/Properties/Resources/Texts/ThirdRulesDic.xml
index 16c1bb3..792da79 100644
--- a/ContextMenuManager/Properties/Resources/Texts/ThirdRulesDic.xml
+++ b/ContextMenuManager/Properties/Resources/Texts/ThirdRulesDic.xml
@@ -1,208 +1,276 @@
-
+
-
- -
-
-
-
- -
- 10.0.14393
- 10.0.17763
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
-
- -
-
-
-
- -
- 10.0.16199
-
-
-
- -
- 10.0
-
-
- -
- 10.0
-
-
-
- -
- 10.0
-
+
+
-
+
+
+
+ -
+ 10.0.14393
+ 10.0.17763
+
+
+ -
+
+
+
+ -
+
+
+
+ -
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+ -
+ 10.0.16199
+
+
+
+ -
+ 10.0
+
+
+ -
+ 10.0.17134
+
+
+
+ -
+ 6.2
+
+
+
+ -
+ 10.0
+
+
+
+ -
+ 6.2
+
+
+
+ -
+ 10.0
+
+
+
+ -
+ 10.0
+
+
+ -
+ 10.0
+
-
- -
-
+
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
-
- -
-
+
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
-
- -
-
+
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
- -
-
+
-
+
-
- -
-
+
+
-
+
- -
-
+
-
+
- -
-
+
-
+
-
- -
-
+
+
-
+
- -
-
+
-
+
- -
-
+
-
+
-
- -
-
+
+
-
+
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
\ No newline at end of file
diff --git a/ContextMenuManager/Properties/Settings.Designer.cs b/ContextMenuManager/Properties/Settings.Designer.cs
index 4ed776d..d902879 100644
--- a/ContextMenuManager/Properties/Settings.Designer.cs
+++ b/ContextMenuManager/Properties/Settings.Designer.cs
@@ -12,7 +12,7 @@ namespace ContextMenuManager.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
diff --git a/ContextMenuManager/Updater.cs b/ContextMenuManager/Updater.cs
index a55e8d8..1c9c1dc 100644
--- a/ContextMenuManager/Updater.cs
+++ b/ContextMenuManager/Updater.cs
@@ -1,6 +1,5 @@
-using BulePointLilac.Methods;
+using BluePointLilac.Methods;
using System;
-using System.Diagnostics;
using System.IO;
using System.Net;
using System.Text;
@@ -44,7 +43,8 @@ private static bool UpdateApp()
if(MessageBoxEx.Show($"{AppString.MessageBox.UpdateApp}{version1}\n{info}",
MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
{
- Process.Start(reader.GetValue("Update", "Url"));
+ string url = reader.GetValue("Update", "Url");
+ ExternalProgram.OpenUrl(url);
return true;
}
}
@@ -55,7 +55,7 @@ private static void UpdateText(string filePath, string url)
{
string contents = GetWebString(url);
if(!contents.IsNullOrWhiteSpace())
- File.WriteAllText(filePath, contents, Encoding.UTF8);
+ File.WriteAllText(filePath, contents.Replace("\n", "\r\n"), Encoding.Unicode);
}
private static string GetWebString(string url)
@@ -64,8 +64,8 @@ private static string GetWebString(string url)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8);
- return reader.ReadToEnd();
+ using(StreamReader reader = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
+ return reader.ReadToEnd();
}
catch { return null; }
}
diff --git a/Donate.md b/Donate.md
index ab17167..1a24440 100644
--- a/Donate.md
+++ b/Donate.md
@@ -8,9 +8,9 @@
## 捐赠名单
-> 此名单不定期更新(上次更新:2021-02-04)
+> 此名单不定期更新(上次更新:**2021-02-22**)
-> 累计金额:**210.82** 元,累计人次:**42** 人次
+> 累计金额:**227.62** 元,累计人次:**46** 人次
|日期|用户ID|平台|金额|备注
|:--:|:--:|:--:|:--:|:--:
@@ -56,3 +56,8 @@
|2020-01-28|*闯|支付宝|5|
|2020-02-02|*强|微信|1|
|2020-02-02|i*y|微信|5|cmm太好用了 救大命
+|2020-02-06|F*t|微信|1|感谢作者,牛年牛牛牛
+|2020-02-10|L*g|微信|2|
+|2020-02-11|戴*n|微信|5|太好用了,第一次捐赠
+|2020-02-12|*奕|支付宝|2.8|真不错
+|2020-02-18|**凯|支付宝|6|方便好用,支持你
\ No newline at end of file
diff --git a/README.md b/README.md
index f9b33f1..fbce345 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
> 一个纯粹的Windows右键菜单管理程序
## 主要功能
-* 启用或禁用文件、文件夹、新建、发送到、打开方式、自定义文件格式等右键菜单项目
+* 启用或禁用文件、文件夹、新建、发送到、打开方式、自定义文件格式、IE浏览器、WinX等右键菜单项目
* 对上述场景右键菜单项目进行修改名称、修改图标、导航注册表位置、导航文件位置、永久删除等操作
* 对上述场景右键菜单自定义添加项目,自定义菜单命令
@@ -14,16 +14,17 @@
* 程序支持国际化多语言显示,欢迎为此程序制作语言字典
## 运行截图
-![](https://gitee.com/BluePointLilac/ContextMenuManager/raw/master/Screenshot.png)
+![](https://raw.githubusercontent.com/BluePointLilac/ContextMenuManager/master/Screenshot.png)
-## 程序图标
-* 程序主图标来自 [Easyicon][1]
![](https://gitee.com/BluePointLilac/ContextMenuManager/raw/master/ContextMenuManager/Properties/AppIcon.ico)
+## 资源引用
+* 程序主图标来自 [Easyicon][1]
![](https://raw.githubusercontent.com/BluePointLilac/ContextMenuManager/master/ContextMenuManager/Properties/AppIcon.ico)
* [程序按钮图标][2] 主要来自于 [阿里巴巴矢量图标资源库][3]
+* WinX HashLnk 作者: [Rafael Rivera][4]
## 下载更新
* 程序有检查更新功能,除了更新程序本身还会更新程序字典,下载完成后直接覆盖原文件即可
-* 由于Github Raw被墙,Gitee Raw有月访问次数上限,故将程序设置为每月自动检测一次更新,
大家也可以自行浏览 [Github Releases][4] 或者 [Gitee 发行版][5] 检查程序是否有更新。
+* 由于Github Raw被墙,Gitee Raw有月访问次数上限,故将程序设置为每月自动检测一次更新,
大家也可以自行浏览 [Github Releases][5] 或者 [Gitee 发行版][6] 检查程序是否有更新。
## 温馨提示
* 一些特殊菜单项目(ShellEx类型,比如文件的加密(&Y))可能会受到其他因素影响,导致不会显示
在右键菜单中,但是按照程序使用的通用规则在此程序中仍会显示为启用,这是正常现象。
@@ -31,17 +32,18 @@
* 此程序不用于清理未卸载干净的程序,但是可以帮助你快速定位菜单项相关注册表位置和文件位置,
你可以根据相关内容进行你的操作。如果你是一个电脑小白,建议只使用启用\禁用功能。
## 联系作者
-* 程序由我个人独立开发,当然也要感谢 [萌研社][6] 站长 @坑晨 平时的答疑解惑。能力有限,难免出现
一些Bug,欢迎大家积极反馈Bug和提出优化建议。
-* 个人B站:[蓝点lilac][7](欢迎大家关注我!)
+* 程序由我个人独立开发,当然也要感谢 [萌研社][7] 站长 @坑晨 平时的答疑解惑。能力有限,难免出现
一些Bug,欢迎大家积极反馈Bug和提出优化建议。
+* 个人B站:[蓝点lilac][8](欢迎大家关注我!)
* 个人邮箱:1617859183@qq.com
## 捐赠作者
-此程序完全免费,如果你觉得这个程序对你有所帮助,可以通过扫面下方二维码(微信、支付宝、QQ)
进行捐赠,金额请随意,谢谢你的理解和支持!更加期待你为此项目点亮Star(这对我很重要!)
![](https://gitee.com/BluePointLilac/ContextMenuManager/raw/master/ContextMenuManager/Properties/Resources/Images/Donate.png)
+此程序完全免费,如果你觉得这个程序对你有所帮助,可以通过扫面下方二维码(微信、支付宝、QQ)
进行捐赠,金额请随意,谢谢你的理解和支持!更加期待你为此项目点亮Star(这对我很重要!)
![](https://raw.githubusercontent.com/BluePointLilac/ContextMenuManager/master/ContextMenuManager/Properties/Resources/Images/Donate.png)
[1]: https://www.easyicon.net/1208132-mouse_icon.html
[2]: https://github.com/BluePointLilac/ContextMenuManager/tree/master/ContextMenuManager/Properties/Resources/Images
[3]: https://www.iconfont.cn/
- [4]: https://github.com/BluePointLilac/ContextMenuManager/releases
- [5]: https://gitee.com/BluePointLilac/ContextMenuManager/releases
- [6]: http://www.pcmoe.net/
- [7]: https://space.bilibili.com/34492771
\ No newline at end of file
+ [4]: https://github.com/riverar/hashlnk
+ [5]: https://github.com/BluePointLilac/ContextMenuManager/releases
+ [6]: https://gitee.com/BluePointLilac/ContextMenuManager/releases
+ [7]: http://www.pcmoe.net/
+ [8]: https://space.bilibili.com/34492771
\ No newline at end of file
diff --git a/languages/zh-CN.ini b/languages/zh-CN.ini
index e670027..818abca 100644
--- a/languages/zh-CN.ini
+++ b/languages/zh-CN.ini
@@ -1,7 +1,7 @@
-;此文件为ContextMenuManager程序的显示文本字典
-;如果你想要帮助作者为此程序添加其他语言字典, 可以修改此文本并保存在.\config\languages文件夹内,
-;比如美国英语字典保存为en-US.ini, 并给[General]\Language赋值 en-US English
-;可以在Github或Gitee上Fork该项目并提交申请给我,或者直接发送文件到邮箱1617859183@qq.com
+;此文件为 ContextMenuManager Windows右键管理程序 的显示文本字典
+;翻译:可帮助作者为此程序提供翻译并提交到Github,以下内容中等号右侧内容替换为翻译文本,
+;General-Translator为翻译贡献者,General-Language为语言名称,如en-US 美国英语
+;翻译文件保存在Config\languages目录中,文件名保存为en-US.ini
;翻译说明:暂时不翻译的值保留为空即可,字典内赋值换行请使用\n进行转义
[General]
@@ -35,22 +35,17 @@ WinX = Win+X
LnkFile = lnk文件
UwpLnk = uwp lnk
ExeFile = exe文件
-TextFile = 文本文件
-DocumentFile = 文档文件
-ImageFile = 图像文件
-VideoFile = 视频文件
-AudioFile = 音频文件
-ImageDirectory = 图像目录
-VideoDirectory = 视频目录
-AudioDirectory = 音频目录
UnknownType = 未知格式
-CustomType = 自选格式
+CustomExtension = 自选格式
+PerceivedType = 感知类型
+DirectoryType = 目录类型
EnhanceMenu = 增强菜单
ThirdRules = 三方规则
+DragDrop = 右键拖拽
PublicReferences = 公共引用
GuidBlocked = GUID 锁
-
+IEMenu = IE 右键
AppSetting = 程序设置
AppLanguage = 程序语言
Dictionaries = 程序字典
@@ -71,29 +66,25 @@ Library = 所有库和库目录背景的右键菜单
New = 所有目录背景和桌面背景的右键 "新建" 的菜单项目
SendTo = 所有文件系统对象的右键 "发送到" 的菜单项目
OpenWith = 所有文件右键 "打开方式" 的菜单项目
-WinX = Win8~Win10 "开始" 按钮的右键Win+X菜单项目
+WinX = Win8~Win10 "开始" 按钮的右键 Win+X 菜单项目
-LnkFile = 所有快捷方式的右键菜单
+LnkFile = 所有LNK快捷方式的右键菜单
UwpLnk = Win8~Win10 UWP应用快捷方式的右键菜单
ExeFile = 所有EXE可执行文件的右键菜单
-TextFile = 通用文本格式 (感知类型为Text) 文件的右键菜单
-DocumentFile = 通用文档格式 (感知类型为Document) 文件的右键菜单
-ImageFile = 通用图像格式 (感知类型为Image) 文件的右键菜单
-VideoFile = 通用视频格式 (感知类型为Video) 文件的右键菜单
-AudioFile = 通用音频格式 (感知类型为Audio) 文件的右键菜单
-ImageDirectory = 通用图像文件目录的右键菜单
-VideoDirectory = 通用视频文件目录的右键菜单
-AudioDirectory = 通用音频文件目录的右键菜单
UnknownType = 所有未关联打开方式的格式文件的右键菜单
-CustomType = 自定义指定格式文件的右键菜单
+CustomExtension = 自定义指定格式文件的右键菜单
+PerceivedType = 自定义指定文件感知类型的右键菜单
+DirectoryType = 自定义指定目录感知类型的右键菜单
EnhanceMenu = 添加一些有用的菜单项
ThirdRules = 程序字典内收录的部分第三方程序内部菜单设置规则
+DragDrop = 右键拖拽文件时的菜单项目
PublicReferences = 编辑用户添加的公共引用的Shell类型子菜单项目
-GuidBlocked = 适用于部分顽固的依赖GUID(部分GUID无效)的ShellEx类型项目
+GuidBlocked = 适用于隐藏部分顽固的依赖GUID的ShellEx类型项目
+IEMenu = Internet Explorer 网页的右键菜单
[Menu]
-ChangeText = 更改名称
+ChangeText = 更改文本
ItemIcon = 菜单图标
ChangeIcon = 更改图标
ShieldIcon = 盾牌图标
@@ -107,10 +98,12 @@ OtherAttributes = 其他属性
OnlyWithShift = 仅在按住 Shift 键后显示
OnlyInExplorer = 仅在 Explorer 窗口显示
NoWorkingDirectory = 不使用右键所处目录信息
-NeverDefault = 从不作为左键默认执行命令
+NeverDefault = 从不用作左键默认执行命令
+ShowAsDisabledIfHidden = 被禁用时灰色显示不隐藏
Details = 详细信息
WebSearch = 网页搜索
ChangeCommand = 更改命令
+RunAsAdministrator = 提升权限
FileProperties = 文件属性
FileLocation = 文件位置
RegistryLocation = 注册表位置
@@ -121,7 +114,10 @@ HandleGuid = 处理guid
CopyGuid = 复制guid
BlockGuid = 锁定guid
AddGuidDic = 添加字典
-InitialData = 初始数据
+InitialData = 编辑文件初始数据
+BeforeSeparator = 显示在分割线上方
+ChangeGroup = 更换分组
+RestoreDefault = 还原默认
Edit = 编辑
Save = 保存
@@ -145,11 +141,18 @@ ShareWithSkype = 使用 Skype 共享
NewItem = 新建一个菜单项目
AddGuidBlockedItem = 添加GUID锁定项目
LockNewMenu = 锁定新建菜单
-CurrentExtension = 你当前选择的文件格式为
-SetPerceivedType = 设置文件格式感知类型
EditSubItems = 编辑 "%s" 的子菜单项目
InvalidItem = 无效菜单项目:
-Separator = ●●●●●●●●●●●●●●●●●●
+Separator = >>>>>> 分割线 <<<<<<
+SelectExtension = 请选择一个文件扩展名
+SelectPerceivedType = 请选择一个文件感知类型
+SelectDirectoryType = 请选择一个目录感知类型
+CurrentExtension = 你当前选择的文件扩展名为 %s
+CurrentPerceivedType = 你当前选择的文件感知类型为 %s
+CurrentDirectoryType = 你当前选择的目录感知类型为 %s
+WinXSortable = 启用 WinX 菜单排序功能
+ShowFilePath = 状态栏实时显示文件路径
+OpenMoreRegedit = 允许注册表编辑器多开
[Dialog]
Ok = 确认
@@ -157,9 +160,6 @@ Cancel = 取消
Browse = 浏览
Program = 程序
RegistryFile = 注册表文件
-NewShellItem = 新建Shell类型右键菜单项目
-NewSendToItem = 新建发送到子菜单项目
-NewOpenWithItem = 新建打开方式菜单项目
ItemText = 菜单文本
ItemCommand = 菜单命令
CommandArguments = 命令参数
@@ -172,9 +172,20 @@ Private = 私有
InputGuid = 输入Guid
AddGuidDic = 添加Guid本地字典
DeleteGuidDic = 删除
-SelectExtension = 请选择一个文件扩展名
+TextFile = 文本文件
+DocumentFile = 文档文件
+ImageFile = 图像文件
+VideoFile = 视频文件
+AudioFile = 音频文件
+CompressedFile = 压缩文件
+SystemFile = 系统文件
+DocumentDirectory = 文档目录
+ImageDirectory = 图像目录
+VideoDirectory = 视频目录
+AudioDirectory = 音频目录
CheckReference = 请勾选你想要引用的菜单项目
CheckCopy = 请勾选你想要复制的菜单项目
+SelectGroup = 请选择保存分组
SelectSubMenuMode = 该多级菜单子项目数为0, 你有两个选择:\n①该多级菜单的所有子菜单项目私有(推荐),\n②该多级菜单可与其他多级菜单引用相同子项,\n请做出你的选择......
[MessageBox]
@@ -183,10 +194,11 @@ CommandCannotBeEmpty = 菜单命令不能为空!
StringParsingFailed = 本地化字符串解析失败!
TextLengthCannotExceed80 = 菜单文本过长, 长度不允许超过80!
ConfirmDeletePermanently = 确认是否永久删除此项?\n此操作无法还原,请谨慎操作!
+DeleteButCanRestore = 确认删除此菜单的注册表项目?\n由于启用了自动备份(默认启用),\n删除后可在备份文件夹中还原。
ConfirmDeleteReference = 确认是否移除对该项目的引用?
ConfirmDelete = 确认是否删除该项?
-ConfirmDeleteReferenced = 确认是否永久删除此项?\n所有引用此项的项目都会失效,请谨慎操作!
-CannotAddNewItem = 系统限制子菜单最大项目数为16,\n无法再进行添加!
+ConfirmDeleteReferenced = 确认是否删除此项?\n所有引用此项的项目都会失效,请谨慎操作!
+CannotAddNewItem = 系统限制子菜单数目最多为16,\n无法添加更多的子菜单项目!
VistaUnsupportedMulti = Vista系统不支持多级菜单!
CannotHideSubItem = 你的系统版本太低,不支持隐藏子级菜单!
UnsupportedFilename = 不支持的文件名,\n可能已经存在相同文件名的菜单项目!
@@ -203,6 +215,9 @@ FileNotExists = 文件不存在!
FolderNotExists = 文件夹不存在!
NoUpdateDetected = 未检测到程序更新,\n但已为你更新网络字典文件。
AuthorityProtection = 此菜单注册表项目可能受安全软件保护,\n无法对其进行禁用删除和其他个性化修改。
+WinXSorted = 为优化排序功能已对部分项目重新编号,\n需要重启文件资源管理器应用效果
+RestoreDefault = 确认还原为默认菜单项目?
+DeleteGroup = 确认永久删除此组及组内所有菜单项目?
[Tip]
RestartExplorer = 重启Explorer会使桌面闪烁片刻, 正常现象无需担心,\n或者你也可以稍后重启或注销计算机使你的操作生效
@@ -214,14 +229,15 @@ EditSubItems = 编辑子菜单项目
AddReference = 从公共引用项目中添加引用
AddFromParentMenu = 从母菜单中复制项目
AddSeparator = 添加分隔线
-Separator = 项目分隔线
DeleteGuidDic = 删除用户自行添加的该项的本地Guid字典
LockNewMenu = 启用后可阻止第三方程序增加项目\n且可对现有项目排序(关闭后复原)
CheckUpdate = 程序每月自动检测一次更新 (启动程序时)\n你可手动点击浏览Github、Gitee检查更新
LastCheckUpdateTime = 上次自动更新检查时间:
OpenLanguagesDir = 打开语言文件夹
OpenDictionariesDir = 打开字典文件夹
-ShareWithSkype = 仅当用户电脑安装了 Skype 应用后有此项目
+ConfigPath = 更改配置和数据文件保存路径后,\n会导致部分已启用增强菜单失效,\n可在增强菜单中重新启用一遍
+CommandFiles = 此命令依赖配置文件,移动配置文件位置\n会导致此菜单项失效,重新启用一遍即可
+CreateGroup = 新建一个分组
[Other]
RestartExplorer = 当前部分操作需要重启文件资源管理器生效
@@ -233,9 +249,9 @@ CommonItemsDictionary = 常用菜单
Translators = 翻译贡献者
OtherLanguages = 下载或上传其他语言文件
DonationList = 捐赠名单
-ConfigFile = 配置和数据文件
-SaveToAppData = 保存到 AppData 目录
-SaveToAppDir = 保存到程序所在目录
+ConfigPath = 配置和数据文件保存位置
+AppDataDir = AppData 目录
+AppDir = 程序所在目录
OpenConfigDir = 打开配置文件所在目录
AutoBackup = 删除菜单时自动备份注册表
OpenBackupDir = 打开备份文件夹
@@ -244,10 +260,10 @@ ImmediatelyCheckUpdate = 立即检查
ProtectOpenItem = 保护 "打开" 菜单项目
WebSearchEngine = 网页搜索使用的搜索引擎
CustomEngine = 自定义
-SetCustomEngine = 设定搜索引擎 (以 %s 代替搜索关键字)
+SetCustomEngine = 设定搜索引擎 (以 %s 代替搜索关键词)
-AboutApp = 【主要功能】\n 1.管理常见位置右键菜单\n 2.自定义添加右键菜单\n\n【兼容性能】\n 1.适用于Win7、8、8.1、10、Vista\n 2.适用于 x64、x32 CPU 操作系统\n 3.适配高分屏,最佳缩放比为150%\n\n【代码开源】\n 1.代码语言:C Sharp, Winform程序\n 2.Github仓库:https://github.com/BluePointLilac/ContextMenuManager \n 3.Gitee仓库:https://gitee.com/BluePointLilac/ContextMenuManager \n 4.使用本程序的源代码请遵守MIT开源协议\n\n【联系作者】\n 1.程序由我个人独立开发,当然也要感谢萌研社 @坑晨 平时的答疑解惑,能力有限,\n 难免出现一些Bug,欢迎大家反馈Bug和提出建议\n 2.个人B站ID:蓝点lilac https://space.bilibili.com/34492771 (欢迎大家关注我!)\n 3.个人邮箱:1617859183@qq.com\n\n【程序图标】\n 1.程序主图标来自 https://www.easyicon.net/1208132-mouse_icon.html \n 2.程序使用到的按钮图标主要来自 https://www.iconfont.cn/ \n\n【程序更新】\n 1.程序有检查更新功能,除了更新程序本身还会更新字典,下载完成后直接覆盖原文件即可\n 2.由于Github Raw被墙,Gitee Raw有每月次数访问上限,程序设置为每月检测一次更新,\n 大家也可以自己浏览Github Releases栏或Gitee 发行版栏检查是否有更新 \n\n【温馨提示】\n 1.一些特殊菜单项可能会受到其他因素影响导致不会显示在右键菜单中,\n 但是按照程序使用的通用规则在此程序中仍会显示为启用,这是正常的现象。\n 2.每个右键管理程序禁用菜单方法可能不同, 建议不要同时使用多个右键菜单管理程序,\n 大部分程序使用简单暴力的备份-删除法, 此程序尽可能使用了系统提供的键值进行隐藏操作,\n 若之前使用过其他程序禁用菜单项,请先使用对应程序还原, 不然可能无法在此程序中看到它。\n 3.此程序不用于清理未卸载干净的程序,但可帮助你定位菜单项相关注册表和文件位置,\n 你可根据相关内容进行你的操作,如果你是一个电脑小白,建议只碰启用\禁用开关。
+AboutApp = 【主要功能】\n 1.管理常见位置右键菜单\n 2.自定义添加右键菜单\n\n【兼容性能】\n 1.适用于Win7、8、8.1、10、Vista\n 2.适用于 x64、x32 CPU 操作系统\n 3.适配高分屏,最佳缩放比为150%\n\n【代码开源】\n 1.代码语言:C Sharp, Winform 程序\n 2.Github 仓库: https://github.com/BluePointLilac/ContextMenuManager \n 3.Gitee 仓库: https://gitee.com/BluePointLilac/ContextMenuManager \n\n【联系作者】\n 1.程序由我个人独立开发,当然也要感谢萌研社 @坑晨 平时的答疑解惑,能力有限,\n 难免出现一些Bug,欢迎大家反馈Bug和提出建议\n 2.个人B站: https://space.bilibili.com/34492771 (欢迎大家关注我!)\n 3.QQ邮箱: 1617859183@qq.com\n\n【资源引用】\n 1.程序主图标来自: https://www.easyicon.net/1208132-mouse_icon.html \n 2.程序按钮图标主要来自阿里巴巴矢量图标库: https://www.iconfont.cn/ \n 3.WinX HashLnk (Rafael Rivera): https://github.com/riverar/hashlnk \n\n【程序更新】\n 1.程序有检查更新功能,除了更新程序本身还会更新字典,下载完成后直接覆盖原文件即可\n 2.由于Github Raw被墙,Gitee Raw有每月次数访问上限,程序设置为每月检测一次更新,\n 大家也可以自己浏览Github Releases栏或Gitee 发行版栏检查是否有更新 \n\n【温馨提示】\n 1.一些特殊菜单项可能会受到其他因素影响导致不会显示在右键菜单中,\n 但是按照程序使用的通用规则在此程序中仍会显示为启用,这是正常的现象。\n 2.每个右键管理程序禁用菜单方法可能不同, 建议不要同时使用多个右键菜单管理程序,\n 大部分程序使用简单暴力的备份-删除法, 此程序尽可能使用了系统提供的键值进行隐藏操作,\n 若之前使用过其他程序禁用菜单项,请先使用对应程序还原, 不然可能无法在此程序中看到它。\n 3.此程序不用于清理未卸载干净的程序,但可帮助你定位菜单项相关注册表和文件位置,\n 你可根据相关内容进行你的操作,如果你是一个电脑小白,建议只碰启用\禁用开关。
-Dictionaries = 【字典说明】\n 此程序拥有几个字典文件, 每份字典又有用户字典和网络字典\n 如果想为此程序添加字典可右键保存字典文件, 并按照文件内相关说明进行添加\n 可将你的用户字典发送到我的邮箱或提交到Github为此项目做出你的贡献\n 右侧选项卡中为原始字典内容, 你可以切换选项卡进行查看\n\n【字典内容】\n 1.程序显示文本语言字典 (languages目录)\n 2.ShellEx菜单项GUID文本图标字典 (GuidInfosDic.ini)\n 3.第三方程序菜单内部设置字典 (ThirdRulesDic.xml)\n 4.增强菜单项目字典 (EnhanceMenusDic.xml)
+Dictionaries = 【字典说明】\n 此程序拥有几个字典文件, 每份字典又有用户字典和网络字典\n 如果想为此程序添加字典可右键保存文件, 并按照文件内说明进行添加\n 可将你的字典发送到我的邮箱或提交到Github为此项目做出你的贡献\n 右侧选项卡中为原始字典内容, 你可以切换选项卡进行查看\n\n【字典内容】\n 1.程序显示文本语言字典 (Languages目录)\n 2.ShellEx菜单项GUID文本图标字典 (GuidInfosDic.ini)\n 3.第三方程序菜单内部设置字典 (ThirdRulesDic.xml)\n 4.增强菜单项目字典 (EnhanceMenusDic.xml)
Donate = 此程序完全免费,如果你觉得这个软件对你有所帮助, 你可以通过扫描\n下方二维码(微信、支付宝、腾讯QQ)进行捐赠, 金额请随意, 谢谢支持!\n也期待你在Github或者Gitee上为此程序项目点亮Star (这对我很重要!)
\ No newline at end of file