public static IDisposable BindScrollbarToHandler(this ViewBase viewBase, Scrollbar scrollBar, Action <float> handler) { var d = scrollBar.AsValueChangedObservable().Subscribe(value => { handler(value); }).DisposeWith(viewBase); return(d); }
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)); }
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)); }