diff --git a/ShareX/Forms/ApplicationSettingsForm.Designer.cs b/ShareX/Forms/ApplicationSettingsForm.Designer.cs index 681bff0d7..42cc86f0d 100644 --- a/ShareX/Forms/ApplicationSettingsForm.Designer.cs +++ b/ShareX/Forms/ApplicationSettingsForm.Designer.cs @@ -141,6 +141,7 @@ private void InitializeComponent() this.tpAdvanced = new System.Windows.Forms.TabPage(); this.pgSettings = new System.Windows.Forms.PropertyGrid(); this.tttvMain = new ShareX.HelpersLib.TabToTreeView(); + this.cbEditWithShareX = new System.Windows.Forms.CheckBox(); this.tcSettings.SuspendLayout(); this.tpGeneral.SuspendLayout(); this.tpIntegration.SuspendLayout(); @@ -392,6 +393,7 @@ private void InitializeComponent() // // gbWindows // + this.gbWindows.Controls.Add(this.cbEditWithShareX); this.gbWindows.Controls.Add(this.cbStartWithWindows); this.gbWindows.Controls.Add(this.cbSendToMenu); this.gbWindows.Controls.Add(this.cbShellContextMenu); @@ -1020,6 +1022,13 @@ private void InitializeComponent() this.tttvMain.TreeViewSize = 175; this.tttvMain.TabChanged += new ShareX.HelpersLib.TabToTreeView.TabChangedEventHandler(this.tttvMain_TabChanged); // + // cbEditWithShareX + // + resources.ApplyResources(this.cbEditWithShareX, "cbEditWithShareX"); + this.cbEditWithShareX.Name = "cbEditWithShareX"; + this.cbEditWithShareX.UseVisualStyleBackColor = true; + this.cbEditWithShareX.CheckedChanged += new System.EventHandler(this.cbEditWithShareX_CheckedChanged); + // // ApplicationSettingsForm // resources.ApplyResources(this, "$this"); @@ -1191,5 +1200,6 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox cbChromeExtensionSupport; private System.Windows.Forms.CheckBox cbFirefoxAddonSupport; private System.Windows.Forms.Button btnResetSettings; + private System.Windows.Forms.CheckBox cbEditWithShareX; } } \ No newline at end of file diff --git a/ShareX/Forms/ApplicationSettingsForm.cs b/ShareX/Forms/ApplicationSettingsForm.cs index f4361829a..25bcc3d5c 100644 --- a/ShareX/Forms/ApplicationSettingsForm.cs +++ b/ShareX/Forms/ApplicationSettingsForm.cs @@ -140,6 +140,7 @@ private void UpdateControls() gbFirefox.Visible = false; #else cbShellContextMenu.Checked = IntegrationHelpers.CheckShellContextMenuButton(); + cbEditWithShareX.Checked = IntegrationHelpers.CheckEditShellContextMenuButton(); cbSendToMenu.Checked = IntegrationHelpers.CheckSendToMenuButton(); cbChromeExtensionSupport.Checked = IntegrationHelpers.CheckChromeExtensionSupport(); btnChromeOpenExtensionPage.Enabled = cbChromeExtensionSupport.Checked; @@ -427,6 +428,14 @@ private void cbShellContextMenu_CheckedChanged(object sender, EventArgs e) } } + private void cbEditWithShareX_CheckedChanged(object sender, EventArgs e) + { + if (ready) + { + IntegrationHelpers.CreateEditShellContextMenuButton(cbEditWithShareX.Checked); + } + } + private void cbSendToMenu_CheckedChanged(object sender, EventArgs e) { if (ready) diff --git a/ShareX/Forms/ApplicationSettingsForm.resx b/ShareX/Forms/ApplicationSettingsForm.resx index 3cf01deeb..a902d259a 100644 --- a/ShareX/Forms/ApplicationSettingsForm.resx +++ b/ShareX/Forms/ApplicationSettingsForm.resx @@ -415,7 +415,7 @@ btnLanguages - ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.1.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MenuButton, ShareX.HelpersLib, Version=12.1.1.0, Culture=neutral, PublicKeyToken=null tpGeneral @@ -655,7 +655,7 @@ 1 - 8, 216 + 8, 240 536, 88 @@ -706,7 +706,7 @@ 0 - 8, 312 + 8, 336 536, 56 @@ -781,7 +781,7 @@ 1 - 8, 120 + 8, 144 536, 88 @@ -804,6 +804,36 @@ 2 + + True + + + NoControl + + + 16, 72 + + + 343, 17 + + + 3 + + + Show "Edit with ShareX" button in Windows Explorer context menu + + + cbEditWithShareX + + + System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + gbWindows + + + 0 + True @@ -829,7 +859,7 @@ gbWindows - 0 + 1 True @@ -838,7 +868,7 @@ NoControl - 16, 72 + 16, 96 181, 17 @@ -859,7 +889,7 @@ gbWindows - 1 + 2 True @@ -889,13 +919,13 @@ gbWindows - 2 + 3 8, 8 - 536, 104 + 536, 128 0 @@ -1717,7 +1747,7 @@ lvClipboardFormats - ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.1.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.1.1.0, Culture=neutral, PublicKeyToken=null gbClipboardFormats @@ -1828,7 +1858,7 @@ lvSecondaryImageUploaders - ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.1.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.1.1.0, Culture=neutral, PublicKeyToken=null gbSecondaryImageUploaders @@ -1882,7 +1912,7 @@ lvSecondaryFileUploaders - ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.1.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.1.1.0, Culture=neutral, PublicKeyToken=null gbSecondaryFileUploaders @@ -1936,7 +1966,7 @@ lvSecondaryTextUploaders - ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.1.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.MyListView, ShareX.HelpersLib, Version=12.1.1.0, Culture=neutral, PublicKeyToken=null gbSecondaryTextUploaders @@ -2920,7 +2950,7 @@ tttvMain - ShareX.HelpersLib.TabToTreeView, ShareX.HelpersLib, Version=12.1.0.0, Culture=neutral, PublicKeyToken=null + ShareX.HelpersLib.TabToTreeView, ShareX.HelpersLib, Version=12.1.1.0, Culture=neutral, PublicKeyToken=null $this diff --git a/ShareX/IntegrationHelpers.cs b/ShareX/IntegrationHelpers.cs index 2bca1dd53..479d23831 100644 --- a/ShareX/IntegrationHelpers.cs +++ b/ShareX/IntegrationHelpers.cs @@ -44,17 +44,22 @@ public static class IntegrationHelpers private static readonly string ShellExtMenuFiles = @"Software\Classes\*\shell\" + ApplicationName; private static readonly string ShellExtMenuFilesCmd = ShellExtMenuFiles + @"\command"; - private static readonly string ShellExtMenuDirectory = @"Software\Classes\Directory\shell\" + ApplicationName; private static readonly string ShellExtMenuDirectoryCmd = ShellExtMenuDirectory + @"\command"; - private static readonly string ShellExtMenuFolders = @"Software\Classes\Folder\shell\" + ApplicationName; private static readonly string ShellExtMenuFoldersCmd = ShellExtMenuFolders + @"\command"; - private static readonly string ShellExtDesc = Resources.IntegrationHelpers_UploadWithShareX; private static readonly string ShellExtIcon = ApplicationPath + ",0"; private static readonly string ShellExtPath = ApplicationPath + " \"%1\""; + private static readonly string ShellExtEditMenuJpeg = @"Software\Classes\.jpg\shell\" + ApplicationName; + private static readonly string ShellExtEditMenuJpegCmd = ShellExtEditMenuJpeg + @"\command"; + private static readonly string ShellExtEditMenuPng = @"Software\Classes\.png\shell\" + ApplicationName; + private static readonly string ShellExtEditMenuPngCmd = ShellExtEditMenuPng + @"\command"; + private static readonly string ShellExtEditDesc = "Edit with ShareX"; // TODO: Translate + private static readonly string ShellExtEditIcon = ApplicationPath + ",0"; + private static readonly string ShellExtEditPath = ApplicationPath + " -ImageEditor \"%1\""; + private static readonly string ShellCustomUploaderExtensionPath = @"Software\Classes\.sxcu"; private static readonly string ShellCustomUploaderExtensionValue = "ShareX.sxcu"; private static readonly string ShellCustomUploaderAssociatePath = @"Software\Classes\" + ShellCustomUploaderExtensionValue; @@ -119,6 +124,57 @@ private static void UnregisterShellContextMenuButton() RegistryHelpers.RemoveRegistry(ShellExtMenuFolders, true); } + public static bool CheckEditShellContextMenuButton() + { + try + { + return RegistryHelpers.CheckRegistry(ShellExtEditMenuJpegCmd, null, ShellExtEditPath) && RegistryHelpers.CheckRegistry(ShellExtEditMenuPngCmd, null, ShellExtEditPath); + } + catch (Exception e) + { + DebugHelper.WriteException(e); + } + + return false; + } + + public static void CreateEditShellContextMenuButton(bool create) + { + try + { + if (create) + { + UnregisterEditShellContextMenuButton(); + RegisterEditShellContextMenuButton(); + } + else + { + UnregisterEditShellContextMenuButton(); + } + } + catch (Exception e) + { + DebugHelper.WriteException(e); + } + } + + private static void RegisterEditShellContextMenuButton() + { + RegistryHelpers.CreateRegistry(ShellExtEditMenuJpeg, ShellExtEditDesc); + RegistryHelpers.CreateRegistry(ShellExtEditMenuJpeg, "Icon", ShellExtEditIcon); + RegistryHelpers.CreateRegistry(ShellExtEditMenuJpegCmd, ShellExtEditPath); + + RegistryHelpers.CreateRegistry(ShellExtEditMenuPng, ShellExtEditDesc); + RegistryHelpers.CreateRegistry(ShellExtEditMenuPng, "Icon", ShellExtEditIcon); + RegistryHelpers.CreateRegistry(ShellExtEditMenuPngCmd, ShellExtEditPath); + } + + private static void UnregisterEditShellContextMenuButton() + { + RegistryHelpers.RemoveRegistry(ShellExtEditMenuJpeg, true); + RegistryHelpers.RemoveRegistry(ShellExtEditMenuPng, true); + } + public static bool CheckCustomUploaderExtension() { try