1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Profile editor - Added F5 hotkey to toggle normal profile playback

Profile editor - Disable toolbar and tools during normal profile playback
Layer conditions - Properly apply Skip To End stop-mode on profile start
This commit is contained in:
Robert 2021-07-02 23:18:50 +02:00
parent 472bcccdb6
commit 51a5724adf
14 changed files with 110 additions and 37 deletions

View File

@ -397,7 +397,7 @@ namespace Artemis.Core
if (conditionMet && !DisplayConditionMet && Timeline.IsFinished) if (conditionMet && !DisplayConditionMet && Timeline.IsFinished)
Timeline.JumpToStart(); Timeline.JumpToStart();
// If regular conditions are no longer met, jump to the end segment if stop mode requires it // If regular conditions are no longer met, jump to the end segment if stop mode requires it
if (!conditionMet && DisplayConditionMet && Timeline.StopMode == TimelineStopMode.SkipToEnd) if (!conditionMet && Timeline.StopMode == TimelineStopMode.SkipToEnd)
Timeline.JumpToEndSegment(); Timeline.JumpToEndSegment();
} }
else if (conditionMet) else if (conditionMet)

View File

@ -216,7 +216,8 @@ namespace Artemis.Core.Services
if (shouldBeActive) if (shouldBeActive)
{ {
profileConfiguration.Update(); profileConfiguration.Update();
shouldBeActive = profileConfiguration.ActivationConditionMet; if (!profileConfiguration.IsBeingEdited)
shouldBeActive = profileConfiguration.ActivationConditionMet;
} }
try try

View File

@ -163,6 +163,9 @@ namespace Artemis.UI.Shared.Services
{ {
lock (_selectedProfileLock) lock (_selectedProfileLock)
{ {
if (SuspendEditing)
throw new ArtemisSharedUIException("Cannot change the selected profile while editing is suspended");
if (SelectedProfileConfiguration == profileConfiguration) if (SelectedProfileConfiguration == profileConfiguration)
return; return;
@ -170,17 +173,21 @@ namespace Artemis.UI.Shared.Services
throw new ArtemisSharedUIException("Cannot select a disposed profile"); throw new ArtemisSharedUIException("Cannot select a disposed profile");
_logger.Verbose("ChangeSelectedProfileConfiguration {profile}", profileConfiguration); _logger.Verbose("ChangeSelectedProfileConfiguration {profile}", profileConfiguration);
if (SelectedProfileConfiguration != null)
SaveSelectedProfileConfiguration();
ChangeSelectedProfileElement(null); ChangeSelectedProfileElement(null);
ProfileConfigurationEventArgs profileConfigurationElementEvent = new(profileConfiguration, SelectedProfileConfiguration); ProfileConfigurationEventArgs profileConfigurationElementEvent = new(profileConfiguration, SelectedProfileConfiguration);
// No need to deactivate the profile, if needed it will be deactivated next update // No need to deactivate the profile, if needed it will be deactivated next update
if (SelectedProfileConfiguration != null) if (SelectedProfileConfiguration != null)
SelectedProfileConfiguration.IsBeingEdited = false; SelectedProfileConfiguration.IsBeingEdited = false;
// The new profile may need activation
PreviousSelectedProfileConfiguration = SelectedProfileConfiguration; PreviousSelectedProfileConfiguration = SelectedProfileConfiguration;
SelectedProfileConfiguration = profileConfiguration; SelectedProfileConfiguration = profileConfiguration;
;
// The new profile may need activation
if (SelectedProfileConfiguration != null) if (SelectedProfileConfiguration != null)
{ {
SelectedProfileConfiguration.IsBeingEdited = true; SelectedProfileConfiguration.IsBeingEdited = true;

View File

@ -462,7 +462,7 @@
The profile is currently running in normal mode and the timeline cannot be edited. The profile is currently running in normal mode and the timeline cannot be edited.
</TextBlock> </TextBlock>
<TextBlock Style="{StaticResource MaterialDesignBody2TextBlock}" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center"> <TextBlock Style="{StaticResource MaterialDesignBody2TextBlock}" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center">
Press <Run Text="F5" FontWeight="Bold"/> to toggle between editor mode and normal mode. Auto-switching can be disabled in the options menu. Press <Run Text="F5" FontWeight="Bold"/> to switch between editor mode and normal mode. Auto-switching can be disabled in the options menu.
</TextBlock> </TextBlock>
</StackPanel> </StackPanel>
</Border> </Border>

View File

@ -26,6 +26,8 @@
<UserControl.InputBindings> <UserControl.InputBindings>
<KeyBinding Command="{s:Action Undo}" Modifiers="Control" Key="Z" /> <KeyBinding Command="{s:Action Undo}" Modifiers="Control" Key="Z" />
<KeyBinding Command="{s:Action Redo}" Modifiers="Control" Key="Y" /> <KeyBinding Command="{s:Action Redo}" Modifiers="Control" Key="Y" />
<KeyBinding Command="{s:Action ToggleSuspend}" Key="F5" />
<KeyBinding Command="{s:Action ToggleAutoSuspend}" Modifiers="Ctrl" Key="F5" />
</UserControl.InputBindings> </UserControl.InputBindings>
<Grid ClipToBounds="True"> <Grid ClipToBounds="True">
@ -97,6 +99,17 @@
Command="{s:Action Paste}" Command="{s:Action Paste}"
InputGestureText="Ctrl+V" /> InputGestureText="Ctrl+V" />
</MenuItem> </MenuItem>
<MenuItem Header="_Run">
<MenuItem Header="_Switch run mode"
Icon="{materialDesign:PackIcon Kind=SwapHorizontal}"
Command="{s:Action ToggleSuspend}"
InputGestureText="F5" />
<MenuItem Header="Run Profile on Focus Loss"
ToolTip="If enabled, regular profile playback is resumed on focus loss"
IsCheckable="True"
IsChecked="{Binding StopOnFocusLoss.Value}"
InputGestureText="Ctrl+F5" />
</MenuItem>
<MenuItem Header="_Scripting" IsEnabled="False"> <MenuItem Header="_Scripting" IsEnabled="False">
<MenuItem Header="_Profile Scripts" <MenuItem Header="_Profile Scripts"
Icon="{materialDesign:PackIcon Kind=BookEdit}" Icon="{materialDesign:PackIcon Kind=BookEdit}"
@ -119,10 +132,7 @@
<MenuItem Header="Display Data Model Values" <MenuItem Header="Display Data Model Values"
IsCheckable="True" IsCheckable="True"
IsChecked="{Binding ShowDataModelValues.Value}"/> IsChecked="{Binding ShowDataModelValues.Value}"/>
<MenuItem Header="Run Profile on Focus Loss"
ToolTip="If enabled, regular profile playback is resumed on focus loss"
IsCheckable="True"
IsChecked="{Binding StopOnFocusLoss.Value}"/>
<MenuItem Header="Apply All Data Bindings During Edit" <MenuItem Header="Apply All Data Bindings During Edit"
ToolTip="If enabled, updates all data bindings instead of only the one you are editing" ToolTip="If enabled, updates all data bindings instead of only the one you are editing"
IsCheckable="True" IsCheckable="True"

View File

@ -37,7 +37,8 @@ namespace Artemis.UI.Screens.ProfileEditor
private LayerPropertiesViewModel _layerPropertiesViewModel; private LayerPropertiesViewModel _layerPropertiesViewModel;
private ProfileTreeViewModel _profileTreeViewModel; private ProfileTreeViewModel _profileTreeViewModel;
private ProfileViewModel _profileViewModel; private ProfileViewModel _profileViewModel;
private bool _suspendedManually;
public ProfileEditorViewModel(ProfileViewModel profileViewModel, public ProfileEditorViewModel(ProfileViewModel profileViewModel,
ProfileTreeViewModel profileTreeViewModel, ProfileTreeViewModel profileTreeViewModel,
DisplayConditionsViewModel dataModelConditionsViewModel, DisplayConditionsViewModel dataModelConditionsViewModel,
@ -62,7 +63,7 @@ namespace Artemis.UI.Screens.ProfileEditor
_eventAggregator = eventAggregator; _eventAggregator = eventAggregator;
_scriptVmFactory = scriptVmFactory; _scriptVmFactory = scriptVmFactory;
_sidebarVmFactory = sidebarVmFactory; _sidebarVmFactory = sidebarVmFactory;
DisplayName = "Profile Editor"; DisplayName = "Profile Editor";
DialogService = dialogService; DialogService = dialogService;
@ -105,6 +106,12 @@ namespace Artemis.UI.Screens.ProfileEditor
set => SetAndNotify(ref _profileViewModel, value); set => SetAndNotify(ref _profileViewModel, value);
} }
public bool SuspendedManually
{
get => _suspendedManually;
set => SetAndNotify(ref _suspendedManually, value);
}
public PluginSetting<GridLength> SidePanelsWidth => _settingsService.GetSetting("ProfileEditor.SidePanelsWidth", new GridLength(385)); public PluginSetting<GridLength> SidePanelsWidth => _settingsService.GetSetting("ProfileEditor.SidePanelsWidth", new GridLength(385));
public PluginSetting<GridLength> DataModelConditionsHeight => _settingsService.GetSetting("ProfileEditor.DataModelConditionsHeight", new GridLength(345)); public PluginSetting<GridLength> DataModelConditionsHeight => _settingsService.GetSetting("ProfileEditor.DataModelConditionsHeight", new GridLength(345));
public PluginSetting<GridLength> BottomPanelsHeight => _settingsService.GetSetting("ProfileEditor.BottomPanelsHeight", new GridLength(265)); public PluginSetting<GridLength> BottomPanelsHeight => _settingsService.GetSetting("ProfileEditor.BottomPanelsHeight", new GridLength(265));
@ -168,6 +175,17 @@ namespace Artemis.UI.Screens.ProfileEditor
_messageService.ShowMessage("Redid profile update", "UNDO", Undo); _messageService.ShowMessage("Redid profile update", "UNDO", Undo);
} }
public void ToggleSuspend()
{
_profileEditorService.SuspendEditing = !_profileEditorService.SuspendEditing;
SuspendedManually = _profileEditorService.SuspendEditing;
}
public void ToggleAutoSuspend()
{
StopOnFocusLoss.Value = !StopOnFocusLoss.Value;
}
#region Overrides of Screen #region Overrides of Screen
protected override void OnInitialActivate() protected override void OnInitialActivate()
@ -194,6 +212,8 @@ namespace Artemis.UI.Screens.ProfileEditor
_profileEditorService.SelectedProfileElementChanged -= ProfileEditorServiceOnSelectedProfileElementChanged; _profileEditorService.SelectedProfileElementChanged -= ProfileEditorServiceOnSelectedProfileElementChanged;
_eventAggregator.Unsubscribe(this); _eventAggregator.Unsubscribe(this);
SaveWorkspaceSettings(); SaveWorkspaceSettings();
_profileEditorService.SuspendEditing = false;
_profileEditorService.ChangeSelectedProfileConfiguration(null); _profileEditorService.ChangeSelectedProfileConfiguration(null);
base.OnClose(); base.OnClose();
@ -210,7 +230,7 @@ namespace Artemis.UI.Screens.ProfileEditor
{ {
NotifyOfPropertyChange(nameof(HasSelectedElement)); NotifyOfPropertyChange(nameof(HasSelectedElement));
} }
private void SaveWorkspaceSettings() private void SaveWorkspaceSettings()
{ {
SidePanelsWidth.Save(); SidePanelsWidth.Save();
@ -322,7 +342,7 @@ namespace Artemis.UI.Screens.ProfileEditor
/// <inheritdoc /> /// <inheritdoc />
public void Handle(MainWindowFocusChangedEvent message) public void Handle(MainWindowFocusChangedEvent message)
{ {
if (!StopOnFocusLoss.Value) if (!StopOnFocusLoss.Value || SuspendedManually)
return; return;
_profileEditorService.SuspendEditing = !message.IsFocused; _profileEditorService.SuspendEditing = !message.IsFocused;

View File

@ -87,7 +87,8 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
Execute.PostToUIThread(async () => Execute.PostToUIThread(async () =>
{ {
await Task.Delay(1500); await Task.Delay(1500);
SelectedTreeItem = ActiveItem.GetAllChildren().FirstOrDefault(c => c.ProfileElement == _profileEditorService.SelectedProfileElement); if (ActiveItem != null)
SelectedTreeItem = ActiveItem.GetAllChildren().FirstOrDefault(c => c.ProfileElement == _profileEditorService.SelectedProfileElement);
}); });
} }

View File

@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.Visualization.ProfileView" <UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@ -7,9 +7,13 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:visualization="clr-namespace:Artemis.UI.Screens.ProfileEditor.Visualization" xmlns:visualization="clr-namespace:Artemis.UI.Screens.ProfileEditor.Visualization"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared" xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
xmlns:Converters="clr-namespace:Artemis.UI.Converters" x:Class="Artemis.UI.Screens.ProfileEditor.Visualization.ProfileView"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="510.9" d:DesignWidth="800" d:DesignHeight="510.9" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileViewModel}}"> d:DataContext="{d:DesignInstance {x:Type visualization:ProfileViewModel}}">
<UserControl.Resources>
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
</UserControl.Resources>
<Grid> <Grid>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -27,13 +31,16 @@
<ListBoxItem ToolTip="Pan over different parts of the surface - Ctrl"> <ListBoxItem ToolTip="Pan over different parts of the surface - Ctrl">
<materialDesign:PackIcon Kind="HandLeft" /> <materialDesign:PackIcon Kind="HandLeft" />
</ListBoxItem> </ListBoxItem>
<ListBoxItem ToolTip="Transform layer shape (hold SHIFT for incremental changes and X/Y snapping) - Ctrl+T" IsEnabled="{Binding CanSelectEditTool}"> <ListBoxItem ToolTip="Transform layer shape (hold SHIFT for incremental changes and X/Y snapping) - Ctrl+T"
IsEnabled="{Binding CanSelectEditTool}">
<materialDesign:PackIcon Kind="TransitConnectionVariant" /> <materialDesign:PackIcon Kind="TransitConnectionVariant" />
</ListBoxItem> </ListBoxItem>
<ListBoxItem ToolTip="Change layer selection (hold SHIFT to add to existing selection) - Ctrl+Q"> <ListBoxItem ToolTip="Change layer selection (hold SHIFT to add to existing selection) - Ctrl+Q"
IsEnabled="{Binding SuspendedEditing, Converter={StaticResource InverseBooleanConverter}, Mode=OneWay}">
<materialDesign:PackIcon Kind="SelectionDrag" /> <materialDesign:PackIcon Kind="SelectionDrag" />
</ListBoxItem> </ListBoxItem>
<ListBoxItem ToolTip="Remove from layer selection - Ctrl+W"> <ListBoxItem ToolTip="Remove from layer selection - Ctrl+W"
IsEnabled="{Binding SuspendedEditing, Converter={StaticResource InverseBooleanConverter}, Mode=OneWay}">
<materialDesign:PackIcon Kind="SelectOff" /> <materialDesign:PackIcon Kind="SelectOff" />
</ListBoxItem> </ListBoxItem>
</ListBox> </ListBox>
@ -71,7 +78,7 @@
</VisualBrush> </VisualBrush>
</Grid.Background> </Grid.Background>
<Grid Name="DeviceDisplayGrid"> <Grid x:Name="DeviceDisplayGrid">
<Grid.RenderTransform> <Grid.RenderTransform>
<TransformGroup> <TransformGroup>
<ScaleTransform ScaleX="{Binding PanZoomViewModel.Zoom}" ScaleY="{Binding PanZoomViewModel.Zoom}" /> <ScaleTransform ScaleX="{Binding PanZoomViewModel.Zoom}" ScaleY="{Binding PanZoomViewModel.Zoom}" />
@ -85,7 +92,7 @@
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle> <ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter"> <Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Left" Value="{Binding X}" /> <Setter Property="Canvas.Left" Value="{Binding X}" />
<Setter Property="Canvas.Top" Value="{Binding Y}" /> <Setter Property="Canvas.Top" Value="{Binding Y}" />
</Style> </Style>
@ -94,13 +101,13 @@
<DataTemplate> <DataTemplate>
<shared:DeviceVisualizer Device="{Binding}" <shared:DeviceVisualizer Device="{Binding}"
ShowColors="True" ShowColors="True"
HighlightedLeds="{Binding DataContext.HighlightedLeds, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=OneWay}" /> HighlightedLeds="{Binding DataContext.HighlightedLeds, Mode=OneWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
</DataTemplate> </DataTemplate>
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
</Grid> </Grid>
<Grid Name="EditorDisplayGrid" <Grid x:Name="EditorDisplayGrid"
Visibility="{Binding SuspendedEditing, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}" Visibility="{Binding SuspendedEditing, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}"
shared:SizeObserver.Observe="True" shared:SizeObserver.Observe="True"
shared:SizeObserver.ObservedHeight="{Binding PanZoomViewModel.CanvasHeight}" shared:SizeObserver.ObservedHeight="{Binding PanZoomViewModel.CanvasHeight}"
@ -118,7 +125,7 @@
</ItemsPanelTemplate> </ItemsPanelTemplate>
</ItemsControl.ItemsPanel> </ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle> <ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter"> <Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Left" Value="{Binding X}" /> <Setter Property="Canvas.Left" Value="{Binding X}" />
<Setter Property="Canvas.Top" Value="{Binding Y}" /> <Setter Property="Canvas.Top" Value="{Binding Y}" />
</Style> </Style>
@ -130,9 +137,9 @@
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
</Grid> </Grid>
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Right" <StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Right"
Margin="10" ZIndex="1"> Margin="10" Panel.ZIndex="1">
<Slider Orientation="Vertical" <Slider Orientation="Vertical"
HorizontalAlignment="Center" HorizontalAlignment="Center"
Margin="0 10" Margin="0 10"

View File

@ -232,12 +232,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
if (CanSelectEditTool == false && ActiveToolIndex == 1) if (CanSelectEditTool == false && ActiveToolIndex == 1)
ActivateToolByIndex(2); ActivateToolByIndex(2);
} }
private void ProfileEditorServiceOnSuspendEditingChanged(object? sender, EventArgs e)
{
NotifyOfPropertyChange(nameof(SuspendedEditing));
}
#region Buttons #region Buttons
private void ActivateToolByIndex(int value) private void ActivateToolByIndex(int value)
@ -315,7 +310,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
TimeSpan delta = DateTime.Now - _lastUpdate; TimeSpan delta = DateTime.Now - _lastUpdate;
_lastUpdate = DateTime.Now; _lastUpdate = DateTime.Now;
if (!_settingsService.GetSetting("ProfileEditor.AlwaysApplyDataBindings", true).Value || _profileEditorService.SelectedProfile == null) if (SuspendedEditing || !_settingsService.GetSetting("ProfileEditor.AlwaysApplyDataBindings", true).Value || _profileEditorService.SelectedProfile == null)
return; return;
foreach (IDataBindingRegistration dataBindingRegistration in _profileEditorService.SelectedProfile.GetAllFolders() foreach (IDataBindingRegistration dataBindingRegistration in _profileEditorService.SelectedProfile.GetAllFolders()
@ -396,6 +391,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
ActivateToolByIndex(2); ActivateToolByIndex(2);
} }
private void ProfileEditorServiceOnSuspendEditingChanged(object? sender, EventArgs e)
{
NotifyOfPropertyChange(nameof(SuspendedEditing));
UpdateCanSelectEditTool();
}
public void Handle(MainWindowKeyEvent message) public void Handle(MainWindowKeyEvent message)
{ {
if (message.KeyDown) if (message.KeyDown)

View File

@ -32,6 +32,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools
{ {
base.MouseUp(sender, e); base.MouseUp(sender, e);
if (ProfileEditorService.SuspendEditing)
return;
Point position = PanZoomViewModel.GetRelativeMousePosition(sender, e); Point position = PanZoomViewModel.GetRelativeMousePosition(sender, e);
Rect selectedRect = new(MouseDownStartPosition, position); Rect selectedRect = new(MouseDownStartPosition, position);

View File

@ -37,6 +37,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools
{ {
base.MouseUp(sender, e); base.MouseUp(sender, e);
if (ProfileEditorService.SuspendEditing)
return;
Point position = PanZoomViewModel.GetRelativeMousePosition(sender, e); Point position = PanZoomViewModel.GetRelativeMousePosition(sender, e);
Rect selectedRect = new(MouseDownStartPosition, position); Rect selectedRect = new(MouseDownStartPosition, position);

View File

@ -20,6 +20,7 @@
UseLayoutRounding="True" UseLayoutRounding="True"
Deactivated="{s:Action WindowDeactivated}" Deactivated="{s:Action WindowDeactivated}"
Activated="{s:Action WindowActivated}" Activated="{s:Action WindowActivated}"
StateChanged="{s:Action WindowStateChanged}"
KeyDown="{s:Action WindowKeyDown}" KeyDown="{s:Action WindowKeyDown}"
KeyUp="{s:Action WindowKeyUp}" KeyUp="{s:Action WindowKeyUp}"
MouseDown="{s:Action WindowMouseDown}" MouseDown="{s:Action WindowMouseDown}"

View File

@ -1,5 +1,6 @@
using System; using System;
using System.Reflection; using System.Reflection;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
@ -79,8 +80,7 @@ namespace Artemis.UI.Screens
public void WindowDeactivated() public void WindowDeactivated()
{ {
WindowState windowState = ((Window) View).WindowState; if (_lostFocus)
if (windowState == WindowState.Minimized)
return; return;
_lostFocus = true; _lostFocus = true;
@ -91,13 +91,30 @@ namespace Artemis.UI.Screens
{ {
if (!_lostFocus) if (!_lostFocus)
return; return;
if (!((MaterialWindow)View).IsActive)
return;
_lostFocus = false; _lostFocus = false;
_eventAggregator.Publish(new MainWindowFocusChangedEvent(true)); _eventAggregator.Publish(new MainWindowFocusChangedEvent(true));
} }
// This is required because Windows incorrectly tells the window it is activated when minimizing using the taskbar
public void WindowStateChanged()
{
if (((Window) View).WindowState == WindowState.Minimized)
WindowDeactivated();
else
WindowActivated();
}
#region Overrides of Screen
/// <inheritdoc />
protected override void OnStateChanged(ScreenState previousState, ScreenState newState)
{
base.OnStateChanged(previousState, newState);
}
#endregion
public void WindowKeyDown(object sender, KeyEventArgs e) public void WindowKeyDown(object sender, KeyEventArgs e)
{ {
_eventAggregator.Publish(new MainWindowKeyEvent(sender, true, e)); _eventAggregator.Publish(new MainWindowKeyEvent(sender, true, e));

View File

@ -153,6 +153,8 @@ namespace Artemis.UI.Screens.Sidebar
foreach (SidebarCategoryViewModel sidebarCategoryViewModel in Items) foreach (SidebarCategoryViewModel sidebarCategoryViewModel in Items)
sidebarCategoryViewModel.SelectedProfileConfiguration = sidebarCategoryViewModel.Items.FirstOrDefault(i => i.ProfileConfiguration == profileConfiguration); sidebarCategoryViewModel.SelectedProfileConfiguration = sidebarCategoryViewModel.Items.FirstOrDefault(i => i.ProfileConfiguration == profileConfiguration);
if (_profileEditorService.SuspendEditing)
_profileEditorService.SuspendEditing = false;
_profileEditorService.ChangeSelectedProfileConfiguration(profileConfiguration); _profileEditorService.ChangeSelectedProfileConfiguration(profileConfiguration);
if (profileConfiguration != null) if (profileConfiguration != null)
{ {