Gradient editor - WIP commit

This commit is contained in:
Robert committed 2020-03-10 17:29:53 +01:00
1 parent 38b6ca32a3
commit 98294956b1
10 files changed
+217 -68

No files matched your search

@@ -1,38 +1,35 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using Artemis.Core.Annotations;
using PropertyChanged;
using SkiaSharp;
using Stylet;
namespace Artemis.Core.Models.Profile
{
[DoNotNotify]
public class ColorGradient : INotifyPropertyChanged
{
private float _rotation;
public ColorGradient()
{
Colors = new BindableCollection<ColorGradientColor>();
}
public BindableCollection<ColorGradientColor> Colors { get; }
public float Rotation { get; set; }
public float Rotation
public SKColor[] GetColorsArray()
{
get => _rotation;
set
{
if (_rotation != value)
{
_rotation = value;
OnPropertyChanged(nameof(Rotation));
}
}
return Colors.OrderBy(c => c.Position).Select(c => c.Color).ToArray();
}
public float[] GetColorPositionsArray()
{
return Colors.OrderBy(c => c.Position).Select(c => c.Position).ToArray();
}
#region PropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
@@ -41,13 +38,15 @@ namespace Artemis.Core.Models.Profile
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public SKColor[] GetColorsArray()
#endregion
public void OnColorValuesUpdated()
{
return Colors.Select(c => c.Color).ToArray();
OnPropertyChanged(nameof(Colors));
}
}
public struct ColorGradientColor
public class ColorGradientColor : INotifyPropertyChanged
{
public ColorGradientColor(SKColor color, float position)
{
@@ -57,5 +56,17 @@ namespace Artemis.Core.Models.Profile
public SKColor Color { get; set; }
public float Position { get; set; }
#region PropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}