Ejemplo n.º 1
0
        public static UnoHostViewFactory Create(IObservable <IBinaryMessage> messagesFromHost, IObserver <IBinaryMessage> messagesToHost)
        {
            var surfaceCache = new SurfaceCache();

            var serverView = new ServerView(surfaceCache)
            {
                WantsBestResolutionOpenGLSurface = true
            };

            Observable
            .Merge(
                serverView.Events.Select(CocoaEventMessage.Compose),
                serverView.Size.CombineLatest(serverView.Density, (s, d) => ResizeMessage.Compose(new SizeData(s, d))))
            .Subscribe(messagesToHost.OnNext);

            messagesFromHost
            .SelectSome(NewSurfaceMessage.TryParse)
            .Subscribe(surfaceCache.SwapAndUpdateCache, e => Console.WriteLine(e));

            return(new UnoHostViewFactory()
            {
                View = serverView,
                Focus = serverView.Focus
            });
        }
Ejemplo n.º 2
0
        internal ServerView(SurfaceCache surfaceCache, Optional <CGRect> frame = default(Optional <CGRect>))
            : base(frame.Or(new CGRect()))
        {
            _surfaceCache = surfaceCache;
            _backedLayer  = new UnoHostLayer(OnDraw);
            surfaceCache.SurfaceSwapped.Subscribe(_ => _backedLayer.MakeDirty());
            WantsLayer = true;

            _trackingArea = new NSTrackingArea(
                new CGRect(),
                NSTrackingAreaOptions.ActiveInKeyWindow | NSTrackingAreaOptions.InVisibleRect | NSTrackingAreaOptions.MouseMoved | NSTrackingAreaOptions.MouseEnteredAndExited,
                this,
                null);
            AddTrackingArea(_trackingArea);

            _density = new BehaviorSubject <Ratio <Pixels, Points> >(GetDensity());
        }