private async Task SearchConfigAsync() { try { _isSearching = true; var disks = await Task.Run(() => DiskSearcher.Search()); foreach (var disk in disks.Where(x => x.CanBeSD).OrderBy(x => x.PhysicalDrive)) { var configNew = new ConfigViewModel(); if (!await configNew.ReadAsync(disk)) { continue; } CurrentConfig = configNew; OperationStatus = Resources.OperationStatus_Found; return; } CurrentConfig = null; OperationStatus = Resources.OperationStatus_No; } finally { _isSearching = false; DelegateCommand.RaiseCanExecuteChanged(); } }
private async Task ApplyConfigAsync() { isApplying = true; var configNew = new ConfigViewModel(); if (!await configNew.ReadAsync(CurrentConfig.AssociatedDisk) || (configNew.CID != CurrentConfig.CID)) { SystemSounds.Hand.Play(); OperationStatus = "FlashAir seems changed."; return; } try { await CurrentConfig.WriteAsync(); SystemSounds.Asterisk.Play(); OperationStatus = "Applied new config."; } catch (Exception ex) { SystemSounds.Hand.Play(); OperationStatus = "Failed to apply new config."; Debug.WriteLine("Failed to apply new config. {0}", ex); } finally { isApplying = false; DelegateCommand.RaiseCanExecuteChanged(); } }
private async Task SearchConfigAsync() { isSearching = true; try { var drives = await Task.Run(() => DiskSearcher.Search()); foreach (var drive in drives.Where(x => x.CanBeSD).OrderBy(x => x.PhysicalDrive)) { var configNew = new ConfigViewModel(); if (!await configNew.ReadAsync(drive)) { continue; } CurrentConfig = configNew; OperationStatus = "Found FlashAir."; return; } CurrentConfig = null; OperationStatus = "No FlashAir."; } finally { isSearching = false; DelegateCommand.RaiseCanExecuteChanged(); } }
private async Task ApplyConfigAsync() { try { _isApplying = true; var configNew = new ConfigViewModel(); if (!await configNew.ReadAsync(CurrentConfig.AssociatedDisk) || (configNew.CID != CurrentConfig.CID)) { SystemSounds.Hand.Play(); OperationStatus = Resources.OperationStatus_Changed; return; } try { await CurrentConfig.WriteAsync(); SystemSounds.Asterisk.Play(); OperationStatus = Resources.OperationStatus_Applied; } catch (Exception ex) { SystemSounds.Hand.Play(); OperationStatus = Resources.OperationStatus_Failed; Debug.WriteLine($"Failed to apply new config.\r\n{ex}"); } } finally { _isApplying = false; DelegateCommand.RaiseCanExecuteChanged(); } }
private async Task ApplyConfigAsync() { try { _isApplying = true; var configNew = new ConfigViewModel(); if (!await configNew.ReadAsync(CurrentConfig.AssociatedDisk) || (configNew.CID != CurrentConfig.CID)) { SystemSounds.Hand.Play(); OperationStatus = Resources.OperationStatus_Changed; return; } try { await CurrentConfig.WriteAsync(); SystemSounds.Asterisk.Play(); OperationStatus = Resources.OperationStatus_Applied; } catch (Exception ex) { SystemSounds.Hand.Play(); OperationStatus = Resources.OperationStatus_Failed; Debug.WriteLine("Failed to apply new config. {0}", ex); } } finally { _isApplying = false; DelegateCommand.RaiseCanExecuteChanged(); } }
private async Task SearchConfigAsync() { try { _isSearching = true; var drives = await Task.Run(() => DiskSearcher.Search()); foreach (var drive in drives.Where(x => x.CanBeSD).OrderBy(x => x.PhysicalDrive)) { var configNew = new ConfigViewModel(); if (!await configNew.ReadAsync(drive)) continue; CurrentConfig = configNew; OperationStatus = Resources.OperationStatus_Found; return; } CurrentConfig = null; OperationStatus = Resources.OperationStatus_No; } finally { _isSearching = false; DelegateCommand.RaiseCanExecuteChanged(); } }