Debian Codegraph @

external/rx/Rx/NET/Samples/HOL/CS/Excercise3/Step06/Program.cs

raw
1 using System;
2 using System.Reactive.Linq;
3 using System.Windows.Forms;
4 using System.Reactive.Disposables;
5
6 namespace Excercise3
7 {
8 class Program
9 {
10 static void Main()
11 {
12 var txt = new TextBox();
13
14 var frm = new Form()
15 {
16 Controls = { txt }
17 };
18
19 var moves = Observable.FromEventPattern<MouseEventArgs>(frm, "MouseMove");
20 var input = Observable.FromEventPattern(txt, "TextChanged");
21
22 var moveSubscription = moves.Subscribe(evt =>
23 {
24 Console.WriteLine("Mouse at: " + evt.EventArgs.Location);
25 });
26
27 var inputSubscription = input.Subscribe(evt =>
28 {
29 Console.WriteLine("User wrote: " + ((TextBox)evt.Sender).Text);
30 });
31
32 using (new CompositeDisposable(moveSubscription, inputSubscription))
33 {
34 Application.Run(frm);
35 }
36 }
37 }
38 }