-
-
Save atsushieno/b5c8beb54312f6452262 to your computer and use it in GitHub Desktop.
Xwt + Observable.FromEventPattern<T>()
This file contains 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
using System; | |
using System.Linq; | |
using Xwt; | |
using System.Reactive.Linq; | |
namespace CSharpReactiveXwt | |
{ | |
class MyWindow : Window | |
{ | |
public static void Main (string[] args) | |
{ | |
Application.Initialize (); | |
new MyWindow ().Show (); | |
Application.Run (); | |
} | |
public MyWindow () | |
{ | |
this.Closed += delegate { Application.Exit (); }; | |
var label = new Label (); | |
var f = new Xwt.Frame () { WidthRequest = 200, HeightRequest = 200 }; | |
var eo = Observable.FromEventPattern<MouseMovedEventArgs> (f, "MouseMoved") | |
//.Buffer (TimeSpan.FromSeconds (1)); | |
.Sample (TimeSpan.FromSeconds (1)); | |
//eo.Subscribe (v => Console.WriteLine (string.Join (";", v.Select (e => e.EventArgs).SelectMany (e => e.Position.ToString ())))); | |
eo.Subscribe (v => label.Text = v.EventArgs.Position.ToString ()); | |
var vb = new VBox (); vb.PackStart (f); vb.PackStart (label); | |
Content = vb; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment