Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Chord"/> with the specified
        /// collection of notes.
        /// </summary>
        /// <param name="notes">Notes to combine into a chord.</param>
        /// <exception cref="ArgumentNullException"><paramref name="notes"/> is null.</exception>
        public Chord(IEnumerable <Note> notes)
        {
            ThrowIfArgument.IsNull(nameof(notes), notes);

            Notes = new NotesCollection(notes);
            Notes.CollectionChanged += OnNotesCollectionChanged;
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NotesManager"/> with the specified events
        /// collection and comparison delegate for events that have same time.
        /// </summary>
        /// <param name="eventsCollection"><see cref="EventsCollection"/> that holds note events to manage.</param>
        /// <param name="sameTimeEventsComparison">Delegate to compare events with the same absolute time.</param>
        /// <remarks>
        /// If the <paramref name="sameTimeEventsComparison"/> is not specified events with the same time
        /// will be placed into the underlying events collection in order of adding them through the manager.
        /// If you want to specify custom order of such events you need to specify appropriate comparison delegate.
        /// </remarks>
        /// <exception cref="ArgumentNullException"><paramref name="eventsCollection"/> is null.</exception>
        public NotesManager(EventsCollection eventsCollection, Comparison <MidiEvent> sameTimeEventsComparison = null)
        {
            ThrowIfArgument.IsNull(nameof(eventsCollection), eventsCollection);

            _timedEventsManager = eventsCollection.ManageTimedEvents(sameTimeEventsComparison);

            Notes = new NotesCollection(CreateNotes(_timedEventsManager.Events));
            Notes.CollectionChanged += OnNotesCollectionChanged;
        }
Esempio n. 3
0
        private void OnNotesCollectionChanged(NotesCollection collection, NotesCollectionChangedEventArgs args)
        {
            var addedNotes = args.AddedNotes;

            if (addedNotes != null)
            {
                _timedEventsManager.Events.Add(GetNotesTimedEvents(addedNotes));
            }

            var removedNotes = args.RemovedNotes;

            if (removedNotes != null)
            {
                _timedEventsManager.Events.Remove(GetNotesTimedEvents(removedNotes));
            }
        }
Esempio n. 4
0
        private void OnChordNotesCollectionChanged(NotesCollection collection, NotesCollectionChangedEventArgs args)
        {
            var addedNotes = args.AddedNotes;

            if (addedNotes != null)
            {
                AddNotes(addedNotes);
            }

            var removedNotes = args.RemovedNotes;

            if (removedNotes != null)
            {
                RemoveNotes(removedNotes);
            }
        }
Esempio n. 5
0
 private void OnNotesCollectionChanged(NotesCollection collection, NotesCollectionChangedEventArgs args)
 {
     NotesCollectionChanged?.Invoke(collection, args);
 }