1
0
mirror of https://github.com/DarthAffe/RGB.NET.git synced 2025-12-13 01:58:30 +00:00

Changed everything related to brushes/gradients to be correctly bindable

This commit is contained in:
Darth Affe 2018-01-30 20:47:14 +01:00
parent 84b0c5402d
commit 98331d0241
7 changed files with 87 additions and 17 deletions

View File

@ -19,21 +19,36 @@ namespace RGB.NET.Brushes
{ {
#region Properties & Fields #region Properties & Fields
private float _origin = (float)Math.Atan2(-1, 0);
/// <summary> /// <summary>
/// Gets or sets the origin (radian-angle) this <see cref="ConicalGradientBrush"/> is drawn to. (default: -π/2) /// Gets or sets the origin (radian-angle) this <see cref="ConicalGradientBrush"/> is drawn to. (default: -π/2)
/// </summary> /// </summary>
public float Origin { get; set; } = (float)Math.Atan2(-1, 0); public float Origin
{
get => _origin;
set => SetProperty(ref _origin, value);
}
private Point _center = new Point(0.5, 0.5);
/// <summary> /// <summary>
/// Gets or sets the center <see cref="Point"/> (as percentage in the range [0..1]) of the <see cref="IGradient"/> drawn by this <see cref="ConicalGradientBrush"/>. (default: 0.5, 0.5) /// Gets or sets the center <see cref="Point"/> (as percentage in the range [0..1]) of the <see cref="IGradient"/> drawn by this <see cref="ConicalGradientBrush"/>. (default: 0.5, 0.5)
/// </summary> /// </summary>
public Point Center { get; set; } = new Point(0.5, 0.5); public Point Center
{
get => _center;
set => SetProperty(ref _center, value);
}
private IGradient _gradient;
/// <inheritdoc /> /// <inheritdoc />
/// <summary> /// <summary>
/// Gets or sets the gradient drawn by the brush. If null it will default to full transparent. /// Gets or sets the gradient drawn by the brush. If null it will default to full transparent.
/// </summary> /// </summary>
public IGradient Gradient { get; set; } public IGradient Gradient
{
get => _gradient;
set => SetProperty(ref _gradient, value);
}
#endregion #endregion

View File

@ -20,18 +20,33 @@ namespace RGB.NET.Brushes
{ {
#region Properties & Fields #region Properties & Fields
private Point _startPoint = new Point(0, 0.5);
/// <summary> /// <summary>
/// Gets or sets the start <see cref="Point"/> (as percentage in the range [0..1]) of the <see cref="IGradient"/> drawn by this <see cref="LinearGradientBrush"/>. (default: 0.0, 0.5) /// Gets or sets the start <see cref="Point"/> (as percentage in the range [0..1]) of the <see cref="IGradient"/> drawn by this <see cref="LinearGradientBrush"/>. (default: 0.0, 0.5)
/// </summary> /// </summary>
public Point StartPoint { get; set; } = new Point(0, 0.5); public Point StartPoint
{
get => _startPoint;
set => SetProperty(ref _startPoint, value);
}
private Point _endPoint = new Point(1, 0.5);
/// <summary> /// <summary>
/// Gets or sets the end <see cref="Point"/> (as percentage in the range [0..1]) of the <see cref="IGradient"/> drawn by this <see cref="LinearGradientBrush"/>. (default: 1.0, 0.5) /// Gets or sets the end <see cref="Point"/> (as percentage in the range [0..1]) of the <see cref="IGradient"/> drawn by this <see cref="LinearGradientBrush"/>. (default: 1.0, 0.5)
/// </summary> /// </summary>
public Point EndPoint { get; set; } = new Point(1, 0.5); public Point EndPoint
{
get => _endPoint;
set => SetProperty(ref _endPoint, value);
}
private IGradient _gradient;
/// <inheritdoc /> /// <inheritdoc />
public IGradient Gradient { get; set; } public IGradient Gradient
{
get => _gradient;
set => SetProperty(ref _gradient, value);
}
#endregion #endregion

View File

@ -18,13 +18,23 @@ namespace RGB.NET.Brushes
{ {
#region Properties & Fields #region Properties & Fields
private Point _center = new Point(0.5, 0.5);
/// <summary> /// <summary>
/// Gets or sets the center <see cref="Point"/> (as percentage in the range [0..1]) around which the <see cref="RadialGradientBrush"/> should be drawn. (default: 0.5, 0.5) /// Gets or sets the center <see cref="Point"/> (as percentage in the range [0..1]) around which the <see cref="RadialGradientBrush"/> should be drawn. (default: 0.5, 0.5)
/// </summary> /// </summary>
public Point Center { get; set; } = new Point(0.5, 0.5); public Point Center
{
get => _center;
set => SetProperty(ref _center, value);
}
private IGradient _gradient;
/// <inheritdoc /> /// <inheritdoc />
public IGradient Gradient { get; set; } public IGradient Gradient
{
get => _gradient;
set => SetProperty(ref _gradient, value);
}
#endregion #endregion

View File

@ -13,10 +13,15 @@ namespace RGB.NET.Brushes
{ {
#region Properties & Fields #region Properties & Fields
private Color _color;
/// <summary> /// <summary>
/// Gets or sets the <see cref="Color"/> drawn by this <see cref="SolidColorBrush"/>. /// Gets or sets the <see cref="Color"/> drawn by this <see cref="SolidColorBrush"/>.
/// </summary> /// </summary>
public Color Color { get; set; } public Color Color
{
get => _color;
set => SetProperty(ref _color, value);
}
#endregion #endregion

View File

@ -2,7 +2,7 @@
// ReSharper disable MemberCanBePrivate.Global // ReSharper disable MemberCanBePrivate.Global
// ReSharper disable AutoPropertyCanBeMadeGetOnly.Global // ReSharper disable AutoPropertyCanBeMadeGetOnly.Global
using System.Collections.Generic; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using RGB.NET.Core; using RGB.NET.Core;
@ -20,14 +20,19 @@ namespace RGB.NET.Brushes.Gradients
/// <summary> /// <summary>
/// Gets a list of the stops used by this <see cref="AbstractGradient"/>. /// Gets a list of the stops used by this <see cref="AbstractGradient"/>.
/// </summary> /// </summary>
public IList<GradientStop> GradientStops { get; } = new List<GradientStop>(); public ObservableCollection<GradientStop> GradientStops { get; } = new ObservableCollection<GradientStop>();
private bool _wrapGradient;
/// <summary> /// <summary>
/// Gets or sets if the Gradient wraps around if there isn't a second stop to take. /// Gets or sets if the Gradient wraps around if there isn't a second stop to take.
/// Example: There is a stop at offset 0.0, 0.5 and 0.75. /// Example: There is a stop at offset 0.0, 0.5 and 0.75.
/// Without wrapping offset 1.0 will be calculated the same as 0.75; with wrapping it would be the same as 0.0. /// Without wrapping offset 1.0 will be calculated the same as 0.75; with wrapping it would be the same as 0.0.
/// </summary> /// </summary>
public bool WrapGradient { get; set; } public bool WrapGradient
{
get => _wrapGradient;
set => SetProperty(ref _wrapGradient, value);
}
#endregion #endregion

View File

@ -8,19 +8,29 @@ namespace RGB.NET.Brushes.Gradients
/// <summary> /// <summary>
/// Represents a stop on a gradient. /// Represents a stop on a gradient.
/// </summary> /// </summary>
public class GradientStop public class GradientStop : AbstractBindable
{ {
#region Properties & Fields #region Properties & Fields
private double _offset;
/// <summary> /// <summary>
/// Gets or sets the percentage offset to place this <see cref="GradientStop"/>. This should be inside the range of [0..1] but it's not necessary. /// Gets or sets the percentage offset to place this <see cref="GradientStop"/>. This should be inside the range of [0..1] but it's not necessary.
/// </summary> /// </summary>
public double Offset { get; set; } public double Offset
{
get => _offset;
set => SetProperty(ref _offset, value);
}
private Color _color;
/// <summary> /// <summary>
/// Gets or sets the <see cref="Color"/> of this <see cref="GradientStop"/>. /// Gets or sets the <see cref="Color"/> of this <see cref="GradientStop"/>.
/// </summary> /// </summary>
public Color Color { get; set; } public Color Color
{
get => _color;
set => SetProperty(ref _color, value);
}
#endregion #endregion

View File

@ -15,15 +15,25 @@ namespace RGB.NET.Brushes.Gradients
{ {
#region Properties & Fields #region Properties & Fields
private double _startHue;
/// <summary> /// <summary>
/// Gets or sets the hue (in degrees) to start from. /// Gets or sets the hue (in degrees) to start from.
/// </summary> /// </summary>
public double StartHue { get; set; } public double StartHue
{
get => _startHue;
set => SetProperty(ref _startHue, value);
}
private double _endHue;
/// <summary> /// <summary>
/// Gets or sets the hue (in degrees) to end the with. /// Gets or sets the hue (in degrees) to end the with.
/// </summary> /// </summary>
public double EndHue { get; set; } public double EndHue
{
get => _endHue;
set => SetProperty(ref _endHue, value);
}
#endregion #endregion