Created
October 19, 2010 09:11
-
-
Save cryks/633896 to your computer and use it in GitHub Desktop.
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
private void Form1_Load(object sender, EventArgs e) { | |
var down = Observable.FromEvent<MouseEventArgs>(this, "MouseDown"); | |
var move = Observable.FromEvent<MouseEventArgs>(this, "MouseMove"); | |
var up = Observable.FromEvent<MouseEventArgs>(this, "MouseUp"); | |
var diff = move | |
.SkipUntil(down) | |
.TakeUntil(up) | |
.Let(m => m.Zip(m.Skip(1), (l, r) => new { Left = l, Right = r })) | |
.Repeat() | |
; | |
Graphics g = this.CreateGraphics(); | |
diff.Subscribe(d => g.DrawLine(Pens.Blue, d.Left.EventArgs.Location, d.Right.EventArgs.Location)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment