Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            //Create a new instance of our scanner
            scanner = new MobileBarcodeScanner();

            //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 += (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
                scanner.Scan().ContinueWith((t) =>
                {
                    //Our scanning finished callback
                    if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
                    {
                        HandleScanResult(t.Result);
                    }
                });
            };

            buttonCustomScan       = new UIButton(UIButtonType.RoundedRect);
            buttonCustomScan.Frame = new RectangleF(20, 20, 280, 40);
            buttonCustomScan.SetTitle("Scan with Custom View", UIControlState.Normal);
            buttonCustomScan.TouchUpInside += (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;

                scanner.Scan().ContinueWith((t) =>
                {
                    //Our scanning finished callback
                    if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
                    {
                        HandleScanResult(t.Result);
                    }
                });
            };

            this.View.AddSubview(buttonDefaultScan);
            this.View.AddSubview(buttonCustomScan);
        }
		public override void ViewDidLoad ()
		{
			//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 += (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
				scanner.Scan ().ContinueWith((t) => 
				                             {
					//Our scanning finished callback
					if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
						HandleScanResult(t.Result);
				});
			};

			buttonCustomScan = new UIButton(UIButtonType.RoundedRect);
			buttonCustomScan.Frame = new RectangleF(20, 20, 280, 40);
			buttonCustomScan.SetTitle("Scan with Custom View", UIControlState.Normal);
			buttonCustomScan.TouchUpInside += (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;

				scanner.Scan ().ContinueWith((t) => 
				{
					//Our scanning finished callback
					if (t.Status == System.Threading.Tasks.TaskStatus.RanToCompletion)
						HandleScanResult(t.Result);
				});
			};

			this.View.AddSubview(buttonDefaultScan);
			this.View.AddSubview(buttonCustomScan);
		}
Ejemplo n.º 3
0
        public override void ViewDidLoad()
        {
            //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);
            };

            this.View.AddSubview(buttonDefaultScan);
            this.View.AddSubview(buttonCustomScan);
        }
Ejemplo n.º 4
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);
		}