From 840f6e0044092c1f19bf85f9cf19018274522dfc Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 13 May 2016 08:56:33 +0300 Subject: [PATCH] Added Text capture (OCR) to capture menu --- ...m.Designer.cs => OCRSpaceForm.Designer.cs} | 12 +- ...{OCRSpaceResultForm.cs => OCRSpaceForm.cs} | 29 +- ...SpaceResultForm.resx => OCRSpaceForm.resx} | 0 .../ShareX.UploadersLib.csproj | 10 +- ShareX/Forms/MainForm.Designer.cs | 20 + ShareX/Forms/MainForm.cs | 34 +- ShareX/Forms/MainForm.resx | 634 +++++++++--------- ShareX/Properties/Resources.Designer.cs | 10 + ShareX/Properties/Resources.resx | 171 ++--- ShareX/Resources/edit-drop-cap.png | Bin 0 -> 290 bytes ShareX/ShareX.csproj | 1 + ShareX/TaskHelpers.cs | 42 +- ShareX/WorkerTask.cs | 2 +- 13 files changed, 549 insertions(+), 416 deletions(-) rename ShareX.UploadersLib/Forms/{OCRSpaceResultForm.Designer.cs => OCRSpaceForm.Designer.cs} (95%) rename ShareX.UploadersLib/Forms/{OCRSpaceResultForm.cs => OCRSpaceForm.cs} (82%) rename ShareX.UploadersLib/Forms/{OCRSpaceResultForm.resx => OCRSpaceForm.resx} (100%) create mode 100644 ShareX/Resources/edit-drop-cap.png diff --git a/ShareX.UploadersLib/Forms/OCRSpaceResultForm.Designer.cs b/ShareX.UploadersLib/Forms/OCRSpaceForm.Designer.cs similarity index 95% rename from ShareX.UploadersLib/Forms/OCRSpaceResultForm.Designer.cs rename to ShareX.UploadersLib/Forms/OCRSpaceForm.Designer.cs index 755110f19..b3d4fcc7a 100644 --- a/ShareX.UploadersLib/Forms/OCRSpaceResultForm.Designer.cs +++ b/ShareX.UploadersLib/Forms/OCRSpaceForm.Designer.cs @@ -1,6 +1,6 @@ namespace ShareX.UploadersLib { - partial class OCRSpaceResultForm + partial class OCRSpaceForm { /// /// Required designer variable. @@ -79,12 +79,12 @@ private void InitializeComponent() // this.llAttribution.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.llAttribution.AutoSize = true; - this.llAttribution.Location = new System.Drawing.Point(488, 8); + this.llAttribution.Location = new System.Drawing.Point(440, 8); this.llAttribution.Name = "llAttribution"; - this.llAttribution.Size = new System.Drawing.Size(64, 13); + this.llAttribution.Size = new System.Drawing.Size(114, 13); this.llAttribution.TabIndex = 4; this.llAttribution.TabStop = true; - this.llAttribution.Text = "OCR.Space"; + this.llAttribution.Text = "Using OCR.Space API"; this.llAttribution.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.llAttribution_LinkClicked); // // btnStartOCR @@ -97,7 +97,7 @@ private void InitializeComponent() this.btnStartOCR.UseVisualStyleBackColor = true; this.btnStartOCR.Click += new System.EventHandler(this.btnStartOCR_Click); // - // OCRSpaceResultForm + // OCRSpaceForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; @@ -108,7 +108,7 @@ private void InitializeComponent() this.Controls.Add(this.txtResult); this.Controls.Add(this.lblLanguage); this.Controls.Add(this.cbLanguages); - this.Name = "OCRSpaceResultForm"; + this.Name = "OCRSpaceForm"; this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "ShareX - Optical character recognition"; diff --git a/ShareX.UploadersLib/Forms/OCRSpaceResultForm.cs b/ShareX.UploadersLib/Forms/OCRSpaceForm.cs similarity index 82% rename from ShareX.UploadersLib/Forms/OCRSpaceResultForm.cs rename to ShareX.UploadersLib/Forms/OCRSpaceForm.cs index 0cc72c094..bdaf0272d 100644 --- a/ShareX.UploadersLib/Forms/OCRSpaceResultForm.cs +++ b/ShareX.UploadersLib/Forms/OCRSpaceForm.cs @@ -37,24 +37,25 @@ You should have received a copy of the GNU General Public License namespace ShareX.UploadersLib { - public partial class OCRSpaceResultForm : Form + public partial class OCRSpaceForm : Form { - public Stream Data { get; private set; } - public string Filename { get; private set; } public OCRSpaceLanguages Language { get; set; } = OCRSpaceLanguages.eng; - public string Result { get; set; } + public string Result { get; private set; } - public OCRSpaceResultForm() + private Stream data; + private string filename; + + public OCRSpaceForm() { InitializeComponent(); Icon = ShareXResources.Icon; cbLanguages.Items.AddRange(Helpers.GetEnumDescriptions()); } - public OCRSpaceResultForm(Stream data, string filename) : this() + public OCRSpaceForm(Stream data, string filename) : this() { - Data = data; - Filename = filename; + this.data = data; + this.filename = filename; } private void OCRSpaceResultForm_Shown(object sender, EventArgs e) @@ -63,7 +64,7 @@ private void OCRSpaceResultForm_Shown(object sender, EventArgs e) if (string.IsNullOrEmpty(Result)) { - StartOCR(); + StartOCR(data, filename); } } @@ -76,12 +77,12 @@ private void UpdateControls() txtResult.Text = Result; } - btnStartOCR.Visible = Data != null && Data.Length > 0 && !string.IsNullOrEmpty(Filename); + btnStartOCR.Visible = data != null && data.Length > 0 && !string.IsNullOrEmpty(filename); } - private void StartOCR() + private void StartOCR(Stream stream, string filename) { - if (Data != null && Data.Length > 0 && !string.IsNullOrEmpty(Filename)) + if (stream != null && stream.Length > 0 && !string.IsNullOrEmpty(filename)) { cbLanguages.Enabled = btnStartOCR.Enabled = txtResult.Enabled = false; @@ -90,7 +91,7 @@ private void StartOCR() try { OCRSpace ocr = new OCRSpace(Language, false); - OCRSpaceResponse response = ocr.DoOCR(Data, Filename); + OCRSpaceResponse response = ocr.DoOCR(stream, filename); if (response != null && !response.IsErroredOnProcessing && response.ParsedResults.Count > 0) { @@ -120,7 +121,7 @@ private void cbLanguages_SelectedIndexChanged(object sender, EventArgs e) private void btnStartOCR_Click(object sender, EventArgs e) { - StartOCR(); + StartOCR(data, filename); } private void llAttribution_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) diff --git a/ShareX.UploadersLib/Forms/OCRSpaceResultForm.resx b/ShareX.UploadersLib/Forms/OCRSpaceForm.resx similarity index 100% rename from ShareX.UploadersLib/Forms/OCRSpaceResultForm.resx rename to ShareX.UploadersLib/Forms/OCRSpaceForm.resx diff --git a/ShareX.UploadersLib/ShareX.UploadersLib.csproj b/ShareX.UploadersLib/ShareX.UploadersLib.csproj index 6bc031c1d..b296906a7 100644 --- a/ShareX.UploadersLib/ShareX.UploadersLib.csproj +++ b/ShareX.UploadersLib/ShareX.UploadersLib.csproj @@ -151,11 +151,11 @@ - + Form - - OCRSpaceResultForm.cs + + OCRSpaceForm.cs Form @@ -586,8 +586,8 @@ OAuthWebForm.cs - - OCRSpaceResultForm.cs + + OCRSpaceForm.cs ResponseForm.cs diff --git a/ShareX/Forms/MainForm.Designer.cs b/ShareX/Forms/MainForm.Designer.cs index 17511bb16..d1ff0c313 100644 --- a/ShareX/Forms/MainForm.Designer.cs +++ b/ShareX/Forms/MainForm.Designer.cs @@ -58,6 +58,7 @@ private void InitializeComponent() this.tsmiScreenRecordingGIF = new System.Windows.Forms.ToolStripMenuItem(); this.tsmiScrollingCapture = new System.Windows.Forms.ToolStripMenuItem(); this.tsmiWebpageCapture = new System.Windows.Forms.ToolStripMenuItem(); + this.tsmiTextCapture = new System.Windows.Forms.ToolStripMenuItem(); this.tsmiAutoCapture = new System.Windows.Forms.ToolStripMenuItem(); this.tsddbUpload = new System.Windows.Forms.ToolStripDropDownButton(); this.tsmiUploadFile = new System.Windows.Forms.ToolStripMenuItem(); @@ -236,6 +237,7 @@ private void InitializeComponent() this.timerTraySingleClick = new System.Windows.Forms.Timer(this.components); this.pTips = new System.Windows.Forms.Panel(); this.lblTips = new System.Windows.Forms.Label(); + this.tsmiTrayTextCapture = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit(); this.scMain.Panel1.SuspendLayout(); this.scMain.Panel2.SuspendLayout(); @@ -401,6 +403,7 @@ private void InitializeComponent() this.tsmiScreenRecordingGIF, this.tsmiScrollingCapture, this.tsmiWebpageCapture, + this.tsmiTextCapture, this.tsmiAutoCapture}); this.tsddbCapture.Image = global::ShareX.Properties.Resources.camera; resources.ApplyResources(this.tsddbCapture, "tsddbCapture"); @@ -496,6 +499,13 @@ private void InitializeComponent() resources.ApplyResources(this.tsmiWebpageCapture, "tsmiWebpageCapture"); this.tsmiWebpageCapture.Click += new System.EventHandler(this.tsmiWebpageCapture_Click); // + // tsmiTextCapture + // + this.tsmiTextCapture.Image = global::ShareX.Properties.Resources.edit_drop_cap; + this.tsmiTextCapture.Name = "tsmiTextCapture"; + resources.ApplyResources(this.tsmiTextCapture, "tsmiTextCapture"); + this.tsmiTextCapture.Click += new System.EventHandler(this.tsmiTextCapture_Click); + // // tsmiAutoCapture // this.tsmiAutoCapture.Image = global::ShareX.Properties.Resources.clock; @@ -1302,6 +1312,7 @@ private void InitializeComponent() this.tsmiTrayScreenRecordingGIF, this.tsmiTrayScrollingCapture, this.tsmiTrayWebpageCapture, + this.tsmiTrayTextCapture, this.tsmiTrayAutoCapture}); this.tsmiTrayCapture.Image = global::ShareX.Properties.Resources.camera; this.tsmiTrayCapture.Name = "tsmiTrayCapture"; @@ -1828,6 +1839,13 @@ private void InitializeComponent() this.lblTips.UseMnemonic = false; this.lblTips.Click += new System.EventHandler(this.lblTips_Click); // + // tsmiTrayTextCapture + // + this.tsmiTrayTextCapture.Image = global::ShareX.Properties.Resources.edit_drop_cap; + this.tsmiTrayTextCapture.Name = "tsmiTrayTextCapture"; + resources.ApplyResources(this.tsmiTrayTextCapture, "tsmiTrayTextCapture"); + this.tsmiTrayTextCapture.Click += new System.EventHandler(this.tsmiTrayTextCapture_Click); + // // MainForm // this.AllowDrop = true; @@ -2071,5 +2089,7 @@ private void InitializeComponent() private System.Windows.Forms.PictureBox pbTips; private System.Windows.Forms.Panel pTips; private System.Windows.Forms.Label lblTips; + private System.Windows.Forms.ToolStripMenuItem tsmiTextCapture; + private System.Windows.Forms.ToolStripMenuItem tsmiTrayTextCapture; } } \ No newline at end of file diff --git a/ShareX/Forms/MainForm.cs b/ShareX/Forms/MainForm.cs index 206ee604a..d3463aa8c 100644 --- a/ShareX/Forms/MainForm.cs +++ b/ShareX/Forms/MainForm.cs @@ -1140,16 +1140,35 @@ private void tsmiScrollingCapture_Click(object sender, EventArgs e) TaskHelpers.OpenScrollingCapture(); } - private void tsmiAutoCapture_Click(object sender, EventArgs e) - { - TaskHelpers.OpenAutoCapture(); - } - private void tsmiWebpageCapture_Click(object sender, EventArgs e) { TaskHelpers.OpenWebpageCapture(); } + private void tsmiTextCapture_Click(object sender, EventArgs e) + { + Hide(); + Thread.Sleep(250); + + try + { + TaskHelpers.OpenOCR(); + } + catch (Exception ex) + { + DebugHelper.WriteException(ex); + } + finally + { + this.ForceActivate(); + } + } + + private void tsmiAutoCapture_Click(object sender, EventArgs e) + { + TaskHelpers.OpenAutoCapture(); + } + private void tsbApplicationSettings_Click(object sender, EventArgs e) { using (ApplicationSettingsForm settingsForm = new ApplicationSettingsForm()) @@ -2437,6 +2456,11 @@ private void tsmiTrayLastRegion_Click(object sender, EventArgs e) CaptureScreenshot(CaptureType.LastRegion, null, false); } + private void tsmiTrayTextCapture_Click(object sender, EventArgs e) + { + TaskHelpers.OpenOCR(); + } + #endregion Tray events #endregion Hotkey/Capture codes and form events diff --git a/ShareX/Forms/MainForm.resx b/ShareX/Forms/MainForm.resx index 03d22fd4d..ad550d07b 100644 --- a/ShareX/Forms/MainForm.resx +++ b/ShareX/Forms/MainForm.resx @@ -210,45 +210,6 @@ 2 - - Filename - - - 150 - - - Status - - - Progress - - - 125 - - - Speed - - - 75 - - - Elapsed - - - 45 - - - Remaining - - - 45 - - - URL - - - 145 - Fill @@ -345,6 +306,45 @@ 2 + + Filename + + + 150 + + + Status + + + Progress + + + 125 + + + Speed + + + 75 + + + Elapsed + + + 45 + + + Remaining + + + 45 + + + URL + + + 145 + 17, 17 @@ -354,6 +354,42 @@ Left + + 0, 0 + + + 6, 6, 6, 6 + + + 160, 407 + + + 1 + + + tsMain + + + System.Windows.Forms.ToolStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + MiddleLeft + + + Magenta + + + 147, 20 + + + Capture + 191, 22 @@ -432,23 +468,29 @@ Webpage capture... + + 191, 22 + + + Text capture (OCR)... + 191, 22 Auto capture... - + MiddleLeft - + Magenta - + 147, 20 - - Capture + + Upload 203, 22 @@ -480,18 +522,6 @@ Drag and drop upload... - - MiddleLeft - - - Magenta - - - 147, 20 - - - Upload - BottomLeft @@ -504,6 +534,18 @@ Workflows + + MiddleLeft + + + Magenta + + + 147, 20 + + + Tools + 183, 22 @@ -594,18 +636,6 @@ Monitor test... - - MiddleLeft - - - Magenta - - - 147, 20 - - - Tools - 147, 6 @@ -633,6 +663,18 @@ After upload tasks + + MiddleLeft + + + Magenta + + + 147, 20 + + + Destinations + 187, 22 @@ -672,18 +714,6 @@ Destination settings... - - MiddleLeft - - - Magenta - - - 147, 20 - - - Destinations - MiddleLeft @@ -759,6 +789,18 @@ Image history... + + MiddleLeft + + + Magenta + + + 147, 20 + + + Debug + 172, 22 @@ -795,18 +837,6 @@ Test URL sharing - - MiddleLeft - - - Magenta - - - 147, 20 - - - Debug - MiddleLeft @@ -831,33 +861,18 @@ About... - - 0, 0 - - - 6, 6, 6, 6 - - - 160, 407 - - - 1 - - - tsMain - - - System.Windows.Forms.ToolStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - $this - - - 3 - 286, 17 + + 173, 340 + + + cmsTaskInfo + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 172, 22 @@ -870,6 +885,12 @@ Stop upload + + 172, 22 + + + Open + 156, 22 @@ -915,11 +936,11 @@ Thumbnail file - + 172, 22 - - Open + + Copy 233, 22 @@ -1053,12 +1074,6 @@ False - - 172, 22 - - - Copy - 172, 22 @@ -1122,6 +1137,12 @@ Hide columns + + 172, 22 + + + Image preview + 130, 22 @@ -1140,21 +1161,6 @@ Automatic - - 172, 22 - - - Image preview - - - 173, 340 - - - cmsTaskInfo - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 105, 17 @@ -1239,6 +1245,12 @@ Webpage capture... + + 191, 22 + + + Text capture (OCR)... + 191, 22 @@ -1251,6 +1263,144 @@ Capture + + 188, 22 + + + Upload + + + 188, 22 + + + Workflows + + + 188, 22 + + + Tools + + + 185, 6 + + + 188, 22 + + + After capture + + + 188, 22 + + + After upload + + + 188, 22 + + + Destinations + + + 188, 22 + + + Application settings... + + + 188, 22 + + + Task settings... + + + 188, 22 + + + Hotkey settings... + + + 188, 22 + + + Disable hotkeys + + + 185, 6 + + + 188, 22 + + + Screenshots folder... + + + 188, 22 + + + History... + + + 188, 22 + + + Image history... + + + 188, 22 + + + Debug + + + 188, 22 + + + Donate... + + + 188, 22 + + + About... + + + 185, 6 + + + 188, 22 + + + Recent links + + + False + + + 188, 22 + + + Open main window + + + 188, 22 + + + Exit + + + 189, 484 + + + cmsTray + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + ShareX + 203, 22 @@ -1281,18 +1431,6 @@ Drag and drop upload... - - 188, 22 - - - Upload - - - 188, 22 - - - Workflows - 183, 22 @@ -1383,27 +1521,6 @@ Monitor test... - - 188, 22 - - - Tools - - - 185, 6 - - - 188, 22 - - - After capture - - - 188, 22 - - - After upload - 187, 22 @@ -1443,57 +1560,6 @@ Destination settings... - - 188, 22 - - - Destinations - - - 188, 22 - - - Application settings... - - - 188, 22 - - - Task settings... - - - 188, 22 - - - Hotkey settings... - - - 188, 22 - - - Disable hotkeys - - - 185, 6 - - - 188, 22 - - - Screenshots folder... - - - 188, 22 - - - History... - - - 188, 22 - - - Image history... - 172, 22 @@ -1530,60 +1596,6 @@ Test URL sharing - - 188, 22 - - - Debug - - - 188, 22 - - - Donate... - - - 188, 22 - - - About... - - - 185, 6 - - - 188, 22 - - - Recent links - - - False - - - 188, 22 - - - Open main window - - - 188, 22 - - - Exit - - - 189, 484 - - - cmsTray - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - ShareX - 405, 17 @@ -1593,27 +1605,6 @@ True - - True - - - Microsoft Sans Serif, 9.75pt - - - NoControl - - - 0, 0 - - - 10, 10, 10, 10 - - - 20, 36 - - - 0 - lblTips @@ -1650,6 +1641,39 @@ 4 + + True + + + Microsoft Sans Serif, 9.75pt + + + NoControl + + + 0, 0 + + + 10, 10, 10, 10 + + + 20, 36 + + + 0 + + + lblTips + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + pTips + + + 0 + True @@ -1794,6 +1818,12 @@ System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tsmiTextCapture + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + tsmiAutoCapture @@ -2838,6 +2868,12 @@ System.Windows.Forms.Timer, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + tsmiTrayTextCapture + + + System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + MainForm diff --git a/ShareX/Properties/Resources.Designer.cs b/ShareX/Properties/Resources.Designer.cs index 397619dc5..cc195e113 100644 --- a/ShareX/Properties/Resources.Designer.cs +++ b/ShareX/Properties/Resources.Designer.cs @@ -682,6 +682,16 @@ public static string DropForm_DrawDropImage_Drop_here { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + public static System.Drawing.Bitmap edit_drop_cap { + get { + object obj = ResourceManager.GetObject("edit-drop-cap", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/ShareX/Properties/Resources.resx b/ShareX/Properties/Resources.resx index f904b9083..f2264a385 100644 --- a/ShareX/Properties/Resources.resx +++ b/ShareX/Properties/Resources.resx @@ -138,6 +138,9 @@ Are you sure you want to continue? Shorten URL ({0}) + + ..\Resources\layer-transparent.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + There is no valid CLI video encoder selected. @@ -154,32 +157,35 @@ Press 'No' to cancel the current upload and disable screenshot auto uploading. ..\Resources\bin.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\toolbox.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Resources\au.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a FFmpeg error - - ..\Resources\checkbox_check.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - FFmpeg successfully downloaded. + + ..\Resources\CaptureSound.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + ..\Resources\document-globe.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\control-record-yellow.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\TaskCompletedSound.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + External libraries Unable to find a valid FTP account. - - ..\Resources\CaptureSound.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Resources\Rectangle.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\tick-button.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -220,12 +226,15 @@ Press 'No' to cancel the current upload and disable screenshot auto uploading. ..\Resources\globe--pencil.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Configure CLI video encoders ---> + + For settings to take effect ShareX needs to be reopened from Steam. Disable hotkeys + + URL shortener: {0} + URL is empty. @@ -248,6 +257,9 @@ Please select a different hotkey or quit the conflicting application and reopen Stop + + Left click to copy URL to clipboard. Right click to open URL. + ..\Resources\robot.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -290,6 +302,9 @@ Please select a different hotkey or quit the conflicting application and reopen ..\Resources\cross.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\application-task.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Task settings @@ -307,23 +322,23 @@ Would you like to automatically download it? You can single left click the ShareX tray icon to start region capture. - - Translators - ..\Resources\image-export.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\pipette.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - External libraries + + ..\Resources\inbox.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\fr.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Cancel + + ..\Resources\control.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\checkbox_uncheck.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Waiting... @@ -343,9 +358,15 @@ Press yes to open image from clipboard. Alternatively, press no to open image fi Hide menu + + Task settings for {0} + Unable to find a valid Twitter account. + + Cursor position (X, Y) = {0}, {1} + ..\Resources\document-break.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -370,6 +391,9 @@ Press yes to open image from clipboard. Alternatively, press no to open image fi Enable hotkeys + + Cancel + Hotkey registration failed @@ -382,6 +406,9 @@ Press yes to open image from clipboard. Alternatively, press no to open image fi Hotkeys disabled. + + ..\Resources\TaskCompletedSound.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + Upload files @@ -394,6 +421,9 @@ Press yes to open image from clipboard. Alternatively, press no to open image fi ..\Resources\kr.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\pencil.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + Error @@ -404,21 +434,18 @@ Press yes to open image from clipboard. Alternatively, press no to open image fi Drop here - - ..\Resources\checkbox_uncheck.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Hotkeys enabled. ..\Resources\crown.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Translators + hotkeys - - ..\Resources\image-saturation.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\drive.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -446,9 +473,6 @@ here Choose encoder path - - For settings to take effect ShareX needs to be reopened from Steam. - Can't access to "{0}" file. Please run ShareX as administrator to change personal folder path. @@ -459,9 +483,6 @@ Please run ShareX as administrator to change personal folder path. ..\Resources\ru.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - History - Error @@ -478,8 +499,8 @@ Please run ShareX as administrator to change personal folder path. FTP client only supports FTP or FTPS. - - ..\Resources\arrow-090.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\layers.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\es.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -494,24 +515,15 @@ Would you like to restart ShareX? ..\Resources\layer-shape.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\eraser.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\image--pencil.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Copied to clipboard: {0} + + ..\Resources\image-saturation.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\cn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\inbox.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\categories.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Use new name: @@ -527,8 +539,8 @@ Would you like to restart ShareX? ..\Resources\us.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\Rectangle.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Start Missing @@ -536,8 +548,8 @@ Would you like to restart ShareX? ..\Resources\nl.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Cursor position (X, Y) = {0}, {1} + + Configure CLI video encoders ---> ..\Resources\folder-open-document.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -557,12 +569,12 @@ Would you like to restart ShareX? ..\Resources\ruler-triangle.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + {0} is about to be uploaded to {1}. You may choose a different destination. + Chrome support enabled. - - ..\Resources\camcorder-image.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Extension can't be empty. @@ -572,8 +584,8 @@ Would you like to restart ShareX? After capture: {0} - - URL shortener: {0} + + History Upload errors @@ -590,20 +602,20 @@ Would you like to restart ShareX? Unable to create folder: + + Choose screenshots folder path + Currently configured hotkeys: ..\Resources\film.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Close + + ..\Resources\arrow-090.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Left click to copy URL to clipboard. Right click to open URL. - - - Download of FFmpeg failed. + + ..\Resources\layer_fullscreen.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\clipboard-list.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -660,8 +672,8 @@ Would you like to restart ShareX? ..\Resources\layer-shape-polygon.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\toolbox.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\checkbox_check.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Edit this menu... @@ -684,18 +696,15 @@ Would you like to restart ShareX? Issues - - Start + + Copied to clipboard: {0} - - ..\Resources\layer-transparent.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + Close ..\Resources\wrench-screwdriver.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Resources\application-browser.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - ..\Resources\ErrorSound.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 @@ -705,8 +714,8 @@ Would you like to restart ShareX? Text upload test - - ..\Resources\application-task.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\application-browser.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Hide columns @@ -717,8 +726,8 @@ Would you like to restart ShareX? ..\Resources\Twitter.ico;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - Task settings for {0} + + ..\Resources\camcorder-image.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\color.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -756,14 +765,14 @@ Would you like to restart ShareX? Website - - ..\Resources\pencil.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\categories.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a After upload: {0} - - Choose screenshots folder path + + ..\Resources\eraser.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a ..\Resources\camera.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -778,19 +787,13 @@ Would you like to restart ShareX? Click to start recording. Text must be equal to or lower than 54 characters because of tray icon text length limit. - - {0} is about to be uploaded to {1}. You may choose a different destination. + + Download of FFmpeg failed. Start screen color picker - - ..\Resources\control.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\layers.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - - ..\Resources\layer_fullscreen.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Resources\edit-drop-cap.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/ShareX/Resources/edit-drop-cap.png b/ShareX/Resources/edit-drop-cap.png new file mode 100644 index 0000000000000000000000000000000000000000..fc0619760deba5dbf6a4602c64f378cf49c9d743 GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5Xj(EB_hE&{2`t$$4J+o>!>e&8hvt$OtD((f_elr(Z37ltpR2vYU zbNCUHK$%N^YmQJH{f$8DRLJ{l@~ lb1ppCkgC?j%fMm4(Dv7b@8I?2>OlW6c)I$ztaD0e0sy@AYIOhr literal 0 HcmV?d00001 diff --git a/ShareX/ShareX.csproj b/ShareX/ShareX.csproj index 32dca194f..0e21569f3 100644 --- a/ShareX/ShareX.csproj +++ b/ShareX/ShareX.csproj @@ -1245,6 +1245,7 @@ + diff --git a/ShareX/TaskHelpers.cs b/ShareX/TaskHelpers.cs index 00c1262ba..5990520d8 100644 --- a/ShareX/TaskHelpers.cs +++ b/ShareX/TaskHelpers.cs @@ -116,6 +116,11 @@ public static string CreateThumbnail(Image img, string folder, string filename, } public static MemoryStream SaveImage(Image img, EImageFormat imageFormat, TaskSettings taskSettings) + { + return SaveImage(img, imageFormat, taskSettings.ImageSettings.ImageJPEGQuality, taskSettings.ImageSettings.ImageGIFQuality); + } + + public static MemoryStream SaveImage(Image img, EImageFormat imageFormat, int jpegQuality = 90, GIFQuality gifQuality = GIFQuality.Default) { MemoryStream stream = new MemoryStream(); @@ -125,10 +130,10 @@ public static MemoryStream SaveImage(Image img, EImageFormat imageFormat, TaskSe img.Save(stream, ImageFormat.Png); break; case EImageFormat.JPEG: - img.SaveJPG(stream, taskSettings.ImageSettings.ImageJPEGQuality); + img.SaveJPG(stream, jpegQuality); break; case EImageFormat.GIF: - img.SaveGIF(stream, taskSettings.ImageSettings.ImageGIFQuality); + img.SaveGIF(stream, gifQuality); break; case EImageFormat.BMP: img.Save(stream, ImageFormat.Bmp); @@ -336,6 +341,19 @@ public static PointInfo SelectPointColor() return null; } + public static Image GetRegionImage() + { + using (RectangleRegionForm form = new RectangleRegionForm()) + using (Image screenshot = Screenshot.CaptureFullscreen()) + { + form.SurfaceImage = screenshot; + form.Prepare(); + form.ShowDialog(); + + return form.GetResultImage(); + } + } + public static Icon GetProgressIcon(int percentage) { using (Bitmap bmp = new Bitmap(16, 16)) @@ -708,6 +726,26 @@ public static void OpenQRCode() new QRCodeForm().Show(); } + public static void OpenOCR() + { + using (Image img = GetRegionImage()) + { + if (img != null) + { + using (Stream stream = SaveImage(img, EImageFormat.JPEG, 90)) + { + if (stream != null) + { + using (OCRSpaceForm form = new OCRSpaceForm(stream, "ShareX.jpg")) + { + form.ShowDialog(); + } + } + } + } + } + } + public static void OpenFTPClient() { if (Program.UploadersConfig != null && Program.UploadersConfig.FTPAccountList != null) diff --git a/ShareX/WorkerTask.cs b/ShareX/WorkerTask.cs index 6c71b5d85..c6eb5c86a 100644 --- a/ShareX/WorkerTask.cs +++ b/ShareX/WorkerTask.cs @@ -968,7 +968,7 @@ private void DoOCR() { if (Data != null && Info.DataType == EDataType.Image) { - using (OCRSpaceResultForm ocrForm = new OCRSpaceResultForm(Data, Info.FileName)) + using (OCRSpaceForm ocrForm = new OCRSpaceForm(Data, Info.FileName)) { ocrForm.ShowDialog(); }