public bool Handle(IEnumerable <Key> keys, Piece piece) { foreach (var hotkey in _hotkeys) { var isHotkey = hotkey.Keys.All(keys.ToList().Contains); if (!isHotkey) { continue; } LilypondConverter lilypondConverter = new LilypondConverter(); LilypondText = lilypondConverter.Convert(piece); hotkey.Command.Piece = piece; hotkey.Command.LilypondText = LilypondText; hotkey.Command.execute(); Piece = hotkey.Command.Piece; LilypondText = hotkey.Command.LilypondText; return(true); } return(false); }
public void RenderStaffs() { LilypondConverter converter = new LilypondConverter(); string[] stringArray = Regex.Replace(mainVM.EditorText, @"\s+", " ").Split(' '); Track domainTrack = converter.CreateTrackFromStringParts(stringArray); ServiceLocator.Current.GetInstance <StaffsViewModel>().SetStaffs(new TrackConverter().ConvertToMusicalSymbols(domainTrack)); }
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 LilypondSaver() { _musicConverter = new LilypondConverter(); FilterName = "Lilypond"; Extension = ".ly"; }
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) { } } }
public SheetMusicSaver() { _musicConverter = new LilypondConverter(); FilterName = "Sheet music"; Extension = ".pdf"; }