/// <summary> /// Executes the command. If the media represented by the <see cref="PlaybackManager"/> /// can be saved, asks the user for a path to the target file and /// copies the media. /// </summary> /// <param name="parameter">An <see cref="object"/></param> public async void Execute(object parameter) { ISavable SavableMedia = this.playbackManager as ISavable; #region Error checking if (SavableMedia == null) { return; } #endregion this.ViewModel.MenuVisible = false; string Filename = String.Empty; if (this.ShowSaveDialog(SavableMedia, out Filename)) { bool Result = false; Progress <LongOperationProgress> Progress = new Progress <LongOperationProgress>(); ProgressBarDialog.ProgressBarDialog dlg = new ProgressBarDialog.ProgressBarDialog( Title: "TomiSoft MP3 Player", Text: "Zene mentése...", Progress: Progress ); dlg.Show(); try { using (Stream s = File.OpenWrite(Filename)) { Result = await SavableMedia.SaveToAsync(s, Progress); } } catch (IOException) { Result = false; } dlg.Close(); if (!Result) { MessageBox.Show( caption: App.Name, messageBoxText: "A fájlt nem sikerült elmenteni.", button: MessageBoxButton.OK, icon: MessageBoxImage.Error ); } } }