/// <summary> /// Initialize and start the camera preview /// </summary> public async Task InitializeAsync() { Status = "Starting camera..."; // Create a camera preview image source (from Imaging SDK) _cameraPreviewImageSource = new CameraPreviewImageSource(); await _cameraPreviewImageSource.InitializeAsync(string.Empty); var properties = await _cameraPreviewImageSource.StartPreviewAsync(); // Create a preview bitmap with the correct aspect ratio var width = 640.0; var height = (width / properties.Width) * properties.Height; var bitmap = new WriteableBitmap((int)width, (int)height); PreviewBitmap = bitmap; // Create a filter effect to be used with the source (no filters yet) _effect = new FilterEffect(_cameraPreviewImageSource); _writeableBitmapRenderer = new WriteableBitmapRenderer(_effect, _writeableBitmap); // Attach preview frame delegate _cameraPreviewImageSource.PreviewFrameAvailable += OnPreviewFrameAvailable; Status = _filterList[_index].Name; Initialized = true; NextFilterCommand.RaiseCanExecuteChanged(); PreviousFilterCommand.RaiseCanExecuteChanged(); }
public MainPageViewModel() { NextFilterCommand = new RelayCommand( () => { if (_index < _filterList.Count - 1) { _index++; _changeFilterRequest = true; NextFilterCommand.RaiseCanExecuteChanged(); PreviousFilterCommand.RaiseCanExecuteChanged(); } }, () => { return(Initialized && _index < _filterList.Count - 1); }); PreviousFilterCommand = new RelayCommand( () => { if (_index > 0) { _index--; _changeFilterRequest = true; NextFilterCommand.RaiseCanExecuteChanged(); PreviousFilterCommand.RaiseCanExecuteChanged(); } }, () => { return(Initialized && _index > 0); }); }