Program.cs 1.3 KB

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