Meta - Code cleanup

This commit is contained in:
SpoinkyNL committed 2020-06-13 22:27:51 +02:00
1 parent 18593853d8
commit fd991112a9
105 files changed
+3097 -2624

No files matched your search

@@ -9,8 +9,8 @@
d:DesignHeight="213.053" d:DesignWidth="254.425">
<StackPanel Margin="16">
<TextBlock Style="{StaticResource MaterialDesignHeadline6TextBlock}">
<Run Text="Rename"></Run>
<Run Text="{Binding Subject, Mode=OneWay}"></Run>
<Run Text="Rename" />
<Run Text="{Binding Subject, Mode=OneWay}" />
</TextBlock>
<TextBox materialDesign:HintAssist.Hint="Element name"
@@ -1,5 +1,4 @@
using System.Threading.Tasks;
using Artemis.Core.Models.Profile;
using Artemis.UI.Shared.Services.Dialog;
using FluentValidation;
using Stylet;
@@ -20,7 +20,7 @@
Conditions are not yet implemented
</TextBlock>
<TextBlock Style="{StaticResource MaterialDesignCaptionTextBlock}" TextWrapping="Wrap" HorizontalAlignment="Center">
Conditions will allow you to easily configure when a layer should be shown.<LineBreak/><LineBreak/>
Conditions will allow you to easily configure when a layer should be shown.<LineBreak /><LineBreak />
You'll also use this to set up how a layer reacts to its conditions being matched, like play the timeline once or keep repeating the timeline until the conditions are no longer matched.
</TextBlock>
</StackPanel>
@@ -16,8 +16,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract
public abstract bool IsVisible { get; }
public List<LayerPropertyBaseViewModel> Children { get; set; }
public abstract void Dispose();
public abstract List<BaseLayerPropertyKeyframe> GetKeyframes(bool expandedOnly);
public abstract void Dispose();
}
}
@@ -30,7 +30,7 @@
Visibility="{Binding HasLayerEffectDescriptors, Converter={x:Static s:BoolToVisibilityConverter.Instance}}">
<ListBox.ItemTemplate>
<DataTemplate DataType="{x:Type layerEffect:LayerEffectDescriptor}">
<Border Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}" VerticalAlignment="Stretch"
<Border Padding="8" BorderThickness="0 0 0 1" BorderBrush="{DynamicResource MaterialDesignDivider}" VerticalAlignment="Stretch"
behaviors:MouseBehaviour.MouseUpCommand="{x:Static materialDesign:Transitioner.MoveFirstCommand}">
<Grid>
<Grid.ColumnDefinitions>
@@ -136,7 +136,7 @@
</Border>
</ScrollViewer>
<materialDesign:TransitionerSlide >
<materialDesign:TransitionerSlide>
<materialDesign:TransitionerSlide.BackwardWipe>
<materialDesign:CircleWipe />
</materialDesign:TransitionerSlide.BackwardWipe>
@@ -8,7 +8,6 @@ using Artemis.Core.Events;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Models.Profile.LayerProperties.Attributes;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories;
@@ -62,6 +61,21 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
public EffectsViewModel EffectsViewModel { get; set; }
public TimelineViewModel TimelineViewModel { get; set; }
#region Effects
public void ToggleAddEffect()
{
if (DateTime.Now - _lastToggle < TimeSpan.FromMilliseconds(500))
return;
_lastToggle = DateTime.Now;
PropertyTreeIndex = PropertyTreeIndex == 0 ? 1 : 0;
if (PropertyTreeIndex == 1)
EffectsViewModel.PopulateDescriptors();
}
#endregion
protected override void OnInitialActivate()
{
PopulateProperties(ProfileEditorService.SelectedProfileElement);
@@ -115,10 +129,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
private void PopulateProperties(ProfileElement profileElement)
{
if (SelectedFolder != null)
{
SelectedFolder = null;
}
if (SelectedFolder != null) SelectedFolder = null;
if (SelectedLayer != null)
{
@@ -133,9 +144,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
_brushPropertyGroup = null;
if (profileElement is Folder folder)
{
SelectedFolder = folder;
}
else if (profileElement is Layer layer)
{
SelectedLayer = layer;
@@ -389,20 +398,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties
}
#endregion
#region Effects
public void ToggleAddEffect()
{
if (DateTime.Now - _lastToggle < TimeSpan.FromMilliseconds(500))
return;
_lastToggle = DateTime.Now;
PropertyTreeIndex = PropertyTreeIndex == 0 ? 1 : 0;
if (PropertyTreeIndex == 1)
EffectsViewModel.PopulateDescriptors();
}
#endregion
}
}
@@ -3,10 +3,10 @@ using System.Collections.Generic;
using System.Linq;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.UI.Exceptions;
using Artemis.UI.PropertyInput;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree;
using Artemis.UI.PropertyInput;
using Artemis.UI.Shared.PropertyInput;
using Artemis.UI.Shared.Services.Interfaces;
using Humanizer;
@@ -16,7 +16,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
public static readonly DependencyProperty PixelsPerSecondProperty = DependencyProperty.Register(nameof(PixelsPerSecond), typeof(int), typeof(PropertyTimelineHeader),
new FrameworkPropertyMetadata(default(int), FrameworkPropertyMetadataOptions.AffectsRender));
public static readonly DependencyProperty HorizontalOffsetProperty = DependencyProperty.Register(nameof(HorizontalOffset), typeof(double), typeof(PropertyTimelineHeader),
new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.AffectsRender));
@@ -4,7 +4,6 @@ using System.Windows;
using System.Windows.Input;
using Artemis.Core.Models.Profile.LayerProperties;
using Artemis.Core.Utilities;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using Stylet;
@@ -41,8 +41,7 @@
StrokeThickness="0"
Width="10"
Height="10"
Margin="-5,6,0,0">
</Ellipse>
Margin="-5,6,0,0" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -55,15 +54,15 @@
<ItemsControl.Resources>
<DataTemplate DataType="{x:Type layerProperties:LayerPropertyGroupViewModel}">
<ContentControl s:View.Model="{Binding TimelinePropertyGroupViewModel}"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
IsTabStop="False" />
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
IsTabStop="False" />
</DataTemplate>
<DataTemplate DataType="{x:Type layerProperties:LayerPropertyViewModel}">
<ContentControl s:View.Model="{Binding TimelinePropertyBaseViewModel}"
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
IsTabStop="False" />
VerticalContentAlignment="Stretch"
HorizontalContentAlignment="Stretch"
IsTabStop="False" />
</DataTemplate>
</ItemsControl.Resources>
</ItemsControl>
@@ -2,7 +2,6 @@
using System.Linq;
using Artemis.UI.Exceptions;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using Stylet;
@@ -23,17 +22,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
_profileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged;
}
private void LayerPropertyOnKeyframeModified(object sender, EventArgs e)
{
UpdateKeyframes();
}
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
{
foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels)
timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond);
}
public LayerPropertyViewModel<T> LayerPropertyViewModel { get; }
public override void UpdateKeyframes()
@@ -53,9 +41,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
);
}
else
{
TimelineKeyframeViewModels.Clear();
}
foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels)
timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond);
@@ -68,6 +54,17 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
LayerPropertyViewModel.LayerProperty.KeyframeRemoved -= LayerPropertyOnKeyframeModified;
LayerPropertyViewModel.LayerProperty.KeyframesToggled -= LayerPropertyOnKeyframeModified;
}
private void LayerPropertyOnKeyframeModified(object sender, EventArgs e)
{
UpdateKeyframes();
}
private void ProfileEditorServiceOnPixelsPerSecondChanged(object sender, EventArgs e)
{
foreach (var timelineKeyframeViewModel in TimelineKeyframeViewModels)
timelineKeyframeViewModel.Update(_profileEditorService.PixelsPerSecond);
}
}
public abstract class TimelinePropertyViewModel : IDisposable
@@ -82,8 +79,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline
public TimelineViewModel TimelineViewModel { get; set; }
public BindableCollection<TimelineKeyframeViewModel> TimelineKeyframeViewModels { get; set; }
public abstract void UpdateKeyframes();
public abstract void Dispose();
public abstract void UpdateKeyframes();
}
}
@@ -130,7 +130,7 @@
ToolTip="Rename"
Width="24"
Height="24"
VerticalAlignment="Center"
VerticalAlignment="Center"
Command="{s:Action RenameEffect}">
<materialDesign:PackIcon Kind="RenameBox" Height="16" Width="16" />
</Button>
@@ -140,11 +140,11 @@
ToolTip="Remove"
Width="24"
Height="24"
VerticalAlignment="Center"
VerticalAlignment="Center"
Command="{s:Action DeleteEffect}">
<materialDesign:PackIcon Kind="TrashCan" Height="16" Width="16" />
</Button>
</Grid>
</StackPanel>
</UserControl>
@@ -8,9 +8,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Tree
{
public class TreePropertyGroupViewModel
{
private readonly IProfileEditorService _profileEditorService;
private readonly ILayerService _layerService;
private readonly IDialogService _dialogService;
private readonly ILayerService _layerService;
private readonly IProfileEditorService _profileEditorService;
public TreePropertyGroupViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel,
IProfileEditorService profileEditorService, ILayerService layerService, IDialogService dialogService)
@@ -11,10 +11,8 @@ using Artemis.Core.Services.Storage.Interfaces;
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties;
using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract;
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree;
using Artemis.UI.Screens.Module.ProfileEditor.Visualization;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using Stylet;
@@ -25,7 +25,7 @@
</TextBlock>
<Separator Style="{StaticResource MaterialDesignDarkSeparator}" Margin="8 0" />
</StackPanel>
<TreeView Grid.Row="1"
ItemsSource="{Binding RootFolder.Children}"
HorizontalContentAlignment="Stretch"
@@ -54,7 +54,7 @@
materialDesign:RippleAssist.IsCentered="True"
ToolTip="Add new folder to root"
Command="{s:Action AddFolder}">
<materialDesign:PackIcon Kind="CreateNewFolder" Width="15"/>
<materialDesign:PackIcon Kind="CreateNewFolder" Width="15" />
</Button>
<Button Style="{StaticResource MaterialDesignIconForegroundButton}"
Width="30"
@@ -63,7 +63,7 @@
materialDesign:RippleAssist.IsCentered="True"
ToolTip="Add new layer to root"
Command="{s:Action AddLayer}">
<materialDesign:PackIcon Kind="LayersPlus" Width="15"/>
<materialDesign:PackIcon Kind="LayersPlus" Width="15" />
</Button>
</StackPanel>
</Grid>
@@ -4,7 +4,6 @@ using System.Windows;
using Artemis.Core.Models.Profile;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using GongSolutions.Wpf.DragDrop;
@@ -1,7 +1,6 @@
using Artemis.Core.Models.Profile;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
@@ -26,13 +26,13 @@
</ContextMenu>
</StackPanel.ContextMenu>
<StackPanel Orientation="Horizontal" Margin="10">
<materialDesign:PackIcon Kind="Layers" Width="16" />
<materialDesign:PackIcon Kind="Layers" Width="16" />
<materialDesign:PackIcon Kind="{Binding Layer.LayerBrush.Descriptor.Icon}"
Width="16"
Margin="5 0 0 0"
ToolTip="{Binding Layer.LayerBrush.Descriptor.DisplayName, Mode=OneWay}"
Visibility="{Binding ShowIcons, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
Background="Transparent"/>
Visibility="{Binding ShowIcons, Converter={x:Static s:BoolToVisibilityConverter.Instance}, Mode=OneWay}"
Background="Transparent" />
<TextBlock Text="{Binding Layer.Name}" Margin="5 0 0 0" />
</StackPanel>
</StackPanel>
@@ -1,7 +1,6 @@
using Artemis.Core.Models.Profile;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
@@ -22,6 +21,5 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.ProfileTree.TreeItem
public Layer Layer => ProfileElement as Layer;
public bool ShowIcons => Layer?.LayerBrush != null;
public override bool SupportsChildren => false;
}
}
@@ -6,7 +6,6 @@ using Artemis.Core.Services.Interfaces;
using Artemis.UI.Exceptions;
using Artemis.UI.Ninject.Factories;
using Artemis.UI.Screens.Module.ProfileEditor.Dialogs;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
using Stylet;
@@ -16,7 +16,7 @@
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="Gray" Duration="0:0:0.5"/>
<ColorAnimation Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="Gray" Duration="0:0:0.5" />
<DoubleAnimation Storyboard.TargetProperty="(Path.StrokeThickness)" To="0.5" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
@@ -24,7 +24,7 @@
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<ColorAnimation Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="{StaticResource Accent700}" Duration="0:0:0.5"/>
<ColorAnimation Storyboard.TargetProperty="(Path.Stroke).(SolidColorBrush.Color)" To="{StaticResource Accent700}" Duration="0:0:0.5" />
<DoubleAnimation Storyboard.TargetProperty="(Path.StrokeThickness)" To="1" Duration="0:0:0.5" />
</Storyboard>
</BeginStoryboard>
@@ -55,21 +55,20 @@
</UserControl.Resources>
<Canvas>
<!-- The part of the layer's shape that falls outside the layer -->
<Path Data="{Binding ShapeGeometry, Mode=OneWay}"
StrokeThickness="0.5"
<Path Data="{Binding ShapeGeometry, Mode=OneWay}"
StrokeThickness="0.5"
Style="{StaticResource SelectedShapeStyle}">
<Path.Stroke>
<SolidColorBrush Color="{StaticResource Primary700}" />
</Path.Stroke>
</Path>
<Path Data="{Binding LayerGeometry, Mode=OneWay}"
ClipToBounds="False"
<Path Data="{Binding LayerGeometry, Mode=OneWay}"
ClipToBounds="False"
Stroke="#A7A7A7"
StrokeThickness="1"
StrokeLineJoin="Round"
x:Name="LayerPath"
Style="{StaticResource SelectedLayerStyle}">
</Path>
Style="{StaticResource SelectedLayerStyle}" />
</Canvas>
</UserControl>
@@ -7,7 +7,6 @@ using System.Windows.Media.Imaging;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Profile.LayerShapes;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.UI.Extensions;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
@@ -148,7 +147,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization
break;
}
if (Layer.LayerBrush == null || Layer.LayerBrush.SupportsTransformation)
if (Layer.LayerBrush == null || Layer.LayerBrush.SupportsTransformation)
shapeGeometry.Transform = _layerEditorService.GetLayerTransformGroup(Layer);
ShapeGeometry = shapeGeometry;
@@ -122,9 +122,9 @@
</ItemsControl.ItemContainerStyle>
<ItemsControl.ItemTemplate>
<DataTemplate>
<controls:DeviceVisualizer Device="{Binding}"
ShowColors="True"
HighlightedLeds="{Binding DataContext.HighlightedLeds, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=OneWay}"/>
<controls:DeviceVisualizer Device="{Binding}"
ShowColors="True"
HighlightedLeds="{Binding DataContext.HighlightedLeds, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}, Mode=OneWay}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
@@ -6,8 +6,6 @@ using System.Windows.Input;
using Artemis.Core.Events;
using Artemis.Core.Models.Profile;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.LayerBrush;
using Artemis.Core.Plugins.LayerBrush.Abstract;
using Artemis.Core.Plugins.Models;
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces;
@@ -4,7 +4,6 @@ using System.Windows;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
@@ -3,10 +3,8 @@ using System.Linq;
using System.Windows;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
using Artemis.Core.Services;
using Artemis.Core.Services.Interfaces;
using Artemis.UI.Properties;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
@@ -1,5 +1,4 @@
using System.Windows.Input;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools
@@ -1,7 +1,6 @@
using System;
using System.Windows;
using System.Windows.Input;
using Artemis.UI.Services.Interfaces;
using Artemis.UI.Shared.Services.Interfaces;
namespace Artemis.UI.Screens.Module.ProfileEditor.Visualization.Tools