| 1 |
using System; |
| 2 |
using System.Reactive.Linq; |
| 3 |
using System.Windows.Forms; |
| 4 |
using System.Reactive.Disposables; |
| 5 |
|
| 6 |
namespace Excercise6 |
| 7 |
{ |
| 8 |
class Program |
| 9 |
{ |
| 10 |
static void Main() |
| 11 |
{ |
| 12 |
var txt = new TextBox(); |
| 13 |
var lbl = new Label { Left = txt.Width + 20 }; |
| 14 |
|
| 15 |
var frm = new Form() |
| 16 |
{ |
| 17 |
Controls = { txt, lbl } |
| 18 |
}; |
| 19 |
|
| 20 |
var input = (from evt in Observable.FromEventPattern(txt, "TextChanged") |
| 21 |
select ((TextBox)evt.Sender).Text) |
| 22 |
.Throttle(TimeSpan.FromSeconds(1)) |
| 23 |
.DistinctUntilChanged(); |
| 24 |
|
| 25 |
using (input.Subscribe(inp => lbl.Text = inp)) |
| 26 |
{ |
| 27 |
Application.Run(frm); |
| 28 |
} |
| 29 |
|
| 30 |
} |
| 31 |
} |
| 32 |
} |