mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Fixed profile editor deselecting layer when closing the edit window
This commit is contained in:
parent
3739ffad03
commit
278afc9110
@ -1,4 +1,5 @@
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using System.ComponentModel;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Audio
|
||||
{
|
||||
@ -10,5 +11,14 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
||||
|
||||
public int Sensitivity { get; set; }
|
||||
public double FadeSpeed { get; set; }
|
||||
public Direction Direction { get; set; }
|
||||
}
|
||||
|
||||
public enum Direction
|
||||
{
|
||||
[Description("Top to bottom")] TopToBottom,
|
||||
[Description("Bottom to top")] BottomToTop,
|
||||
[Description("Left to right")] LeftToRight,
|
||||
[Description("Right to left")] RightToLeft
|
||||
}
|
||||
}
|
||||
@ -4,9 +4,21 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:properties="clr-namespace:Artemis.Profiles.Layers.Types.Audio"
|
||||
xmlns:system="clr-namespace:System;assembly=mscorlib"
|
||||
xmlns:converters="clr-namespace:Artemis.Utilities.Converters"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="500">
|
||||
<UserControl.Resources>
|
||||
<converters:EnumDescriptionConverter x:Key="HEnumDescriptionConverter" />
|
||||
<ObjectDataProvider MethodName="GetValues"
|
||||
ObjectType="{x:Type system:Enum}"
|
||||
x:Key="DirectionEnumValues">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type TypeName="properties:Direction" />
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
</UserControl.Resources>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
@ -49,12 +61,18 @@
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Random color -->
|
||||
<!-- Bar direction -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Bar direction:"
|
||||
VerticalAlignment="Top" Height="18" />
|
||||
<controls:ToggleSwitch Grid.Row="1" Grid.Column="3" OnLabel="Yes" OffLabel="No"
|
||||
IsChecked="{Binding Path=LayerModel.Properties.RandomColor, Mode=TwoWay}"
|
||||
VerticalAlignment="Top" Margin="10,5,10,2" />
|
||||
<ComboBox Grid.Row="1" Grid.Column="3" ItemsSource="{Binding Source={StaticResource DirectionEnumValues}}"
|
||||
Margin="10,10,10,0" SelectedItem="{Binding Path=LayerModel.Properties.Direction}"
|
||||
VerticalAlignment="Top" Height="22">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Converter={StaticResource HEnumDescriptionConverter}}" />
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -41,6 +41,7 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
||||
_waveIn.StartRecording();
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
public List<byte> SpectrumData { get; set; } = new List<byte>();
|
||||
|
||||
public string Name { get; } = "Keyboard - Audio visualization";
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
VerticalAlignment="Top" Height="18" />
|
||||
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Top"
|
||||
TickPlacement="None" TickFrequency="0.05"
|
||||
Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
|
||||
Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}" Minimum="0.5" Maximum="5"
|
||||
SmallChange="0" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
|
||||
|
||||
<!-- Colors -->
|
||||
|
||||
@ -15,6 +15,7 @@ using Artemis.ViewModels.Profiles.Events;
|
||||
using Caliburn.Micro;
|
||||
using Newtonsoft.Json;
|
||||
using Ninject;
|
||||
using NuGet;
|
||||
|
||||
namespace Artemis.ViewModels.Profiles
|
||||
{
|
||||
@ -40,6 +41,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
|
||||
Layer = layer;
|
||||
ProposedLayer = GeneralHelpers.Clone(layer);
|
||||
ProposedLayer.Children.Clear();
|
||||
|
||||
if (Layer.Properties == null)
|
||||
Layer.SetupProperties();
|
||||
@ -165,24 +167,7 @@ namespace Artemis.ViewModels.Profiles
|
||||
public void Apply()
|
||||
{
|
||||
LayerPropertiesViewModel?.ApplyProperties();
|
||||
var appliedLayer = GeneralHelpers.Clone(ProposedLayer);
|
||||
|
||||
// Fix relations
|
||||
if (Layer.Parent != null)
|
||||
{
|
||||
Layer.Parent.Children.Add(appliedLayer);
|
||||
Layer.Parent.Children.Remove(Layer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Layer.Profile.Layers.Add(appliedLayer);
|
||||
Layer.Profile.Layers.Remove(Layer);
|
||||
}
|
||||
appliedLayer.Children.Clear();
|
||||
foreach (var layerModel in Layer.Children)
|
||||
appliedLayer.Children.Add(layerModel);
|
||||
|
||||
Layer = appliedLayer;
|
||||
JsonConvert.PopulateObject(JsonConvert.SerializeObject(ProposedLayer), Layer);
|
||||
|
||||
// TODO: EventPropVM must have layer too
|
||||
if (EventPropertiesViewModel != null)
|
||||
@ -227,7 +212,11 @@ namespace Artemis.ViewModels.Profiles
|
||||
ProposedLayer.Properties.Contain = Layer.Properties.Contain;
|
||||
}
|
||||
|
||||
var current = JsonConvert.SerializeObject(Layer, Formatting.Indented);
|
||||
// Ignore the children, can't just temporarily add them to the proposed layer because
|
||||
// that would upset the child layers' relations (sounds like an episode of Dr. Phil amirite?)
|
||||
var currentObj = GeneralHelpers.Clone(Layer);
|
||||
currentObj.Children.Clear();
|
||||
var current = JsonConvert.SerializeObject(currentObj, Formatting.Indented);
|
||||
var proposed = JsonConvert.SerializeObject(ProposedLayer, Formatting.Indented);
|
||||
|
||||
if (current.Equals(proposed))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user