async public Task TextChanged(string lilypondText) { var sheetReaderFactory = new SheetReaderFactory(); var sheetReader = sheetReaderFactory.GetReader(".ly"); try { var sheet = await sheetReader.ReadFromStringAsync(lilypondText); var converter = new SheetToWPFConverter(); WPFStaffs.Clear(); WPFStaffs.AddRange(converter.ConvertSheet(sheet)); WPFStaffsChanged?.Invoke(this, new WPFStaffsEventArgs() { Symbols = WPFStaffs }); MidiSequence = GetSequenceFromWPFStaffs(); MidiSequenceChanged?.Invoke(this, new MidiSequenceEventArgs() { MidiSequence = MidiSequence }); } catch (Exception) { Messenger.Default.Send(new CurrentStateMessage() { State = "Error parsing lilypond" }); } }
private int _beatsPerBar; // Aantal beatnotes per maat. async public Task OpenFile(string fileName) { var sheetReaderFactory = new SheetReaderFactory(); var sheetWriterFactory = new SheetWriterFactory(); var sheetReader = sheetReaderFactory.GetReader(fileName); var converter = new SheetToWPFConverter(); var writer = sheetWriterFactory.GetWriter(".ly"); var sheet = await sheetReader.ReadFromFileAsync(); WPFStaffs.Clear(); WPFStaffs.AddRange(converter.ConvertSheet(sheet)); WPFStaffsChanged?.Invoke(this, new WPFStaffsEventArgs() { Symbols = WPFStaffs }); LilypondTextChanged?.Invoke(this, new LilypondEventArgs { LilypondText = await writer.WriteToString(sheet) }); MidiSequence = GetSequenceFromWPFStaffs(); MidiSequenceChanged?.Invoke(this, new MidiSequenceEventArgs() { MidiSequence = MidiSequence }); }