mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added after capture task "Scan QR code", it requires image to be saved as file
This commit is contained in:
parent
a36b948fa1
commit
217018b388
6 changed files with 60 additions and 24 deletions
|
@ -252,6 +252,15 @@ internal static string AfterCaptureTasks_SaveThumbnailImageToFile {
|
|||
}
|
||||
}
|
||||
|
||||
/// <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>
|
||||
|
|
|
@ -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>
|
|
@ -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]
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue