Binding a cursor to a time source

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

drakesmith wrote at 2013-01-20 17:39:

I have created an audio waveform plot for a .wav player application. So far, OxyPlot has been fantastic for that. I use a vertical line annotation whose X position is bound to the playback position to track media position within the waveform. The position is updated every 100mS and the cursor looks great. The problem is that changing LineAnnotation.X at that rate uses 100% CPU.

Is there a better way to create a vertical position marker? A custom tracker seems close, but I want the cursor to move independently of the mouse. I don’t need any text or fancy graphic or mouse interaction, just a thin vertical cursor that overlays the plot.

Thank you.


objo wrote at 2013-01-22 09:34:

Yes, the whole model will be redrawn when changing an annotation. Check that you are not invalidating the data, no need to refresh data bindings when changing an annotation. Also see the Performance section under documentation.

In WPF, you could draw the cursor line in a canvas overlay above the plot control - subscribe to the axis changed events and use the transform methods on the axes to get the correct positions.


drakesmith wrote at 2013-01-22 10:50:

Thanks objo, your recommendation to use a canvas overlay is a reasonable workaround.

I will document those details and submit them back to you for inclusion in your documentation if you so choose.