public void DeleteNoteControl(NoteControl noteControl) { NoteCanvas.Children.Remove(noteControl); NoteControls.Remove(noteControl); if (noteControl.note != null) { Part.DeleteNote(noteControl.note); } }
private void MakeNote(NoteControl noteControl, int noteNumber, long startTime, int duration) { var top = MusicMath.Current.GetNoteYPosition(noteNumber); var left = MusicMath.Current.GetNoteXPosition(startTime); noteControl.Width = duration * Settings.Current.xScale; noteControl.grid.RowDefinitions[1].Height = new GridLength(Settings.Current.yScale); noteControl.SetValue(Canvas.TopProperty, top); noteControl.SetValue(Canvas.LeftProperty, left); }
public void DrawNotes() { // BUG: crash when open another project if (NoteCanvas.Children.Count != NoteControls.Count) { throw new Exception(); } if (Part == null) { return; } var i = 0; foreach (var note in Part.Notes) { NoteControl noteControl; if (i < NoteControls.Count) { noteControl = NoteControls[i]; } else { noteControl = new NoteControl(this); NoteCanvas.Children.Add(noteControl); NoteControls.Add(noteControl); noteControl.OnNoteDeleted += DeleteNoteControl; } MakeNote(noteControl, note.NoteNum, note.FinalPosition, note.FinalLength); lastPosition = Math.Max(lastPosition, lastPosition + note.FinalLength); note.SetNoteControl(noteControl); i++; } while (i < NoteControls.Count) { NoteControls[i].note = null; // now may refer to a note from different noteControl DeleteNoteControl(NoteControls[i]); } }
public void Remove(NoteControl note) { NoteCanvas.Children.Remove(note); }