Comments (5)
Thomas,
Do you want EventsCollection
to be something like ObservableCollection
that can notify subscribers about collection changing?
from drywetmidi.
Yes, I think so.
I‘m currently working on a midi-editor, based on your drywetmidi-library. I didn’t programmed since a lot of years, so a lot of things are unknown to me. I‘m currently using 2 datagridviews, in which I can show - in a human readable format - the events of a chunk. I implemented things like copy/paste/delete and Drag /drop. Also from one grid to the other. If an event of a chunk is deleted, and the other grid shows the same chunk, I need the possibility to be notified. (The Datagrids are encapsulated in a user-Control, I‘m currently filling the grids - and I‘m not using binding)
I yesterday did a test with binding: I added „..chunk.events.ToList()“ to the binding of a datagridview - the grid then shows 2 columns of the events: the type and the delta-time. But when I delete an entry of the events (from outside), the datagridview does not update....
I hope I could explane my needs 😉
from drywetmidi.
Thanks for explanation!
I think current implementation of EventsCollection
shouldn't be changed since notifying about changes can cause performance penalties. Instead you should use another collection classes dumping all events into them before binding to UI controls.
For example, you read a MIDI file and want to use events collection of first track chunk as binding source for your DataGridView
. In this case create dedicated collection class instance and copy all original events into it:
var originalEvents = trackChunk.Events;
var bindableCollection = new BindingList<MidiEvent>(originalEvents.ToList());
Then use bindableCollection
as binding source for UI control. When you are done with MIDI data in your MIDI editor, just replace all original events with those contained in the bindableCollection
:
originalEvents.Clear();
originalEvents.AddRange(bindableCollection);
Please let me know if it's worked.
from drywetmidi.
Sure, this will work, but....
I‘m currently working directly at the chunks and events from DryWetMIDI. I‘m also deleting, merging and creating new chunks. To use own collections means to use the chunks-classes only for serializing the midi file. That‘s a pity. And by the way: I‘m also using playback etc....
But as I wrote: Sure, I can do that...,
Thanks a lot!
Thomas
from drywetmidi.
Although you've closed the issue, let me explain why you should create appropriate collections on your side.
Different frameworks requires different interfaces to support changes notification. WinForms works with IBindingList
, WPF with INotifyCollectionChanged
, some other frameworks requires another interfaces (probably those are not a part of standard .NET class library). So it's a bad idea to implement them all.
Also data binding is a concept related to MVVM, where there is a separation between data and UI. DryWetMIDI provides a layer that relates to data (model in terms of MVVM). Interaction with UI is absolutely up to user of the library.
from drywetmidi.
Related Issues (20)
- Remove all notes example from the README not working HOT 9
- Using wetdrymidi in C# project causes error CS0009
- InputDevice event listening crash HOT 2
- Crash when running in Unity on M2 MacBook HOT 3
- MidiDeviceException Internal error HOT 9
- Android Support
- Unity cannot exit after use HOT 10
- MidiClock sync problem HOT 6
- MIDI Tempo changes count returns 1 but the song has 6 tempo changes. HOT 1
- add il2cpp mode HOT 5
- CustomChunk no mididata throw error HOT 4
- CSharp Code Error HOT 2
- MIDI File returns error: InvalidMetaEventParameterValueException HOT 1
- Unable to send Note-On event to device HOT 8
- Cannot get track name to change HOT 10
- How to use DryWetMidi in Visual Basic (VS 2022) ? HOT 20
- Plans for MIDI 2.0 Support? HOT 2
- Skipping notes HOT 5
- Playback Loop=True skips empty steps in the end of a Pattern HOT 2
- Syncing multiple Playbacks HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drywetmidi.