Merge branch 'development'

This commit is contained in:
Robert committed 2021-07-11 19:32:56 +02:00
commit 719d95bd33
19 files changed
+457 -97

No files matched your search

@@ -24,8 +24,6 @@ namespace Artemis.UI.Screens.ProfileEditor.Conditions
: base(dataModelConditionListPredicate, modules, profileEditorService, dataModelUIService, conditionOperatorService, settingsService)
{
_dataModelUIService = dataModelUIService;
DataModelPathSegment dataModelPathSegment = dataModelConditionListPredicate.LeftPath.Segments.ToList()[1];
var segmentDescription = dataModelPathSegment.GetPropertyDescription();
LeftSideColor = new SolidColorBrush(Color.FromRgb(71, 108, 188));
}
@@ -501,11 +501,17 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
public void GoToEnd()
{
if (SelectedProfileElement == null)
return;
ProfileEditorService.CurrentTime = SelectedProfileElement.Timeline.EndSegmentEndPosition;
}
public void GoToPreviousFrame()
{
if (SelectedProfileElement == null)
return;
double frameTime = 1000.0 / SettingsService.GetSetting("Core.TargetFrameRate", 25).Value;
double newTime = Math.Max(0, Math.Round((ProfileEditorService.CurrentTime.TotalMilliseconds - frameTime) / frameTime) * frameTime);
ProfileEditorService.CurrentTime = TimeSpan.FromMilliseconds(newTime);
@@ -513,6 +519,9 @@ namespace Artemis.UI.Screens.ProfileEditor.LayerProperties
public void GoToNextFrame()
{
if (SelectedProfileElement == null)
return;
double frameTime = 1000.0 / SettingsService.GetSetting("Core.TargetFrameRate", 25).Value;
double newTime = Math.Round((ProfileEditorService.CurrentTime.TotalMilliseconds + frameTime) / frameTime) * frameTime;
newTime = Math.Min(newTime, SelectedProfileElement.Timeline.EndSegmentEndPosition.TotalMilliseconds);
@@ -1,6 +1,7 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Timers;
using System.Windows;
using System.Windows.Input;
using Artemis.Core;
@@ -20,11 +21,13 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
private bool _draggingTreeView;
private TreeItemViewModel _selectedTreeItem;
private bool _updatingTree;
private readonly Timer _timer;
public ProfileTreeViewModel(IProfileEditorService profileEditorService, IProfileTreeVmFactory profileTreeVmFactory)
{
_profileEditorService = profileEditorService;
_profileTreeVmFactory = profileTreeVmFactory;
_timer = new Timer(500);
}
public TreeItemViewModel SelectedTreeItem
@@ -54,12 +57,15 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
{
Subscribe();
CreateRootFolderViewModel();
_timer.Start();
base.OnInitialActivate();
}
protected override void OnClose()
{
Unsubscribe();
_timer.Stop();
_timer.Dispose();
base.OnClose();
}
@@ -203,12 +209,14 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
{
_profileEditorService.SelectedProfileChanged += OnSelectedProfileChanged;
_profileEditorService.SelectedProfileElementChanged += OnSelectedProfileElementChanged;
_timer.Elapsed += TimerOnElapsed;
}
private void Unsubscribe()
{
_profileEditorService.SelectedProfileChanged -= OnSelectedProfileChanged;
_profileEditorService.SelectedProfileElementChanged -= OnSelectedProfileElementChanged;
_timer.Elapsed -= TimerOnElapsed;
}
private void OnSelectedProfileElementChanged(object sender, RenderProfileElementEventArgs e)
@@ -242,6 +250,11 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree
CreateRootFolderViewModel();
}
private void TimerOnElapsed(object sender, ElapsedEventArgs e)
{
ActiveItem?.UpdateBrokenState();
}
#endregion
}
@@ -1,17 +1,20 @@
<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"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:treeItem1="clr-namespace:Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem"
xmlns:Converters="clr-namespace:Artemis.UI.Converters" x:Class="Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem.FolderView"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type treeItem1:FolderViewModel}}">
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"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:treeItem1="clr-namespace:Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem"
xmlns:converters="clr-namespace:Artemis.UI.Converters"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem.FolderView"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type treeItem1:FolderViewModel}}">
<UserControl.Resources>
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter"/>
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
</UserControl.Resources>
<!-- Capture clicks on full tree view item -->
<StackPanel Margin="-10" Background="Transparent" ContextMenuOpening="{s:Action ContextMenuOpening}">
@@ -58,18 +61,32 @@
</StackPanel.ContextMenu>
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<materialDesign:PackIcon Grid.Column="0"
<Button Grid.Column="0"
Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}"
ToolTip="{Binding BrokenState}"
Visibility="{Binding BrokenState, Converter={StaticResource NullToVisibilityConverter}}"
Foreground="White"
Background="#E74C4C"
BorderBrush="#E74C4C"
Width="18"
Height="18"
Margin="0 0 5 0"
Command="{s:Action ShowBrokenStateExceptions}">
<materialDesign:PackIcon Kind="AlertCircle" Height="12" Width="12" />
</Button>
<materialDesign:PackIcon Grid.Column="1"
Kind="Folder"
Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.InverseInstance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
<materialDesign:PackIcon Grid.Column="0"
<materialDesign:PackIcon Grid.Column="1"
Kind="FolderOpen"
Visibility="{Binding IsExpanded, Converter={x:Static s:BoolToVisibilityConverter.Instance}, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TreeViewItem}}}" />
<TextBlock Grid.Column="1" Text="{Binding ProfileElement.Name}" Margin="10 0 0 0" VerticalAlignment="Center" />
<ToggleButton Grid.Column="2"
<TextBlock Grid.Column="2" Text="{Binding ProfileElement.Name}" Margin="10 0 0 0" VerticalAlignment="Center" />
<ToggleButton Grid.Column="3"
Style="{StaticResource MaterialDesignFlatToggleButton}"
ToolTip="Toggle suspended state"
Width="18"
@@ -1,5 +1,9 @@
using System.ComponentModel;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.LayerEffects;
using Artemis.Core.Services;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Shared.Services;
@@ -27,12 +31,28 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
set => ((Folder) ProfileElement).IsExpanded = value;
}
public override void UpdateBrokenState()
{
List<IBreakableModel> brokenModels = ProfileElement.GetBrokenHierarchy().ToList();
if (!brokenModels.Any())
BrokenState = null;
else
{
BrokenState = "Folder is in a broken state, click to view exception(s).\r\n" +
$"{string.Join("\r\n", brokenModels.Select(e => $" • {e.BrokenDisplayName} - {e.BrokenState}"))}";
}
foreach (TreeItemViewModel treeItemViewModel in GetChildren())
treeItemViewModel.UpdateBrokenState();
}
private void ProfileElementOnPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(Folder.IsExpanded))
NotifyOfPropertyChange(nameof(IsExpanded));
}
#region Overrides of Screen
/// <inheritdoc />
@@ -6,14 +6,15 @@
xmlns:s="https://github.com/canton7/Stylet"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:treeItem1="clr-namespace:Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem"
xmlns:Converters="clr-namespace:Artemis.UI.Converters"
xmlns:converters="clr-namespace:Artemis.UI.Converters"
xmlns:shared="clr-namespace:Artemis.UI.Shared;assembly=Artemis.UI.Shared"
x:Class="Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem.LayerView"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
d:DataContext="{d:DesignInstance {x:Type treeItem1:LayerViewModel}}">
<UserControl.Resources>
<Converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<converters:InverseBooleanConverter x:Key="InverseBooleanConverter" />
<shared:NullToVisibilityConverter x:Key="NullToVisibilityConverter" />
</UserControl.Resources>
<!-- Capture clicks on full tree view item -->
<StackPanel Margin="-10" Background="Transparent" ContextMenuOpening="{s:Action ContextMenuOpening}">
@@ -55,13 +56,27 @@
</StackPanel.ContextMenu>
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<materialDesign:PackIcon Grid.Column="0" Kind="Layers" Width="16" VerticalAlignment="Center" />
<shared:ArtemisIcon Grid.Column="1"
<Button Grid.Column="0"
Style="{StaticResource MaterialDesignFloatingActionMiniDarkButton}"
ToolTip="{Binding BrokenState}"
Visibility="{Binding BrokenState, Converter={StaticResource NullToVisibilityConverter}}"
Foreground="White"
Background="#E74C4C"
BorderBrush="#E74C4C"
Width="18"
Height="18"
Margin="0 0 5 0"
Command="{s:Action ShowBrokenStateExceptions}">
<materialDesign:PackIcon Kind="AlertCircle" Height="12" Width="12" />
</Button>
<materialDesign:PackIcon Grid.Column="1" Kind="Layers" Width="16" VerticalAlignment="Center" />
<shared:ArtemisIcon Grid.Column="2"
VerticalAlignment="Center"
Icon="{Binding Layer.LayerBrush.Descriptor.Icon}"
Width="16"
@@ -69,8 +84,8 @@
ToolTip="{Binding Layer.LayerBrush.Descriptor.DisplayName, Mode=OneWay}"
Visibility="{Binding ShowIcons, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
Background="Transparent" />
<TextBlock Grid.Column="2" Text="{Binding Layer.Name}" VerticalAlignment="Center" Margin="5 0 0 0" />
<ToggleButton Grid.Column="3"
<TextBlock Grid.Column="3" Text="{Binding Layer.Name}" VerticalAlignment="Center" Margin="5 0 0 0" />
<ToggleButton Grid.Column="4"
Style="{StaticResource MaterialDesignFlatToggleButton}"
Width="18"
Height="18"
@@ -1,4 +1,9 @@
using Artemis.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Artemis.Core;
using Artemis.Core.LayerEffects;
using Artemis.Core.Services;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Shared.Services;
@@ -9,7 +14,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
public class LayerViewModel : TreeItemViewModel
{
private readonly IWindowManager _windowManager;
private ILayerHintVmFactory _vmFactory;
private readonly ILayerHintVmFactory _vmFactory;
public LayerViewModel(ProfileElement layer,
IRgbService rgbService,
@@ -25,15 +30,27 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
_vmFactory = vmFactory;
}
public void OpenAdaptionHints()
{
_windowManager.ShowDialog(_vmFactory.LayerHintsDialogViewModel(Layer));
}
public Layer Layer => ProfileElement as Layer;
public bool ShowIcons => Layer?.LayerBrush != null;
public override bool SupportsChildren => false;
public override bool IsExpanded { get; set; }
public void OpenAdaptionHints()
{
_windowManager.ShowDialog(_vmFactory.LayerHintsDialogViewModel(Layer));
}
public override void UpdateBrokenState()
{
List<IBreakableModel> brokenModels = ProfileElement.GetBrokenHierarchy().ToList();
if (!brokenModels.Any())
BrokenState = null;
else
{
BrokenState = "Layer is in a broken state, click to view exception(s).\r\n" +
$"{string.Join("\r\n", brokenModels.Select(e => $" • {e.BrokenDisplayName} - {e.BrokenState}"))}";
}
}
}
}
@@ -23,6 +23,7 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
private readonly IProfileTreeVmFactory _profileTreeVmFactory;
private readonly IRgbService _rgbService;
private ProfileElement _profileElement;
private string _brokenState;
protected TreeItemViewModel(ProfileElement profileElement,
IRgbService rgbService,
@@ -49,6 +50,12 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
set => SetAndNotify(ref _profileElement, value);
}
public string BrokenState
{
get => _brokenState;
set => SetAndNotify(ref _brokenState, value);
}
public bool CanPasteElement => _profileEditorService.GetCanPasteProfileElement();
public abstract bool SupportsChildren { get; }
@@ -286,6 +293,23 @@ namespace Artemis.UI.Screens.ProfileEditor.ProfileTree.TreeItem
NotifyOfPropertyChange(nameof(CanPasteElement));
}
public abstract void UpdateBrokenState();
public async Task ShowBrokenStateExceptions()
{
List<IBreakableModel> broken = ProfileElement.GetBrokenHierarchy().Where(b => b.BrokenStateException != null).ToList();
foreach (IBreakableModel current in broken)
{
_dialogService.ShowExceptionDialog($"{current.BrokenDisplayName} - {current.BrokenState}", current.BrokenStateException!);
if (broken.Last() != current)
{
if (!await _dialogService.ShowConfirmDialog("Broken state", "Do you want to view the next exception?"))
return;
}
}
}
private void Subscribe()
{
ProfileElement.ChildAdded += ProfileElementOnChildAdded;