Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPageViewModel"/> class.
        /// </summary>
        /// <param name="navigationService">Navigation service.</param>
        /// <param name="cameraProvider">Camera provider.</param>
        /// <param name="storageService">Phone storage service.</param>
        /// <param name="settingsProvider">Settings provider.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="navigationService"/> is <see langword="null"/>.
        ///     <para>-or-</para>
        /// <paramref name="cameraProvider"/> is <see langword="null"/>.
        ///     <para>-or-</para>
        /// <paramref name="storageService"/> is <see langword="null"/>.
        ///     <para>-or-</para>
        /// <paramref name="settingsProvider"/> is <see langword="null"/>.
        /// </exception>
        public MainPageViewModel(INavigationService navigationService, ICameraProvider cameraProvider, IStorageService storageService, ISettingsProvider settingsProvider)
        {
            if (navigationService == null)
            {
                throw new ArgumentNullException("navigationService");
            }

            if (cameraProvider == null)
            {
                throw new ArgumentNullException("cameraProvider");
            }

            if (storageService == null)
            {
                throw new ArgumentNullException("storageService");
            }

            if (settingsProvider == null)
            {
                throw new ArgumentNullException("settingsProvider");
            }

            this.navigationService   = navigationService;
            this.cameraProvider      = cameraProvider;
            this.storageService      = storageService;
            this.settingsProvider    = settingsProvider;
            this.items               = new ObservableCollection <object>();
            this.state               = MainPageViewModelState.Unloaded;
            this.applicationSettings = settingsProvider.GetApplicationSettings();
            this.cameraSettings      = settingsProvider.GetCameraSettings(this.applicationSettings.CameraType);
        }
Exemplo n.º 2
0
 public DeviceRootDeviceManager(ICameraSettings cameraSettings,
                                IHSApplication HS,
                                CancellationToken cancellationToken)
 {
     this.HS = HS;
     this.cancellationToken = cancellationToken;
     CameraSettings         = cameraSettings;
     GetCurrentDevices();
     CreateParentDevice();
 }
Exemplo n.º 3
0
        public CameraManager(IHSApplication HS,
                             ICameraSettings cameraSettings,
                             CancellationToken shutdownDownToken)
        {
            this.HS           = HS;
            CameraSettings    = cameraSettings;
            cancelTokenSource = new CombinedCancelToken(shutdownDownToken);
            rootDeviceData    = new DeviceRootDeviceManager(cameraSettings, this.HS, cancelTokenSource.Token);
            camera            = cameraSettings.CreateCamera(shutdownDownToken);

            TaskHelper.StartAsyncWithErrorChecking(Invariant($"{cameraSettings.Name} Process Updates"),
                                                   ProcessUpdates, cancelTokenSource.Token);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Loads camera device, if needed.
        /// </summary>
        /// <param name="areaSize">The size of the area available for the video preview.</param>
        /// <returns>Awaitable task.</returns>
        public async Task EnsureCameraLoadedAsync(Size areaSize)
        {
            if (this.camera != null)
            {
                // Make sure the the correct camera is loaded.
                if (this.camera.CameraType == this.CameraType && this.State != MainPageViewModelState.Unloaded)
                {
                    Tracing.Trace("MainPageViewModel: {0} camera is already loaded.", this.CameraType);
                    return;
                }

                await this.UnloadCameraAsync();
            }

            this.State = MainPageViewModelState.Loading;

            this.camera = await this.cameraProvider.GetCameraAsync(this.CameraType);

            this.cameraSettings     = this.settingsProvider.GetCameraSettings(this.CameraType);
            this.camera.Orientation = this.orientation;
            this.previewAreaSize    = areaSize;

            await this.camera.LoadCameraAsync();

            await this.StartPreviewAsync(this.previewAreaSize);

            // Allow camera to automatically focus without user requests, if supported.
            await this.TryToEnableContinuousAutoFocusAsync();

            this.camera.FocusChanged   += this.CameraOnFocusChanged;
            this.camera.PhotoCaptured  += this.CameraOnPhotoCaptured;
            this.camera.CaptureStopped += this.CameraOnCaptureStopped;

            this.PreviewSize    = this.camera.PreviewSize;
            this.PreviewBrush   = this.camera.PreviewBrush;
            this.FlashSupported = this.camera.FlashSupported;

            await this.UpdatePhotoCaptureAsync();

            this.State = MainPageViewModelState.Loaded;

            EventHandler handler = this.CameraLoaded;

            if (handler != null)
            {
                handler.Invoke(this, EventArgs.Empty);
            }
        }
Exemplo n.º 5
0
 public override void SetOnDeviceCreateData(IHSApplication HS, ICameraSettings cameraSettings, int refID)
 {
     HS.set_DeviceInvalidValue(refID, false);
     HS.SetDeviceString(refID, "Root", false);
 }
Exemplo n.º 6
0
 public override void OnPlugInLoad(IHSApplication HS, ICameraSettings cameraSettings)
 {
     // Method intentionally left empty.
 }
Exemplo n.º 7
0
        /// <summary>
        /// Loads camera device, if needed.
        /// </summary>
        /// <param name="areaSize">The size of the area available for the video preview.</param>
        /// <returns>Awaitable task.</returns>
        public async Task EnsureCameraLoadedAsync(Size areaSize)
        {
            if (this.camera != null)
            {
                // Make sure the the correct camera is loaded.
                if (this.camera.CameraType == this.CameraType && this.State != MainPageViewModelState.Unloaded)
                {
                    Tracing.Trace("MainPageViewModel: {0} camera is already loaded.", this.CameraType);
                    return;
                }

                await this.UnloadCameraAsync();
            }

            this.State = MainPageViewModelState.Loading;

            this.camera             = await this.cameraProvider.GetCameraAsync(this.CameraType);
            this.cameraSettings     = this.settingsProvider.GetCameraSettings(this.CameraType);
            this.camera.Orientation = this.orientation;
            this.previewAreaSize    = areaSize;

            await this.camera.LoadCameraAsync();
            await this.StartPreviewAsync(this.previewAreaSize);

            // Allow camera to automatically focus without user requests, if supported.
            await this.TryToEnableContinuousAutoFocusAsync();

            this.camera.FocusChanged   += this.CameraOnFocusChanged;
            this.camera.PhotoCaptured  += this.CameraOnPhotoCaptured;
            this.camera.CaptureStopped += this.CameraOnCaptureStopped;

            this.PreviewSize    = this.camera.PreviewSize;
            this.PreviewBrush   = this.camera.PreviewBrush;
            this.FlashSupported = this.camera.FlashSupported;

            await this.UpdatePhotoCaptureAsync();

            this.State = MainPageViewModelState.Loaded;

            EventHandler handler = this.CameraLoaded;
            if (handler != null)
            {
                handler.Invoke(this, EventArgs.Empty);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MainPageViewModel"/> class.
        /// </summary>
        /// <param name="navigationService">Navigation service.</param>
        /// <param name="cameraProvider">Camera provider.</param>
        /// <param name="storageService">Phone storage service.</param>
        /// <param name="settingsProvider">Settings provider.</param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="navigationService"/> is <see langword="null"/>.
        ///     <para>-or-</para>
        /// <paramref name="cameraProvider"/> is <see langword="null"/>.
        ///     <para>-or-</para>
        /// <paramref name="storageService"/> is <see langword="null"/>.
        ///     <para>-or-</para>
        /// <paramref name="settingsProvider"/> is <see langword="null"/>.
        /// </exception>
        public MainPageViewModel(INavigationService navigationService, ICameraProvider cameraProvider, IStorageService storageService, ISettingsProvider settingsProvider)
        {
            if (navigationService == null)
            {
                throw new ArgumentNullException("navigationService");
            }

            if (cameraProvider == null)
            {
                throw new ArgumentNullException("cameraProvider");
            }

            if (storageService == null)
            {
                throw new ArgumentNullException("storageService");
            }

            if (settingsProvider == null)
            {
                throw new ArgumentNullException("settingsProvider");
            }

            this.navigationService   = navigationService;
            this.cameraProvider      = cameraProvider;
            this.storageService      = storageService;
            this.settingsProvider    = settingsProvider;
            this.items               = new ObservableCollection<object>();
            this.state               = MainPageViewModelState.Unloaded;
            this.applicationSettings = settingsProvider.GetApplicationSettings();
            this.cameraSettings      = settingsProvider.GetCameraSettings(this.applicationSettings.CameraType);
        }
Exemplo n.º 9
0
 public virtual void SetOnDeviceCreateData(IHSApplication HS, ICameraSettings cameraSettings, int refId)
 {
     HS.SetDeviceValueByRef(refId, 0D, false);
     HS.set_DeviceInvalidValue(refId, true);
 }
Exemplo n.º 10
0
 public virtual void OnPlugInLoad(IHSApplication HS, ICameraSettings cameraSettings)
 {
 }