public BasicUsageViewModel()
 {
     Input  = new ReactiveProperty <string>("");
     Output = Input.Delay(TimeSpan.FromSeconds(1))
              .Select(x => x.ToUpper())
              .ToReadOnlyReactiveProperty();
 }
        public RegexSenseiViewModel()
        {
            InputPattern            = new ReactiveProperty <string>("").AddTo(this.disposable);
            StatusMessage           = new ReactiveProperty <string>("").AddTo(this.disposable);
            Multiline               = new ReactiveProperty <bool>(false).AddTo(this.disposable);
            IgnoreCase              = new ReactiveProperty <bool>(false).AddTo(this.disposable);
            ExplicitCapture         = new ReactiveProperty <bool>(false).AddTo(this.disposable);
            Compiled                = new ReactiveProperty <bool>(false).AddTo(this.disposable);
            Singleline              = new ReactiveProperty <bool>(false).AddTo(this.disposable);
            IgnorePatternWhitespace = new ReactiveProperty <bool>(false).AddTo(this.disposable);
            RightToLeft             = new ReactiveProperty <bool>(false).AddTo(this.disposable);
            ECMAScript              = new ReactiveProperty <bool>(false).AddTo(this.disposable);
            CultureInvariant        = new ReactiveProperty <bool>(false).AddTo(this.disposable);
            Text            = new ReactiveProperty <string>("").AddTo(this.disposable);
            PremadeDocument = new FlowDocument();
            OutputDocument  = new FlowDocument();

            RunMatchRegex = new ReactiveCommand().AddTo(disposable);
            //OutputDocument = new FlowDocument();
            //OutputDocument.Blocks.Add(new Paragraph(new Run("foo bar baz")));


            InputPattern.Delay(TimeSpan.FromMilliseconds(500)).Subscribe(_ => {
                try {
                    model.Pattern       = InputPattern.Value;
                    StatusMessage.Value = "OK";
                    //MatchCommand();
                } catch (Exception e) {
                    StatusMessage.Value = e.Message;
                }
            });

            Text.Delay(TimeSpan.FromMilliseconds(500)).Subscribe(_ => {
                try {
                    model.Text = Text.Value;
                    //MatchCommand();
                } catch (Exception e) {
                    StatusMessage.Value = e.Message;
                }
            });

            RunMatchRegex.Subscribe(_ => {
                MatchCommand();
            });

            IgnoreCase.Subscribe(_ => model.SetOption(RegexOptions.IgnoreCase, IgnoreCase.Value));
            Multiline.Subscribe(_ => model.SetOption(RegexOptions.Multiline, Multiline.Value));
            ExplicitCapture.Subscribe(_ => model.SetOption(RegexOptions.ExplicitCapture, ExplicitCapture.Value));
            Compiled.Subscribe(_ => model.SetOption(RegexOptions.Compiled, Compiled.Value));
            Singleline.Subscribe(_ => model.SetOption(RegexOptions.Singleline, Singleline.Value));
            IgnorePatternWhitespace.Subscribe(_ => model.SetOption(RegexOptions.IgnorePatternWhitespace, IgnorePatternWhitespace.Value));
            RightToLeft.Subscribe(_ => model.SetOption(RegexOptions.RightToLeft, RightToLeft.Value));
            ECMAScript.Subscribe(_ => model.SetOption(RegexOptions.ECMAScript, ECMAScript.Value));
            CultureInvariant.Subscribe(_ => model.SetOption(RegexOptions.CultureInvariant, CultureInvariant.Value));
        }
        public ViewAViewModel()
        {
            Input  = new ReactiveProperty <string>("");
            Output = Input.Delay(TimeSpan.FromSeconds(1))
                     .Select(x => x.ToUpper())
                     .ToReadOnlyReactiveProperty();

            ResetCommand = Input.Select(x => !string.IsNullOrWhiteSpace(x))
                           .ToReactiveCommand()
                           .WithSubscribe(() => Input.Value = "");
        }
        public BasicUsagesWindowVewModel()
        {
            Input  = new ReactiveProperty <string>();
            Output = Input.Delay(TimeSpan.FromSeconds(1))
                     .Select(x => x?.ToUpper())
                     .ToReadOnlyReactiveProperty()
                     .AddTo(Disposables);

            InputSlim  = new ReactivePropertySlim <string>();
            OutputSlim = InputSlim.Delay(TimeSpan.FromSeconds(1))
                         .Select(x => x?.ToUpper())
                         .ObserveOnUIDispatcher()
                         .ToReadOnlyReactivePropertySlim() // TODO:???必要なのか?
                         .AddTo(Disposables);
        }
示例#5
0
        public MainPageViewModel()
        {
            Input  = new ReactiveProperty <string>("");
            Output = Input
                     .Delay(TimeSpan.FromSeconds(1))
                     .Select(x => x.ToUpper())
                     .ToReadOnlyReactiveProperty();

            SpeechTitles = storyModel.AllStories.ToReadOnlyReactiveCollection();
            SelectedTitle.Subscribe(x => StorySelectionChanged(x?.Title)).AddTo(disposable);
            SelectedTitle.Value = SpeechTitles.First();

            TextBoxInput     = new ReactiveProperty <string>(storyModel.InitialStory.Content);
            TextBoxSelection = new ReactiveProperty <string>("");

            PlayIconTextBoxInput     = new ReactiveProperty <string>(playIcon);
            PlayIconTextBoxSelection = new ReactiveProperty <string>(playIcon);
            storyModel.CurrentStory.Subscribe(x => TextBoxInput.Value = x.Content).AddTo(disposable);
        }