Пример #1
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			this.RequestWindowFeature (WindowFeatures.NoTitle);

			this.Window.AddFlags (WindowManagerFlags.Fullscreen); //to show
			this.Window.AddFlags (WindowManagerFlags.KeepScreenOn); //Don't go to sleep while scanning

			scanner = new ZxingSurfaceView (this, ScanningOptions);
			SetContentView (scanner);

			var layoutParams = new LinearLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);

			if (!UseCustomView)
			{
				zxingOverlay = new ZxingOverlayView (this);
				zxingOverlay.TopText = TopText ?? "";
				zxingOverlay.BottomText = BottomText ?? "";

				this.AddContentView (zxingOverlay, layoutParams);
			}
			else if (CustomOverlayView != null)
			{
				this.AddContentView(CustomOverlayView, layoutParams);
			}

			OnCancelRequested += HandleCancelScan;
			OnAutoFocusRequested += HandleAutoFocus;
			OnTorchRequested += HandleTorchRequested;

		}
Пример #2
0
		public void Initialize()
        {
			this.InvokeOnMainThread (() => {
				if (IsSourceTypeAvailable (UIImagePickerControllerSourceType.Camera))
					SourceType = UIImagePickerControllerSourceType.Camera;
				else
					SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
			

			
				ShowsCameraControls = false;
				AllowsEditing = true;
				WantsFullScreenLayout = true;
				var tf = MonoTouch.CoreGraphics.CGAffineTransform.MakeScale (1.25f, 1.25f); //CGAffineTransformScale(_picker.cameraViewTransform, CAMERA_TRANSFORM, CAMERA_TRANSFORM);
				CameraViewTransform = tf;

				UIView overlayView = null;

				if (Scanner.UseCustomOverlay && Scanner.CustomOverlay != null)
					overlayView = Scanner.CustomOverlay;

				SurfaceView = new ZxingSurfaceView (this, Scanner, this.ScanningOptions, overlayView);

				CameraOverlayView = SurfaceView;
			});
        }
Пример #3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            this.RequestWindowFeature(WindowFeatures.NoTitle);

            this.Window.AddFlags(WindowManagerFlags.Fullscreen);              //to show
            this.Window.AddFlags(WindowManagerFlags.KeepScreenOn);            //Don't go to sleep while scanning

            scanner = new ZxingSurfaceView(this, ScanningOptions);
            SetContentView(scanner);

            var layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);

            if (!UseCustomView)
            {
                zxingOverlay            = new ZxingOverlayView(this);
                zxingOverlay.TopText    = TopText ?? "";
                zxingOverlay.BottomText = BottomText ?? "";

                this.AddContentView(zxingOverlay, layoutParams);
            }
            else if (CustomOverlayView != null)
            {
                this.AddContentView(CustomOverlayView, layoutParams);
            }

            OnCancelRequested    += HandleCancelScan;
            OnAutoFocusRequested += HandleAutoFocus;
            OnTorchRequested     += HandleTorchRequested;
        }
        public void Initialize()
        {
            this.InvokeOnMainThread(() => {
                if (IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera))
                {
                    SourceType = UIImagePickerControllerSourceType.Camera;
                }
                else
                {
                    SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
                }



                ShowsCameraControls   = false;
                AllowsEditing         = true;
                WantsFullScreenLayout = true;
                var tf = MonoTouch.CoreGraphics.CGAffineTransform.MakeScale(1.25f, 1.25f);                  //CGAffineTransformScale(_picker.cameraViewTransform, CAMERA_TRANSFORM, CAMERA_TRANSFORM);
                CameraViewTransform = tf;

                UIView overlayView = null;

                if (Scanner.UseCustomOverlay && Scanner.CustomOverlay != null)
                {
                    overlayView = Scanner.CustomOverlay;
                }

                SurfaceView = new ZxingSurfaceView(this, Scanner, this.ScanningOptions, overlayView);

                CameraOverlayView = SurfaceView;
            });
        }
Пример #5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            this.RequestWindowFeature(WindowFeatures.NoTitle);

            this.Window.AddFlags(WindowManagerFlags.Fullscreen);             //to show
            this.Window.AddFlags(WindowManagerFlags.KeepScreenOn);           //Don't go to sleep while scanning

            scanner = new ZxingSurfaceView(this);
            SetContentView(scanner);

            var layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);

            var customLayout = LayoutInflater.FromContext(this).Inflate(ZXing.YuvTool.Resource.Layout.Main, null);

            var buttonCapture = customLayout.FindViewById <Button>(ZXing.YuvTool.Resource.Id.MyButton);

            buttonCapture.Click += (sender, args) =>
            {
                var yuv    = scanner.GetLastYuvImage();
                var width  = scanner.GetLastWidth();
                var height = scanner.GetLastHeight();

                if (yuv == null)
                {
                    return;
                }


                using (var stream = this.OpenFileOutput("YuvData.txt", FileCreationMode.WorldReadable))
                    using (var sw = new System.IO.StreamWriter(stream))
                    {
                        sw.Write(Convert.ToBase64String(yuv.GetYuvData()));
                        sw.WriteLine();
                        sw.WriteLine("WIDTH=" + width + ", HEIGHT=" + height);
                    }

                using (var stream = this.OpenFileOutput("YuvImage.jpg", FileCreationMode.WorldReadable))
                    using (var sw = new System.IO.StreamWriter(stream))
                    {
                        yuv.CompressToJpeg(new Rect(0, 0, width, height), 100, stream);
                    }

                var intent = new Intent(this, typeof(AnalyzeImageActivity));
                intent.PutExtra("IMGWIDTH", yuv.Width);
                intent.PutExtra("IMGHEIGHT", yuv.Height);
                StartActivity(intent);
            };


            this.AddContentView(customLayout, layoutParams);
        }
Пример #6
0
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

			this.RequestWindowFeature(WindowFeatures.NoTitle);

			this.Window.AddFlags(WindowManagerFlags.Fullscreen); //to show
			this.Window.AddFlags(WindowManagerFlags.KeepScreenOn); //Don't go to sleep while scanning

			scanner = new ZxingSurfaceView(this);
			SetContentView(scanner);

			var layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);

			var customLayout = LayoutInflater.FromContext(this).Inflate(ZXing.YuvTool.Resource.Layout.Main, null);

			var buttonCapture = customLayout.FindViewById<Button>(ZXing.YuvTool.Resource.Id.MyButton);

			buttonCapture.Click += (sender, args) =>
				{
					var yuv = scanner.GetLastYuvImage();
					var width = scanner.GetLastWidth();
					var height = scanner.GetLastHeight();

					if (yuv == null)
						return;


					using (var stream = this.OpenFileOutput("YuvData.txt", FileCreationMode.WorldReadable))
					using (var sw = new System.IO.StreamWriter(stream))
					{
						sw.Write(Convert.ToBase64String(yuv.GetYuvData()));
						sw.WriteLine();
						sw.WriteLine("WIDTH=" + width + ", HEIGHT="+ height);
					}

					using (var stream = this.OpenFileOutput("YuvImage.jpg", FileCreationMode.WorldReadable))
					using (var sw = new System.IO.StreamWriter(stream))
					{
						yuv.CompressToJpeg(new Rect(0, 0, width, height), 100, stream);
					}

					var intent = new Intent(this, typeof (AnalyzeImageActivity));
					intent.PutExtra("IMGWIDTH", yuv.Width);
					intent.PutExtra("IMGHEIGHT", yuv.Height);
					StartActivity(intent);
				};
			
		
			this.AddContentView(customLayout, layoutParams);
		
		}
Пример #7
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);

			this.RequestWindowFeature (WindowFeatures.NoTitle);

			this.Window.AddFlags (WindowManagerFlags.Fullscreen); //to show
			this.Window.AddFlags (WindowManagerFlags.KeepScreenOn); //Don't go to sleep while scanning

			scanner = new ZxingSurfaceView (this, ScanningOptions);
			SetContentView (scanner);

			var layoutParams = new LinearLayout.LayoutParams (ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);

			if (!UseCustomView)
			{
				Console.WriteLine("ZXING MOBILE: Using Default Overlay");

				zxingOverlay = new ZxingOverlayView (this);
				zxingOverlay.TopText = TopText;
				zxingOverlay.BottomText = BottomText;

				this.AddContentView (zxingOverlay, layoutParams);
			}
			else if (CustomOverlayView != null)
			{
				Console.WriteLine("ZXING MOBILE: Using Default Overlay");

				this.AddContentView(CustomOverlayView, layoutParams);
			}

			OnCancelRequested += () => {
				this.CancelScan();
			};

			OnAutoFocusRequested += () => {
				this.AutoFocus();
			};

			OnTorchRequested += (bool on) => {
				this.SetTorch(on);
			};

		}
Пример #8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            this.RequestWindowFeature(WindowFeatures.NoTitle);

            this.Window.AddFlags(WindowManagerFlags.Fullscreen);              //to show
            this.Window.AddFlags(WindowManagerFlags.KeepScreenOn);            //Don't go to sleep while scanning

            scanner = new ZxingSurfaceView(this, ScanningOptions);
            SetContentView(scanner);

            var layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent);

            if (!UseCustomView)
            {
                Console.WriteLine("ZXING MOBILE: Using Default Overlay");

                zxingOverlay            = new ZxingOverlayView(this);
                zxingOverlay.TopText    = TopText;
                zxingOverlay.BottomText = BottomText;

                this.AddContentView(zxingOverlay, layoutParams);
            }
            else if (CustomOverlayView != null)
            {
                Console.WriteLine("ZXING MOBILE: Using Default Overlay");

                this.AddContentView(CustomOverlayView, layoutParams);
            }

            OnCancelRequested += () => {
                this.CancelScan();
            };

            OnAutoFocusRequested += () => {
                this.AutoFocus();
            };

            OnTorchRequested += (bool on) => {
                this.SetTorch(on);
            };
        }
        public override void ViewWillDisappear(bool animated)
        {
            base.ViewWillDisappear(animated);
			
			if (SurfaceView != null)
			{
                SurfaceView.StopWorker();
				SurfaceView.Dispose();
				SurfaceView = null;
			}
		
			if (_observer != null)
			{
				NSNotificationCenter.DefaultCenter.RemoveObserver(_observer);
				_observer.Dispose();
				_observer = null;
			}
		}
        public virtual void DismissViewController()
        {
			if (torch)
				ToggleTorch();

          	if (SurfaceView != null)
			{
                SurfaceView.StopWorker();
				SurfaceView.Dispose();
				SurfaceView = null;
			}

			if(_imageView!=null)
			{
				_imageView.RemoveFromSuperview();
				_imageView.Dispose();
				_imageView = null;
			}
			
			DismissModalViewControllerAnimated(true);
			
			
	    }