Added after capture task "Scan QR code", it requires image to be saved as file

This commit is contained in:
Jaex 2018-04-03 21:21:41 +03:00
parent a36b948fa1
commit 217018b388
6 changed files with 60 additions and 24 deletions

View file

@ -252,6 +252,15 @@ internal class Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Scan QR code.
/// </summary>
internal static string AfterCaptureTasks_ScanQRCode {
get {
return ResourceManager.GetString("AfterCaptureTasks_ScanQRCode", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Print image.
/// </summary>

View file

@ -1160,4 +1160,7 @@ Would you like to download it?</value>
<data name="WavFileNameEditor_EditValue_Browse_for_a_sound_file___" xml:space="preserve">
<value>Browse for a sound file...</value>
</data>
<data name="AfterCaptureTasks_ScanQRCode" xml:space="preserve">
<value>Scan QR code</value>
</data>
</root>

View file

@ -110,10 +110,11 @@ public enum AfterCaptureTasks // Localized
CopyFileToClipboard = 1 << 10,
CopyFilePathToClipboard = 1 << 11,
ShowInExplorer = 1 << 12,
DoOCR = 1 << 13,
ShowBeforeUploadWindow = 1 << 14,
UploadImageToHost = 1 << 15,
DeleteFile = 1 << 16
ScanQRCode = 1 << 13,
DoOCR = 1 << 14,
ShowBeforeUploadWindow = 1 << 15,
UploadImageToHost = 1 << 16,
DeleteFile = 1 << 17
}
[Flags]

View file

@ -52,18 +52,29 @@ public QRCodeForm(string text = null)
{
txtQRCode.Text = text;
}
else
{
if (Clipboard.ContainsText())
{
text = Clipboard.GetText();
}
if (TaskHelpers.CheckQRCodeContent(text))
{
txtQRCode.Text = text;
}
public static QRCodeForm EncodeClipboard()
{
if (Clipboard.ContainsText())
{
string text = Clipboard.GetText();
if (TaskHelpers.CheckQRCodeContent(text))
{
return new QRCodeForm(text);
}
}
return new QRCodeForm();
}
public static QRCodeForm DecodeFile(string filePath)
{
QRCodeForm form = new QRCodeForm();
form.tcMain.SelectedTab = form.tpDecode;
form.DecodeFromFile(filePath);
return form;
}
private void QRCodeForm_Shown(object sender, EventArgs e)
@ -110,6 +121,20 @@ private void DecodeImage(Bitmap bmp)
txtDecodeResult.Text = output;
}
private void DecodeFromFile(string filePath)
{
if (!string.IsNullOrEmpty(filePath))
{
using (Image img = ImageHelpers.LoadImage(filePath))
{
if (img != null)
{
DecodeImage((Bitmap)img);
}
}
}
}
private void QRCodeForm_Resize(object sender, EventArgs e)
{
EncodeText(txtQRCode.Text);
@ -212,16 +237,7 @@ private void btnDecodeFromFile_Click(object sender, EventArgs e)
{
string filePath = ImageHelpers.OpenImageFileDialog();
if (!string.IsNullOrEmpty(filePath))
{
using (Image img = ImageHelpers.LoadImage(filePath))
{
if (img != null)
{
DecodeImage((Bitmap)img);
}
}
}
DecodeFromFile(filePath);
}
}
}

View file

@ -1010,7 +1010,7 @@ public static void RunShareXAsAdmin(string arguments)
public static void OpenQRCode()
{
new QRCodeForm().Show();
QRCodeForm.EncodeClipboard().Show();
}
public static void OpenRuler(TaskSettings taskSettings = null)
@ -1336,6 +1336,8 @@ public static Image FindMenuIcon<T>(int index)
return Resources.clipboard_list;
case AfterCaptureTasks.ShowInExplorer:
return Resources.folder_stand;
case AfterCaptureTasks.ScanQRCode:
return Resources.barcode_2d;
case AfterCaptureTasks.DoOCR:
return Resources.edit_drop_cap;
case AfterCaptureTasks.ShowBeforeUploadWindow:

View file

@ -718,6 +718,11 @@ private void DoFileJobs()
{
Helpers.OpenFolderWithFile(Info.FilePath);
}
if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.ScanQRCode) && Info.DataType == EDataType.Image)
{
QRCodeForm.DecodeFile(Info.FilePath).ShowDialog();
}
}
}