Ejemplo n.º 1
0
    public static IDisposable BindScrollbarToHandler(this ViewBase viewBase, Scrollbar scrollBar, Action <float> handler)
    {
        var d = scrollBar.AsValueChangedObservable().Subscribe(value =>
        {
            handler(value);
        }).DisposeWith(viewBase);

        return(d);
    }
Ejemplo n.º 2
0
        public static IDisposable BindScrollbarToProperty(this ViewBase viewBase, Scrollbar scrollbar, P <float> property)
        {
            var d1 = scrollbar.AsValueChangedObservable().Subscribe(value =>
            {
                property.OnNext(value);
            }).DisposeWith(viewBase);

            var d2 = property.Subscribe(value =>
            {
                scrollbar.value = value;
            });

            return(Disposable.Create(() =>
            {
                d1.Dispose();
                d2.Dispose();
            }).DisposeWith(viewBase));
        }
Ejemplo n.º 3
0
    public static IDisposable BindScrollbarToProperty <TO>(this ViewBase viewBase, Scrollbar scrollbar, P <TO> property, Func <float, TO> i2pSelector, Func <TO, float> p2iSelector)
    {
        var d1 = scrollbar.AsValueChangedObservable().Subscribe(value =>
        {
            property.OnNext(i2pSelector(value));
        });

        var d2 = property.Subscribe(value =>
        {
            scrollbar.value = p2iSelector(value);
        });

        return(Disposable.Create(() =>
        {
            d1.Dispose();
            d2.Dispose();
        }).DisposeWith(viewBase));
    }