Fixed warnings

This commit is contained in:
DarthAffe committed 2021-02-02 23:37:56 +01:00
1 parent 57dc9afb32
commit a0a1521658
118 files changed
+802 -1181

No files matched your search

@@ -29,7 +29,7 @@ namespace RGB.NET.Brushes
set => SetProperty(ref _origin, value);
}
private Point _center = new Point(0.5, 0.5);
private Point _center = new(0.5, 0.5);
/// <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)
/// </summary>
@@ -39,12 +39,12 @@ namespace RGB.NET.Brushes
set => SetProperty(ref _center, value);
}
private IGradient _gradient;
private IGradient? _gradient;
/// <inheritdoc />
/// <summary>
/// Gets or sets the gradient drawn by the brush. If null it will default to full transparent.
/// </summary>
public IGradient Gradient
public IGradient? Gradient
{
get => _gradient;
set => SetProperty(ref _gradient, value);
@@ -104,6 +104,8 @@ namespace RGB.NET.Brushes
/// <inheritdoc />
protected override Color GetColorAtPoint(Rectangle rectangle, BrushRenderTarget renderTarget)
{
if (Gradient == null) return Color.Transparent;
double centerX = rectangle.Size.Width * Center.X;
double centerY = rectangle.Size.Height * Center.Y;
+1 -1
View File
@@ -12,6 +12,6 @@ namespace RGB.NET.Brushes
/// <summary>
/// Gets the <see cref="IGradient"/> used by this <see cref="IGradientBrush"/>.
/// </summary>
IGradient Gradient { get; }
IGradient? Gradient { get; }
}
}
@@ -20,7 +20,7 @@ namespace RGB.NET.Brushes
{
#region Properties & Fields
private Point _startPoint = new Point(0, 0.5);
private Point _startPoint = new(0, 0.5);
/// <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)
/// </summary>
@@ -30,7 +30,7 @@ namespace RGB.NET.Brushes
set => SetProperty(ref _startPoint, value);
}
private Point _endPoint = new Point(1, 0.5);
private Point _endPoint = new(1, 0.5);
/// <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)
/// </summary>
@@ -40,9 +40,9 @@ namespace RGB.NET.Brushes
set => SetProperty(ref _endPoint, value);
}
private IGradient _gradient;
private IGradient? _gradient;
/// <inheritdoc />
public IGradient Gradient
public IGradient? Gradient
{
get => _gradient;
set => SetProperty(ref _gradient, value);
@@ -97,8 +97,8 @@ namespace RGB.NET.Brushes
{
if (Gradient == null) return Color.Transparent;
Point startPoint = new Point(StartPoint.X * rectangle.Size.Width, StartPoint.Y * rectangle.Size.Height);
Point endPoint = new Point(EndPoint.X * rectangle.Size.Width, EndPoint.Y * rectangle.Size.Height);
Point startPoint = new(StartPoint.X * rectangle.Size.Width, StartPoint.Y * rectangle.Size.Height);
Point endPoint = new(EndPoint.X * rectangle.Size.Width, EndPoint.Y * rectangle.Size.Height);
double offset = GradientHelper.CalculateLinearGradientOffset(startPoint, endPoint, renderTarget.Point);
return Gradient.GetColor(offset);
@@ -18,7 +18,7 @@ namespace RGB.NET.Brushes
{
#region Properties & Fields
private Point _center = new Point(0.5, 0.5);
private Point _center = new(0.5, 0.5);
/// <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)
/// </summary>
@@ -28,9 +28,9 @@ namespace RGB.NET.Brushes
set => SetProperty(ref _center, value);
}
private IGradient _gradient;
private IGradient? _gradient;
/// <inheritdoc />
public IGradient Gradient
public IGradient? Gradient
{
get => _gradient;
set => SetProperty(ref _gradient, value);
@@ -78,7 +78,7 @@ namespace RGB.NET.Brushes
{
if (Gradient == null) return Color.Transparent;
Point centerPoint = new Point(rectangle.Location.X + (rectangle.Size.Width * Center.X), rectangle.Location.Y + (rectangle.Size.Height * Center.Y));
Point centerPoint = new(rectangle.Location.X + (rectangle.Size.Width * Center.X), rectangle.Location.Y + (rectangle.Size.Height * Center.Y));
// Calculate the distance to the farthest point from the center as reference (this has to be a corner)
// ReSharper disable once RedundantCast - never trust this ...
+1 -1
View File
@@ -52,7 +52,7 @@ namespace RGB.NET.Brushes
/// Converts a <see cref="Color" /> to a <see cref="SolidColorBrush" />.
/// </summary>
/// <param name="color">The <see cref="Color"/> to convert.</param>
public static explicit operator SolidColorBrush(Color color) => new SolidColorBrush(color);
public static explicit operator SolidColorBrush(Color color) => new(color);
/// <summary>
/// Converts a <see cref="SolidColorBrush" /> to a <see cref="Color" />.
@@ -23,7 +23,7 @@ namespace RGB.NET.Brushes.Gradients
/// <summary>
/// Gets a list of the stops used by this <see cref="AbstractGradient"/>.
/// </summary>
public ObservableCollection<GradientStop> GradientStops { get; } = new ObservableCollection<GradientStop>();
public ObservableCollection<GradientStop> GradientStops { get; } = new();
private bool _wrapGradient;
/// <summary>
@@ -42,7 +42,7 @@ namespace RGB.NET.Brushes.Gradients
#region Events
/// <inheritdoc />
public event EventHandler GradientChanged;
public event EventHandler? GradientChanged;
#endregion
@@ -54,7 +54,7 @@ namespace RGB.NET.Brushes.Gradients
protected AbstractGradient()
{
GradientStops.CollectionChanged += GradientCollectionChanged;
PropertyChanged += (sender, args) => OnGradientChanged();
PropertyChanged += (_, _) => OnGradientChanged();
}
/// <summary>
@@ -64,7 +64,7 @@ namespace RGB.NET.Brushes.Gradients
protected AbstractGradient(params GradientStop[] gradientStops)
{
GradientStops.CollectionChanged += GradientCollectionChanged;
PropertyChanged += (sender, args) => OnGradientChanged();
PropertyChanged += (_, _) => OnGradientChanged();
foreach (GradientStop gradientStop in gradientStops)
GradientStops.Add(gradientStop);
@@ -80,7 +80,7 @@ namespace RGB.NET.Brushes.Gradients
this.WrapGradient = wrapGradient;
GradientStops.CollectionChanged += GradientCollectionChanged;
PropertyChanged += (sender, args) => OnGradientChanged();
PropertyChanged += (_, _) => OnGradientChanged();
foreach (GradientStop gradientStop in gradientStops)
GradientStops.Add(gradientStop);
@@ -128,9 +128,9 @@ namespace RGB.NET.Brushes.Gradients
/// <summary>
/// Should be called to indicate that the gradient was changed.
/// </summary>
protected void OnGradientChanged() => GradientChanged?.Invoke(this, null);
protected void OnGradientChanged() => GradientChanged?.Invoke(this, EventArgs.Empty);
private void GradientCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
private void GradientCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
foreach (GradientStop gradientStop in e.OldItems)
@@ -143,7 +143,7 @@ namespace RGB.NET.Brushes.Gradients
OnGradientChanged();
}
private void GradientStopChanged(object sender, PropertyChangedEventArgs propertyChangedEventArgs) => OnGradientChanged();
private void GradientStopChanged(object? sender, PropertyChangedEventArgs propertyChangedEventArgs) => OnGradientChanged();
#endregion
}
+7 -7
View File
@@ -16,7 +16,7 @@ namespace RGB.NET.Brushes.Gradients
#region Properties & Fields
private bool _isOrderedGradientListDirty = true;
private LinkedList<GradientStop> _orderedGradientStops;
private LinkedList<GradientStop> _orderedGradientStops = new();
#endregion
@@ -60,12 +60,12 @@ namespace RGB.NET.Brushes.Gradients
private void Initialize()
{
void OnGradientStopOnPropertyChanged(object sender, PropertyChangedEventArgs args) => _isOrderedGradientListDirty = true;
void OnGradientStopOnPropertyChanged(object? sender, PropertyChangedEventArgs args) => _isOrderedGradientListDirty = true;
foreach (GradientStop gradientStop in GradientStops)
gradientStop.PropertyChanged += OnGradientStopOnPropertyChanged;
GradientStops.CollectionChanged += (sender, args) =>
GradientStops.CollectionChanged += (_, args) =>
{
if (args.OldItems != null)
foreach (GradientStop gradientStop in args.OldItems)
@@ -114,18 +114,18 @@ namespace RGB.NET.Brushes.Gradients
/// <returns></returns>
protected virtual (GradientStop gsBefore, GradientStop gsAfter) GetEnclosingGradientStops(double offset, LinkedList<GradientStop> orderedStops, bool wrap)
{
LinkedList<GradientStop> gradientStops = new LinkedList<GradientStop>(orderedStops);
LinkedList<GradientStop> gradientStops = new(orderedStops);
if (wrap)
{
GradientStop gsBefore, gsAfter;
GradientStop? gsBefore, gsAfter;
do
{
gsBefore = gradientStops.LastOrDefault(n => n.Offset <= offset);
if (gsBefore == null)
{
GradientStop lastStop = gradientStops.Last.Value;
GradientStop lastStop = gradientStops.Last!.Value;
gradientStops.AddFirst(new GradientStop(lastStop.Offset - 1, lastStop.Color));
gradientStops.RemoveLast();
}
@@ -133,7 +133,7 @@ namespace RGB.NET.Brushes.Gradients
gsAfter = gradientStops.FirstOrDefault(n => n.Offset >= offset);
if (gsAfter == null)
{
GradientStop firstStop = gradientStops.First.Value;
GradientStop firstStop = gradientStops.First!.Value;
gradientStops.AddLast(new GradientStop(firstStop.Offset + 1, firstStop.Color));
gradientStops.RemoveFirst();
}
+4 -4
View File
@@ -41,7 +41,7 @@ namespace RGB.NET.Brushes.Gradients
#region Events
/// <inheritdoc />
public event EventHandler GradientChanged;
public event EventHandler? GradientChanged;
#endregion
@@ -57,7 +57,7 @@ namespace RGB.NET.Brushes.Gradients
this.StartHue = startHue;
this.EndHue = endHue;
PropertyChanged += (sender, args) => OnGradientChanged();
PropertyChanged += (_, _) => OnGradientChanged();
}
#endregion
@@ -85,7 +85,7 @@ namespace RGB.NET.Brushes.Gradients
StartHue += offset;
EndHue += offset;
while ((StartHue > 360) && (EndHue > 360))
{
StartHue -= 360;
@@ -101,7 +101,7 @@ namespace RGB.NET.Brushes.Gradients
/// <summary>
/// Should be called to indicate that the gradient was changed.
/// </summary>
protected void OnGradientChanged() => GradientChanged?.Invoke(this, null);
protected void OnGradientChanged() => GradientChanged?.Invoke(this, EventArgs.Empty);
#endregion
}