Binding a cursor to a time source

Jan 20, 2013 at 4:39 PM

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.

Jan 22, 2013 at 8:34 AM

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.

Jan 22, 2013 at 9:50 AM

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.