예제 #1
0
        public void AppVirtuallMovingToThisDevice(TemporaryAppItemViewModel app)
        {
            app.Expired += App_Expired;

            foreach (var childApp in app.ChildApps)
            {
                _device.UnhideSessionsForProcessId(childApp.ProcessId);
            }

            bool hasExistingAppGroup = false;

            foreach (var a in Apps)
            {
                if (a.DoesGroupWith(app))
                {
                    hasExistingAppGroup = true;
                    break;
                }
            }

            if (!hasExistingAppGroup)
            {
                // Add a fake app entry.
                Apps.AddSorted(app, AppItemViewModel.CompareByExeName);
            }
        }
예제 #2
0
        public void Refresh()
        {
            var defaultDevice = _deviceService.GetAudioDevices().FirstOrDefault(x => x.IsDefault);
            var volume        = _deviceService.GetAudioDeviceVolume(defaultDevice.Id);
            var newDevice     = new DeviceAppItemViewModel(_proxy, defaultDevice, volume);

            if (Device != null && Device.IsSame(newDevice))
            {
                Device.UpdateFromOther(newDevice);
            }
            else
            {
                Device = newDevice;
            }
            RaisePropertyChanged("Device");

            bool hasApps = Apps.Count > 0;

            var sessions = _audioService.GetAudioSessionGroups().Select(x => new AppItemViewModel(_proxy, x));

            List <AppItemViewModel> staleSessionsToRemove = new List <AppItemViewModel>();

            // remove stale apps
            foreach (var app in Apps)
            {
                if (!sessions.Where(x => (x.IsSame(app))).Any())
                {
                    staleSessionsToRemove.Add(app);
                }
            }
            foreach (var app in staleSessionsToRemove)
            {
                Apps.Remove(app);
            }

            // add new apps
            foreach (var session in sessions)
            {
                var findApp = Apps.FirstOrDefault(x => x.IsSame(session));
                if (findApp == null)
                {
                    Apps.AddSorted(session, AppItemViewModelComparer.Instance);
                }
                else
                {
                    // update existing apps
                    findApp.UpdateFromOther(session);
                }
            }

            ListVisibility       = Apps.Count > 0 ? Visibility.Visible : Visibility.Hidden;
            NoAppsPaneVisibility = Apps.Count == 0 ? Visibility.Visible : Visibility.Hidden;

            if (hasApps != (Apps.Count > 0))
            {
                RaisePropertyChanged("ListVisibility");
                RaisePropertyChanged("NoAppsPaneVisibility");
            }
        }
예제 #3
0
        public void Refresh()
        {
            bool hasApps = Apps.Count > 0;

            var titleProvider = ProcessTitleProviderFactoryService.CreateProvider();
            var sessions      = _audioService.GetAudioSessionGroups().Select(x => new AppItemViewModel(_proxy, x, titleProvider));

            List <AppItemViewModel> staleSessionsToRemove = new List <AppItemViewModel>();

            // remove stale apps
            foreach (var app in Apps)
            {
                if (!sessions.Where(x => (x.IsSame(app) && (!app.IsDesktop || UserPreferencesService.ShowDesktopApps))).Any())
                {
                    staleSessionsToRemove.Add(app);
                }
            }
            foreach (var app in staleSessionsToRemove)
            {
                Apps.Remove(app);
            }

            // add new apps
            foreach (var session in sessions)
            {
                var findApp = Apps.FirstOrDefault(x => x.IsSame(session));
                if (findApp == null)
                {
                    if (!session.IsDesktop || UserPreferencesService.ShowDesktopApps)
                    {
                        Apps.AddSorted(session, AppItemViewModelComparer.Instance);
                    }
                }
                else
                {
                    // update existing apps
                    findApp.UpdateFromOther(session);
                }
            }

            ListVisibility       = Apps.Count > 0 ? Visibility.Visible : Visibility.Hidden;
            NoAppsPaneVisibility = Apps.Count == 0 ? Visibility.Visible : Visibility.Hidden;

            if (hasApps != (Apps.Count > 0))
            {
                RaisePropertyChanged("ListVisibility");
                RaisePropertyChanged("NoAppsPaneVisibility");
            }
        }
예제 #4
0
        private void AddSession(IAudioDeviceSession session)
        {
            var newSession = new AppItemViewModel(session);

            foreach (var a in Apps)
            {
                if (a.DoesGroupWith(newSession))
                {
                    // Remove the fake app entry after copying any changes the user did.
                    newSession.Volume  = a.Volume;
                    newSession.IsMuted = a.IsMuted;
                    Apps.Remove(a);
                    break;
                }
            }

            Apps.AddSorted(newSession, AppItemViewModel.CompareByExeName);
        }