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 committed 2021-07-02 23:18:50 +02:00
1 parent 472bcccdb6
commit 51a5724adf
14 files changed
+110 -37

No files matched your search

@@ -462,7 +462,7 @@
The profile is currently running in normal mode and the timeline cannot be edited.
</TextBlock>
<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>
</StackPanel>
</Border>
@@ -26,6 +26,8 @@
<UserControl.InputBindings>
<KeyBinding Command="{s:Action Undo}" Modifiers="Control" Key="Z" />
<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>
<Grid ClipToBounds="True">
@@ -97,6 +99,17 @@
Command="{s:Action Paste}"
InputGestureText="Ctrl+V" />
</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="_Profile Scripts"
Icon="{materialDesign:PackIcon Kind=BookEdit}"
@@ -119,10 +132,7 @@
<MenuItem Header="Display Data Model Values"
IsCheckable="True"
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"
ToolTip="If enabled, updates all data bindings instead of only the one you are editing"
IsCheckable="True"
@@ -37,7 +37,8 @@ namespace Artemis.UI.Screens.ProfileEditor
private LayerPropertiesViewModel _layerPropertiesViewModel;
private ProfileTreeViewModel _profileTreeViewModel;
private ProfileViewModel _profileViewModel;
private bool _suspendedManually;
public ProfileEditorViewModel(ProfileViewModel profileViewModel,
ProfileTreeViewModel profileTreeViewModel,
DisplayConditionsViewModel dataModelConditionsViewModel,
@@ -62,7 +63,7 @@ namespace Artemis.UI.Screens.ProfileEditor
_eventAggregator = eventAggregator;
_scriptVmFactory = scriptVmFactory;
_sidebarVmFactory = sidebarVmFactory;
DisplayName = "Profile Editor";
DialogService = dialogService;
@@ -105,6 +106,12 @@ namespace Artemis.UI.Screens.ProfileEditor
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> DataModelConditionsHeight => _settingsService.GetSetting("ProfileEditor.DataModelConditionsHeight", new GridLength(345));
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);
}
public void ToggleSuspend()
{
_profileEditorService.SuspendEditing = !_profileEditorService.SuspendEditing;
SuspendedManually = _profileEditorService.SuspendEditing;
}
public void ToggleAutoSuspend()
{
StopOnFocusLoss.Value = !StopOnFocusLoss.Value;
}
#region Overrides of Screen
protected override void OnInitialActivate()
@@ -194,6 +212,8 @@ namespace Artemis.UI.Screens.ProfileEditor
_profileEditorService.SelectedProfileElementChanged -= ProfileEditorServiceOnSelectedProfileElementChanged;
_eventAggregator.Unsubscribe(this);
SaveWorkspaceSettings();
_profileEditorService.SuspendEditing = false;
_profileEditorService.ChangeSelectedProfileConfiguration(null);
base.OnClose();
@@ -210,7 +230,7 @@ namespace Artemis.UI.Screens.ProfileEditor
{
NotifyOfPropertyChange(nameof(HasSelectedElement));
}
private void SaveWorkspaceSettings()
{
SidePanelsWidth.Save();
@@ -322,7 +342,7 @@ namespace Artemis.UI.Screens.ProfileEditor
/// <inheritdoc />
public void Handle(MainWindowFocusChangedEvent message)
{
if (!StopOnFocusLoss.Value)
if (!StopOnFocusLoss.Value || SuspendedManually)
return;
_profileEditorService.SuspendEditing = !message.IsFocused;
@@ -87,7 +87,8 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
Execute.PostToUIThread(async () =>
{
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);
});
}
@@ -1,4 +1,4 @@
<UserControl x:Class="Artemis.UI.Screens.ProfileEditor.Visualization.ProfileView"
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
@@ -7,9 +7,13 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:visualization="clr-namespace:Artemis.UI.Screens.ProfileEditor.Visualization"
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"
d:DesignHeight="510.9" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type visualization:ProfileViewModel}}">
<UserControl.Resources>
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
@@ -27,13 +31,16 @@
<ListBoxItem ToolTip="Pan over different parts of the surface - Ctrl">
<materialDesign:PackIcon Kind="HandLeft" />
</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" />
</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" />
</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" />
</ListBoxItem>
</ListBox>
@@ -71,7 +78,7 @@
</VisualBrush>
</Grid.Background>
<Grid Name="DeviceDisplayGrid">
<Grid x:Name="DeviceDisplayGrid">
<Grid.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="{Binding PanZoomViewModel.Zoom}" ScaleY="{Binding PanZoomViewModel.Zoom}" />
@@ -85,7 +92,7 @@
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Left" Value="{Binding X}" />
<Setter Property="Canvas.Top" Value="{Binding Y}" />
</Style>
@@ -94,13 +101,13 @@
<DataTemplate>
<shared:DeviceVisualizer Device="{Binding}"
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>
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<Grid Name="EditorDisplayGrid"
<Grid x:Name="EditorDisplayGrid"
Visibility="{Binding SuspendedEditing, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, Mode=OneWay}"
shared:SizeObserver.Observe="True"
shared:SizeObserver.ObservedHeight="{Binding PanZoomViewModel.CanvasHeight}"
@@ -118,7 +125,7 @@
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemContainerStyle>
<Style TargetType="ContentPresenter">
<Style TargetType="{x:Type ContentPresenter}">
<Setter Property="Canvas.Left" Value="{Binding X}" />
<Setter Property="Canvas.Top" Value="{Binding Y}" />
</Style>
@@ -130,9 +137,9 @@
</ItemsControl.ItemTemplate>
</ItemsControl>
</Grid>
<StackPanel Orientation="Vertical" VerticalAlignment="Bottom" HorizontalAlignment="Right"
Margin="10" ZIndex="1">
Margin="10" Panel.ZIndex="1">
<Slider Orientation="Vertical"
HorizontalAlignment="Center"
Margin="0 10"
@@ -232,12 +232,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
if (CanSelectEditTool == false && ActiveToolIndex == 1)
ActivateToolByIndex(2);
}
private void ProfileEditorServiceOnSuspendEditingChanged(object? sender, EventArgs e)
{
NotifyOfPropertyChange(nameof(SuspendedEditing));
}
#region Buttons
private void ActivateToolByIndex(int value)
@@ -315,7 +310,7 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
TimeSpan delta = DateTime.Now - _lastUpdate;
_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;
foreach (IDataBindingRegistration dataBindingRegistration in _profileEditorService.SelectedProfile.GetAllFolders()
@@ -396,6 +391,12 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization
ActivateToolByIndex(2);
}
private void ProfileEditorServiceOnSuspendEditingChanged(object? sender, EventArgs e)
{
NotifyOfPropertyChange(nameof(SuspendedEditing));
UpdateCanSelectEditTool();
}
public void Handle(MainWindowKeyEvent message)
{
if (message.KeyDown)
@@ -32,6 +32,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools
{
base.MouseUp(sender, e);
if (ProfileEditorService.SuspendEditing)
return;
Point position = PanZoomViewModel.GetRelativeMousePosition(sender, e);
Rect selectedRect = new(MouseDownStartPosition, position);
@@ -37,6 +37,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Visualization.Tools
{
base.MouseUp(sender, e);
if (ProfileEditorService.SuspendEditing)
return;
Point position = PanZoomViewModel.GetRelativeMousePosition(sender, e);
Rect selectedRect = new(MouseDownStartPosition, position);