diff --git a/ShareX/Forms/OCRForm.Designer.cs b/ShareX/Forms/OCRForm.Designer.cs
index f1769fd8b..ef4d8f1c7 100644
--- a/ShareX/Forms/OCRForm.Designer.cs
+++ b/ShareX/Forms/OCRForm.Designer.cs
@@ -51,6 +51,7 @@ private void InitializeComponent()
this.cbLanguages.Name = "cbLanguages";
this.cbLanguages.Size = new System.Drawing.Size(216, 21);
this.cbLanguages.TabIndex = 1;
+ this.cbLanguages.SelectedIndexChanged += new System.EventHandler(this.cbLanguages_SelectedIndexChanged);
//
// lblResult
//
diff --git a/ShareX/Forms/OCRForm.cs b/ShareX/Forms/OCRForm.cs
index b1938adf4..e13d045c8 100644
--- a/ShareX/Forms/OCRForm.cs
+++ b/ShareX/Forms/OCRForm.cs
@@ -25,15 +25,14 @@ You should have received a copy of the GNU General Public License
using ShareX.HelpersLib;
using System.IO;
-using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
-using Windows.Media.Ocr;
namespace ShareX
{
public partial class OCRForm : Form
{
+ public OCRLanguage Language { get; set; }
public string Result { get; private set; }
private Stream stream;
@@ -45,19 +44,14 @@ public OCRForm(Stream stream)
InitializeComponent();
ShareXResources.ApplyTheme(this);
- cbLanguages.Items.AddRange(OcrEngine.AvailableRecognizerLanguages.Select(x => x.DisplayName).ToArray());
+ cbLanguages.Items.AddRange(OCRHelper.AvailableLanguages);
cbLanguages.SelectedIndex = 0;
txtResult.SupportSelectAll();
}
- private async void OCRForm_Shown(object sender, System.EventArgs e)
+ private async Task OCR(string languageTag)
{
- await OCR();
- }
-
- private async Task OCR()
- {
- Result = await OCRHelper.OCR(stream);
+ Result = await OCRHelper.OCR(stream, languageTag);
if (!IsDisposed)
{
@@ -65,5 +59,15 @@ private async Task OCR()
txtResult.Text = Result;
}
}
+
+ private async void OCRForm_Shown(object sender, System.EventArgs e)
+ {
+ await OCR(Language.LanguageTag);
+ }
+
+ private void cbLanguages_SelectedIndexChanged(object sender, System.EventArgs e)
+ {
+ Language = cbLanguages.SelectedItem as OCRLanguage;
+ }
}
}
\ No newline at end of file
diff --git a/ShareX/OCRHelper.cs b/ShareX/OCRHelper.cs
index a22f0feb2..e6f105213 100644
--- a/ShareX/OCRHelper.cs
+++ b/ShareX/OCRHelper.cs
@@ -44,6 +44,14 @@ public static bool IsSupported
}
}
+ public static OCRLanguage[] AvailableLanguages
+ {
+ get
+ {
+ return OcrEngine.AvailableRecognizerLanguages.Select(x => new OCRLanguage(x.DisplayName, x.LanguageTag)).ToArray();
+ }
+ }
+
public static void ThrowIfNotSupported()
{
if (!IsSupported)
diff --git a/ShareX/OCRLanguage.cs b/ShareX/OCRLanguage.cs
new file mode 100644
index 000000000..d5cba9c98
--- /dev/null
+++ b/ShareX/OCRLanguage.cs
@@ -0,0 +1,44 @@
+#region License Information (GPL v3)
+
+/*
+ ShareX - A program that allows you to take screenshots and share any file type
+ Copyright (c) 2007-2022 ShareX Team
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 2
+ of the License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ Optionally you can also view the license at .
+*/
+
+#endregion License Information (GPL v3)
+
+namespace ShareX
+{
+ public class OCRLanguage
+ {
+ public string DisplayName { get; set; }
+ public string LanguageTag { get; set; }
+
+ public OCRLanguage(string displayName, string languageTag)
+ {
+ DisplayName = displayName;
+ LanguageTag = languageTag;
+ }
+
+ public override string ToString()
+ {
+ return DisplayName;
+ }
+ }
+}
\ No newline at end of file
diff --git a/ShareX/ShareX.csproj b/ShareX/ShareX.csproj
index 79da97ae1..2be18ea1d 100644
--- a/ShareX/ShareX.csproj
+++ b/ShareX/ShareX.csproj
@@ -208,6 +208,7 @@
+
Form