static IControl ImageImpl( IScheduler dispatcher, IObservable <IImage> streams, Optional <IObservable <Color> > overlayColor, Optional <IObservable <IColorMap> > colorMap, Optional <IObservable <Ratio <Pixels, Points> > > dpiOverride) { BehaviorSubject <Size <Points> > desiredSize = new BehaviorSubject <Size <Points> >(Size.Zero <Points>()); return(Control.Create( ctrl => { var dummyControl = new DpiAwareView() { AutoresizesSubviews = true }; ctrl.BindNativeDefaults(dummyControl, dispatcher); var tintedImage = new TintedImage() { AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.HeightSizable }; dummyControl.AddSubview(tintedImage); ctrl.BindNativeProperty(dispatcher, "image", dpiOverride.Or(dummyControl.GetDpi()) .CombineLatest(streams, colorMap.Select(x => x.Select(Optional.Some)).Or(Observable.Return <Optional <IColorMap> >(Optional.None())), (dpi, imgStreams, cm) => new { dpi, imgStreams, colorMap = cm }), x => { var iv = x.imgStreams.Load <NSImage>(x.dpi, x.colorMap); tintedImage.CurrentImage = iv.Image; tintedImage.SetFrameSize(dummyControl.Frame.Size); var size = Size.Create <Pixels>((double)iv.Image.Size.Width, (double)iv.Image.Size.Height) / iv.ScaleFactor; desiredSize.OnNext(size); }); overlayColor.Do( colorObs => { ctrl.BindNativeProperty( dispatcher, "tintColor", colorObs, color => tintedImage.TintColor = color.ToNSColor()); }); return dummyControl; }).WithSize(desiredSize.Transpose())); }