private void MoveAppToDeviceInternal(IAppItemViewModel app, DeviceViewModel dev) { var searchId = dev?.Id; if (dev == null) { searchId = _deviceManager.DefaultPlaybackDevice.Id; } DeviceViewModel oldDevice = AllDevices.First(d => d.Apps.Contains(app)); DeviceViewModel newDevice = AllDevices.First(d => searchId == d.Id); try { bool isLogicallyMovingDevices = (oldDevice != newDevice); var tempApp = new TemporaryAppItemViewModel(app); app.MoveToDevice(dev?.Id, hide: isLogicallyMovingDevices); // Update the UI if the device logically changed places. if (isLogicallyMovingDevices) { oldDevice.AppVirtuallyLeavingFromThisDevice(app); newDevice.AppVirtuallMovingToThisDevice(tempApp); } } catch (Exception ex) { AppTrace.LogWarning(ex); } }
public void MoveAppToDevice(IAppItemViewModel app, DeviceViewModel dev) { // Collect all matching apps on all devices. var apps = new List <IAppItemViewModel>(); apps.Add(app); foreach (var device in AllDevices) { foreach (var deviceApp in device.Apps) { if (deviceApp.DoesGroupWith(app)) { if (!apps.Contains(deviceApp)) { apps.Add(deviceApp); break; } } } } foreach (var foundApp in apps) { MoveAppToDeviceInternal(foundApp, dev); } // Collect and move any hidden/moved sessions. _deviceManager.MoveHiddenAppsToDevice(app.AppId, dev?.Id); }
private void MoveAppToDeviceInternal(IAppItemViewModel app, DeviceViewModel dev) { var searchId = dev?.Id; if (dev == null) { searchId = _deviceManager.Default.Id; } try { DeviceViewModel oldDevice = AllDevices.First(d => d.Apps.Contains(app)); DeviceViewModel newDevice = AllDevices.First(d => searchId == d.Id); bool isLogicallyMovingDevices = (oldDevice != newDevice); var tempApp = new TemporaryAppItemViewModel(this, _deviceManager, app); app.MoveToDevice(dev?.Id, hide: isLogicallyMovingDevices); // Update the UI if the device logically changed places. if (isLogicallyMovingDevices) { oldDevice.AppLeavingFromThisDevice(app); newDevice.AppMovingToThisDevice(tempApp); } } catch (Exception ex) { Trace.WriteLine($"{ex}"); } }
internal void AppLeavingFromThisDevice(IAppItemViewModel app) { if (app is TemporaryAppItemViewModel) { Apps.Remove(app); } }
public void OnInvoked(object sender, IAppItemViewModel vivewModel) { _part.App = new AppRef { Id = vivewModel.Id }; RaisePropertyChanged(""); // Signal change so ToString will be called. var popup = ((DependencyObject)sender).FindVisualParent <Popup>(); popup.IsOpen = false; }
public void ExpandApp(IAppItemViewModel vm, UIElement container) { if (IsShowingModalDialog) { CollapseApp(); } AppExpanded?.Invoke(this, new AppExpandedEventArgs { Container = container, ViewModel = vm }); IsShowingModalDialog = true; RaisePropertyChanged(nameof(IsShowingModalDialog)); }
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) }); } } }
public bool DoesGroupWith(IAppItemViewModel app) => (AppId == app.AppId);