Giter Club home page Giter Club logo

Comments (5)

melanchall avatar melanchall commented on June 19, 2024

Thomas,

Do you want EventsCollection to be something like ObservableCollection that can notify subscribers about collection changing?

from drywetmidi.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

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.

melanchall avatar melanchall commented on June 19, 2024

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.

FischertBilligheim avatar FischertBilligheim commented on June 19, 2024

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.

melanchall avatar melanchall commented on June 19, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.