private void MenuSongsCreate_Click(object sender, EventArgs e) { SongData song = new SongData(Storage); FormatData data = new TemporaryFormatData(song, Storage); if (EditForm.Show(data, true, true, this) != DialogResult.Cancel) { Progress.QueueTask(progress => { progress.NewTask("Installing \"" + data.Song.Name + "\" locally", 2); FormatData localdata = PlatformLocalStorage.Instance.CreateSong(Storage, data.Song); data.SaveTo(localdata); data.Dispose(); progress.Progress(); PlatformLocalStorage.Instance.SaveSong(Storage, localdata, progress); progress.Progress(); UpdateSongList(); progress.EndTask(); }); } else { data.Dispose(); } }
private void QueueInstallLocal(FormatData data) { Progress.QueueTask(progress => { progress.NewTask("Ripping \"" + data.Song.Name + "\" locally", 16); FormatData destination = PlatformLocalStorage.Instance.CreateSong(Storage, data.Song); progress.SetNextWeight(14); try { bool audio = false; if (Configuration.LocalTranscode && !data.Formats.Contains(AudioFormatRB2Mogg.Instance) && !data.Formats.Contains(AudioFormatRB2Bink.Instance)) { TaskMutex.WaitOne(); TemporaryFormatData olddata = new TemporaryFormatData(data.Song, data.PlatformData); data.SaveTo(olddata, FormatType.Audio); data.SaveTo(olddata, FormatType.Metadata); TaskMutex.ReleaseMutex(); audio = true; try { Platform.Transcode(FormatType.Audio, olddata, new IFormat[] { AudioFormatRB2Mogg.Instance }, destination, progress); } catch (UnsupportedTranscodeException exception) { Exceptions.Warning(exception, "Transcoding audio from " + data.Song.Name + " to Rock Band 2 format failed."); } olddata.Dispose(); } progress.Progress(14); TaskMutex.WaitOne(); if (!audio) { data.SaveTo(destination); } else { data.SaveTo(destination, FormatType.Chart); data.SaveTo(destination, FormatType.Metadata); } TaskMutex.ReleaseMutex(); progress.Progress(); PlatformLocalStorage.Instance.SaveSong(Storage, destination, progress); } catch (Exception ex) { PlatformLocalStorage.Instance.DeleteSong(Storage, destination, progress); throw new Exception("An error occurred when installing " + data.Song.Name + " locally.", ex); } progress.Progress(); UpdateSongList(); progress.EndTask(); }); }