From 409df4fe7e1cda0084a4917a98e8b33ee8193ede Mon Sep 17 00:00:00 2001 From: Kurt Date: Fri, 27 Feb 2015 18:20:50 -0800 Subject: [PATCH] QR handling for multiple QR codes in same img --- PKX/f1-Main.cs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/PKX/f1-Main.cs b/PKX/f1-Main.cs index f97605073..8d793fcf2 100644 --- a/PKX/f1-Main.cs +++ b/PKX/f1-Main.cs @@ -1567,8 +1567,11 @@ private void clickQR(object sender, EventArgs e) System.Net.HttpWebResponse httpWebReponse = (System.Net.HttpWebResponse)httpWebRequest.GetResponse(); var reader = new StreamReader(httpWebReponse.GetResponseStream()); string data = reader.ReadToEnd(); - string pkstr = data.Substring(data.IndexOf("#") + 1).Replace("\",\"error\":null}]}]", ""); - pkstr = pkstr.Replace("\\", ""); + // Quickly convert the json response to a data string + string pkstr = data.Substring(data.IndexOf("#") + 1); // Trim intro + pkstr = pkstr.Substring(0, pkstr.IndexOf("\",\"error\":null}]}]")); // Trim outro + if (pkstr.Contains("nQR-Code:")) pkstr = pkstr.Substring(0, pkstr.IndexOf("nQR-Code:")); // Remove multiple QR codes in same image + pkstr = pkstr.Replace("\\", ""); // Rectify response byte[] ekx; try { ekx = Convert.FromBase64String(pkstr); } @@ -1582,11 +1585,7 @@ private void clickQR(object sender, EventArgs e) else Util.Alert("Invalid checksum in QR data."); } catch { Util.Alert("Error loading decrypted data"); } } - catch // (Exception e) - { - Util.Alert("Unable to connect to the internet to decode QR code."); - } - return; + catch { Util.Alert("Unable to connect to the internet to decode QR code."); } } else {