public static void InvokeScanner(this Xamarin.UITest.IApp app, BarcodeFormat format, Xamarin.UITest.Platform platform) { if (platform == Xamarin.UITest.Platform.iOS) { app.Invoke("UITestBackdoorScan:", format.ToString()); } else { app.Invoke("UITestBackdoorScan", format.ToString()); } }
public ZXingDecoder(VisualDecoder caller, BarcodeFormat codeType) : base(caller) { list = new List <BarcodeFormat> { codeType }; this.codeType = codeType.ToString(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.SetContentView(Resource.Layout.EncoderActivityLayout); buttonGenerate = this.FindViewById <Button>(Resource.Id.buttonEncoderGenerate); buttonSaveToGallery = this.FindViewById <Button>(Resource.Id.buttonEncoderSaveBarcode); textValue = this.FindViewById <EditText>(Resource.Id.textEncoderValue); imageBarcode = this.FindViewById <ImageView>(Resource.Id.imageViewEncoderBarcode); textViewEncoderMsg = this.FindViewById <TextView>(Resource.Id.textViewEncoderMsg); this.buttonSaveToGallery.Enabled = true; this.Title = "Write: " + CurrentFormat.ToString(); buttonGenerate.Click += (sender, e) => { var value = string.Empty; this.RunOnUiThread(() => { value = this.textValue.Text; }); try { var writer = new BarcodeWriter { Format = CurrentFormat, Options = new EncodingOptions { Height = 200, Width = 600 } }; bitmap = writer.Write(value); this.RunOnUiThread(() => { this.imageBarcode.SetImageDrawable(new Android.Graphics.Drawables.BitmapDrawable(bitmap)); this.buttonSaveToGallery.Enabled = true; }); } catch (Exception ex) { bitmap = null; this.buttonSaveToGallery.Enabled = false; this.RunOnUiThread(() => this.textViewEncoderMsg.Text = ex.ToString()); } }; buttonSaveToGallery.Click += (sender, e) => { Android.Provider.MediaStore.Images.Media.InsertImage(this.ContentResolver, bitmap, "Zxing.Net: " + CurrentFormat.ToString(), ""); }; }
public static void DisplayBarcode(this Xamarin.UITest.IApp app, BarcodeFormat format, string value) { var host = Environment.GetEnvironmentVariable("BARCODE_SERVER_URL"); if (string.IsNullOrEmpty(host)) { Console.WriteLine("No Barcode Display Server specified, skipping..."); return; } var fullUrl = host + "?format=" + System.Net.WebUtility.UrlEncode(format.ToString()) + "&value=" + System.Net.WebUtility.UrlEncode(value); Console.WriteLine("DisplayBarcode -> " + fullUrl); var webClient = new System.Net.WebClient(); webClient.DownloadString(fullUrl); }
static public string ToString(BarcodeFormat barcodeFormat) { switch (barcodeFormat) { case BarcodeFormat.EAN_8: return(BarcodeType.Ean8); case BarcodeFormat.EAN_13: return(BarcodeType.Ean13); case BarcodeFormat.CODE_128: return(BarcodeType.Code128); default: return(barcodeFormat.ToString()); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); this.SetContentView(Resource.Layout.DecoderActivityLayout); this.Title = "Read: " + CurrentFormat.ToString(); this.buttonLoadSample = this.FindViewById <Button>(Resource.Id.buttonDecoderAppSample); this.buttonChooseExisting = this.FindViewById <Button>(Resource.Id.buttonDecoderChooseExisting); this.buttonTakeNew = this.FindViewById <Button>(Resource.Id.buttonDecoderTakeNew); this.imageViewBarcode = this.FindViewById <ImageView>(Resource.Id.imageViewDecoderBarcode); this.textViewResults = this.FindViewById <TextView>(Resource.Id.textViewDecoderResult); this.buttonskipScan = this.FindViewById <Button>(Resource.Id.buttonskipScan); this.buttonLoadSample.Click += (sender, e) => { int r = 0; switch (CurrentFormat.ToString().ToLower()) { case "aztec": r = Resource.Drawable.aztec; break; case "codabar": r = Resource.Drawable.codabar; break; case "code_128": r = Resource.Drawable.code_128; break; case "code_39": r = Resource.Drawable.code_39; break; case "code_93": r = Resource.Drawable.code_93; break; case "data_matrix": r = Resource.Drawable.data_matrix; break; case "ean_13": r = Resource.Drawable.ean_13; break; case "ean_8": r = Resource.Drawable.ean_8; break; case "itf": r = Resource.Drawable.itf; break; case "pdf_417": r = Resource.Drawable.pdf_417; break; case "qr_code": r = Resource.Drawable.qr_code; break; case "upc_a": r = Resource.Drawable.upc_a; break; case "upc_e": r = Resource.Drawable.upc_e; break; default: r = Resource.Drawable.aztec; break; } var d = Resources.GetDrawable(r); var bmp = ((Android.Graphics.Drawables.BitmapDrawable)d).Bitmap; this.imageViewBarcode.SetImageBitmap(bmp); Decode(bmp); }; this.buttonChooseExisting.Click += (sender, e) => { var imageIntent = new Intent(); imageIntent.SetType("image/*"); imageIntent.SetAction(Intent.ActionGetContent); StartActivityForResult(Intent.CreateChooser(imageIntent, "Choose an Existing Barcode Photo"), 101); }; this.buttonTakeNew.Click += (sender, e) => { var intent = new Intent(Android.Provider.MediaStore.ActionImageCapture); var availableActivities = this.PackageManager.QueryIntentActivities(intent, Android.Content.PM.PackageInfoFlags.MatchDefaultOnly); if (availableActivities != null && availableActivities.Count > 0) { var dir = new Java.IO.File(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryPictures), "Barcode Reader"); if (!dir.Exists()) { dir.Mkdirs(); } _file = new Java.IO.File(dir, String.Format("zxingreader{0}.jpg", Guid.NewGuid())); intent.PutExtra(Android.Provider.MediaStore.ExtraOutput, Android.Net.Uri.FromFile(_file)); StartActivityForResult(intent, 102); } }; this.buttonskipScan.Click += (sender, e) => { StartActivity(typeof(UnitInfoActivity)); }; }
public static BarCodeType ZxingToBarcode(BarcodeFormat format) { return Enum.GetValues(typeof(BarCodeType)) .Cast<BarCodeType>().First(type => format.ToString().Equals(type.ToString())); }
public static void InvokeScanner (this Xamarin.UITest.IApp app, BarcodeFormat format, Xamarin.UITest.Platform platform) { if (platform == Xamarin.UITest.Platform.iOS) app.Invoke ("UITestBackdoorScan:", format.ToString ()); else app.Invoke ("UITestBackdoorScan", format.ToString ()); }
public static void DisplayBarcode (this Xamarin.UITest.IApp app, BarcodeFormat format, string value) { var host = Environment.GetEnvironmentVariable ("BARCODE_SERVER_URL"); if (string.IsNullOrEmpty (host)) { Console.WriteLine ("No Barcode Display Server specified, skipping..."); return; } var fullUrl = host + "?format=" + System.Net.WebUtility.UrlEncode (format.ToString ()) + "&value=" + System.Net.WebUtility.UrlEncode (value); Console.WriteLine ("DisplayBarcode -> " + fullUrl); var webClient = new System.Net.WebClient (); webClient.DownloadString (fullUrl); }
public void OnFinish(BarcodeFormat format, string message) { txtMessage.text = message; txtType.text = format.ToString(); }
/// <summary> /// 获取文件路径 /// </summary> /// <param name="fileCategory"></param> /// <param name="content"></param> /// <param name="format"></param> /// <returns></returns> private static string GetFilePath(string fileCategory, string content, BarcodeFormat format) { var now = DateTime.Now; var filePath = $"{AppDomain.CurrentDomain.BaseDirectory}Zxing\\{fileCategory}\\{now.Year}\\{now.Month}\\{format.ToString()}"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } filePath += $"\\{content}.jpg"; return(filePath); }
void IBarCodeCamera.SetSupportFormat(BarcodeFormat barcodeFormats) { BarcodeFormats = (Android.Gms.Vision.Barcodes.BarcodeFormat)Enum.Parse(typeof(Android.Gms.Vision.Barcodes.BarcodeFormat), barcodeFormats.ToString()); if (BarcodeFormats == Android.Gms.Vision.Barcodes.BarcodeFormat.AllFormats) { BarcodeFormats = Android.Gms.Vision.Barcodes.BarcodeFormat.Code128 | Android.Gms.Vision.Barcodes.BarcodeFormat.Code39 | Android.Gms.Vision.Barcodes.BarcodeFormat.Code93 | Android.Gms.Vision.Barcodes.BarcodeFormat.Codabar | Android.Gms.Vision.Barcodes.BarcodeFormat.DataMatrix | Android.Gms.Vision.Barcodes.BarcodeFormat.Ean13 | Android.Gms.Vision.Barcodes.BarcodeFormat.Ean8 | Android.Gms.Vision.Barcodes.BarcodeFormat.Itf | Android.Gms.Vision.Barcodes.BarcodeFormat.QrCode | Android.Gms.Vision.Barcodes.BarcodeFormat.UpcA | Android.Gms.Vision.Barcodes.BarcodeFormat.UpcE | Android.Gms.Vision.Barcodes.BarcodeFormat.Pdf417 | Android.Gms.Vision.Barcodes.BarcodeFormat.Aztec; } }