From 991418fcbeb513426aa59b6a8be2ed6704deb530 Mon Sep 17 00:00:00 2001 From: Jaex Date: Wed, 14 Jun 2023 09:35:37 +0300 Subject: [PATCH] QR code window new layout --- ShareX/Forms/QRCodeForm.Designer.cs | 245 +++++------- ShareX/Forms/QRCodeForm.cs | 165 ++++---- ShareX/Forms/QRCodeForm.resx | 573 +++++++++++++--------------- ShareX/TaskHelpers.cs | 6 +- ShareX/WorkerTask.cs | 2 +- 5 files changed, 427 insertions(+), 564 deletions(-) diff --git a/ShareX/Forms/QRCodeForm.Designer.cs b/ShareX/Forms/QRCodeForm.Designer.cs index 21b77a8bc..c51494cdd 100644 --- a/ShareX/Forms/QRCodeForm.Designer.cs +++ b/ShareX/Forms/QRCodeForm.Designer.cs @@ -28,110 +28,47 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(QRCodeForm)); - this.cmsQR = new System.Windows.Forms.ContextMenuStrip(this.components); - this.tsmiCopy = new System.Windows.Forms.ToolStripMenuItem(); - this.tsmiSaveAs = new System.Windows.Forms.ToolStripMenuItem(); - this.tsmiUpload = new System.Windows.Forms.ToolStripMenuItem(); - this.tss1 = new System.Windows.Forms.ToolStripSeparator(); - this.tsmiDecode = new System.Windows.Forms.ToolStripMenuItem(); - this.txtQRCode = new System.Windows.Forms.TextBox(); - this.tcMain = new System.Windows.Forms.TabControl(); - this.tpEncode = new System.Windows.Forms.TabPage(); - this.nudQRCodeSize = new System.Windows.Forms.NumericUpDown(); - this.tpDecode = new System.Windows.Forms.TabPage(); - this.pDecodeResult = new System.Windows.Forms.Panel(); - this.rtbDecodeResult = new System.Windows.Forms.RichTextBox(); - this.btnDecodeFromFile = new System.Windows.Forms.Button(); - this.lblDecodeResult = new System.Windows.Forms.Label(); - this.btnDecodeFromScreen = new System.Windows.Forms.Button(); - this.pbQRCode = new ShareX.HelpersLib.MyPictureBox(); - this.lblQRCodeSize = new System.Windows.Forms.Label(); + this.txtText = new System.Windows.Forms.TextBox(); this.lblQRCodeSizeHint = new System.Windows.Forms.Label(); - this.cmsQR.SuspendLayout(); - this.tcMain.SuspendLayout(); - this.tpEncode.SuspendLayout(); + this.lblQRCodeSize = new System.Windows.Forms.Label(); + this.nudQRCodeSize = new System.Windows.Forms.NumericUpDown(); + this.pbQRCode = new ShareX.HelpersLib.MyPictureBox(); + this.lblQRCode = new System.Windows.Forms.Label(); + this.lblText = new System.Windows.Forms.Label(); + this.btnCopyImage = new System.Windows.Forms.Button(); + this.btnSaveImage = new System.Windows.Forms.Button(); + this.btnUploadImage = new System.Windows.Forms.Button(); + this.btnScanQRCodeFromScreen = new System.Windows.Forms.Button(); + this.btnScanQRCodeFromImageFile = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.nudQRCodeSize)).BeginInit(); - this.tpDecode.SuspendLayout(); - this.pDecodeResult.SuspendLayout(); this.SuspendLayout(); // - // cmsQR + // txtText // - this.cmsQR.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.tsmiCopy, - this.tsmiSaveAs, - this.tsmiUpload, - this.tss1, - this.tsmiDecode}); - this.cmsQR.Name = "cmsQR"; - this.cmsQR.ShowImageMargin = false; - resources.ApplyResources(this.cmsQR, "cmsQR"); + resources.ApplyResources(this.txtText, "txtText"); + this.txtText.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.txtText.Name = "txtText"; + this.txtText.TextChanged += new System.EventHandler(this.txtText_TextChanged); // - // tsmiCopy + // lblQRCodeSizeHint // - this.tsmiCopy.Name = "tsmiCopy"; - resources.ApplyResources(this.tsmiCopy, "tsmiCopy"); - this.tsmiCopy.Click += new System.EventHandler(this.tsmiCopy_Click); + resources.ApplyResources(this.lblQRCodeSizeHint, "lblQRCodeSizeHint"); + this.lblQRCodeSizeHint.Name = "lblQRCodeSizeHint"; // - // tsmiSaveAs + // lblQRCodeSize // - this.tsmiSaveAs.Name = "tsmiSaveAs"; - resources.ApplyResources(this.tsmiSaveAs, "tsmiSaveAs"); - this.tsmiSaveAs.Click += new System.EventHandler(this.tsmiSaveAs_Click); - // - // tsmiUpload - // - this.tsmiUpload.Name = "tsmiUpload"; - resources.ApplyResources(this.tsmiUpload, "tsmiUpload"); - this.tsmiUpload.Click += new System.EventHandler(this.tsmiUpload_Click); - // - // tss1 - // - this.tss1.Name = "tss1"; - resources.ApplyResources(this.tss1, "tss1"); - // - // tsmiDecode - // - this.tsmiDecode.Name = "tsmiDecode"; - resources.ApplyResources(this.tsmiDecode, "tsmiDecode"); - this.tsmiDecode.Click += new System.EventHandler(this.tsmiDecode_Click); - // - // txtQRCode - // - resources.ApplyResources(this.txtQRCode, "txtQRCode"); - this.txtQRCode.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.txtQRCode.Name = "txtQRCode"; - this.txtQRCode.TextChanged += new System.EventHandler(this.txtQRCode_TextChanged); - // - // tcMain - // - this.tcMain.Controls.Add(this.tpEncode); - this.tcMain.Controls.Add(this.tpDecode); - resources.ApplyResources(this.tcMain, "tcMain"); - this.tcMain.Name = "tcMain"; - this.tcMain.SelectedIndex = 0; - // - // tpEncode - // - this.tpEncode.BackColor = System.Drawing.SystemColors.Window; - this.tpEncode.Controls.Add(this.lblQRCodeSizeHint); - this.tpEncode.Controls.Add(this.lblQRCodeSize); - this.tpEncode.Controls.Add(this.nudQRCodeSize); - this.tpEncode.Controls.Add(this.pbQRCode); - this.tpEncode.Controls.Add(this.txtQRCode); - resources.ApplyResources(this.tpEncode, "tpEncode"); - this.tpEncode.Name = "tpEncode"; + resources.ApplyResources(this.lblQRCodeSize, "lblQRCodeSize"); + this.lblQRCodeSize.Name = "lblQRCodeSize"; // // nudQRCodeSize // + resources.ApplyResources(this.nudQRCodeSize, "nudQRCodeSize"); this.nudQRCodeSize.Increment = new decimal(new int[] { 64, 0, 0, 0}); - resources.ApplyResources(this.nudQRCodeSize, "nudQRCodeSize"); this.nudQRCodeSize.Maximum = new decimal(new int[] { 2048, 0, @@ -140,108 +77,98 @@ private void InitializeComponent() this.nudQRCodeSize.Name = "nudQRCodeSize"; this.nudQRCodeSize.ValueChanged += new System.EventHandler(this.nudQRCodeSize_ValueChanged); // - // tpDecode - // - this.tpDecode.BackColor = System.Drawing.SystemColors.Window; - this.tpDecode.Controls.Add(this.pDecodeResult); - this.tpDecode.Controls.Add(this.btnDecodeFromFile); - this.tpDecode.Controls.Add(this.lblDecodeResult); - this.tpDecode.Controls.Add(this.btnDecodeFromScreen); - resources.ApplyResources(this.tpDecode, "tpDecode"); - this.tpDecode.Name = "tpDecode"; - // - // pDecodeResult - // - resources.ApplyResources(this.pDecodeResult, "pDecodeResult"); - this.pDecodeResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; - this.pDecodeResult.Controls.Add(this.rtbDecodeResult); - this.pDecodeResult.Name = "pDecodeResult"; - // - // rtbDecodeResult - // - this.rtbDecodeResult.BorderStyle = System.Windows.Forms.BorderStyle.None; - resources.ApplyResources(this.rtbDecodeResult, "rtbDecodeResult"); - this.rtbDecodeResult.Name = "rtbDecodeResult"; - this.rtbDecodeResult.LinkClicked += new System.Windows.Forms.LinkClickedEventHandler(this.rtbDecodeResult_LinkClicked); - // - // btnDecodeFromFile - // - resources.ApplyResources(this.btnDecodeFromFile, "btnDecodeFromFile"); - this.btnDecodeFromFile.Name = "btnDecodeFromFile"; - this.btnDecodeFromFile.UseVisualStyleBackColor = true; - this.btnDecodeFromFile.Click += new System.EventHandler(this.btnDecodeFromFile_Click); - // - // lblDecodeResult - // - resources.ApplyResources(this.lblDecodeResult, "lblDecodeResult"); - this.lblDecodeResult.Name = "lblDecodeResult"; - // - // btnDecodeFromScreen - // - resources.ApplyResources(this.btnDecodeFromScreen, "btnDecodeFromScreen"); - this.btnDecodeFromScreen.Name = "btnDecodeFromScreen"; - this.btnDecodeFromScreen.UseVisualStyleBackColor = true; - this.btnDecodeFromScreen.Click += new System.EventHandler(this.btnDecodeFromScreen_Click); - // // pbQRCode // resources.ApplyResources(this.pbQRCode, "pbQRCode"); this.pbQRCode.BackColor = System.Drawing.SystemColors.Window; - this.pbQRCode.ContextMenuStrip = this.cmsQR; + this.pbQRCode.FullscreenOnClick = true; this.pbQRCode.Name = "pbQRCode"; this.pbQRCode.PictureBoxBackColor = System.Drawing.SystemColors.Window; // - // lblQRCodeSize + // lblQRCode // - resources.ApplyResources(this.lblQRCodeSize, "lblQRCodeSize"); - this.lblQRCodeSize.Name = "lblQRCodeSize"; + resources.ApplyResources(this.lblQRCode, "lblQRCode"); + this.lblQRCode.Name = "lblQRCode"; // - // lblQRCodeSizeHint + // lblText // - resources.ApplyResources(this.lblQRCodeSizeHint, "lblQRCodeSizeHint"); - this.lblQRCodeSizeHint.Name = "lblQRCodeSizeHint"; + resources.ApplyResources(this.lblText, "lblText"); + this.lblText.Name = "lblText"; + // + // btnCopyImage + // + resources.ApplyResources(this.btnCopyImage, "btnCopyImage"); + this.btnCopyImage.Name = "btnCopyImage"; + this.btnCopyImage.UseVisualStyleBackColor = true; + this.btnCopyImage.Click += new System.EventHandler(this.btnCopyImage_Click); + // + // btnSaveImage + // + resources.ApplyResources(this.btnSaveImage, "btnSaveImage"); + this.btnSaveImage.Name = "btnSaveImage"; + this.btnSaveImage.UseVisualStyleBackColor = true; + this.btnSaveImage.Click += new System.EventHandler(this.btnSaveImage_Click); + // + // btnUploadImage + // + resources.ApplyResources(this.btnUploadImage, "btnUploadImage"); + this.btnUploadImage.Name = "btnUploadImage"; + this.btnUploadImage.UseVisualStyleBackColor = true; + this.btnUploadImage.Click += new System.EventHandler(this.btnUploadImage_Click); + // + // btnScanQRCodeFromScreen + // + resources.ApplyResources(this.btnScanQRCodeFromScreen, "btnScanQRCodeFromScreen"); + this.btnScanQRCodeFromScreen.Name = "btnScanQRCodeFromScreen"; + this.btnScanQRCodeFromScreen.UseVisualStyleBackColor = true; + this.btnScanQRCodeFromScreen.Click += new System.EventHandler(this.btnScanQRCodeFromScreen_Click); + // + // btnScanQRCodeFromImageFile + // + resources.ApplyResources(this.btnScanQRCodeFromImageFile, "btnScanQRCodeFromImageFile"); + this.btnScanQRCodeFromImageFile.Name = "btnScanQRCodeFromImageFile"; + this.btnScanQRCodeFromImageFile.UseVisualStyleBackColor = true; + this.btnScanQRCodeFromImageFile.Click += new System.EventHandler(this.btnScanQRCodeFromImageFile_Click); // // QRCodeForm // resources.ApplyResources(this, "$this"); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.BackColor = System.Drawing.SystemColors.Window; - this.Controls.Add(this.tcMain); + this.Controls.Add(this.btnScanQRCodeFromImageFile); + this.Controls.Add(this.btnScanQRCodeFromScreen); + this.Controls.Add(this.btnUploadImage); + this.Controls.Add(this.btnSaveImage); + this.Controls.Add(this.btnCopyImage); + this.Controls.Add(this.lblText); + this.Controls.Add(this.lblQRCode); + this.Controls.Add(this.pbQRCode); + this.Controls.Add(this.lblQRCodeSizeHint); + this.Controls.Add(this.lblQRCodeSize); + this.Controls.Add(this.nudQRCodeSize); + this.Controls.Add(this.txtText); this.Name = "QRCodeForm"; this.Shown += new System.EventHandler(this.QRCodeForm_Shown); this.Resize += new System.EventHandler(this.QRCodeForm_Resize); - this.cmsQR.ResumeLayout(false); - this.tcMain.ResumeLayout(false); - this.tpEncode.ResumeLayout(false); - this.tpEncode.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.nudQRCodeSize)).EndInit(); - this.tpDecode.ResumeLayout(false); - this.tpDecode.PerformLayout(); - this.pDecodeResult.ResumeLayout(false); this.ResumeLayout(false); + this.PerformLayout(); } #endregion - private System.Windows.Forms.TextBox txtQRCode; - private System.Windows.Forms.ContextMenuStrip cmsQR; - private System.Windows.Forms.ToolStripMenuItem tsmiCopy; - private System.Windows.Forms.ToolStripMenuItem tsmiSaveAs; - private System.Windows.Forms.TabControl tcMain; - private System.Windows.Forms.TabPage tpEncode; - private System.Windows.Forms.TabPage tpDecode; - private System.Windows.Forms.Button btnDecodeFromScreen; - private System.Windows.Forms.Label lblDecodeResult; - private System.Windows.Forms.Button btnDecodeFromFile; - private System.Windows.Forms.ToolStripMenuItem tsmiDecode; - private System.Windows.Forms.ToolStripMenuItem tsmiUpload; - private System.Windows.Forms.ToolStripSeparator tss1; - private System.Windows.Forms.RichTextBox rtbDecodeResult; - private System.Windows.Forms.Panel pDecodeResult; + private System.Windows.Forms.TextBox txtText; private System.Windows.Forms.NumericUpDown nudQRCodeSize; private HelpersLib.MyPictureBox pbQRCode; private System.Windows.Forms.Label lblQRCodeSize; private System.Windows.Forms.Label lblQRCodeSizeHint; + private System.Windows.Forms.Label lblQRCode; + private System.Windows.Forms.Label lblText; + private System.Windows.Forms.Button btnCopyImage; + private System.Windows.Forms.Button btnSaveImage; + private System.Windows.Forms.Button btnUploadImage; + private System.Windows.Forms.Button btnScanQRCodeFromScreen; + private System.Windows.Forms.Button btnScanQRCodeFromImageFile; } } \ No newline at end of file diff --git a/ShareX/Forms/QRCodeForm.cs b/ShareX/Forms/QRCodeForm.cs index d44dcb572..4e023be06 100644 --- a/ShareX/Forms/QRCodeForm.cs +++ b/ShareX/Forms/QRCodeForm.cs @@ -60,16 +60,15 @@ public static QRCodeForm Instance public QRCodeForm(string text = null) { InitializeComponent(); - rtbDecodeResult.AddContextMenu(); ShareXResources.ApplyTheme(this, true); if (!string.IsNullOrEmpty(text)) { - txtQRCode.Text = text; + txtText.Text = text; } } - public static QRCodeForm EncodeClipboard() + public static QRCodeForm GenerateQRCodeFromClipboard() { string text = ClipboardHelpers.GetText(true); @@ -81,31 +80,20 @@ public static QRCodeForm EncodeClipboard() return new QRCodeForm(); } - public static QRCodeForm OpenFormDecodeFromFile(string filePath) + public static QRCodeForm OpenFormScanFromImageFile(string filePath) { QRCodeForm form = new QRCodeForm(); - form.tcMain.SelectedTab = form.tpDecode; - form.DecodeFromFile(filePath); + form.ScanFromImageFile(filePath); return form; } - public static QRCodeForm OpenFormDecodeFromScreen() + public static QRCodeForm OpenFormScanFromScreen() { QRCodeForm form = Instance; - form.tcMain.SelectedTab = form.tpDecode; - form.DecodeFromScreen(); + form.ScanFromScreen(); return form; } - private void QRCodeForm_Shown(object sender, EventArgs e) - { - isReady = true; - - txtQRCode.SetWatermark(Resources.QRCodeForm_InputTextToEncode); - - EncodeText(txtQRCode.Text); - } - private void ClearQRCode() { if (pbQRCode.Image != null) @@ -113,34 +101,41 @@ private void ClearQRCode() Image temp = pbQRCode.Image; pbQRCode.Reset(); temp.Dispose(); + + pbQRCode.PictureBoxBackColor = BackColor; } } - private void EncodeText(string text) + private void GenerateQRCode(string text) { if (isReady) { ClearQRCode(); - int size; - - if (nudQRCodeSize.Value > 0) + if (!string.IsNullOrEmpty(text)) { - size = (int)nudQRCodeSize.Value; - } - else - { - size = Math.Min(pbQRCode.Width, pbQRCode.Height); - } + int size; - size = Math.Max(size, 64); + if (nudQRCodeSize.Value > 0) + { + size = (int)nudQRCodeSize.Value; + } + else + { + size = Math.Min(pbQRCode.Width, pbQRCode.Height); + } - Image qrCode = TaskHelpers.CreateQRCode(text, size); - pbQRCode.LoadImage(qrCode); + size = Math.Max(size, 64); + + Image qrCode = TaskHelpers.GenerateQRCode(text, size); + + pbQRCode.PictureBoxBackColor = Color.White; + pbQRCode.LoadImage(qrCode); + } } } - private void DecodeImage(Bitmap bmp) + private void ScanImage(Bitmap bmp) { string output = ""; @@ -151,24 +146,10 @@ private void DecodeImage(Bitmap bmp) output = string.Join(Environment.NewLine + Environment.NewLine, results); } - rtbDecodeResult.Text = output; + txtText.Text = output; } - private void DecodeFromFile(string filePath) - { - if (!string.IsNullOrEmpty(filePath)) - { - using (Bitmap bmp = ImageHelpers.LoadImage(filePath)) - { - if (bmp != null) - { - DecodeImage(bmp); - } - } - } - } - - private void DecodeFromScreen() + private void ScanFromScreen() { try { @@ -184,7 +165,7 @@ private void DecodeFromScreen() { if (bmp != null) { - DecodeImage(bmp); + ScanImage(bmp); } } } @@ -194,25 +175,64 @@ private void DecodeFromScreen() } } + private void ScanFromImageFile(string filePath) + { + if (!string.IsNullOrEmpty(filePath)) + { + using (Bitmap bmp = ImageHelpers.LoadImage(filePath)) + { + if (bmp != null) + { + ScanImage(bmp); + } + } + } + } + + private void QRCodeForm_Shown(object sender, EventArgs e) + { + isReady = true; + + txtText.SetWatermark(Resources.QRCodeForm_InputTextToEncode); + + GenerateQRCode(txtText.Text); + } + private void QRCodeForm_Resize(object sender, EventArgs e) { if (nudQRCodeSize.Value == 0) { - EncodeText(txtQRCode.Text); + GenerateQRCode(txtText.Text); } } - private void txtQRCode_TextChanged(object sender, EventArgs e) + private void btnScanQRCodeFromScreen_Click(object sender, EventArgs e) { - EncodeText(txtQRCode.Text); + txtText.ResetText(); + + ScanFromScreen(); + } + + private void btnScanQRCodeFromImageFile_Click(object sender, EventArgs e) + { + txtText.ResetText(); + + string filePath = ImageHelpers.OpenImageFileDialog(); + + ScanFromImageFile(filePath); + } + + private void txtText_TextChanged(object sender, EventArgs e) + { + GenerateQRCode(txtText.Text); } private void nudQRCodeSize_ValueChanged(object sender, EventArgs e) { - EncodeText(txtQRCode.Text); + GenerateQRCode(txtText.Text); } - private void tsmiCopy_Click(object sender, EventArgs e) + private void btnCopyImage_Click(object sender, EventArgs e) { if (pbQRCode.Image != null) { @@ -220,14 +240,14 @@ private void tsmiCopy_Click(object sender, EventArgs e) } } - private void tsmiSaveAs_Click(object sender, EventArgs e) + private void btnSaveImage_Click(object sender, EventArgs e) { - if (!string.IsNullOrEmpty(txtQRCode.Text)) + if (!string.IsNullOrEmpty(txtText.Text)) { using (SaveFileDialog sfd = new SaveFileDialog()) { sfd.Filter = @"PNG (*.png)|*.png|JPEG (*.jpg)|*.jpg|Bitmap (*.bmp)|*.bmp|SVG (*.svg)|*.svg"; - sfd.FileName = txtQRCode.Text; + sfd.FileName = txtText.Text; sfd.DefaultExt = "png"; if (sfd.ShowDialog() == DialogResult.OK) @@ -246,7 +266,7 @@ private void tsmiSaveAs_Click(object sender, EventArgs e) CharacterSet = "UTF-8" } }; - SvgRenderer.SvgImage svgImage = writer.Write(txtQRCode.Text); + SvgRenderer.SvgImage svgImage = writer.Write(txtText.Text); File.WriteAllText(filePath, svgImage.Content, Encoding.UTF8); } else @@ -261,7 +281,7 @@ private void tsmiSaveAs_Click(object sender, EventArgs e) } } - private void tsmiUpload_Click(object sender, EventArgs e) + private void btnUploadImage_Click(object sender, EventArgs e) { if (pbQRCode.Image != null) { @@ -269,32 +289,5 @@ private void tsmiUpload_Click(object sender, EventArgs e) UploadManager.UploadImage(bmp); } } - - private void tsmiDecode_Click(object sender, EventArgs e) - { - if (pbQRCode.Image != null) - { - tcMain.SelectedTab = tpDecode; - - DecodeImage((Bitmap)pbQRCode.Image); - } - } - - private void btnDecodeFromScreen_Click(object sender, EventArgs e) - { - DecodeFromScreen(); - } - - private void btnDecodeFromFile_Click(object sender, EventArgs e) - { - string filePath = ImageHelpers.OpenImageFileDialog(); - - DecodeFromFile(filePath); - } - - private void rtbDecodeResult_LinkClicked(object sender, LinkClickedEventArgs e) - { - URLHelpers.OpenURL(e.LinkText); - } } } \ No newline at end of file diff --git a/ShareX/Forms/QRCodeForm.resx b/ShareX/Forms/QRCodeForm.resx index fea3ea86b..f6d5226c8 100644 --- a/ShareX/Forms/QRCodeForm.resx +++ b/ShareX/Forms/QRCodeForm.resx @@ -117,89 +117,62 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - - - - 180, 22 - - - Copy image to clipboard - - - 180, 22 - - - Save as image file... - - - 180, 22 - - - Upload image - - - 177, 6 - - - 180, 22 - - - Decode - - - 181, 98 - - - cmsQR - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Top, Left, Right + + Top, Bottom, Left - - 8, 8 + + + 16, 88 + + + 4, 4, 4, 4 - + + 2952 + + True - + Both - - 560, 56 + + 552, 408 - - 0 + + 3 - - txtQRCode + + txtText - + System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - tpEncode + + $this - - 4 + + 11 + + + Bottom, Left True - 221, 72 + 125, 531 + + + 4, 0, 4, 0 - 18, 13 + 21, 16 - 5 + 6 px @@ -211,19 +184,25 @@ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - tpEncode + $this - 0 + 8 + + + Bottom, Left True - 5, 72 + 13, 504 + + + 4, 0, 4, 0 - 74, 13 + 91, 16 4 @@ -238,19 +217,25 @@ System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - tpEncode + $this - 1 + 9 + + + Bottom, Left - 136, 68 + 16, 528 + + + 4, 4, 4, 4 - 80, 20 + 104, 22 - 2 + 5 Center @@ -262,22 +247,25 @@ System.Windows.Forms.NumericUpDown, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - tpEncode + $this - 2 + 10 Top, Bottom, Left, Right - 8, 96 + 584, 39 + + + 5, 5, 5, 5 - 560, 430 + 512, 465 - 3 + 8 pbQRCode @@ -286,229 +274,214 @@ ShareX.HelpersLib.MyPictureBox, ShareX.HelpersLib, Version=15.0.1.0, Culture=neutral, PublicKeyToken=null - tpEncode - - - 3 - - - 4, 22 - - - 5, 5, 5, 5 - - - 576, 535 - - - 0 - - - Encode - - - tpEncode - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tcMain - - - 0 - - - Top, Bottom, Left, Right - - - Fill - - - 2, 2 - - - 554, 456 - - - 0 - - - - - - rtbDecodeResult - - - System.Windows.Forms.RichTextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - pDecodeResult - - - 0 - - - 8, 64 - - - 2, 2, 2, 2 - - - 560, 462 - - - 3 - - - pDecodeResult - - - System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tpDecode - - - 0 - - - 244, 8 - - - 224, 32 - - - 1 - - - Decode from image file... - - - btnDecodeFromFile - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tpDecode - - - 1 - - - True - - - 5, 48 - - - 40, 13 - - - 2 - - - Result: - - - lblDecodeResult - - - System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tpDecode - - - 2 - - - 8, 8 - - - 224, 32 - - - 0 - - - Decode from screen... - - - btnDecodeFromScreen - - - System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tpDecode - - - 3 - - - 4, 22 - - - 3, 3, 3, 3 - - - 576, 535 - - - 1 - - - Decode - - - tpDecode - - - System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tcMain - - - 1 - - - Fill - - - 0, 0 - - - 584, 561 - - - 2 - - - tcMain - - - System.Windows.Forms.TabControl, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - $this - + + 7 + + + True + + + 581, 16 + + + 4, 0, 4, 0 + + + 64, 16 + + + 7 + + + QR code: + + + lblQRCode + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 6 + + + True + + + 13, 64 + + + 36, 16 + + + 2 + + + Text: + + + lblText + + + System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 5 + + + Bottom, Left + + + 584, 512 + + + 160, 40 + + + 9 + + + Copy image + + + btnCopyImage + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 4 + + + Bottom, Left + + + 752, 512 + + + 160, 40 + + + 10 + + + Save image... + + + btnSaveImage + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 3 + + + Bottom, Left + + + 920, 512 + + + 160, 40 + + + 11 + + + Upload image + + + btnUploadImage + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 2 + + + 16, 16 + + + 272, 40 + + + 0 + + + Scan QR code from screen... + + + btnScanQRCodeFromScreen + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + 1 + + 296, 16 + + + 272, 40 + + + 1 + + + Scan QR code from image file... + + + btnScanQRCodeFromImageFile + + + System.Windows.Forms.Button, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + $this + + + 0 + True - 6, 13 + 8, 16 - 584, 561 + 1111, 567 + + + Microsoft Sans Serif, 9.75pt + + + 4, 4, 4, 4 - 300, 300 + 900, 450 CenterScreen @@ -516,36 +489,6 @@ ShareX - QR code - - tsmiCopy - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tsmiSaveAs - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tsmiUpload - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tss1 - - - System.Windows.Forms.ToolStripSeparator, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tsmiDecode - - - System.Windows.Forms.ToolStripMenuItem, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - QRCodeForm diff --git a/ShareX/TaskHelpers.cs b/ShareX/TaskHelpers.cs index 76c57941f..feb9f11bc 100644 --- a/ShareX/TaskHelpers.cs +++ b/ShareX/TaskHelpers.cs @@ -1259,12 +1259,12 @@ public static void RunShareXAsAdmin(string arguments = null) public static void OpenQRCode() { - QRCodeForm.EncodeClipboard().Show(); + QRCodeForm.GenerateQRCodeFromClipboard().Show(); } public static void OpenQRCodeDecodeFromScreen() { - QRCodeForm.OpenFormDecodeFromScreen(); + QRCodeForm.OpenFormScanFromScreen(); } public static void OpenRuler(TaskSettings taskSettings = null) @@ -1985,7 +1985,7 @@ public static async Task DownloadAppVeyorBuild() UpdateMessageBox.Start(updateChecker); } - public static Image CreateQRCode(string text, int size) + public static Image GenerateQRCode(string text, int size) { if (CheckQRCodeContent(text)) { diff --git a/ShareX/WorkerTask.cs b/ShareX/WorkerTask.cs index ad06ac4cb..c65869143 100644 --- a/ShareX/WorkerTask.cs +++ b/ShareX/WorkerTask.cs @@ -812,7 +812,7 @@ private void DoFileJobs() if (Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.ScanQRCode) && Info.DataType == EDataType.Image) { - QRCodeForm.OpenFormDecodeFromFile(Info.FilePath).ShowDialog(); + QRCodeForm.OpenFormScanFromImageFile(Info.FilePath).ShowDialog(); } } }