예제 #1
0
        protected override void OnCreate(Bundle savedInstance)
        {
            base.OnCreate(savedInstance);
            SetContentView(R.Layout.MainLayout);

            var camera        = GetCamera();
            var preview       = FindViewById <FrameLayout>(R.Id.preview);
            var captureButton = FindViewById <Button>(R.Id.captureButton);
            var previewButton = FindViewById <Button>(R.Id.previewButton);

            if (camera != null)
            {
                var cameraPreview = new CameraPreview(this, camera);
                preview.AddView(cameraPreview);
                previewButton.Visibility = View.INVISIBLE;
                captureButton.Click     += (s, x) => {
                    camera.TakePicture(null, null, new PictureCallback());
                    previewButton.Visibility = View.VISIBLE;
                };
                previewButton.Click += (s, x) => {
                    camera.StartPreview();
                    previewButton.Visibility = View.INVISIBLE;
                };
            }
            else
            {
                preview.AddView(new TextView(this)
                {
                    Text = "No camera found"
                });
                captureButton.Visibility = View.INVISIBLE;
                previewButton.Visibility = View.INVISIBLE;
            }
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstance)
        {
            base.OnCreate(savedInstance);
            SetContentView(R.Layouts.MainLayout);

            var camera = GetCamera();
            var preview = FindViewById<FrameLayout>(R.Ids.preview);
            var captureButton = FindViewById<Button>(R.Ids.captureButton);
            var previewButton = FindViewById<Button>(R.Ids.previewButton);

            if (camera != null)
            {
                var cameraPreview = new CameraPreview(this, camera);
                preview.AddView(cameraPreview);
                previewButton.Visibility = View.INVISIBLE;
                captureButton.Click += (s, x) => {
                    camera.TakePicture(null, null, new PictureCallback());
                    previewButton.Visibility = View.VISIBLE;
                };
                previewButton.Click += (s, x) => {
                    camera.StartPreview();
                    previewButton.Visibility = View.INVISIBLE;
                };
            }
            else
            {
                preview.AddView(new TextView(this) { Text = "No camera found" });
                captureButton.Visibility = View.INVISIBLE;
                previewButton.Visibility = View.INVISIBLE;
            }
        }