Exemplo n.º 1
0
 public void DeleteNoteControl(NoteControl noteControl)
 {
     NoteCanvas.Children.Remove(noteControl);
     NoteControls.Remove(noteControl);
     if (noteControl.note != null)
     {
         Part.DeleteNote(noteControl.note);
     }
 }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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]);
            }
        }
Exemplo n.º 4
0
 public void Remove(NoteControl note)
 {
     NoteCanvas.Children.Remove(note);
 }