public override void ViewDidLoad()
        {
            //Create a new instance of our scanner
            scanner = new MobileBarcodeScanner(this.NavigationController);

            Root = new RootElement ("ZXing.Net.Mobile") {
                new Section {

                    new StyledStringElement ("Scan with Default View", async () => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;
                        //We can customize the top and bottom text of the default overlay
                        scanner.TopText = "Hold camera up to barcode to scan";
                        scanner.BottomText = "Barcode will automatically scan";

                        //Start scanning
                        var result = await scanner.Scan ();

                        HandleScanResult(result);
                    }),

                    new StyledStringElement ("Scan Continuously", () => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;

                        //Tell our scanner to use our custom overlay
                        scanner.UseCustomOverlay = true;
                        scanner.CustomOverlay = customOverlay;

                        var opt = new MobileBarcodeScanningOptions ();
                        opt.DelayBetweenContinuousScans = 3000;

                        //Start scanning
                        scanner.ScanContinuously (opt, true, HandleScanResult);
                    }),

                    new StyledStringElement ("Scan with Custom View", async () => {
                        //Create an instance of our custom overlay
                        customOverlay = new CustomOverlayView();
                        //Wireup the buttons from our custom overlay
                        customOverlay.ButtonTorch.TouchUpInside += delegate {
                            scanner.ToggleTorch();
                        };
                        customOverlay.ButtonCancel.TouchUpInside += delegate {
                            scanner.Cancel();
                        };

                        //Tell our scanner to use our custom overlay
                        scanner.UseCustomOverlay = true;
                        scanner.CustomOverlay = customOverlay;

                        var result = await scanner.Scan ();

                        HandleScanResult(result);
                    }),

                    new StyledStringElement ("Scan with AVCapture Engine", async () => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;
                        //We can customize the top and bottom text of the default overlay
                        scanner.TopText = "Hold camera up to barcode to scan";
                        scanner.BottomText = "Barcode will automatically scan";

                        //Start scanning
                        var result = await scanner.Scan (true);

                        HandleScanResult (result);
                    }),

                    new StyledStringElement ("Generate Barcode", () => {
                        NavigationController.PushViewController (new ImageViewController (), true);
                    })
                }
            };
        }
Example #2
0
        public override void ViewDidLoad()
        {
            if (is7orgreater)
            {
                EdgesForExtendedLayout = UIRectEdge.None;
            }

            NavigationItem.Title = "ZXing.Net.Mobile";

            //Create a new instance of our scanner
            scanner = new MobileBarcodeScanner(this.NavigationController);

            //Setup our button
            buttonDefaultScan       = new UIButton(UIButtonType.RoundedRect);
            buttonDefaultScan.Frame = new RectangleF(20, 80, 280, 40);
            buttonDefaultScan.SetTitle("Scan with Default View", UIControlState.Normal);
            buttonDefaultScan.TouchUpInside += async(sender, e) =>
            {
                //Tell our scanner to use the default overlay
                scanner.UseCustomOverlay = false;
                //We can customize the top and bottom text of the default overlay
                scanner.TopText    = "Hold camera up to barcode to scan";
                scanner.BottomText = "Barcode will automatically scan";

                //Start scanning
                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            buttonCustomScan       = new UIButton(UIButtonType.RoundedRect);
            buttonCustomScan.Frame = new RectangleF(20, 20, 280, 40);
            buttonCustomScan.SetTitle("Scan with Custom View", UIControlState.Normal);
            buttonCustomScan.TouchUpInside += async(sender, e) =>
            {
                //Create an instance of our custom overlay
                customOverlay = new CustomOverlayView();
                //Wireup the buttons from our custom overlay
                customOverlay.ButtonTorch.TouchUpInside += delegate {
                    scanner.ToggleTorch();
                };
                customOverlay.ButtonCancel.TouchUpInside += delegate {
                    scanner.Cancel();
                };

                //Tell our scanner to use our custom overlay
                scanner.UseCustomOverlay = true;
                scanner.CustomOverlay    = customOverlay;

                var result = await scanner.Scan();

                HandleScanResult(result);
            };

            if (is7orgreater)
            {
                buttonAVCaptureScan       = new UIButton(UIButtonType.RoundedRect);
                buttonAVCaptureScan.Frame = new RectangleF(20, 140, 280, 40);
                buttonAVCaptureScan.SetTitle("Scan with AVCapture Engine", UIControlState.Normal);
                buttonAVCaptureScan.TouchUpInside += async(sender, e) =>
                {
                    //Tell our scanner to use the default overlay
                    scanner.UseCustomOverlay = false;
                    //We can customize the top and bottom text of the default overlay
                    scanner.TopText    = "Hold camera up to barcode to scan";
                    scanner.BottomText = "Barcode will automatically scan";

                    //Start scanning
                    var result = await scanner.Scan(true);

                    HandleScanResult(result);
                };
            }

            this.View.AddSubview(buttonDefaultScan);
            this.View.AddSubview(buttonCustomScan);

            if (is7orgreater)
            {
                this.View.AddSubview(buttonAVCaptureScan);
            }
        }
		public override void ViewDidLoad ()
		{
			if (is7orgreater)
				EdgesForExtendedLayout = UIRectEdge.None;
	
			NavigationItem.Title = "ZXing.Net.Mobile";

			//Create a new instance of our scanner
			scanner = new MobileBarcodeScanner(this.NavigationController);

			//Setup our button
			buttonDefaultScan = new UIButton(UIButtonType.RoundedRect);
			buttonDefaultScan.Frame = new RectangleF(20, 80, 280, 40);
			buttonDefaultScan.SetTitle("Scan with Default View", UIControlState.Normal);
			buttonDefaultScan.TouchUpInside += async (sender, e) => 
			{
				//Tell our scanner to use the default overlay
				scanner.UseCustomOverlay = false;
				//We can customize the top and bottom text of the default overlay
				scanner.TopText = "Hold camera up to barcode to scan";
				scanner.BottomText = "Barcode will automatically scan";

				//Start scanning
				var result = await scanner.Scan ();

				HandleScanResult(result);
			};

			buttonCustomScan = new UIButton(UIButtonType.RoundedRect);
			buttonCustomScan.Frame = new RectangleF(20, 20, 280, 40);
			buttonCustomScan.SetTitle("Scan with Custom View", UIControlState.Normal);
			buttonCustomScan.TouchUpInside += async (sender, e) =>
			{
				//Create an instance of our custom overlay
				customOverlay = new CustomOverlayView();
				//Wireup the buttons from our custom overlay
				customOverlay.ButtonTorch.TouchUpInside += delegate {
					scanner.ToggleTorch();		
				};
				customOverlay.ButtonCancel.TouchUpInside += delegate {
					scanner.Cancel();
				};

				//Tell our scanner to use our custom overlay
				scanner.UseCustomOverlay = true;
				scanner.CustomOverlay = customOverlay;

				var result = await scanner.Scan ();
				
				HandleScanResult(result);
			};

			if (is7orgreater)
			{
				buttonAVCaptureScan = new UIButton (UIButtonType.RoundedRect);
				buttonAVCaptureScan.Frame = new RectangleF (20, 140, 280, 40);
				buttonAVCaptureScan.SetTitle ("Scan with AVCapture Engine", UIControlState.Normal);
				buttonAVCaptureScan.TouchUpInside += async (sender, e) =>
				{
					//Tell our scanner to use the default overlay
					scanner.UseCustomOverlay = false;
					//We can customize the top and bottom text of the default overlay
					scanner.TopText = "Hold camera up to barcode to scan";
					scanner.BottomText = "Barcode will automatically scan";

					//Start scanning
					var result = await scanner.Scan (true);

					HandleScanResult (result);
				};
			}

			this.View.AddSubview (buttonDefaultScan);
			this.View.AddSubview (buttonCustomScan);

			if (is7orgreater)
				this.View.AddSubview (buttonAVCaptureScan);
		}
Example #4
0
        public override void ViewDidLoad()
        {
            //Create a new instance of our scanner
            scanner = new MobileBarcodeScanner(this.NavigationController);

            Root = new RootElement("ZXing.Net.Mobile")
            {
                new Section {
                    new StyledStringElement("Scan with Default View", async() => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;
                        //We can customize the top and bottom text of the default overlay
                        scanner.TopText    = "Hold camera up to barcode to scan";
                        scanner.BottomText = "Barcode will automatically scan";

                        //Start scanning
                        var result = await scanner.Scan();

                        HandleScanResult(result);
                    }),

                    new StyledStringElement("Scan Continuously", () => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;

                        //Tell our scanner to use our custom overlay
                        scanner.UseCustomOverlay = true;
                        scanner.CustomOverlay    = customOverlay;


                        var opt = new MobileBarcodeScanningOptions();
                        opt.DelayBetweenContinuousScans = 3000;

                        //Start scanning
                        scanner.ScanContinuously(opt, true, HandleScanResult);
                    }),

                    new StyledStringElement("Scan with Custom View", async() => {
                        //Create an instance of our custom overlay
                        customOverlay = new CustomOverlayView();
                        //Wireup the buttons from our custom overlay
                        customOverlay.ButtonTorch.TouchUpInside += delegate {
                            scanner.ToggleTorch();
                        };
                        customOverlay.ButtonCancel.TouchUpInside += delegate {
                            scanner.Cancel();
                        };

                        //Tell our scanner to use our custom overlay
                        scanner.UseCustomOverlay = true;
                        scanner.CustomOverlay    = customOverlay;

                        var result = await scanner.Scan();

                        HandleScanResult(result);
                    }),

                    new StyledStringElement("Scan with AVCapture Engine", async() => {
                        //Tell our scanner to use the default overlay
                        scanner.UseCustomOverlay = false;
                        //We can customize the top and bottom text of the default overlay
                        scanner.TopText    = "Hold camera up to barcode to scan";
                        scanner.BottomText = "Barcode will automatically scan";

                        //Start scanning
                        var result = await scanner.Scan(true);

                        HandleScanResult(result);
                    }),

                    new StyledStringElement("Generate Barcode", () => {
                        NavigationController.PushViewController(new ImageViewController(), true);
                    })
                }
            };
        }