Example #1
0
 public static Menu Create(
     IProperty <VirtualDevice> currentDevice,
     PreviewDevices previewDevices)
 {
     return(Menu.Submenu(
                "Device",
                Menu.Item(
                    "Flip aspect",
                    command: Command.Enabled(() =>
                                             currentDevice
                                             .Select(device => device.With(
                                                         orientation: device.Orientation == DeviceOrientation.Landscape
                                                                         ? DeviceOrientation.Portrait
                                                                         : DeviceOrientation.Landscape))
                                             .Take(1)
                                             .Subscribe(device => currentDevice.Write(device))),
                    hotkey: HotKey.Create(ModifierKeys.Meta, Key.F))
                + Menu.Separator
                + previewDevices.Devicess.Select(devices => devices.Select((dev, j) =>
                                                                           Menu.Option(
                                                                               name: dev.Name,
                                                                               value: dev,
                                                                               hotkey: GetHotKey(j),
                                                                               property: currentDevice.Convert(
                                                                                   convert: info => info.Screen,
                                                                                   convertBack: screen => new VirtualDevice(screen, screen.DefaultOrientation)))))
                .Concat()
                + Menu.Separator
                + Menu.Item("Customize...", previewDevices.CustomizeDevices())));
 }
Example #2
0
        public StageController(
            ViewportFactory viewportFactory,
            PreviewDevices previewDevices,
            IProperty <bool> selectionEnabled)
        {
            _viewportFactory  = viewportFactory;
            _previewDevices   = previewDevices;
            _selectionEnabled = selectionEnabled;

            var fallbackDevice = previewDevices.DefaultDevice
                                 .Select(dev => new VirtualDevice(dev, dev.DefaultOrientation))
                                 .AsProperty();

            var device = _focusedViewport
                         .Select(mv => mv.Select(v => v.VirtualDevice.AsProperty()).Or(fallbackDevice))
                         .Switch();

            _latestDevice = device;
        }