Exemplo n.º 1
0
        IControl EncapsulateView(IViewport viewport)
        {
            var deviceSize      = viewport.VirtualDevice.Select(s => s.GetOrientedSizeInPoints()).Transpose();
            var deviceNameLabel = Label.Create(
                text: viewport.VirtualDevice.Select(d => d.Screen.Name).AsText(),
                font: Theme.DescriptorFont,
                color: Theme.DescriptorText);

            var focusedProperty = _stage.FocusedViewport
                                  .Select(maybeViewport => maybeViewport.Select(vp => vp == viewport).Or(false))
                                  .AsProperty(write: (b, save) => { if (b)
                                                                    {
                                                                        viewport.Focus();
                                                                    }
                                              });

            var view = Layout.StackFromTop(
                Layout.StackFromLeft(
                    FocusBox.Create(focusedProperty).DockBottom(),
                    Spacer.Small,
                    deviceNameLabel),
                viewport.Control.WithSize(deviceSize).DropShadow(
                    color: Theme.Shadow,
                    radius: Observable.Return(new Points(5)),
                    distance: Observable.Return(new Points(2))))
                       .WithPadding(new Thickness <Points>(15));

            return(view);
        }