Esempio n. 1
0
        public AsyncKinectManager()
        {
            _Sensor = ObservableProperty.CreateSettable <KinectSensor>(null);
            Sensor  = _Sensor.ToGetOnlyMask();

            SensorDisconnected = _Sensor
                                 .Select(s => _sensorCache)
                                 .Where(s => s != null)
                                 .ToGetOnly(null, true);
            SensorConnected = _Sensor
                              .Do(s => _sensorCache = s)
                              .Where(s => s != null)
                              .ToGetOnly(null, true);
        }
Esempio n. 2
0
        public AppModel()
        {
            var timer  = Observable.Interval(TimeSpan.FromSeconds(1)).Select(_ => DateTime.Now);
            var random = new Random();

            FirstName = ObservableProperty.CreateSettable("Jiro");
            LastName  = ObservableProperty.CreateSettable("Mita");
            FullName  = ObservableProperty.CreateGetOnly(() => string.Format("{0} {1}", FirstName.Value, LastName.Value));
            FirstName.Merge(LastName).Subscribe(FullName);
            Message     = FirstName.SelectToGetOnly(name => string.Format("Hello, {0}!", name));
            CurrentTime = timer.ToGetOnly(DateTime.Now);

            // 初期値をランダムに設定する場合。
            //RandomNumber = CurrentTime.SelectToGetOnly(_ => random.Next(0, 3), true);
            RandomNumber = timer.Select(_ => random.Next(0, 3)).ToGetOnly(0, true);
            _Count       = ObservableProperty.CreateSettable(0);
            Count        = _Count.ToGetOnlyMask();
            RandomNumber.Subscribe(_ => _Count.Value++);
        }