Created
December 12, 2013 21:30
-
-
Save philcleveland/7935821 to your computer and use it in GitHub Desktop.
Drag and drop with Rx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mouseDown = Observable.FromEventPattern<MouseButtonEventArgs>(this, "MouseDown") | |
.Select(x => x.EventArgs.GetPosition(this)); | |
var mouseUp = Observable.FromEventPattern<MouseButtonEventArgs>(this, "MouseUp") | |
.Select(x => x.EventArgs.GetPosition(this)); | |
var mouseMove = Observable.FromEventPattern<MouseEventArgs>(this, "MouseMove") | |
.Select(x => x.EventArgs.GetPosition(this)); | |
mouseMove.SkipUntil(mouseDown) | |
.TakeUntil(mouseUp) | |
.Subscribe(x => | |
{ | |
output.Text += string.Format("Drag&Drop yeah. {0}", x); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment