/// <summary> /// Checks with the use if this window can be closed. /// </summary> /// <returns> /// Returns true if the window can be closed. /// </returns> public bool CanClose() { IQueueService processor = IoC.Get <IQueueService>(); if (processor != null && processor.IsEncoding) { MessageBoxResult result = this.errorService.ShowMessageBox( Resources.ShellViewModel_CanClose, Resources.Warning, MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { processor.Stop(); this.MainViewModel?.Shutdown(); return(true); } return(false); } this.OptionsViewModel?.Close(); this.MainViewModel?.Shutdown(); return(true); }
/// <summary> /// Recover a queue from file. /// </summary> /// <param name="encodeQueue"> /// The encode Queue. /// </param> /// <param name="errorService"> /// The error Service. /// </param> /// <param name="silentRecovery"> /// The silent Recovery. /// </param> /// <param name="queueFilter"> /// The queue Filter. /// </param> /// <returns> /// The <see cref="bool"/>. /// </returns> public static bool RecoverQueue(IQueueService encodeQueue, IErrorService errorService, bool silentRecovery, List <string> queueFilter) { string appDataPath = DirectoryUtilities.GetUserStoragePath(VersionHelper.IsNightly()); List <string> queueFiles = CheckQueueRecovery(queueFilter); MessageBoxResult result = MessageBoxResult.None; if (!silentRecovery) { if (queueFiles.Count == 1) { result = errorService.ShowMessageBox( Properties.Resources.Queue_RecoverQueueQuestionSingular, Properties.Resources.Queue_RecoveryPossible, MessageBoxButton.YesNo, MessageBoxImage.Question); } else if (queueFiles.Count > 1) { result = errorService.ShowMessageBox( Properties.Resources.Queue_RecoverQueueQuestionPlural, Properties.Resources.Queue_RecoveryPossible, MessageBoxButton.YesNo, MessageBoxImage.Question); } } else { result = MessageBoxResult.Yes; } if (result == MessageBoxResult.Yes) { bool isRecovered = false; foreach (string file in queueFiles) { // Recover the Queue encodeQueue.RestoreQueue(Path.Combine(appDataPath, file)); isRecovered = true; // Cleanup CleanupFiles(new List <string> { file }, false); } return(isRecovered); } CleanupFiles(queueFiles, true); return(false); }