diff --git a/src/Artemis.UI/Screens/RootView.xaml b/src/Artemis.UI/Screens/RootView.xaml index 50eebd295..4ad50b41c 100644 --- a/src/Artemis.UI/Screens/RootView.xaml +++ b/src/Artemis.UI/Screens/RootView.xaml @@ -61,6 +61,19 @@ VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" /> + + + + + + + + + Activating profile... + + + + + @@ -74,7 +75,8 @@ Margin="0 2" ItemContainerStyle="{StaticResource SidebarListBoxItem}" ItemsSource="{Binding SidebarScreens}" - SelectedItem="{Binding SelectedSidebarScreen}"> + SelectedItem="{Binding SelectedSidebarScreen}" + IsEnabled="{Binding ActivatingProfile, Converter={StaticResource InverseBooleanConverter}}"> @@ -105,7 +107,11 @@ dd:DragDrop.DropHandler="{Binding}"> - + diff --git a/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs b/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs index 9b484250d..5ac1bf54e 100644 --- a/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs +++ b/src/Artemis.UI/Screens/Sidebar/SidebarViewModel.cs @@ -35,6 +35,7 @@ namespace Artemis.UI.Screens.Sidebar private MainScreenViewModel _selectedScreen; private readonly SidebarScreenViewModel _profileEditor; private readonly DefaultDropHandler _defaultDropHandler; + private bool _activatingProfile; public SidebarViewModel(IKernel kernel, IEventAggregator eventAggregator, @@ -96,6 +97,12 @@ namespace Artemis.UI.Screens.Sidebar } } + public bool ActivatingProfile + { + get => _activatingProfile; + set => SetAndNotify(ref _activatingProfile, value); + } + private void ActivateScreenViewModel(SidebarScreenViewModel screenViewModel) { SelectedScreen = screenViewModel.CreateInstance(_kernel); @@ -155,18 +162,34 @@ namespace Artemis.UI.Screens.Sidebar if (_profileEditorService.SuspendEditing) _profileEditorService.SuspendEditing = false; - _profileEditorService.ChangeSelectedProfileConfiguration(profileConfiguration); - if (profileConfiguration != null) + + Task.Run(() => { - // Little workaround to clear the selected item in the menu, ugly but oh well - if (_selectedSidebarScreen != _profileEditor) + try { - _selectedSidebarScreen = null; - NotifyOfPropertyChange(nameof(SelectedSidebarScreen)); + ActivatingProfile = true; + _profileEditorService.ChangeSelectedProfileConfiguration(profileConfiguration); + } + finally + { + ActivatingProfile = false; } - SelectedSidebarScreen = _profileEditor; - } + if (profileConfiguration == null) + return; + + Execute.PostToUIThread(() => + { + // Little workaround to clear the selected item in the menu, ugly but oh well + if (_selectedSidebarScreen != _profileEditor) + { + _selectedSidebarScreen = null; + NotifyOfPropertyChange(nameof(SelectedSidebarScreen)); + } + + SelectedSidebarScreen = _profileEditor; + }); + }); } #region Overrides of Screen @@ -212,7 +235,7 @@ namespace Artemis.UI.Screens.Sidebar Items[index].ProfileCategory.Order = index; // Bit dumb but gets the job done - foreach (SidebarCategoryViewModel viewModel in Items) + foreach (SidebarCategoryViewModel viewModel in Items) _profileService.SaveProfileCategory(viewModel.ProfileCategory); }