diff --git a/src/Markdowser/ViewModels/MainWindowViewModel.cs b/src/Markdowser/ViewModels/MainWindowViewModel.cs index 78dbad7..2c70421 100644 --- a/src/Markdowser/ViewModels/MainWindowViewModel.cs +++ b/src/Markdowser/ViewModels/MainWindowViewModel.cs @@ -47,7 +47,7 @@ public partial class MainWindowViewModel : ViewModelBase _ = this.RaiseAndSetIfChanged(ref currentTab!, value); - Url = currentTab?.Tag?.ToString() ?? string.Empty; + Url = value?.Tag?.ToString() ?? string.Empty; FetchUrl(); } @@ -132,18 +132,32 @@ public partial class MainWindowViewModel : ViewModelBase public ICommand CloseTab => ReactiveCommand.Create(() => { + if (IsBusy) + { + WindowNotificationManager.Show(new Notification("Busy", "The browser is currently busy.", NotificationType.Warning)); + return; + } + if (Tabs.Count > 1) { int currentIndex = Tabs.IndexOf(CurrentTab); - _ = Tabs.Remove(CurrentTab); CurrentTab = currentIndex > 0 ? Tabs[currentIndex - 1] : Tabs[0]; + + Tabs.RemoveAt(currentIndex); + this.RaisePropertyChanged(nameof(CloseTabEnabled)); } }); public ICommand NewTab => ReactiveCommand.Create(() => { + if (IsBusy) + { + WindowNotificationManager.Show(new Notification("Busy", "The browser is currently busy.", NotificationType.Warning)); + return; + } + TabItem tab = new() { Header = "New Tab", Name = Guid.NewGuid().ToString() }; Tabs.Add(tab); CurrentTab = tab; diff --git a/src/Markdowser/Views/MainWindow.axaml b/src/Markdowser/Views/MainWindow.axaml index e634897..16f77a7 100644 --- a/src/Markdowser/Views/MainWindow.axaml +++ b/src/Markdowser/Views/MainWindow.axaml @@ -45,9 +45,16 @@ - - + + +