Example #1
0
 public ZxingCameraViewController(ZxingScanningOptions options, ZxingScanner scanner)
     : base()
 {
     this.ScanningOptions = options;
     this.Scanner         = scanner;
     Initialize();
 }
        public ZxingCameraViewController(ZxingScanningOptions options, ZxingScanner scanner)
            : base()
        {
			this.ScanningOptions = options;
			this.Scanner = scanner;
            Initialize();
        }
Example #3
0
        public override void StartScanning(ZxingScanningOptions options, Action <ZxingBarcodeResult> onFinished)
        {
            viewController = new ZxingCameraViewController(options, this);

            viewController.BarCodeEvent += (BarCodeEventArgs e) => {
                viewController.DismissViewController();

                ZxingBarcodeResult result = null;

                if (e.BarcodeResult != null)
                {
                    result = ZxingBarcodeResult.FromZxingResult(e.BarcodeResult);
                }

                if (onFinished != null)
                {
                    onFinished(result);
                }
            };

            viewController.Canceled += (sender, e) => {
                viewController.DismissViewController();

                if (onFinished != null)
                {
                    onFinished(null);
                }
            };

            appController.PresentViewController(viewController, true, () => { });
        }
Example #4
0
        /// <summary>
        /// Initializes the SimpleCameraReader
        /// </summary>
        /// <param name="scanOnAutoFocus">Sets whether the camera should scan on completed autofocus or on a timely fashion</param>
        public SimpleCameraReader(ZxingScannerBase scanner, ZxingScanningOptions options)
        {
            this.Options = options;
            this.Scanner = scanner;

            Initialize();
        }
		public override void StartScanning (ZxingScanningOptions options, Action<ZxingBarcodeResult> onFinished)
		{

			viewController = new ZxingCameraViewController(options, this);

			viewController.BarCodeEvent += (BarCodeEventArgs e) => {

				viewController.DismissViewController();

				ZxingBarcodeResult result = null;

				if (e.BarcodeResult != null)
					result = ZxingBarcodeResult.FromZxingResult(e.BarcodeResult);

				if (onFinished != null)
					onFinished(result);
			};

			viewController.Canceled += (sender, e) => {

				viewController.DismissViewController();

				if (onFinished != null)
					onFinished(null);
			};

			appController.PresentViewController(viewController, true, () => { });
		}
        public override void StartScanning(ZxingScanningOptions options, Action<ZxingBarcodeResult> onFinished)
        {
            //Navigate: /ZxingSharp.WindowsPhone;component/Scan.xaml

            Scan.ScanningOptions = options;          
            Scan.FinishedAction = onFinished;
            Scan.UseCustomOverlay = this.UseCustomOverlay;
            Scan.CustomOverlay = this.CustomOverlay;
            Scan.TopText = TopText;
            Scan.BottomText = BottomText;

            ((Microsoft.Phone.Controls.PhoneApplicationFrame)Application.Current.RootVisual).Navigate(
                new Uri("/ZxingSharpWindowsPhone;component/WindowsPhone/Scan.xaml", UriKind.Relative));
        }
        public override void StartScanning(ZxingScanningOptions options, Action <ZxingBarcodeResult> onFinished)
        {
            //Navigate: /ZxingSharp.WindowsPhone;component/Scan.xaml

            Scan.ScanningOptions  = options;
            Scan.FinishedAction   = onFinished;
            Scan.UseCustomOverlay = this.UseCustomOverlay;
            Scan.CustomOverlay    = this.CustomOverlay;
            Scan.TopText          = TopText;
            Scan.BottomText       = BottomText;

            ((Microsoft.Phone.Controls.PhoneApplicationFrame)Application.Current.RootVisual).Navigate(
                new Uri("/ZxingSharpWindowsPhone;component/WindowsPhone/Scan.xaml", UriKind.Relative));
        }
        public ZxingSurfaceView(ZxingCameraViewController parentController, ZxingScanner scanner, ZxingScanningOptions options, UIView overlayView) : base()
        {
			var screenFrame = UIScreen.MainScreen.Bounds;
			var scale = UIScreen.MainScreen.Scale;
			screenFrame = new RectangleF(screenFrame.X, screenFrame.Y, screenFrame.Width * scale, screenFrame.Height * scale);

			var picFrameWidth = Math.Round(screenFrame.Width * 0.90); //screenFrame.Width;
			var picFrameHeight = Math.Round(screenFrame.Height * 0.60);
			var picFrameX = (screenFrame.Width - picFrameWidth) / 2;
			var picFrameY = (screenFrame.Height - picFrameHeight) / 2;

			picFrame = new RectangleF((int)picFrameX, (int)picFrameY, (int)picFrameWidth, (int)picFrameHeight);

			//Console.WriteLine(picFrame.X + ", " + picFrame.Y + " -> " + picFrame.Width + " x " + picFrame.Height);
			this.OverlayView = overlayView;
			this.Scanner = scanner;
			this.Options = options;

            Initialize();
			_parentViewController = parentController;
        }
        public ZxingSurfaceView(ZxingCameraViewController parentController, ZxingScanner scanner, ZxingScanningOptions options, UIView overlayView) : base()
        {
            var screenFrame = UIScreen.MainScreen.Bounds;
            var scale       = UIScreen.MainScreen.Scale;

            screenFrame = new RectangleF(screenFrame.X, screenFrame.Y, screenFrame.Width * scale, screenFrame.Height * scale);

            var picFrameWidth  = Math.Round(screenFrame.Width * 0.90);            //screenFrame.Width;
            var picFrameHeight = Math.Round(screenFrame.Height * 0.60);
            var picFrameX      = (screenFrame.Width - picFrameWidth) / 2;
            var picFrameY      = (screenFrame.Height - picFrameHeight) / 2;

            picFrame = new RectangleF((int)picFrameX, (int)picFrameY, (int)picFrameWidth, (int)picFrameHeight);

            //Console.WriteLine(picFrame.X + ", " + picFrame.Y + " -> " + picFrame.Width + " x " + picFrame.Height);
            this.OverlayView = overlayView;
            this.Scanner     = scanner;
            this.Options     = options;

            Initialize();
            _parentViewController = parentController;
        }
		public override void StartScanning(ZxingScanningOptions options, Action<ZxingBarcodeResult> onFinishedScanning)
		{
			var scanIntent = new Intent(this.Context, typeof(ZxingActivity));

			ZxingActivity.UseCustomView = this.UseCustomOverlay;
			ZxingActivity.CustomOverlayView = this.CustomOverlay;
			ZxingActivity.ScanningOptions = options;
			ZxingActivity.TopText = TopText;
			ZxingActivity.BottomText = BottomText;

			ZxingActivity.OnCanceled += () => 
			{
				onFinishedScanning(null);
			};

			ZxingActivity.OnScanCompleted += (com.google.zxing.Result result) => 
			{
				onFinishedScanning(ZxingBarcodeResult.FromZxingResult(result));
			};

			this.Context.StartActivity(scanIntent);
		}
Example #11
0
        public override void StartScanning(ZxingScanningOptions options, Action <ZxingBarcodeResult> onFinishedScanning)
        {
            var scanIntent = new Intent(this.Context, typeof(ZxingActivity));

            ZxingActivity.UseCustomView     = this.UseCustomOverlay;
            ZxingActivity.CustomOverlayView = this.CustomOverlay;
            ZxingActivity.ScanningOptions   = options;
            ZxingActivity.TopText           = TopText;
            ZxingActivity.BottomText        = BottomText;

            ZxingActivity.OnCanceled += () =>
            {
                onFinishedScanning(null);
            };

            ZxingActivity.OnScanCompleted += (com.google.zxing.Result result) =>
            {
                onFinishedScanning(ZxingBarcodeResult.FromZxingResult(result));
            };

            this.Context.StartActivity(scanIntent);
        }
        public ZxingSurfaceView(ZxingActivity activity, ZxingScanningOptions options)
            : base(activity)
        {
            this.activity = activity;

            screenResolution = new Size(this.activity.WindowManager.DefaultDisplay.Width, this.activity.WindowManager.DefaultDisplay.Height);

            this.options = options;

            this.reader = new MultiFormatReader {
                Hints = new Hashtable {
                    //Formats to use
                    { DecodeHintType.POSSIBLE_FORMATS, this.options.GetFormats() }
                }
            };

            this.surface_holder = Holder;
            this.surface_holder.AddCallback(this);
            this.surface_holder.SetType(SurfaceType.PushBuffers);



            this.tokenSource = new System.Threading.CancellationTokenSource();
        }
		public ZxingSurfaceView (ZxingActivity activity, ZxingScanningOptions options)
			: base (activity)
		{
			this.activity = activity;

			screenResolution = new Size(this.activity.WindowManager.DefaultDisplay.Width, this.activity.WindowManager.DefaultDisplay.Height);

			this.options = options;

			this.reader = new MultiFormatReader {
				Hints = new Hashtable {
					//Formats to use
					{ DecodeHintType.POSSIBLE_FORMATS, this.options.GetFormats() }
				}
			};

			this.surface_holder = Holder;
			this.surface_holder.AddCallback (this);
			this.surface_holder.SetType (SurfaceType.PushBuffers);



			this.tokenSource = new System.Threading.CancellationTokenSource();
		}
		public abstract void StartScanning(ZxingScanningOptions options, Action<ZxingBarcodeResult> onFinished);
		/// <summary>
		/// Initializes the SimpleCameraReader
		/// </summary>
		/// <param name="scanOnAutoFocus">Sets whether the camera should scan on completed autofocus or on a timely fashion</param>
		public SimpleCameraReader(ZxingScannerBase scanner, ZxingScanningOptions options)
		{
            this.Options = options;
            this.Scanner = scanner;

			Initialize();
		}
 public abstract void StartScanning(ZxingScanningOptions options, Action <ZxingBarcodeResult> onFinished);