void HandleScanResult(ZXing.Result result) { string msg = ""; if (result != null && !string.IsNullOrEmpty (result.Text)) { SystemSound.Vibrate.PlayAlertSound (); SystemSound.Vibrate.PlaySystemSound (); PersonDetailViewController personVC = Storyboard.InstantiateViewController ("PersonDetailViewController") as PersonDetailViewController; personVC.SetTask (this, result.Text); NavigationController.PushViewController (personVC, true); //msg = "Found Barcode: " + result.Text; } else { msg = "Scanning Canceled!"; PersonDetailViewController personVC = Storyboard.InstantiateViewController ("PersonDetailViewController") as PersonDetailViewController; personVC.SetTask (this, msg); NavigationController.PushViewController (personVC, true); } // this.InvokeOnMainThread(() => { // var av = new UIAlertView("Barcode Result", msg, null, "OK", null); // av.Show(); // }); }
// Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes. public override ParsedResult parse(ZXing.Result result) { BarcodeFormat format = result.BarcodeFormat; if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E || format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) { return null; } // Really neither of these should happen: String rawText = result.Text; if (rawText == null) { return null; } if (!isStringOfDigits(rawText, rawText.Length)) { return null; } // Not actually checking the checksum again here String normalizedProductID; // Expand UPC-E for purposes of searching if (format == BarcodeFormat.UPC_E && rawText.Length == 8) { normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText); } else { normalizedProductID = rawText; } return new ProductParsedResult(rawText, normalizedProductID); }
/// <summary> /// parse() /// </summary> /// <param name="result"></param> /// <returns></returns> override public ParsedResult parse(ZXing.Result result) { String rawText = result.Text; if (!(rawText.StartsWith("smtp:") || rawText.StartsWith("SMTP:"))) { return null; } String emailAddress = rawText.Substring(5); String subject = null; String body = null; int colon = emailAddress.IndexOf(':'); if (colon >= 0) { subject = emailAddress.Substring(colon + 1); emailAddress = emailAddress.Substring(0, colon); colon = subject.IndexOf(':'); if (colon >= 0) { body = subject.Substring(colon + 1); subject = subject.Substring(0, colon); } } return new EmailAddressParsedResult(new[] { emailAddress }, null, null, subject, body); }
override public ParsedResult parse(ZXing.Result result) { var rawText = result.Text; // MEMORY is mandatory; seems like a decent indicator, as does end-of-record separator CR/LF if (rawText == null || rawText.IndexOf("MEMORY") < 0 || rawText.IndexOf("\r\n") < 0) { return null; } // NAME1 and NAME2 have specific uses, namely written name and pronunciation, respectively. // Therefore we treat them specially instead of as an array of names. var name = matchSinglePrefixedField("NAME1:", rawText, '\r', true); var pronunciation = matchSinglePrefixedField("NAME2:", rawText, '\r', true); var phoneNumbers = matchMultipleValuePrefix("TEL", 3, rawText, true); var emails = matchMultipleValuePrefix("MAIL", 3, rawText, true); var note = matchSinglePrefixedField("MEMORY:", rawText, '\r', false); var address = matchSinglePrefixedField("ADD:", rawText, '\r', true); var addresses = address == null ? null : new [] { address }; return new AddressBookParsedResult(maybeWrap(name), pronunciation, phoneNumbers, null, emails, null, null, note, addresses, null, null, null, null, null); }
// Yes, we extend AbstractDoCoMoResultParser since the format is very much // like the DoCoMo MECARD format, but this is not technically one of // DoCoMo's proposed formats override public ParsedResult parse(ZXing.Result result) { String rawText = result.Text; if (rawText == null || !rawText.StartsWith("BIZCARD:")) { return null; } String firstName = matchSingleDoCoMoPrefixedField("N:", rawText, true); String lastName = matchSingleDoCoMoPrefixedField("X:", rawText, true); String fullName = buildName(firstName, lastName); String title = matchSingleDoCoMoPrefixedField("T:", rawText, true); String org = matchSingleDoCoMoPrefixedField("C:", rawText, true); String[] addresses = matchDoCoMoPrefixedField("A:", rawText, true); String phoneNumber1 = matchSingleDoCoMoPrefixedField("B:", rawText, true); String phoneNumber2 = matchSingleDoCoMoPrefixedField("M:", rawText, true); String phoneNumber3 = matchSingleDoCoMoPrefixedField("F:", rawText, true); String email = matchSingleDoCoMoPrefixedField("E:", rawText, true); return new AddressBookParsedResult(maybeWrap(fullName), null, null, buildPhoneNumbers(phoneNumber1, phoneNumber2, phoneNumber3), null, maybeWrap(email), null, null, null, addresses, null, org, null, title, null, null); }
// public void HandleScanResult(ZXing.Result result) { //The logic for settings string msg = ""; if (result != null && !string.IsNullOrEmpty (result.Text)) { if (result.Text.Contains (".json")) { JSONParser.ParseDataCompleteURL (result.Text); } else { JSONParser.ParseData (result.Text); } msg = "QR Code Settings are set!"; } else msg="Scanning Canceled!"; this.RunOnUiThread (()=>Toast.MakeText(this,msg,ToastLength.Short).Show()); //http://profiles.hookflash.com/itunes-appstore/config.json }
void HandleScanResult(ZXing.Result result) { string msg = ""; if (result != null && !string.IsNullOrEmpty(result.Text)) msg = "Found Barcode: " + result.Text; else msg = "Scanning Canceled!"; Info = msg; }
void HandleScanResult(ZXing.Result result) { string msg = ""; if (result != null && !string.IsNullOrEmpty(result.Text)) msg = "Found Barcode: " + result.Text; else msg = "Scanning Canceled!"; this.RunOnUiThread(() => scannedResult.Text = msg); }
private void AddBarcodeToResults(ZXing.Result result) { SetActivityMessage("Barcode decoded", false); //BarcodeResult.AddToResultCollection(result, _viewModel); format = result.BarcodeFormat.ToString(); contents = result.Text; raw = result.RawBytes; com.codename1.ui.Display d = (com.codename1.ui.Display)com.codename1.ui.Display.getInstance(); d.callSerially(this); }
void HandleScanResult (ZXing.Result result) { string msg = ""; if (result != null && !string.IsNullOrEmpty(result.Text)) msg = "Found Barcode: " + result.Text; else msg = "Scanning Canceled!"; this.RunOnUiThread(() => Toast.MakeText(this, msg, ToastLength.Short).Show()); }
override public ParsedResult parse(ZXing.Result result) { String rawText = result.Text; if (rawText == null || !(rawText.StartsWith("sms:") || rawText.StartsWith("SMS:") || rawText.StartsWith("mms:") || rawText.StartsWith("MMS:"))) { return null; } // Check up front if this is a URI syntax string with query arguments var nameValuePairs = parseNameValuePairs(rawText); String subject = null; String body = null; var querySyntax = false; if (nameValuePairs != null && nameValuePairs.Count != 0) { subject = nameValuePairs["subject"]; body = nameValuePairs["body"]; querySyntax = true; } // Drop sms, query portion //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'" var queryStart = rawText.IndexOf('?', 4); String smsURIWithoutQuery; // If it's not query syntax, the question mark is part of the subject or message if (queryStart < 0 || !querySyntax) { smsURIWithoutQuery = rawText.Substring(4); } else { smsURIWithoutQuery = rawText.Substring(4, (queryStart) - (4)); } int lastComma = -1; int comma; var numbers = new List<String>(1); var vias = new List<String>(1); while ((comma = smsURIWithoutQuery.IndexOf(',', lastComma + 1)) > lastComma) { String numberPart = smsURIWithoutQuery.Substring(lastComma + 1, comma); addNumberVia(numbers, vias, numberPart); lastComma = comma; } addNumberVia(numbers, vias, smsURIWithoutQuery.Substring(lastComma + 1)); return new SMSParsedResult(SupportClass.toStringArray(numbers), SupportClass.toStringArray(vias), subject, body); }
void HandleResult(ZXing.Result result){ if (result != null) { var msg = "NO barcode!"; msg = "barcode: " + result.Text + "was not in your database"; // LagerDAO dao = new LagerDAO(); int id = -1; try{ id = Convert.ToInt32(result.Text); }catch(Exception e){ Console.WriteLine(e.Message); } IList<LagerObject> lol = null; if(id != -1){ lol = new List<LagerObject> (); lol.Add(AppDelegate.dao.GetLagerObjectByID(id)); } if (lol != null) { if (lol.Count == 0) { var title = "no barcode"; var alert = new UIAlertView(title, msg, null, "cancel", null); alert.Show(); } else { LagerObject lo = lol[0]; if (lo.isContainer == "true") { var cd = new no.dctapps.commons.events.screens.ContainerDetails(lo); parent.PresentViewControllerAsync(cd, true); } else if (lo.isLargeObject == "true") { BigItemDetailScreen bs = new BigItemDetailScreen(lo); parent.PresentViewControllerAsync(bs, true); } else { var alert = new UIAlertView("No such object", msg, null, "cancel", null); alert.Show(); } } } } }
void HandleScanResult(ZXing.Result result) { string msg = ""; if (result != null && !string.IsNullOrEmpty(result.Text)) msg = "Found Barcode: " + result.Text; else msg = "Scanning Canceled!"; this.InvokeOnMainThread(() => { var av = new UIAlertView("Barcode Result", msg, null, "OK", null); av.Show(); }); }
private static Rectangle RectangleFromResultPoints(ZXing.ResultPoint[] resultPoints) { PointF minPoint = new PointF(resultPoints[0].X, resultPoints[0].Y); PointF maxPoint = minPoint; foreach (var point in resultPoints) { minPoint.X = Math.Min(minPoint.X, point.X); minPoint.Y = Math.Min(minPoint.Y, point.Y); maxPoint.X = Math.Max(maxPoint.X, point.X); maxPoint.Y = Math.Max(maxPoint.Y, point.Y); } return new Rectangle((int)minPoint.X, (int)minPoint.Y, (int)(maxPoint.X - minPoint.X), (int)(maxPoint.Y - minPoint.Y)); }
override public ParsedResult parse(ZXing.Result result) { String rawText = result.Text; if (rawText == null || (!rawText.StartsWith("tel:") && !rawText.StartsWith("TEL:"))) { return null; } // Normalize "TEL:" to "tel:" String telURI = rawText.StartsWith("TEL:") ? "tel:" + rawText.Substring(4) : rawText; // Drop tel, query portion //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'" int queryStart = rawText.IndexOf('?', 4); String number = queryStart < 0 ? rawText.Substring(4) : rawText.Substring(4, (queryStart) - (4)); return new TelParsedResult(number, telURI, null); }
override public ParsedResult parse(ZXing.Result result) { String rawText = result.Text; if (rawText == null || !rawText.StartsWith("MECARD:")) { return null; } String[] rawName = matchDoCoMoPrefixedField("N:", rawText, true); if (rawName == null) { return null; } String name = parseName(rawName[0]); String pronunciation = matchSingleDoCoMoPrefixedField("SOUND:", rawText, true); String[] phoneNumbers = matchDoCoMoPrefixedField("TEL:", rawText, true); String[] emails = matchDoCoMoPrefixedField("EMAIL:", rawText, true); String note = matchSingleDoCoMoPrefixedField("NOTE:", rawText, false); String[] addresses = matchDoCoMoPrefixedField("ADR:", rawText, true); String birthday = matchSingleDoCoMoPrefixedField("BDAY:", rawText, true); if (birthday != null && !isStringOfDigits(birthday, 8)) { // No reason to throw out the whole card because the birthday is formatted wrong. birthday = null; } String url = matchSingleDoCoMoPrefixedField("URL:", rawText, true); // Although ORG may not be strictly legal in MECARD, it does exist in VCARD and we might as well // honor it when found in the wild. String org = matchSingleDoCoMoPrefixedField("ORG:", rawText, true); return new AddressBookParsedResult(maybeWrap(name), null, pronunciation, phoneNumbers, null, emails, null, null, note, addresses, null, org, birthday, null, url, null); }
override public ParsedResult parse(ZXing.Result result) { var rawText = result.Text; if (rawText == null || (!rawText.StartsWith("urlto:") && !rawText.StartsWith("URLTO:"))) { return null; } //UPGRADE_WARNING: Method 'java.lang.String.indexOf' was converted to 'System.String.IndexOf' which may throw an exception. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1101'" int titleEnd = rawText.IndexOf(':', 6); if (titleEnd < 0) { return null; } var title = titleEnd <= 6 ? null : rawText.Substring(6, (titleEnd) - (6)); var uri = rawText.Substring(titleEnd + 1); return new URIParsedResult(uri, title); }
override public ParsedResult parse(ZXing.Result result) { String rawText = result.Text; if (rawText == null || !rawText.StartsWith("MEBKM:")) { return null; } String title = matchSingleDoCoMoPrefixedField("TITLE:", rawText, true); String[] rawUri = matchDoCoMoPrefixedField("URL:", rawText, true); if (rawUri == null) { return null; } String uri = rawUri[0]; if (!URIResultParser.isBasicallyValidURI(uri)) { return null; } return new URIParsedResult(uri, title); }
/// <summary> /// See <a href="http://www.bisg.org/isbn-13/for.dummies.html">ISBN-13 For Dummies</a> /// </summary> /// <param name="result">The result.</param> /// <returns></returns> override public ParsedResult parse(ZXing.Result result) { BarcodeFormat format = result.BarcodeFormat; if (format != BarcodeFormat.EAN_13) { return null; } String rawText = result.Text; int length = rawText.Length; if (length != 13) { return null; } if (!rawText.StartsWith("978") && !rawText.StartsWith("979")) { return null; } return new ISBNParsedResult(rawText); }
void ScanResultHandler(ZXing.Result result) { string message = ""; if (result != null && !string.IsNullOrEmpty(result.Text)) { message = result.Text; } else { message = "Scan cancelled"; } MainText = message; if (result != null && String.Equals(result.BarcodeFormat.ToString(), "PDF_417", StringComparison.OrdinalIgnoreCase)) { string[] arr = result.Text.Split('%'); string antwoord; antwoord = "Make: " + arr[9] + "\nModel: " + arr[10] + "\nCar Description: " + arr[8] + "\nCar Colour: " + arr[11] + "\nLicense number: " + arr[6] + "\nDate of Expiry: " + arr[14]; MainText = antwoord; } }
override public ParsedResult parse(ZXing.Result result) { String rawText = result.Text; if (!(rawText.StartsWith("smsto:") || rawText.StartsWith("SMSTO:") || rawText.StartsWith("mmsto:") || rawText.StartsWith("MMSTO:"))) { return null; } // Thanks to dominik.wild for suggesting this enhancement to support // smsto:number:body URIs String number = rawText.Substring(6); String body = null; int bodyStart = number.IndexOf(':'); if (bodyStart >= 0) { body = number.Substring(bodyStart + 1); number = number.Substring(0, bodyStart); } return new SMSParsedResult(number, null, null, body); }
void HandleScanResult(ZXing.Result result) { string msg = ""; if (result != null && !string.IsNullOrEmpty(result.Text)) msg = "Found Barcode: " + result.Text; else msg = "Scanning Canceled!"; this.Dispatcher.BeginInvoke(() => { MessageBox.Show(msg); //Go back to the main page NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative)); //Don't allow to navigate back to the scanner with the back button NavigationService.RemoveBackEntry(); }); }
override public ParsedResult parse(ZXing.Result result) { String rawText = result.Text; if (rawText == null) { return null; } String emailAddress; if (rawText.ToLower().StartsWith("mailto:")) { // If it starts with mailto:, assume it is definitely trying to be an email address emailAddress = rawText.Substring(7); int queryStart = emailAddress.IndexOf('?'); if (queryStart >= 0) { emailAddress = emailAddress.Substring(0, queryStart); } emailAddress = urlDecode(emailAddress); var nameValues = parseNameValuePairs(rawText); String subject = null; String body = null; if (nameValues != null) { if (emailAddress.Length == 0) { emailAddress = nameValues["to"]; } subject = nameValues["subject"]; body = nameValues["body"]; } return new EmailAddressParsedResult(emailAddress, subject, body, rawText); } if (!EmailDoCoMoResultParser.isBasicallyValidEmailAddress(rawText)) { return null; } emailAddress = rawText; return new EmailAddressParsedResult(emailAddress, null, null, "mailto:" + emailAddress); }
// Treat all UPC and EAN variants as UPCs, in the sense that they are all product barcodes. override public ParsedResult parse(ZXing.Result result) { BarcodeFormat format = result.BarcodeFormat; if (!(format == BarcodeFormat.UPC_A || format == BarcodeFormat.UPC_E || format == BarcodeFormat.EAN_8 || format == BarcodeFormat.EAN_13)) { return null; } // Really neither of these should happen: String rawText = result.Text; if (rawText == null) { return null; } int length = rawText.Length; for (int x = 0; x < length; x++) { char c = rawText[x]; if (c < '0' || c > '9') { return null; } } // Not actually checking the checksum again here String normalizedProductID; // Expand UPC-E for purposes of searching if (format == BarcodeFormat.UPC_E) { normalizedProductID = UPCEReader.convertUPCEtoUPCA(rawText); } else { normalizedProductID = rawText; } return new ProductParsedResult(rawText, normalizedProductID); }
public ZXingScannerPage (ZXing.Mobile.MobileBarcodeScanningOptions options = null, View customOverlay = null) : base () { zxing = new ZXingScannerView { HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand }; zxing.OnScanResult += (result) => { var eh = this.OnScanResult; if (eh != null) eh(result); //Device.BeginInvokeOnMainThread (() => eh (result)); }; if (customOverlay == null) { defaultOverlay = new ZXingDefaultOverlay { TopText = "Hold your phone up to the barcode", BottomText = "Scanning will happen automatically", ShowFlashButton = zxing.HasTorch, }; defaultOverlay.FlashButtonClicked += (sender, e) => { zxing.IsTorchOn = !zxing.IsTorchOn; }; Overlay = defaultOverlay; } else { Overlay = customOverlay; } var grid = new Grid { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, }; grid.Children.Add(zxing); grid.Children.Add(Overlay); // The root page of your application Content = grid; }
/// <summary> /// parse() /// </summary> /// <param name="result"></param> /// <returns></returns> override public ParsedResult parse(ZXing.Result result) { var rawText = result.Text; if (!rawText.StartsWith("WIFI:")) { return null; } var ssid = matchSinglePrefixedField("S:", rawText, ';', false); if (string.IsNullOrEmpty(ssid)) { return null; } var pass = matchSinglePrefixedField("P:", rawText, ';', false); var type = matchSinglePrefixedField("T:", rawText, ';', false) ?? "nopass"; bool hidden = false; #if WindowsCE try { hidden = Boolean.Parse(matchSinglePrefixedField("H:", rawText, ';', false)); } catch { } #else Boolean.TryParse(matchSinglePrefixedField("H:", rawText, ';', false), out hidden); #endif return new WifiParsedResult(type, ssid, pass, hidden); }
void HandleScanResult (ZXing.Result result) { string testmsg = " "; if (result != null && !string.IsNullOrEmpty (result.Text)) { string[] msg = VDateToDateTime (result.Text); string inputTitle = (string.IsNullOrEmpty (msg [0])) ? ("") : msg [0]; string inputLocation = (string.IsNullOrEmpty (msg [1])) ? ("") : msg [1]; DateTime inputDStart = IcalToDateTime (msg [2]); DateTime inputDEnd = IcalToDateTime (msg [3]); // Create a new Alert Controller UIAlertController actionSheetAlert = UIAlertController.Create ("Action Sheet", "Select an event from below", UIAlertControllerStyle.ActionSheet); // Add Actions actionSheetAlert.AddAction (UIAlertAction.Create ("Add To Calendar", UIAlertActionStyle.Default, (action) => Add (0, inputDStart, inputDEnd, inputTitle, inputLocation))); actionSheetAlert.AddAction (UIAlertAction.Create ("Add To Reminders", UIAlertActionStyle.Default, (action) => Add (1, inputDStart, inputDEnd, inputTitle, inputLocation))); actionSheetAlert.AddAction (UIAlertAction.Create ("Add To Both", UIAlertActionStyle.Default, (action) => Add (2, inputDStart, inputDEnd, inputTitle, inputLocation))); actionSheetAlert.AddAction (UIAlertAction.Create ("Cancel", UIAlertActionStyle.Cancel, (action) => Console.WriteLine ("Cancel button pressed."))); // Xamarin code // Required for iPad - You must specify a source for the Action Sheet since it is // displayed as a popover UIPopoverPresentationController presentationPopover = actionSheetAlert.PopoverPresentationController; if (presentationPopover != null) { presentationPopover.SourceView = this.View; presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; } // Display the alert this.PresentViewController (actionSheetAlert, true, null); } else new UIAlertView ("QR Code Scan Results:", "Scanning Canceled!", null, "ok", null).Show (); }
override public ParsedResult parse(ZXing.Result result) { String rawText = result.Text; if (rawText == null) { return null; } int vEventStart = rawText.IndexOf("BEGIN:VEVENT"); if (vEventStart < 0) { return null; } String summary = matchSingleVCardPrefixedField("SUMMARY", rawText, true); String start = matchSingleVCardPrefixedField("DTSTART", rawText, true); if (start == null) { return null; } String end = matchSingleVCardPrefixedField("DTEND", rawText, true); String duration = matchSingleVCardPrefixedField("DURATION", rawText, true); String location = matchSingleVCardPrefixedField("LOCATION", rawText, true); String organizer = stripMailto(matchSingleVCardPrefixedField("ORGANIZER", rawText, true)); String[] attendees = matchVCardPrefixedField("ATTENDEE", rawText, true); if (attendees != null) { for (int i = 0; i < attendees.Length; i++) { attendees[i] = stripMailto(attendees[i]); } } String description = matchSingleVCardPrefixedField("DESCRIPTION", rawText, true); String geoString = matchSingleVCardPrefixedField("GEO", rawText, true); double latitude; double longitude; if (geoString == null) { latitude = Double.NaN; longitude = Double.NaN; } else { int semicolon = geoString.IndexOf(';'); #if WindowsCE try { latitude = Double.Parse(geoString.Substring(0, semicolon), NumberStyles.Float, CultureInfo.InvariantCulture); } catch { return null; } try { longitude = Double.Parse(geoString.Substring(semicolon + 1), NumberStyles.Float, CultureInfo.InvariantCulture); } catch { return null; } #else if (!Double.TryParse(geoString.Substring(0, semicolon), NumberStyles.Float, CultureInfo.InvariantCulture, out latitude)) return null; if (!Double.TryParse(geoString.Substring(semicolon + 1), NumberStyles.Float, CultureInfo.InvariantCulture, out longitude)) return null; #endif } try { return new CalendarParsedResult(summary, start, end, duration, location, organizer, attendees, description, latitude, longitude); } catch (ArgumentException ) { return null; } }
void HandleResult(ZXing.Result result) { LastScanResult = result; var evt = ResultFoundAction; if (evt != null) evt(LastScanResult); if (!ContinuousScanning) { if (NavigationService.CanGoBack) NavigationService.GoBack(); } }
private void drawResultPoints(Bitmap barcode, ZXing.Result rawResult) { var points = rawResult.ResultPoints; if (points != null && points.Length > 0) { var canvas = new Canvas(barcode); Paint paint = new Paint(); paint.Color = Android.Graphics.Color.White; paint.StrokeWidth = 3.0f; paint.SetStyle(Paint.Style.Stroke); var border = new RectF(2, 2, barcode.Width - 2, barcode.Height - 2); canvas.DrawRect(border, paint); paint.Color = Android.Graphics.Color.Purple; if (points.Length == 2) { paint.StrokeWidth = 4.0f; drawLine(canvas, paint, points[0], points[1]); } else if (points.Length == 4 && (rawResult.BarcodeFormat == BarcodeFormat.UPC_A || rawResult.BarcodeFormat == BarcodeFormat.EAN_13)) { // Hacky special case -- draw two lines, for the barcode and metadata drawLine(canvas, paint, points[0], points[1]); drawLine(canvas, paint, points[2], points[3]); } else { paint.StrokeWidth = 10.0f; foreach (ResultPoint point in points) canvas.DrawPoint(point.X, point.Y, paint); } } }