public void LoadLilypond() { LilypondLoader lilypondLoader = new LilypondLoader(); //lilypondLoader.FilePath = "C:\\Users\\Danielle\\Documents\\SourceTree projects\\DPA_Startup_Musicsheets\\DPA_Musicsheets\\Files\\Alle-eendjes-zwemmen-in-het-water.ly"; lilypondLoader.FilePath = "C:\\Users\\Danielle\\Documents\\SourceTree projects\\DPA_Startup_Musicsheets\\DPA_Musicsheets\\Files\\Twee-emmertjes-water-halen.ly"; Piece piece = lilypondLoader.Load(); string test = ""; }
public override void execute() { if (Piece == null) { return; } LilypondLoader lilypondLoader = new LilypondLoader(); lilypondLoader.IsFixingBars = true; var piece = lilypondLoader.LoadLilypond(LilypondText); var message = FileHelper.Instance.WriteFile(piece, _filter); if (message != null) { MessageBox.Show(message); } EventBus.Fire(new PieceSavedEvent()); }
public override void execute() { if (Loader == null) { return; } if (Loader is LilypondLoader) { LilypondLoader lilypondLoader = (LilypondLoader)Loader; lilypondLoader.IsFixingBars = true; Piece = lilypondLoader.Load(); } else { Piece = Loader.Load(); } EventBus.Fire(new PieceLoadedEvent(Piece)); }
public void insert(string text, int?position = null, bool convert = true) { var newText = LilypondText.Insert(position ?? SelectionStart, text); if (!convert) { LilypondText = newText; return; } try { Piece = new LilypondLoader().LoadLilypond(newText); LilypondText = new LilypondConverter().Convert(Piece); EventBus.Fire(new PieceChangedEvent(Piece)); } catch { LilypondText = newText; } }
public override void execute() { if (_fixAllBars) { try { // Fix bars LilypondLoader lilypondLoader = new LilypondLoader(); lilypondLoader.IsFixingBars = true; Piece = lilypondLoader.LoadLilypond(LilypondText); // Piece changed EventBus.Fire(new PieceChangedEvent(Piece)); } catch (Exception) { } } else { // Lilypond text of parts string begin = LilypondText.Substring(0, SelectionStart); string select = LilypondText.Substring(SelectionStart, SelectionLength); string end = LilypondText.Substring(SelectionStart + SelectionLength); // Regex string regexWithoutBar = "[a-gr][,']*[\\d][\\d]*[.]*[~]*"; // Matches int totalNotesBeginning = Regex.Matches(begin, regexWithoutBar).Count; int totalNotesSelection = Regex.Matches(select, regexWithoutBar).Count; int totalNotesEnding = Regex.Matches(end, regexWithoutBar).Count; // Fix all bars LilypondLoader lilypondLoader = new LilypondLoader(); lilypondLoader.IsFixingBars = true; LilypondConverter lilypondConverter = new LilypondConverter(); try { string lilypondTextWithoutBars = LilypondText.Replace("|", " ").Replace("\n", "\n ").Replace("\n ", "\n "); Piece = lilypondLoader.LoadLilypond(lilypondTextWithoutBars); string newLilypondText = lilypondConverter.Convert(Piece); // Matches renewed text MatchCollection matchesWithoutBar = Regex.Matches(newLilypondText, regexWithoutBar); int firstIndexSelection = matchesWithoutBar[totalNotesBeginning].Index; int firstIndexEnding = matchesWithoutBar[totalNotesBeginning + totalNotesSelection].Index; // Selection renewed text int selectionLength = firstIndexEnding - firstIndexSelection; string newSelectionText = newLilypondText.Substring(firstIndexSelection, selectionLength); // Combine old and new lilypond text LilypondText = begin + newSelectionText + end; lilypondLoader = new LilypondLoader(); Piece = lilypondLoader.LoadLilypond(LilypondText); // Piece changed EventBus.Fire(new PieceChangedEvent(Piece)); } catch (Exception) { } } }