Exemplo n.º 1
0
        public FocusedDeviceViewModel(DeviceCollectionViewModel mainViewModel, DeviceViewModel device)
        {
            DisplayName = device.DisplayName;
            Toolbar     = new ObservableCollection <ToolbarItemViewModel>();
            Toolbar.Add(new ToolbarItemViewModel
            {
                GlyphFontSize = 10,
                DisplayName   = Properties.Resources.CloseButtonAccessibleText,
                Glyph         = "\uE8BB",
                Command       = new RelayCommand(() => RequestClose.Invoke())
            });

            if (AddonContentItems != null)
            {
                Addons = new ObservableCollection <object>(AddonContentItems.Select(a => a.GetContentForDevice(device.Id, () => RequestClose.Invoke())).ToArray());
            }

            if (Features.IsEnabled(Feature.Addons) &&
                AddonContextMenuItems != null && AddonContextMenuItems.Any())
            {
                var menuItems = AddonContextMenuItems.SelectMany(a => a.GetItemsForDevice(device.Id));
                Toolbar.Insert(0, new ToolbarItemViewModel
                {
                    GlyphFontSize = 16,
                    DisplayName   = Properties.Resources.MoreCommandsAccessibleText,
                    Glyph         = "\uE10C",
                    Menu          = new ObservableCollection <ContextMenuItem>(menuItems)
                });
            }
        }
Exemplo n.º 2
0
 public FullWindowViewModel(DeviceCollectionViewModel mainViewModel)
 {
     Dialog                   = new ModalDialogViewModel();
     _mainViewModel           = mainViewModel;
     _mainViewModel.AppPopup += OnAppPopup;
     _mainViewModel.OnFullWindowOpened();
 }
Exemplo n.º 3
0
        public FullWindowViewModel(DeviceCollectionViewModel mainViewModel)
        {
            Dialog         = new ModalDialogViewModel();
            _mainViewModel = mainViewModel;
            _mainViewModel.OnFullWindowOpened();
            _mainViewModel.AllDevices.CollectionChanged += OnDevicesChanged;

            DisplaySettingsChanged = new RelayCommand(() => Dialog.IsVisible = false);
        }
Exemplo n.º 4
0
        public FlyoutViewModel(DeviceCollectionViewModel mainViewModel)
        {
            Dialog  = new ModalDialogViewModel();
            Devices = new ObservableCollection <DeviceViewModel>();

            _mainViewModel = mainViewModel;
            _mainViewModel.DefaultChanged += OnDefaultPlaybackDeviceChanged;
            _mainViewModel.AllDevices.CollectionChanged += AllDevices_CollectionChanged;
            AllDevices_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));

            _hideTimer.Tick += HideTimer_Tick;
        }
Exemplo n.º 5
0
        public FlyoutViewModel(DeviceCollectionViewModel mainViewModel)
        {
            Dialog  = new ModalDialogViewModel();
            Devices = new ObservableCollection <DeviceViewModel>();

            _mainViewModel = mainViewModel;
            _mainViewModel.DefaultChanged += OnDefaultPlaybackDeviceChanged;
            _mainViewModel.AllDevices.CollectionChanged += AllDevices_CollectionChanged;
            _mainViewModel.AppPopup += OnAppPopup;
            AllDevices_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));

            _hideTimer.Tick += HideTimer_Tick;

            ExpandCollapse = new RelayCommand(() => BeginClose(FlyoutViewModel.CloseReason.CloseThenOpen));
        }
Exemplo n.º 6
0
        public FlyoutViewModel(DeviceCollectionViewModel mainViewModel, Action returnFocusToTray)
        {
            Dialog                         = new ModalDialogViewModel();
            Devices                        = new ObservableCollection <DeviceViewModel>();
            _returnFocusToTray             = returnFocusToTray;
            _mainViewModel                 = mainViewModel;
            _mainViewModel.DefaultChanged += OnDefaultPlaybackDeviceChanged;
            _mainViewModel.AllDevices.CollectionChanged += AllDevices_CollectionChanged;
            AllDevices_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));

            _hideTimer.Tick += HideTimer_Tick;

            ExpandCollapse = new RelayCommand(() =>
            {
                IsExpandingOrCollapsing = true;
                BeginClose(LastInput);
            });
        }
Exemplo n.º 7
0
        public FlyoutViewModel(DeviceCollectionViewModel mainViewModel, Action returnFocusToTray)
        {
            Dialog                         = new ModalDialogViewModel();
            Devices                        = new ObservableCollection <DeviceViewModel>();
            _returnFocusToTray             = returnFocusToTray;
            _mainViewModel                 = mainViewModel;
            _mainViewModel.DefaultChanged += OnDefaultPlaybackDeviceChanged;
            _mainViewModel.AllDevices.CollectionChanged += AllDevices_CollectionChanged;
            AllDevices_CollectionChanged(null, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset));

            // This timer is used to enable clicking on the tray icon while the flyout is open, and not causing a
            // rapid hide and show cycle.  This time represents the minimum time between which the flyout may be opened.
            _deBounceTimer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(300)
            };
            _deBounceTimer.Tick += OnDeBounceTimerTick;

            ExpandCollapse = new RelayCommand(() =>
            {
                IsExpandingOrCollapsing = true;
                BeginClose(LastInput);
            });
            DisplaySettingsChanged = new RelayCommand(() => BeginClose(InputType.Command));
        }
Exemplo n.º 8
0
        public FocusedAppItemViewModel(DeviceCollectionViewModel parent, IAppItemViewModel app)
        {
            App = app;

            Toolbar = new ObservableCollection <ToolbarItemViewModel>();
            Toolbar.Add(new ToolbarItemViewModel
            {
                GlyphFontSize = 10,
                DisplayName   = Properties.Resources.CloseButtonAccessibleText,
                Glyph         = "\uE8BB",
                Command       = new RelayCommand(() => RequestClose.Invoke())
            });

            if (app.IsMovable)
            {
                var persistedDeviceId = app.PersistedOutputDevice;

                var items = parent.AllDevices.Select(dev => new ContextMenuItem
                {
                    DisplayName = dev.DisplayName,
                    Command     = new RelayCommand(() =>
                    {
                        parent.MoveAppToDevice(app, dev);
                        RequestClose.Invoke();
                    }),
                    IsChecked = (dev.Id == persistedDeviceId),
                }).ToList();

                items.Insert(0, new ContextMenuItem
                {
                    DisplayName = Properties.Resources.DefaultDeviceText,
                    IsChecked   = (string.IsNullOrWhiteSpace(persistedDeviceId)),
                    Command     = new RelayCommand(() =>
                    {
                        parent.MoveAppToDevice(app, null);
                        RequestClose.Invoke();
                    }),
                });
                items.Insert(1, new ContextMenuSeparator());
                Toolbar.Insert(0, new ToolbarItemViewModel
                {
                    GlyphFontSize = 16,
                    DisplayName   = Properties.Resources.MoveButtonAccessibleText,
                    Glyph         = "\uE8AB",
                    Menu          = new ObservableCollection <ContextMenuItem>(items)
                });
            }

            var contentItems = AddonManager.Host.AppContentItems;

            if (contentItems != null)
            {
                Addons = new ObservableCollection <object>(contentItems.Select(a => a.GetContentForApp(App.Parent.Id, App.Id, () => RequestClose.Invoke())).ToArray());

                var menuItems = contentItems.SelectMany(a => a.GetItemsForApp(app.Parent.Id, app.AppId));
                if (menuItems.Any())
                {
                    Toolbar.Insert(0, new ToolbarItemViewModel
                    {
                        GlyphFontSize = 16,
                        DisplayName   = Properties.Resources.MoreCommandsAccessibleText,
                        Glyph         = "\uE10C",
                        Menu          = new ObservableCollection <ContextMenuItem>(menuItems)
                    });
                }
            }
        }