From f3a3a4215b7c67dfc1b4745bef40b3fabd2e22ae Mon Sep 17 00:00:00 2001 From: Jaex Date: Tue, 25 Apr 2023 18:52:30 +0300 Subject: [PATCH] Added "Beautify image" button to task context menu --- ShareX/Forms/MainForm.Designer.cs | 10 + ShareX/Forms/MainForm.cs | 13 +- ShareX/Forms/MainForm.resx | 712 ++++++++++++++++-------------- ShareX/TaskHelpers.cs | 9 +- ShareX/UploadInfoManager.cs | 5 + 5 files changed, 406 insertions(+), 343 deletions(-) diff --git a/ShareX/Forms/MainForm.Designer.cs b/ShareX/Forms/MainForm.Designer.cs index 5b88eb820..2a7ca05ce 100644 --- a/ShareX/Forms/MainForm.Designer.cs +++ b/ShareX/Forms/MainForm.Designer.cs @@ -286,6 +286,7 @@ private void InitializeComponent() this.ucTaskThumbnailView = new ShareX.TaskThumbnailView(); this.ttMain = new System.Windows.Forms.ToolTip(this.components); this.pToolbars = new System.Windows.Forms.Panel(); + this.tsmiBeautifyImage = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit(); this.scMain.Panel1.SuspendLayout(); this.scMain.Panel2.SuspendLayout(); @@ -1097,6 +1098,7 @@ private void InitializeComponent() this.tsmiUploadSelectedFile, this.tsmiDownloadSelectedURL, this.tsmiEditSelectedFile, + this.tsmiBeautifyImage, this.tsmiAddImageEffects, this.tsmiPinSelectedFile, this.tsmiRunAction, @@ -2246,6 +2248,13 @@ private void InitializeComponent() this.pToolbars.Controls.Add(this.tsMain); this.pToolbars.Name = "pToolbars"; // + // tsmiBeautifyImage + // + this.tsmiBeautifyImage.Image = global::ShareX.Properties.Resources.picture_sunset; + this.tsmiBeautifyImage.Name = "tsmiBeautifyImage"; + resources.ApplyResources(this.tsmiBeautifyImage, "tsmiBeautifyImage"); + this.tsmiBeautifyImage.Click += new System.EventHandler(this.tsmiBeautifyImage_Click); + // // MainForm // this.AllowDrop = true; @@ -2541,5 +2550,6 @@ private void InitializeComponent() private System.Windows.Forms.ToolStripMenuItem tsmiTrayPinToScreen; private System.Windows.Forms.ToolStripMenuItem tsmiImageBeautifier; private System.Windows.Forms.ToolStripMenuItem tsmiTrayImageBeautifier; + private System.Windows.Forms.ToolStripMenuItem tsmiBeautifyImage; } } \ No newline at end of file diff --git a/ShareX/Forms/MainForm.cs b/ShareX/Forms/MainForm.cs index 743d401af..fad241984 100644 --- a/ShareX/Forms/MainForm.cs +++ b/ShareX/Forms/MainForm.cs @@ -615,9 +615,10 @@ private void UpdateInfoManager() { cmsTaskInfo.SuspendLayout(); - tsmiStopUpload.Visible = tsmiOpen.Visible = tsmiCopy.Visible = tsmiShowErrors.Visible = tsmiShowResponse.Visible = tsmiGoogleImageSearch.Visible = - tsmiBingVisualSearch.Visible = tsmiShowQRCode.Visible = tsmiOCRImage.Visible = tsmiCombineImages.Visible = tsmiUploadSelectedFile.Visible = - tsmiDownloadSelectedURL.Visible = tsmiEditSelectedFile.Visible = tsmiAddImageEffects.Visible = tsmiPinSelectedFile.Visible = tsmiRunAction.Visible = + tsmiStopUpload.Visible = tsmiOpen.Visible = tsmiCopy.Visible = tsmiShowErrors.Visible = tsmiShowResponse.Visible = + tsmiGoogleImageSearch.Visible = tsmiBingVisualSearch.Visible = tsmiShowQRCode.Visible = tsmiOCRImage.Visible = + tsmiCombineImages.Visible = tsmiUploadSelectedFile.Visible = tsmiDownloadSelectedURL.Visible = tsmiEditSelectedFile.Visible = + tsmiBeautifyImage.Visible = tsmiAddImageEffects.Visible = tsmiPinSelectedFile.Visible = tsmiRunAction.Visible = tsmiDeleteSelectedItem.Visible = tsmiDeleteSelectedFile.Visible = tsmiShortenSelectedURL.Visible = tsmiShareSelectedURL.Visible = false; if (Program.Settings.TaskViewMode == TaskViewMode.ListView) @@ -725,6 +726,7 @@ private void UpdateInfoManager() tsmiUploadSelectedFile.Visible = uim.SelectedItem.IsFileExist; tsmiDownloadSelectedURL.Visible = uim.SelectedItem.IsFileURL; tsmiEditSelectedFile.Visible = uim.SelectedItem.IsImageFile; + tsmiBeautifyImage.Visible = uim.SelectedItem.IsImageFile; tsmiAddImageEffects.Visible = uim.SelectedItem.IsImageFile; tsmiPinSelectedFile.Visible = uim.SelectedItem.IsImageFile; UpdateActionsMenu(uim.SelectedItem.Info.FilePath); @@ -2343,6 +2345,11 @@ private void tsmiEditSelectedFile_Click(object sender, EventArgs e) uim.EditImage(); } + private void tsmiBeautifyImage_Click(object sender, EventArgs e) + { + uim.BeautifyImage(); + } + private void tsmiAddImageEffects_Click(object sender, EventArgs e) { uim.AddImageEffects(); diff --git a/ShareX/Forms/MainForm.resx b/ShareX/Forms/MainForm.resx index 7816de0be..cd464b6c6 100644 --- a/ShareX/Forms/MainForm.resx +++ b/ShareX/Forms/MainForm.resx @@ -159,45 +159,6 @@ 0 - - Filename - - - 150 - - - Status - - - Progress - - - 125 - - - Speed - - - 75 - - - Elapsed - - - 45 - - - Remaining - - - 45 - - - URL - - - 145 - Fill @@ -294,12 +255,90 @@ 3 + + Filename + + + 150 + + + Status + + + Progress + + + 125 + + + Speed + + + 75 + + + Elapsed + + + 45 + + + Remaining + + + 45 + + + URL + + + 145 + 17, 17 Fill + + 0, 0 + + + 165, 0 + + + 6, 5, 6, 2 + + + 165, 471 + + + 1 + + + tsMain + + + ShareX.HelpersLib.ToolStripBorderRight, ShareX.HelpersLib, Version=15.0.1.0, Culture=neutral, PublicKeyToken=null + + + pToolbars + + + 0 + + + MiddleLeft + + + Magenta + + + 152, 20 + + + Capture + 191, 22 @@ -375,6 +414,12 @@ Show cursor + + 191, 22 + + + Screenshot delay + 126, 22 @@ -411,23 +456,17 @@ 5 seconds - - 191, 22 - - - Screenshot delay - - + MiddleLeft - + Magenta - + 152, 20 - - Capture + + Upload 203, 22 @@ -477,18 +516,6 @@ Tweet message... - - MiddleLeft - - - Magenta - - - 152, 20 - - - Upload - BottomLeft @@ -501,6 +528,18 @@ Workflows + + MiddleLeft + + + Magenta + + + 152, 20 + + + Tools + 184, 22 @@ -645,18 +684,6 @@ DNS changer... - - MiddleLeft - - - Magenta - - - 152, 20 - - - Tools - 152, 6 @@ -684,6 +711,18 @@ After upload tasks + + MiddleLeft + + + Magenta + + + 152, 20 + + + Destinations + 219, 22 @@ -729,18 +768,6 @@ Custom uploader settings... - - MiddleLeft - - - Magenta - - - 152, 20 - - - Destinations - MiddleLeft @@ -819,6 +846,18 @@ 152, 6 + + MiddleLeft + + + Magenta + + + 152, 20 + + + Debug + 171, 22 @@ -855,18 +894,6 @@ Test URL sharing - - MiddleLeft - - - Magenta - - - 152, 20 - - - Debug - MiddleLeft @@ -915,33 +942,6 @@ About... - - 0, 0 - - - 165, 0 - - - 6, 5, 6, 2 - - - 165, 471 - - - 1 - - - tsMain - - - ShareX.HelpersLib.ToolStripBorderRight, ShareX.HelpersLib, Version=15.0.1.0, Culture=neutral, PublicKeyToken=null - - - pToolbars - - - 0 - 286, 17 @@ -957,6 +957,162 @@ Stop upload + + 228, 22 + + + Open + + + 228, 22 + + + Copy + + + Ctrl+U + + + 228, 22 + + + Upload + + + Ctrl+D + + + 228, 22 + + + Download + + + Ctrl+E + + + 228, 22 + + + Edit image... + + + 228, 22 + + + Beautify image... + + + 228, 22 + + + Add image effects... + + + Ctrl+P + + + 228, 22 + + + Pin to screen + + + 228, 22 + + + Run action + + + Del + + + 228, 22 + + + Remove task from list + + + Shift+Del + + + 228, 22 + + + Delete file locally... + + + 228, 22 + + + Shorten URL + + + 228, 22 + + + Share URL + + + 228, 22 + + + Google image search... + + + 228, 22 + + + Bing visual search (OCR)... + + + 228, 22 + + + Show QR code... + + + 228, 22 + + + OCR image... + + + 228, 22 + + + Combine images... + + + 228, 22 + + + Show response... + + + 228, 22 + + + Clear task list + + + 225, 6 + + + 228, 22 + + + Switch to thumbnail view + + + 229, 538 + + + cmsTaskInfo + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Enter @@ -1011,12 +1167,6 @@ Thumbnail file - - 228, 22 - - - Open - Ctrl+C @@ -1188,114 +1338,6 @@ False - - 228, 22 - - - Copy - - - Ctrl+U - - - 228, 22 - - - Upload - - - Ctrl+D - - - 228, 22 - - - Download - - - Ctrl+E - - - 228, 22 - - - Edit image... - - - 228, 22 - - - Add image effects... - - - Ctrl+P - - - 228, 22 - - - Pin to screen - - - 228, 22 - - - Run action - - - Del - - - 228, 22 - - - Remove task from list - - - Shift+Del - - - 228, 22 - - - Delete file locally... - - - 228, 22 - - - Shorten URL - - - 228, 22 - - - Share URL - - - 228, 22 - - - Google image search... - - - 228, 22 - - - Bing visual search (OCR)... - - - 228, 22 - - - Show QR code... - - - 228, 22 - - - OCR image... - 188, 22 @@ -1308,48 +1350,30 @@ Combine vertically - - 228, 22 - - - Combine images... - - - 228, 22 - - - Show response... - - - 228, 22 - - - Clear task list - - - 225, 6 - - - 228, 22 - - - Switch to thumbnail view - - - 229, 494 - - - cmsTaskInfo - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 105, 17 190, 17 + + 201, 440 + + + cmsTray + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ShareX + + + 200, 22 + + + Capture + 191, 22 @@ -1425,6 +1449,12 @@ Show cursor + + 191, 22 + + + Screenshot delay + 126, 22 @@ -1461,17 +1491,11 @@ 5 seconds - - 191, 22 - - - Screenshot delay - - + 200, 22 - - Capture + + Upload 203, 22 @@ -1521,18 +1545,18 @@ Tweet message... - - 200, 22 - - - Upload - 200, 22 Workflows + + 200, 22 + + + Tools + 184, 22 @@ -1677,12 +1701,6 @@ DNS changer... - - 200, 22 - - - Tools - 197, 6 @@ -1698,6 +1716,12 @@ After upload tasks + + 200, 22 + + + Destinations + 219, 22 @@ -1743,12 +1767,6 @@ Custom uploader settings... - - 200, 22 - - - Destinations - 200, 22 @@ -1833,21 +1851,57 @@ Exit - - 201, 440 - - - cmsTray - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ShareX - 405, 17 + + lblThumbnailViewTip + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pThumbnailView + + + 0 + + + ucTaskThumbnailView + + + ShareX.TaskThumbnailView, ShareX, Version=15.0.1.0, Culture=neutral, PublicKeyToken=null + + + pThumbnailView + + + 1 + + + Fill + + + 165, 0 + + + 679, 471 + + + 7 + + + pThumbnailView + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + True @@ -1911,30 +1965,6 @@ 1 - - Fill - - - 165, 0 - - - 679, 471 - - - 7 - - - pThumbnailView - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 2 - 567, 17 @@ -3453,6 +3483,12 @@ System.Windows.Forms.ToolTip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tsmiBeautifyImage + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MainForm diff --git a/ShareX/TaskHelpers.cs b/ShareX/TaskHelpers.cs index 44ca39488..3b91de71a 100644 --- a/ShareX/TaskHelpers.cs +++ b/ShareX/TaskHelpers.cs @@ -1067,12 +1067,17 @@ public static Bitmap AnnotateImage(Bitmap bmp, string filePath, TaskSettings tas public static void OpenImageBeautifier(TaskSettings taskSettings = null) { - if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings(); - string filePath = ImageHelpers.OpenImageFileDialog(); + OpenImageBeautifier(filePath); + } + + public static void OpenImageBeautifier(string filePath, TaskSettings taskSettings = null) + { if (!string.IsNullOrEmpty(filePath)) { + if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings(); + ImageBeautifierForm imageBeautifierForm = new ImageBeautifierForm(filePath, new ImageBeautifierOptions()); imageBeautifierForm.UploadImageRequested += output => diff --git a/ShareX/UploadInfoManager.cs b/ShareX/UploadInfoManager.cs index bdea91c3a..45f6c3f5c 100644 --- a/ShareX/UploadInfoManager.cs +++ b/ShareX/UploadInfoManager.cs @@ -342,6 +342,11 @@ public void EditImage() if (IsItemSelected && SelectedItem.IsImageFile) TaskHelpers.AnnotateImageFromFile(SelectedItem.Info.FilePath); } + public void BeautifyImage() + { + if (IsItemSelected && SelectedItem.IsImageFile) TaskHelpers.OpenImageBeautifier(SelectedItem.Info.FilePath); + } + public void AddImageEffects() { if (IsItemSelected && SelectedItem.IsImageFile) TaskHelpers.OpenImageEffects(SelectedItem.Info.FilePath);