public MainViewModel(INavigationService navigationService, IDialogService dialogService, IBluetoothLeService bluetoothLeService) { this.navigationService = navigationService; this.dialogService = dialogService; this.bluetoothLeService = bluetoothLeService; exposureTimeOptions = new ObservableCollection <ExposureTime>(ExposureTime.Times); exposureTime = exposureTimeOptions.FirstOrDefault(e => e.Milliseconds == 8); }
public ConfigurationViewModel(IDialogService dialogService, IBluetoothLeService bluetoothLeService) { this.dialogService = dialogService; this.bluetoothLeService = bluetoothLeService; exposureTimeOptions = new ObservableCollection <ExposureTime>(ExposureTime.Times); directionOptions = new ObservableCollection <SliderDirection>(Enum.GetValues(typeof(SliderDirection)).Cast <SliderDirection>()); // Set defaults exposureTime = exposureTimeOptions.FirstOrDefault(e => e.Milliseconds == 8); direction = directionOptions.FirstOrDefault(); totalSteps = 10000; numberOfShots = 10; Interval = 5; }
async void SaveImageMethod() { //Setup metadata. var metaData = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>( "Format", "png" ), new KeyValuePair <string, string>( "Application Name", "Reconstruction and Calibration Tool (UWP)" ), new KeyValuePair <string, string>( "Camera Manufacturer", "Centice" ), new KeyValuePair <string, string>( "Exposure Time", ExposureTime.ToString() ), new KeyValuePair <string, string>( "Laser enabled", IsLaserChecked.ToString() ), new KeyValuePair <string, string>( "Values scaled", IsScaledChecked.ToString() ), new KeyValuePair <string, string>( "Min value", MinValue ), new KeyValuePair <string, string>( "Max value", MaxValue ) }; if (SaveAmount == 1) { var saveFileSettings = new FileSavePickerSettings { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, FileTypeChoices = new Dictionary <string, IList <string> > { { "PNG Images", new List <string> { ".png" } } }, DefaultFileExtension = ".png" }; StorageFile storageFile = await _dialogService.PickSaveFileAsync(saveFileSettings); if (storageFile != null) { StorageFile img = await Imaging.WriteableBitmapToStorageFile(_lastImageArray, IsScaledChecked, metaData); await img.CopyAndReplaceAsync(storageFile); } } else { //Disable Buttons. SaveImageButtonEnabled = false; GetImageButtonEnabled = false; //Get folder to save imgs. var folderPickerSettings = new FolderPickerSettings { SuggestedStartLocation = PickerLocationId.DocumentsLibrary, FileTypeFilter = new List <string> { ".png" } }; StorageFolder storageFolder = await _dialogService.PickSingleFolderAsync(folderPickerSettings); //GetImage, Save, Loop. for (uint i = 0; i < SaveAmount; i++) { try { Image = await GetImageFromCamera(); } catch (Exception) { // ignored } StorageFile img = await Imaging.WriteableBitmapToStorageFile(_lastImageArray, IsScaledChecked, metaData); string strDateTime = DateTime.Now.ToString("yyyyMMdd-HHmmss-"); await img.CopyAsync(storageFolder, strDateTime + "img" + i + ".png"); } SaveImageButtonEnabled = true; GetImageButtonEnabled = true; } }
public override string ToString() { return(TotalExposureCount.ToString() + "x" + ExposureTime.ToString() + " " + ImageType); }