Esempio n. 1
0
    private void ConfigCameraDevice(CameraDeviceSettings newSettings, bool creating)
    {
        if (!creating && (newSettings.cameraId != cameraDeviceSettings.cameraId ||
                          newSettings.videoImageSize != cameraDeviceSettings.videoImageSize))
        {
            cameraDeviceSettings = newSettings;
            if (enabled_)
            {
                DoDisable();
                DoEnable();
            }
        }
        else
        {
            if (creating || newSettings.focusMode != cameraDeviceSettings.focusMode)
            {
                var modes    = new smartar.FocusMode[32];
                var numModes = cameraDevice_.GetSupportedFocusMode(modes);
                modes = new ArraySegment <smartar.FocusMode>(modes, 0, numModes).Array;
                if (((System.Collections.Generic.IList <smartar.FocusMode>)modes).Contains(newSettings.focusMode))
                {
                    cameraDevice_.SetFocusMode(newSettings.focusMode);
                }
            }

            cameraDeviceSettings = newSettings;
        }
    }
        protected override void OnElementChanged(ElementChangedEventArgs <CameraView> e)
        {
            base.OnElementChanged(e);
            if (Control == null)
            {
                iosCameraView = new IOSCameraView(e.NewElement.DeviceOptions);
                SetNativeControl(iosCameraView);

                e.NewElement.TakePhoto = async(ratios) =>
                {
                    var imageArray = await iosCameraView.CapturePhoto();

                    return(imageArray);
                };

                e.NewElement.GetCameraDeviceSettings = () =>
                {
                    var zoomSettings = new CameraDeviceSettings()
                    {
                        MaxZoom     = iosCameraView.GetMaxZoom(),
                        MinZoom     = iosCameraView.GetMinZoom(),
                        CurrentZoom = iosCameraView.GetCurrentZoom()
                    };

                    return(zoomSettings);
                };
            }
        }