From aed8bc2a0463d09ed1adef7c4c1e5f7941837bf9 Mon Sep 17 00:00:00 2001 From: Joao Rua Date: Fri, 19 Jul 2024 13:15:44 +0100 Subject: [PATCH] first commit --- COMETwebapp/ViewModels/Pages/TabsViewModel.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/COMETwebapp/ViewModels/Pages/TabsViewModel.cs b/COMETwebapp/ViewModels/Pages/TabsViewModel.cs index bacfe704..99b94f68 100644 --- a/COMETwebapp/ViewModels/Pages/TabsViewModel.cs +++ b/COMETwebapp/ViewModels/Pages/TabsViewModel.cs @@ -71,6 +71,7 @@ public TabsViewModel(ISessionService sessionService, IServiceProvider servicePro this.sessionService = sessionService; this.serviceProvider = serviceProvider; this.Disposables.Add(this.WhenAnyValue(x => x.SelectedApplication).Subscribe(_ => this.OnSelectedApplicationChange())); + this.Disposables.Add(this.WhenAnyValue(x => x.CurrentTab).Subscribe(_ => this.OnSelectedApplicationChange())); this.Disposables.Add(this.sessionService.OpenIterations.CountChanged.Subscribe(this.CloseTabIfIterationClosed)); this.Disposables.Add(this.OpenTabs.Connect().WhereReasonsAre(ListChangeReason.Remove, ListChangeReason.RemoveRange).Subscribe(this.OnOpenTabRemoved)); } @@ -170,6 +171,19 @@ private void OnSelectedApplicationChange() this.CurrentTab = this.OpenTabs.Items.FirstOrDefault(x => x.ComponentType == this.SelectedApplication.ComponentType && x.Panel == null); } + /// + /// Method executed everytime the changes + /// + private void OnCurrentTabChange() + { + if (this.CurrentTab == null) + { + return; + } + + this.SelectedApplication = Applications.ExistingApplications.OfType().First(x => x.ComponentType == this.CurrentTab.ComponentType); + } + /// /// Closes a tab if its iteration has been closed ///