PianoKeyboard | A Piano Keyboard implemented in Swift | Keyboard library
kandi X-RAY | PianoKeyboard Summary
kandi X-RAY | PianoKeyboard Summary
A Piano Keyboard implemented in Swift
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of PianoKeyboard
PianoKeyboard Key Features
PianoKeyboard Examples and Code Snippets
Community Discussions
Trending Discussions on PianoKeyboard
QUESTION
I am trying to use the WPF Grid as an ItemsControl using attached properties for the purposes of creating a scalable Piano Keyboard. Each key in the keyboard may span 1 to three columns depending upon what precedes and succeeds it and will span 1 row if sharp or 2 if natural. I already have 2 attached properties for setting the Grid's Column Count and Row Count dynamically (albeit these will need to be adjusted to support the setting of each column/row's width/height).
What I now need to implement are two attachable properties for the ItemsSource
(Keys) and the ItemTemplate
(PianoKeyView). I need to use this on the Grid control because ItemsControl
only supports UniformGrid
as a Grid for its ItemsPanel
and also doesn't assignment of specific items to specific columns/rows. My Piano Keyboard would require 17 columns per octave of keys but an ItemsControl would only create 12 columns in a UniformGrid
as there would only be 12 keys passed to it. I have included an image of a 1-octave Piano Keyboard with the index of each required column included.
This is my code for the keyboard as it currently stands, I am missing the implementation for GridExtensions.ItemsSource
and GridExtensions.ItemTemplate
. GridExtensions
is a static class containing attachable properties.
ANSWER
Answered 2017-Nov-06 at 18:23What I was trying to achieve with the Grid
directly could be achieved with an ItemsControl
with an ItemsPanel
of Grid
.
It turns out the missing piece that was needed was a Style
with a TargetType
of ContentPresenter
. In this style, the attachable Grid
properties such as Grid.RowSpan
, Grid.Column
and Grid.ColumnSpan
are settable via the appropriate converters which take in the ItemsControl and Key's DataContext and return the required integer. The Z-Index of the keys is also settable here so that the sharp keys appear above the natural keys.
QUESTION
This is totally mysterious. I checked everything, googled everything, but looks like this should work. I've done same things in my code with others html elements and they all give me the values, but this time I'm getting undefined for this particular HTML element. The snippet of code below:
...ANSWER
Answered 2017-Aug-13 at 19:57That is because
value
attribute. It is only for a selected subset of elements:
,
,
,
,
,
, and
.
You can store the value as a HTML5 data-
attribute, i.e.:
QUESTION
I am trying to write a XAML control for a Piano Keyboard in WPF which responds to NoteOn and NoteOff MIDI events from an external MIDI keyboard. I am using Tom Lokovic's midi-dot-net to raise NoteOn and NoteOff events triggered by the hardware but I need a way to get these events to raise the NoteOn and NoteOff events of my XAML Key class (derived from the WPF Button). The colour of a key should change when it is on and the event should be subscribable to so that a user of the Piano Keyboard control can play a sound the key is pressed.
I could do this by passing every Midi.InputDevice to every single key on the keyboard so that each one can subscribe to the NoteOn and NoteOff events of every InputDevice then, in turn raise their own NoteOn and NoteOff events but the problem with this is that the PianoKeyboard control (an ItemsControl which holds Keys) and its nested Key controls all become tightly coupled to the implementation of midi-dot-net. If I have to do this I will, but it seemed like there should be a better way of doing this in WPF moving the dependency on midi-dot-net higher up in the call stack.
I have too much code to paste in its entirety here and still be readable so here's a sample of one of the DataTemplates I'm using as my PianoKeyboard's ItemTemplate.
Essentially what I'm asking is: given an input device is not supported to trigger a WPF button with the button's built in behaviour (e.g. a mouse click), how does one get it to trigger the button without coupling it to a derived class of the button?
...ANSWER
Answered 2017-Apr-18 at 12:17You could raise the Click
event programmatically:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install PianoKeyboard
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page