From 6c5b0a10c6bbc63ff4d4be4fbc898d8c9a689ae2 Mon Sep 17 00:00:00 2001 From: Jaex Date: Wed, 15 Jan 2020 12:00:10 +0300 Subject: [PATCH] Make QR code result links clickable --- ShareX/Forms/QRCodeForm.Designer.cs | 29 ++++++-- ShareX/Forms/QRCodeForm.cs | 7 +- ShareX/Forms/QRCodeForm.resx | 109 +++++++++++++++++----------- 3 files changed, 92 insertions(+), 53 deletions(-) diff --git a/ShareX/Forms/QRCodeForm.Designer.cs b/ShareX/Forms/QRCodeForm.Designer.cs index 44c22e58e..3e2676491 100644 --- a/ShareX/Forms/QRCodeForm.Designer.cs +++ b/ShareX/Forms/QRCodeForm.Designer.cs @@ -42,14 +42,16 @@ private void InitializeComponent() this.tpEncode = new System.Windows.Forms.TabPage(); this.tpDecode = new System.Windows.Forms.TabPage(); this.btnDecodeFromFile = new System.Windows.Forms.Button(); - this.txtDecodeResult = new System.Windows.Forms.TextBox(); this.lblDecodeResult = new System.Windows.Forms.Label(); this.btnDecodeFromScreen = new System.Windows.Forms.Button(); + this.rtbDecodeResult = new System.Windows.Forms.RichTextBox(); + this.pDecodeResult = new System.Windows.Forms.Panel(); this.cmsQR.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pbQRCode)).BeginInit(); this.tcMain.SuspendLayout(); this.tpEncode.SuspendLayout(); this.tpDecode.SuspendLayout(); + this.pDecodeResult.SuspendLayout(); this.SuspendLayout(); // // cmsQR @@ -126,8 +128,8 @@ private void InitializeComponent() // 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.txtDecodeResult); this.tpDecode.Controls.Add(this.lblDecodeResult); this.tpDecode.Controls.Add(this.btnDecodeFromScreen); resources.ApplyResources(this.tpDecode, "tpDecode"); @@ -140,11 +142,6 @@ private void InitializeComponent() this.btnDecodeFromFile.UseVisualStyleBackColor = true; this.btnDecodeFromFile.Click += new System.EventHandler(this.btnDecodeFromFile_Click); // - // txtDecodeResult - // - resources.ApplyResources(this.txtDecodeResult, "txtDecodeResult"); - this.txtDecodeResult.Name = "txtDecodeResult"; - // // lblDecodeResult // resources.ApplyResources(this.lblDecodeResult, "lblDecodeResult"); @@ -157,6 +154,20 @@ private void InitializeComponent() this.btnDecodeFromScreen.UseVisualStyleBackColor = true; this.btnDecodeFromScreen.Click += new System.EventHandler(this.btnDecodeFromScreen_Click); // + // 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); + // + // pDecodeResult + // + resources.ApplyResources(this.pDecodeResult, "pDecodeResult"); + this.pDecodeResult.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.pDecodeResult.Controls.Add(this.rtbDecodeResult); + this.pDecodeResult.Name = "pDecodeResult"; + // // QRCodeForm // resources.ApplyResources(this, "$this"); @@ -173,6 +184,7 @@ private void InitializeComponent() this.tpEncode.PerformLayout(); this.tpDecode.ResumeLayout(false); this.tpDecode.PerformLayout(); + this.pDecodeResult.ResumeLayout(false); this.ResumeLayout(false); } @@ -188,11 +200,12 @@ private void InitializeComponent() private System.Windows.Forms.TabPage tpEncode; private System.Windows.Forms.TabPage tpDecode; private System.Windows.Forms.Button btnDecodeFromScreen; - private System.Windows.Forms.TextBox txtDecodeResult; 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; } } \ No newline at end of file diff --git a/ShareX/Forms/QRCodeForm.cs b/ShareX/Forms/QRCodeForm.cs index de1f634a6..b29ea226b 100644 --- a/ShareX/Forms/QRCodeForm.cs +++ b/ShareX/Forms/QRCodeForm.cs @@ -115,7 +115,7 @@ private void DecodeImage(Bitmap bmp) output = string.Join(Environment.NewLine + Environment.NewLine, results); } - txtDecodeResult.Text = output; + rtbDecodeResult.Text = output; } private void DecodeFromFile(string filePath) @@ -238,5 +238,10 @@ private void btnDecodeFromFile_Click(object sender, EventArgs e) 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 baa9a8ed2..235ba2da2 100644 --- a/ShareX/Forms/QRCodeForm.resx +++ b/ShareX/Forms/QRCodeForm.resx @@ -121,6 +121,15 @@ 17, 17 + + 181, 98 + + + cmsQR + + + System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + 180, 22 @@ -148,15 +157,6 @@ Decode - - 181, 98 - - - cmsQR - - - System.Windows.Forms.ContextMenuStrip, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Top, Left, Right @@ -243,6 +243,60 @@ 0 + + Top, Bottom, Left, Right + + + Fill + + + 2, 2 + + + 454, 406 + + + 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 + + + 460, 412 + + + 3 + + + pDecodeResult + + + System.Windows.Forms.Panel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + tpDecode + + + 0 + 244, 8 @@ -250,7 +304,7 @@ 224, 32 - 3 + 1 Decode from image file... @@ -265,39 +319,6 @@ tpDecode - 0 - - - Top, Bottom, Left, Right - - - Microsoft Sans Serif, 9.75pt - - - 8, 64 - - - True - - - Both - - - 460, 412 - - - 2 - - - txtDecodeResult - - - System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - tpDecode - - 1 @@ -310,7 +331,7 @@ 40, 13 - 1 + 2 Result: