diff --git a/HexExplorer/BindingEnum.cs b/HexExplorer/BindingEnum.cs index ce2e73d..e59b88c 100644 --- a/HexExplorer/BindingEnum.cs +++ b/HexExplorer/BindingEnum.cs @@ -75,7 +75,7 @@ namespace HexExplorer } public static readonly Binding LogInfo = new Binding("Text", LoggingLib.Instance, "LogInfo"); - + public static readonly Binding UseShell = new Binding("Checked", FrmSetting.UseShell, null , true, DataSourceUpdateMode.OnPropertyChanged); } } diff --git a/HexExplorer/FrmMain.Designer.cs b/HexExplorer/FrmMain.Designer.cs index 47a8335..6bc35cc 100644 --- a/HexExplorer/FrmMain.Designer.cs +++ b/HexExplorer/FrmMain.Designer.cs @@ -1801,6 +1801,7 @@ this.Text = "羽云十六进制浏览器"; this.WindowState = System.Windows.Forms.FormWindowState.Maximized; this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmMain_FormClosing); + this.Load += new System.EventHandler(this.FrmMain_Load); MainMenu.ResumeLayout(false); MainMenu.PerformLayout(); this.hexMenuStrip.ResumeLayout(false); diff --git a/HexExplorer/FrmMain.cs b/HexExplorer/FrmMain.cs index 29273e3..3028f41 100644 --- a/HexExplorer/FrmMain.cs +++ b/HexExplorer/FrmMain.cs @@ -14,6 +14,7 @@ namespace HexExplorer public partial class FrmMain : FormBase { private readonly EditorPageManager pageManager; + private string[] Args; private readonly string EditFileExt = string.Empty; @@ -59,10 +60,7 @@ namespace HexExplorer pageManager.EditorPageClosing += PageManager_EditorPageClosing; SingleInstanceHelper.StartUpNextInstance += SingleInstanceHelper_StartUpNextInstance; - if (args != null && args.Length > 0) - { - CreateOrOpen(args[0].Trim()); - } + Args = args; constInfo = new ConstInfo(); pgConst.SelectedObject = constInfo; @@ -1095,6 +1093,21 @@ namespace HexExplorer } } } - + + private void FrmMain_Load(object sender, EventArgs e) + { + if (Args != null && Args.Length > 0) + { + foreach (var item in Args) + { + var filename = item.Trim(); + + if (File.Exists(filename)) + { + CreateOrOpen(filename); + } + } + } + } } } \ No newline at end of file diff --git a/HexExplorer/FrmMain.resx b/HexExplorer/FrmMain.resx index 4657209..93a2ea4 100644 --- a/HexExplorer/FrmMain.resx +++ b/HexExplorer/FrmMain.resx @@ -233,7 +233,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADQ - DwAAAk1TRnQBSQFMAgEBBAEAAbgBBAG4AQQBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA + DwAAAk1TRnQBSQFMAgEBBAEAAcABBAHAAQQBEAEAARABAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFA AwABIAMAAQEBAAEgBgABIP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8AugADQAFwA2IB7wNi Ae8DQAFwGAAD9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8cAAP2Af8D9gH/A/YB/wP2 Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af8D9gH/A/YB/wP2Af9QAAMXASADWQG/ diff --git a/HexExplorer/FrmSetting.Designer.cs b/HexExplorer/FrmSetting.Designer.cs index 5e02f1a..9cbbb1b 100644 --- a/HexExplorer/FrmSetting.Designer.cs +++ b/HexExplorer/FrmSetting.Designer.cs @@ -38,6 +38,7 @@ namespace HexExplorer System.Windows.Forms.TabPage tabPE; System.Windows.Forms.TabPage tabBookMark; System.Windows.Forms.TabPage tabPlugin; + System.Windows.Forms.TabPage tabOther; this.label1 = new System.Windows.Forms.Label(); this.btnFont = new System.Windows.Forms.Button(); this.cbEncoding = new System.Windows.Forms.ComboBox(); @@ -72,6 +73,7 @@ namespace HexExplorer this.pgPlugin = new System.Windows.Forms.PropertyGrid(); this.clbPlugin = new System.Windows.Forms.ListBox(); this.cbEnablePlugin = new System.Windows.Forms.CheckBox(); + this.cbShellRight = new System.Windows.Forms.CheckBox(); this.tabSetting = new System.Windows.Forms.TabControl(); this.cD = new System.Windows.Forms.ColorDialog(); this.fD = new System.Windows.Forms.FontDialog(); @@ -84,6 +86,7 @@ namespace HexExplorer tabPE = new System.Windows.Forms.TabPage(); tabBookMark = new System.Windows.Forms.TabPage(); tabPlugin = new System.Windows.Forms.TabPage(); + tabOther = new System.Windows.Forms.TabPage(); tabGeneral.SuspendLayout(); groupBox2.SuspendLayout(); groupBox1.SuspendLayout(); @@ -91,6 +94,7 @@ namespace HexExplorer tabPE.SuspendLayout(); tabBookMark.SuspendLayout(); tabPlugin.SuspendLayout(); + tabOther.SuspendLayout(); this.tabSetting.SuspendLayout(); this.SuspendLayout(); // @@ -651,12 +655,37 @@ namespace HexExplorer this.cbEnablePlugin.Text = "启用插件支持 ⏱"; this.cbEnablePlugin.UseVisualStyleBackColor = true; // + // tabOther + // + tabOther.Controls.Add(this.cbShellRight); + tabOther.Location = new System.Drawing.Point(4, 25); + tabOther.Name = "tabOther"; + tabOther.Padding = new System.Windows.Forms.Padding(3); + tabOther.Size = new System.Drawing.Size(612, 339); + tabOther.TabIndex = 4; + tabOther.Text = "杂项"; + tabOther.UseVisualStyleBackColor = true; + // + // cbShellRight + // + this.cbShellRight.AutoSize = true; + this.cbShellRight.Enabled = false; + this.cbShellRight.Location = new System.Drawing.Point(35, 34); + this.cbShellRight.Name = "cbShellRight"; + this.cbShellRight.Size = new System.Drawing.Size(224, 19); + this.cbShellRight.TabIndex = 0; + this.cbShellRight.Text = "将所有文件类型添加右键菜单"; + this.toolTip.SetToolTip(this.cbShellRight, "需要管理员权限"); + this.cbShellRight.UseVisualStyleBackColor = true; + this.cbShellRight.CheckedChanged += new System.EventHandler(this.CbShellRight_CheckedChanged); + // // tabSetting // this.tabSetting.Controls.Add(tabGeneral); this.tabSetting.Controls.Add(tabPE); this.tabSetting.Controls.Add(tabBookMark); this.tabSetting.Controls.Add(tabPlugin); + this.tabSetting.Controls.Add(tabOther); this.tabSetting.Dock = System.Windows.Forms.DockStyle.Fill; this.tabSetting.Location = new System.Drawing.Point(0, 0); this.tabSetting.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); @@ -684,6 +713,7 @@ namespace HexExplorer this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.Name = "FrmSetting"; this.Text = "设置"; + this.Load += new System.EventHandler(this.FrmSetting_Load); this.VisibleChanged += new System.EventHandler(this.FrmSetting_VisibleChanged); tabGeneral.ResumeLayout(false); groupBox2.ResumeLayout(false); @@ -697,6 +727,8 @@ namespace HexExplorer tabBookMark.PerformLayout(); tabPlugin.ResumeLayout(false); tabPlugin.PerformLayout(); + tabOther.ResumeLayout(false); + tabOther.PerformLayout(); this.tabSetting.ResumeLayout(false); this.ResumeLayout(false); @@ -742,5 +774,6 @@ namespace HexExplorer private System.Windows.Forms.CheckedListBox clbBookMark; private System.Windows.Forms.CheckBox cbEnablePE; private System.Windows.Forms.CheckBox cbAdmin; + private System.Windows.Forms.CheckBox cbShellRight; } } \ No newline at end of file diff --git a/HexExplorer/FrmSetting.cs b/HexExplorer/FrmSetting.cs index 7b9ecd1..4cd19fb 100644 --- a/HexExplorer/FrmSetting.cs +++ b/HexExplorer/FrmSetting.cs @@ -2,7 +2,9 @@ using System.ComponentModel; using Be.Windows.Forms; using System.Drawing; +using Microsoft.Win32; using System.Collections.Generic; +using System; namespace HexExplorer { @@ -10,8 +12,11 @@ namespace HexExplorer { private static FrmSetting frmSetting=null; + public static bool UseShell = false; private readonly List pluginInfos; private readonly WSPlugin plugin = WSPlugin.Instance; + private static string app= Application.ExecutablePath; + private string appp = $"\"{app}\" \"%1\""; public static FrmSetting Instance { @@ -69,6 +74,13 @@ namespace HexExplorer btnStringLine.DataBindings.Add(BindingEnum.Setting.HexStringLinePen); btnStringLine.DataBindings.Add(BindingEnum.Setting.HexStringLinePenFore); + cbShellRight.DataBindings.Add(BindingEnum.UseShell); + + if (AdminLib.Instance.IsAdmin) + { + cbShellRight.Enabled = true; + } + MUserProfile mUser = UserSetting.UserProfile; var dplugin = mUser.DisableGuid; if (mUser.EnablePlugin) @@ -84,7 +96,7 @@ namespace HexExplorer } - private void FrmSetting_VisibleChanged(object sender, System.EventArgs e) + private void FrmSetting_VisibleChanged(object sender, EventArgs e) { if (Visible) { @@ -100,7 +112,7 @@ namespace HexExplorer } } - private void BtnSelectColor_Click(object sender, System.EventArgs e) + private void BtnSelectColor_Click(object sender, EventArgs e) { if (cD.ShowDialog() == DialogResult.OK) { @@ -113,7 +125,7 @@ namespace HexExplorer } } - private void BtnPenFEdit_Click(object sender, System.EventArgs e) + private void BtnPenFEdit_Click(object sender, EventArgs e) { using (FrmPenFEdit frmPenF = FrmPenFEdit.Instance) { @@ -123,7 +135,7 @@ namespace HexExplorer } } - private void ClbPlugin_SelectedIndexChanged(object sender, System.EventArgs e) + private void ClbPlugin_SelectedIndexChanged(object sender, EventArgs e) { var sel = clbPlugin.SelectedIndex; if (sel >= 0) @@ -132,5 +144,60 @@ namespace HexExplorer } } + private void FrmSetting_Load(object sender, EventArgs e) + { + RegistryKey key = Registry.ClassesRoot.OpenSubKey(@"*\shell"); + if ((key = key.OpenSubKey("WCHexExplorer")) != null) + { + if (!key.GetValue("Icon", null).Equals(app)) + goto endl; + if ((key = key.OpenSubKey("command")) != null) + { + if (key.GetValue("").Equals(appp)) + { + UseShell = true; + } + else + { + goto endl; + } + } + else + { + goto endl; + } + return; + } + endl: + UseShell = false; + } + + private void CbShellRight_CheckedChanged(object sender, EventArgs e) + { + if (cbShellRight.Checked) + { + var app = Application.ExecutablePath; + using (var key = Registry.ClassesRoot.OpenSubKey(@"*\shell", true)) + { + using (var key0 = key.CreateSubKey("WCHexExplorer")) + { + key0.SetValue("", "用羽云十六进制浏览器打开"); + key0.SetValue("Icon", app); + using (var key1 = key0.CreateSubKey("command")) + { + key1.SetValue("", appp); + } + } + } + + } + else + { + using (var key = Registry.ClassesRoot.OpenSubKey(@"*\shell", true)) + { + key.DeleteSubKeyTree("WCHexExplorer"); + } + } + } } } \ No newline at end of file diff --git a/HexExplorer/FrmSetting.resx b/HexExplorer/FrmSetting.resx index f732fb1..02d9c78 100644 --- a/HexExplorer/FrmSetting.resx +++ b/HexExplorer/FrmSetting.resx @@ -156,13 +156,16 @@ False + + False + + + 167, 17 + 17, 17 93, 17 - - 167, 17 - \ No newline at end of file diff --git a/HexExplorer/WingCloudHexExplorer.csproj.user b/HexExplorer/WingCloudHexExplorer.csproj.user index 77b19b8..c3d438e 100644 --- a/HexExplorer/WingCloudHexExplorer.csproj.user +++ b/HexExplorer/WingCloudHexExplorer.csproj.user @@ -12,7 +12,6 @@ false - - + C:\Users\wingsummer\Desktop\GuessFileType.cs \ No newline at end of file