mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 11:56:30 +00:00
Core - Made FloatRange and IntRange readonly structs
ColorGradient - Fixed missing subscribtions when using object list manipulation API ColorGradient - Fixed editor VM going out of sync
This commit is contained in:
1 parent
bd26f447c6
commit
e385165200
19 files changed
+337
-327
No files matched your search
@@ -3,8 +3,8 @@
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ApplicationIcon />
|
||||
<StartupObject />
|
||||
<ApplicationIcon/>
|
||||
<StartupObject/>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Platforms>x64</Platforms>
|
||||
@@ -15,20 +15,20 @@
|
||||
<ItemGroup>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.10.15" />
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.15" />
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.15" />
|
||||
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.14" />
|
||||
<PackageReference Include="DynamicData" Version="7.8.6" />
|
||||
<PackageReference Include="FluentAvaloniaUI" Version="1.4.1" />
|
||||
<PackageReference Include="Material.Icons.Avalonia" Version="1.0.2" />
|
||||
<PackageReference Include="ReactiveUI" Version="17.1.50" />
|
||||
<PackageReference Include="ReactiveUI.Validation" Version="2.2.1" />
|
||||
<PackageReference Include="RGB.NET.Core" Version="1.0.0-prerelease.32" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.1" />
|
||||
<PackageReference Include="Avalonia" Version="0.10.15"/>
|
||||
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.15"/>
|
||||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.15"/>
|
||||
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.14"/>
|
||||
<PackageReference Include="DynamicData" Version="7.8.6"/>
|
||||
<PackageReference Include="FluentAvaloniaUI" Version="1.4.1"/>
|
||||
<PackageReference Include="Material.Icons.Avalonia" Version="1.0.2"/>
|
||||
<PackageReference Include="ReactiveUI" Version="17.1.50"/>
|
||||
<PackageReference Include="ReactiveUI.Validation" Version="2.2.1"/>
|
||||
<PackageReference Include="RGB.NET.Core" Version="1.0.0-prerelease.32"/>
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.1-preview.1"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Artemis.Core\Artemis.Core.csproj" />
|
||||
<ProjectReference Include="..\Artemis.Core\Artemis.Core.csproj"/>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Controls\HotkeyBox.axaml.cs">
|
||||
|
||||
@@ -24,7 +24,7 @@ public class GradientPickerButton : TemplatedControl
|
||||
/// Gets or sets the color gradient.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<ColorGradient?> ColorGradientProperty =
|
||||
AvaloniaProperty.Register<GradientPickerButton, ColorGradient?>(nameof(ColorGradient), notifying: ColorGradientChanged, defaultValue: ColorGradient.GetUnicornBarf());
|
||||
AvaloniaProperty.Register<GradientPickerButton, ColorGradient?>(nameof(ColorGradient), notifying: ColorGradientChanged);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a boolean indicating whether the gradient picker should be in compact mode or not.
|
||||
@@ -108,7 +108,8 @@ public class GradientPickerButton : TemplatedControl
|
||||
|
||||
private static void ColorGradientChanged(IAvaloniaObject sender, bool before)
|
||||
{
|
||||
(sender as GradientPickerButton)?.Subscribe();
|
||||
if (!before)
|
||||
(sender as GradientPickerButton)?.Subscribe();
|
||||
}
|
||||
|
||||
private void Subscribe()
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Artemis.Core;
|
||||
|
||||
namespace Artemis.UI.Shared.Services.ProfileEditor.Commands;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a profile editor command that can be used to update a layer property of type <typeparamref name="T" />.
|
||||
/// </summary>
|
||||
public class UpdateColorGradient : IProfileEditorCommand
|
||||
{
|
||||
private readonly ColorGradient _colorGradient;
|
||||
private readonly List<ColorGradientStop> _stops;
|
||||
private readonly List<ColorGradientStop> _originalStops;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="UpdateColorGradient" /> class.
|
||||
/// </summary>
|
||||
public UpdateColorGradient(ColorGradient colorGradient, List<ColorGradientStop> stops, List<ColorGradientStop>? originalStops)
|
||||
{
|
||||
_colorGradient = colorGradient;
|
||||
_stops = stops;
|
||||
_originalStops = originalStops ?? _colorGradient.Select(s => new ColorGradientStop(s.Color, s.Position)).ToList();
|
||||
}
|
||||
|
||||
#region Implementation of IProfileEditorCommand
|
||||
|
||||
/// <inheritdoc />
|
||||
public string DisplayName => "Update color gradient";
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Execute()
|
||||
{
|
||||
_colorGradient.Clear();
|
||||
foreach (ColorGradientStop colorGradientStop in _stops)
|
||||
_colorGradient.Add(colorGradientStop);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Undo()
|
||||
{
|
||||
_colorGradient.Clear();
|
||||
foreach (ColorGradientStop colorGradientStop in _originalStops)
|
||||
_colorGradient.Add(colorGradientStop);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
Reference in new issue
Block a user