public ShellViewModel(IProvider provider) { _topBrush = new ObservableProperty <Brush>(DefaultBrush, this, () => TopBrush); _leftBrush = new ObservableProperty <Brush>(DefaultBrush, this, () => LeftBrush); _rightBrush = new ObservableProperty <Brush>(DefaultBrush, this, () => RightBrush); _bottomBrush = new ObservableProperty <Brush>(DefaultBrush, this, () => BottomBrush); _leftTopShelf = new ObservableProperty <Brush>(DefaultBrush, this, () => LeftTopShelf); _leftMiddleShelf = new ObservableProperty <Brush>(DefaultBrush, this, () => LeftMiddleShelf); _leftBottomShelf = new ObservableProperty <Brush>(DefaultBrush, this, () => LeftBottomShelf); _rightTopShelf = new ObservableProperty <Brush>(DefaultBrush, this, () => RightTopShelf); _rightMiddleShelf = new ObservableProperty <Brush>(DefaultBrush, this, () => RightMiddleShelf); _rightBottomShelf = new ObservableProperty <Brush>(DefaultBrush, this, () => RightBottomShelf); _fps = new ObservableProperty <int>(0, this, () => Fps); _source = provider.Processed.Select(processed => processed.Layers.FirstOrDefault()).Where(value => value != null).ObserveOnDispatcher().Publish(); /* * _source.Select(processed => processed.Left) * .Select(colors => ToShelveColor(colors, Shelf.Top)) * .StartWith(DefaultColor) * .Buffer(2) * .Select(colors => new { Shelf = Shelf.Top, Color = colors[1], Difference = ColorDifference.FindDifference(colors[0], colors[1]) }); * * _source.Select(processed => processed.Left).Select(colors => ToShelveColor(colors, Shelf.Middle)); * _source.Select(processed => processed.Left).Select(colors => ToShelveColor(colors, Shelf.Bottom)); */ _brushSubscription = new CompositeDisposable( _source.Buffer(TimeSpan.FromSeconds(1)).Select(buffer => buffer.Count).Subscribe(_fps), _source.Select(processed => processed.Top).Select(colors => AsGradientBrush(colors, Side.Top)).Subscribe(_topBrush), _source.Select(processed => processed.Left).Select(colors => AsGradientBrush(colors, Side.Left)).Subscribe(_leftBrush), _source.Select(processed => processed.Right).Select(colors => AsGradientBrush(colors, Side.Right)).Subscribe(_rightBrush), _source.Select(processed => processed.Bottom).Select(colors => AsGradientBrush(colors, Side.Bottom)).Subscribe(_bottomBrush) ); }