예제 #1
0
        public BarControl(string morphName)
        {
            InitializeComponent( );
            //Lattice.LatticeString[ i ].BindTo( lats[ i ] , x=>x.Text , BindingMode.TwoWay ,
            //	targetUpdateTrigger: ReactiveHelper.TextBoxChanged( lats[ i ] ) );

            Coef.BindTo(trackBar, x => x.Value, BindingMode.TwoWay, targetUpdateTrigger: ReactiveHelper.BarChanged(trackBar));
            MorphName  = morphName;
            label.Text = MorphName;
        }
        public void BindToOneWayTest()
        {
            var target = new ReactiveProperty <string>();
            var obj    = new Poco();

            target.BindTo(obj, o => o.Name);

            obj.Name.IsNull();

            target.Value = "Hello world";
            obj.Name.Is("Hello world");
        }
        public void BindToOnwWayConvertTest()
        {
            var target = new ReactiveProperty <int>();
            var obj    = new Poco();

            target.BindTo(
                obj,
                o => o.Name,
                convert: i => "value is " + i);

            obj.Name.Is("value is 0");

            target.Value = 1;
            obj.Name.Is("value is 1");
        }
        public void BindToTwoWayTest()
        {
            var target = new ReactiveProperty <string>();
            var obj    = new Poco();

            target.BindTo(obj,
                          o => o.Name,
                          mode: BindingMode.TwoWay,
                          targetUpdateTrigger: obj.ObserveProperty(o => o.Name).ToUnit());
            obj.Name.IsNull();

            target.Value = "Hello world";
            obj.Name.Is("Hello world");

            obj.Name = "tanaka";
            target.Value.Is("tanaka");
        }
        public void BindToOneWayToSourceTest()
        {
            var target = new ReactiveProperty <string>();
            var obj    = new Poco();

            target.BindTo(obj,
                          o => o.Name,
                          mode: BindingMode.OneWayToSource,
                          convertBack: s =>
            {
                Debug.WriteLine(s);
                return(s + "!");
            },
                          targetUpdateTrigger: obj.ObserveProperty(o => o.Name).ToUnit());

            obj.Name.IsNull();

            obj.Name = "Hello";
            target.Value.Is("Hello!");
        }
        public void BindToTwoWayConvertTest()
        {
            var target = new ReactiveProperty <int>();
            var obj    = new Poco();

            target.BindTo(obj,
                          o => o.Name,
                          mode: BindingMode.TwoWay,
                          convert: i => "value is " + i,
                          convertBack: s =>
            {
                Debug.WriteLine(s);
                return(int.Parse(s, NumberStyles.Integer));
            },
                          targetUpdateTrigger: obj.ObserveProperty(o => o.Name).ToUnit());

            obj.Name.Is("value is 0");

            target.Value = 1;
            obj.Name.Is("value is 1");

            obj.Name = "3";
            target.Value.Is(3);
        }
예제 #7
0
        internal FormDelay(ReadOnlyReactiveCollection <DelayViewModel.EntryViewModel> delay)
        {
            InitializeComponent();

            disposable = new CompositeDisposable();

            listViewDelay.Items.AddRange(delay.Select((x, i) => new ListViewItem(new[] { (i + 1).ToString(CultureInfo.InvariantCulture), x.Up.Value, x.Down.Value })
            {
                Tag = x
            }).ToArray());

            SelectedEntry = new ReactiveProperty <DelayViewModel.EntryViewModel>();

            SelectedEntry
            .BindTo(
                listViewDelay,
                x => x.FocusedItem,
                BindingMode.OneWayToSource,
                null,
                x => (DelayViewModel.EntryViewModel)x?.Tag,
                Observable.FromEvent <EventHandler, EventArgs>(
                    h => (s, e) => h(e),
                    h => listViewDelay.SelectedIndexChanged += h,
                    h => listViewDelay.SelectedIndexChanged -= h
                    )
                .ToUnit()
                )
            .AddTo(disposable);

            CompositeDisposable entryDisposable = new CompositeDisposable().AddTo(disposable);

            SelectedEntry
            .Where(x => x != null)
            .Subscribe(x =>
            {
                entryDisposable.Dispose();
                entryDisposable = new CompositeDisposable().AddTo(disposable);

                x.Up.BindTo(
                    textBoxUp,
                    y => y.Text,
                    BindingMode.TwoWay,
                    null,
                    null,
                    Observable.FromEvent <EventHandler, EventArgs>(
                        h => (s, e) => h(e),
                        h => textBoxUp.TextChanged   += h,
                        h => textBoxDown.TextChanged -= h
                        )
                    .ToUnit()
                    )
                .AddTo(entryDisposable);

                x.Up.BindTo(
                    listViewDelay.FocusedItem.SubItems[1],
                    y => y.Text
                    )
                .AddTo(entryDisposable);

                x.Up.BindToErrorProvider(errorProvider, textBoxUp).AddTo(entryDisposable);

                x.Down.BindTo(
                    textBoxDown,
                    y => y.Text,
                    BindingMode.TwoWay,
                    null,
                    null,
                    Observable.FromEvent <EventHandler, EventArgs>(
                        h => (s, e) => h(e),
                        h => textBoxDown.TextChanged += h,
                        h => textBoxDown.TextChanged -= h
                        )
                    .ToUnit()
                    )
                .AddTo(entryDisposable);

                x.Down.BindTo(
                    listViewDelay.FocusedItem.SubItems[2],
                    y => y.Text
                    )
                .AddTo(entryDisposable);

                x.Down.BindToErrorProvider(errorProvider, textBoxDown).AddTo(entryDisposable);
            })
            .AddTo(disposable);

            groupBoxEntry.Enabled = listViewDelay.SelectedIndices.Count == 1;
        }