mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profiles - Don't run ModuleActivated on UI thread closes #617
Profiles - Show busy indicator on slow activating profiles
This commit is contained in:
parent
35f27b14df
commit
f1a4203345
@ -61,6 +61,19 @@
|
|||||||
VerticalContentAlignment="Stretch"
|
VerticalContentAlignment="Stretch"
|
||||||
HorizontalContentAlignment="Stretch"
|
HorizontalContentAlignment="Stretch"
|
||||||
IsTabStop="False" />
|
IsTabStop="False" />
|
||||||
|
|
||||||
|
<Border Grid.Row="1" Visibility="{Binding SidebarViewModel.ActivatingProfile, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay, Delay=2000}">
|
||||||
|
<Border.Background>
|
||||||
|
<SolidColorBrush Color="{Binding Path=Color, Source={StaticResource MaterialDesignToolBarBackground}}" Opacity="0.5"></SolidColorBrush>
|
||||||
|
</Border.Background>
|
||||||
|
<StackPanel VerticalAlignment="Center" HorizontalAlignment="Center">
|
||||||
|
<ProgressBar Style="{StaticResource MaterialDesignCircularProgressBar}" Value="0" IsIndeterminate="True" Width="50" Height="50" Margin="20"/>
|
||||||
|
<TextBlock TextAlignment="Center" Style="{StaticResource MaterialDesignHeadline5TextBlock}">
|
||||||
|
Activating profile...
|
||||||
|
</TextBlock>
|
||||||
|
</StackPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
<materialDesign:Snackbar Grid.Row="0"
|
<materialDesign:Snackbar Grid.Row="0"
|
||||||
Grid.RowSpan="2"
|
Grid.RowSpan="2"
|
||||||
x:Name="MainSnackbar"
|
x:Name="MainSnackbar"
|
||||||
|
|||||||
@ -18,6 +18,7 @@
|
|||||||
<ResourceDictionary.MergedDictionaries>
|
<ResourceDictionary.MergedDictionaries>
|
||||||
<ResourceDictionary Source="ArtemisSidebar.xaml" />
|
<ResourceDictionary Source="ArtemisSidebar.xaml" />
|
||||||
</ResourceDictionary.MergedDictionaries>
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
|
||||||
</ResourceDictionary>
|
</ResourceDictionary>
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<materialDesign:DialogHost IsTabStop="False" Focusable="False" Identifier="SidebarDialog" DialogTheme="Inherit" DialogMargin="14">
|
<materialDesign:DialogHost IsTabStop="False" Focusable="False" Identifier="SidebarDialog" DialogTheme="Inherit" DialogMargin="14">
|
||||||
@ -74,7 +75,8 @@
|
|||||||
Margin="0 2"
|
Margin="0 2"
|
||||||
ItemContainerStyle="{StaticResource SidebarListBoxItem}"
|
ItemContainerStyle="{StaticResource SidebarListBoxItem}"
|
||||||
ItemsSource="{Binding SidebarScreens}"
|
ItemsSource="{Binding SidebarScreens}"
|
||||||
SelectedItem="{Binding SelectedSidebarScreen}">
|
SelectedItem="{Binding SelectedSidebarScreen}"
|
||||||
|
IsEnabled="{Binding ActivatingProfile, Converter={StaticResource InverseBooleanConverter}}">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
||||||
@ -105,7 +107,11 @@
|
|||||||
dd:DragDrop.DropHandler="{Binding}">
|
dd:DragDrop.DropHandler="{Binding}">
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<ContentControl s:View.Model="{Binding}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" IsTabStop="False" />
|
<ContentControl s:View.Model="{Binding}"
|
||||||
|
VerticalContentAlignment="Stretch"
|
||||||
|
HorizontalContentAlignment="Stretch"
|
||||||
|
IsTabStop="False"
|
||||||
|
IsEnabled="{Binding DataContext.ActivatingProfile, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Converter={StaticResource InverseBooleanConverter}}" />
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
|
|||||||
@ -35,6 +35,7 @@ namespace Artemis.UI.Screens.Sidebar
|
|||||||
private MainScreenViewModel _selectedScreen;
|
private MainScreenViewModel _selectedScreen;
|
||||||
private readonly SidebarScreenViewModel<ProfileEditorViewModel> _profileEditor;
|
private readonly SidebarScreenViewModel<ProfileEditorViewModel> _profileEditor;
|
||||||
private readonly DefaultDropHandler _defaultDropHandler;
|
private readonly DefaultDropHandler _defaultDropHandler;
|
||||||
|
private bool _activatingProfile;
|
||||||
|
|
||||||
public SidebarViewModel(IKernel kernel,
|
public SidebarViewModel(IKernel kernel,
|
||||||
IEventAggregator eventAggregator,
|
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)
|
private void ActivateScreenViewModel(SidebarScreenViewModel screenViewModel)
|
||||||
{
|
{
|
||||||
SelectedScreen = screenViewModel.CreateInstance(_kernel);
|
SelectedScreen = screenViewModel.CreateInstance(_kernel);
|
||||||
@ -155,18 +162,34 @@ namespace Artemis.UI.Screens.Sidebar
|
|||||||
|
|
||||||
if (_profileEditorService.SuspendEditing)
|
if (_profileEditorService.SuspendEditing)
|
||||||
_profileEditorService.SuspendEditing = false;
|
_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
|
try
|
||||||
if (_selectedSidebarScreen != _profileEditor)
|
|
||||||
{
|
{
|
||||||
_selectedSidebarScreen = null;
|
ActivatingProfile = true;
|
||||||
NotifyOfPropertyChange(nameof(SelectedSidebarScreen));
|
_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
|
#region Overrides of Screen
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user