In WPF, I would like to subscribe to mouse position points only while holding the key. Then I want to set the captured points to the property only when the key is released (i.e., when I have a full set of captured points) and continue listening to the next up / down combination of keys to create another capture of mouse positions, etc.
My interpretation of the above is that I need to call the sequence when the key is down and stop accepting when the key is released, but I want OnNext to get a set of mouse points.
From a lot of reading (I'm new to Rx), I put together the following pseudo / real sample:
var keyDownSeq = Observable.FromEvent(...);
var keyUpSeq = Observable.FromEvent(...);
var mouseMoveSeq = Observable.FromEvent(...);
var mouseMovesWhileKeyDown = keyDownSeq
.Where(keyEventArgs => keyEventArgs.IsRepeat == false)
.Where(keyEventArgs => keyEventArgs.Key == Key.Space)
.Select(_ => mouseMoveSeq
.TakeUntil(keyUpSeq)
.ToList())
.Subscribe(listOfMousePoints => MyProperty = listOfMousePoints);
, , , , ? ToList(), , ?
Where ( () ), ?
.
Edit
, ?
- KeyDown Select()
- Reset null, KeyUpSeq
- KeyDownSeq, ,
- KeyUpSeq, KeyUp,
Rx ?