| 1 |
using System; |
| 2 |
using System.Reactive.Linq; |
| 3 |
using System.Windows.Forms; |
| 4 |
using System.Reactive.Disposables; |
| 5 |
using Excercise8.DictionarySuggestService; |
| 6 |
|
| 7 |
namespace Excercise8 |
| 8 |
{ |
| 9 |
class Program |
| 10 |
{ |
| 11 |
static void Main() |
| 12 |
{ |
| 13 |
var txt = new TextBox(); |
| 14 |
var lst = new ListBox { Top = txt.Height + 10 }; |
| 15 |
|
| 16 |
var frm = new Form() |
| 17 |
{ |
| 18 |
Controls = { txt, lst } |
| 19 |
}; |
| 20 |
|
| 21 |
var input = (from evt in Observable.FromEventPattern(txt, "TextChanged") |
| 22 |
select ((TextBox)evt.Sender).Text) |
| 23 |
.Throttle(TimeSpan.FromSeconds(1)) |
| 24 |
.DistinctUntilChanged() |
| 25 |
.Do(x => Console.WriteLine(x)); |
| 26 |
|
| 27 |
var svc = new DictServiceSoapClient("DictServiceSoap"); |
| 28 |
var matchInDict = Observable.FromAsyncPattern<string, string, string, DictionaryWord[]> |
| 29 |
(svc.BeginMatchInDict, svc.EndMatchInDict); |
| 30 |
|
| 31 |
Func<string, IObservable<DictionaryWord[]>> matchInWordNetByPrefix = |
| 32 |
term => matchInDict("wn", term, "prefix"); |
| 33 |
|
| 34 |
using (input.Subscribe(inp => Console.WriteLine("User wrote: " + inp))) |
| 35 |
{ |
| 36 |
Application.Run(frm); |
| 37 |
} |
| 38 |
} |
| 39 |
} |
| 40 |
} |