private void OpenFile_Impl() { if (ConfirmSaveChanges() == ConfirmSaveResult.Cancel) { return; } string filename = services.OpenFileDialog("Open File", "Showlight XML files|*.xml"); if (filename is not null) { try { var showlightFile = ShowLights.Load(filename); Showlights.Clear(); foreach (var sl in showlightFile) { // Old versions of Toolkit have generated undefined notes if (sl.GetShowLightType() != ShowLightType.Undefined) { Showlights.AddOrUpdate(new ShowLightViewModel(sl)); } } ResetEditor(filename, clearShowlights: false); } catch (Exception ex) { services.ShowError("Opening the file failed:" + Environment.NewLine + ex.Message); } } }
private async Task SelectArrangement_Impl(ShowLightType type) { string filename = services.OpenFileDialog($"Select Rocksmith 2014 XML File For {type} Colors Generation", "Rocksmith 2014 XML files|*.xml"); if (filename is not null && await XmlHelper.ValidateRootElementAsync(filename, "song")) { ArrangementSelected = true; if (type == ShowLightType.Beam) { ArrangementForBeamsFilename = filename; if (string.IsNullOrEmpty(ArrangementForFogFilename)) { ArrangementForFogFilename = filename; } } else { ArrangementForFogFilename = filename; if (string.IsNullOrEmpty(ArrangementForBeamsFilename)) { ArrangementForBeamsFilename = filename; } } } }
/// <summary> /// Removes dynamic difficulty levels from the files the user chooses. /// </summary> private async Task RemoveDDImpl() { var fileNames = await services .OpenFileDialog( "Select RS2014 XML File(s) to Remove DD From", FileFilter.RSXmlFiles, multiSelect : true) .ConfigureAwait(false); if (fileNames?.Length > 0) { ShowInStatusbar("Removing DD..."); #if DEBUG Stopwatch stopwatch = Stopwatch.StartNew(); #endif await Task.Run(() => Parallel.ForEach( fileNames, new ParallelOptions { MaxDegreeOfParallelism = Math.Max(1, Environment.ProcessorCount / 4) }, async fn => { var arrangement = InstrumentalArrangement.Load(fn); await DDRemover.RemoveDD(arrangement, MatchPhrasesToSections, DeleteTranscriptionTrack).ConfigureAwait(false); string oldFileName = Path.GetFileName(fn); string newFileName = oldFileName.StartsWith("DDC_") ? oldFileName.Substring(4) : oldFileName; arrangement.Save(Path.Combine(Path.GetDirectoryName(fn) !, "NDD_" + newFileName)); })); string files = (fileNames.Length == 1) ? "File" : "Files"; string statusText = $"Removing DD completed. {files} saved with NDD_ prefix."; #if DEBUG statusText += " Elapsed: " + stopwatch.ElapsedMilliseconds; #endif ShowInStatusbar(statusText); } }