Exemplo n.º 1
0
        public MainWindow()
        {
            this.InitializeComponent();

            Transaction.RunVoid(() =>
            {
                STextBox word           = new STextBox(string.Empty);
                CellLoop <bool> enabled = new CellLoop <bool>();
                SButton button          = new SButton(enabled)
                {
                    Content = "look up"
                };
                Stream <string> sWord = button.SClicked.Snapshot(word.Text);
                IsBusy <string, Maybe <string> > ib = new IsBusy <string, Maybe <string> >(Lookup, sWord);
                Stream <string> sDefinition         = ib.SOut.Map(o => o.Match(v => v, () => "ERROR!"));
                Cell <string> definition            = sDefinition.Hold(string.Empty);
                Cell <string> output = definition.Lift(ib.Busy, (def, bsy) => bsy ? "Looking up..." : def);
                enabled.Loop(ib.Busy.Map(b => !b));
                STextBox outputArea = new STextBox(output.Values(), string.Empty, enabled)
                {
                    TextWrapping = TextWrapping.Wrap, AcceptsReturn = true
                };
                this.TextBoxPlaceholder.Child = word;
                this.ButtonPlaceholder.Child  = button;
                this.OutputPlaceholder.Child  = outputArea;
            });
        }