Browse Source

feat(ColorPicker): Address rule CA1822

pull/9189/head
Giuseppe Lippolis 4 years ago
parent
commit
4620e5cf99
  1. 8
      src/Avalonia.Controls.ColorPicker/ColorPalettes/MaterialColorPalette.cs
  2. 6
      src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs
  3. 4
      src/Avalonia.Controls.ColorPicker/ColorSpectrum/ColorSpectrum.cs

8
src/Avalonia.Controls.ColorPicker/ColorPalettes/MaterialColorPalette.cs

@ -35,7 +35,7 @@ namespace Avalonia.Controls
/// This is pulled out separately to lazy load for performance. /// This is pulled out separately to lazy load for performance.
/// If no material color palette is ever used, no colors will be created. /// If no material color palette is ever used, no colors will be created.
/// </remarks> /// </remarks>
private void InitColorChart() private static void InitColorChart()
{ {
lock (_colorChartMutex) lock (_colorChartMutex)
{ {
@ -322,7 +322,7 @@ namespace Avalonia.Controls
{ {
if (_colorChart == null) if (_colorChart == null)
{ {
InitColorChart(); MaterialColorPalette.InitColorChart();
} }
return _colorChartColorCount; return _colorChartColorCount;
@ -336,7 +336,7 @@ namespace Avalonia.Controls
{ {
if (_colorChart == null) if (_colorChart == null)
{ {
InitColorChart(); MaterialColorPalette.InitColorChart();
} }
return _colorChartShadeCount; return _colorChartShadeCount;
@ -348,7 +348,7 @@ namespace Avalonia.Controls
{ {
if (_colorChart == null) if (_colorChart == null)
{ {
InitColorChart(); MaterialColorPalette.InitColorChart();
} }
return _colorChart![ return _colorChart![

6
src/Avalonia.Controls.ColorPicker/ColorSlider/ColorSlider.cs

@ -121,7 +121,7 @@ namespace Avalonia.Controls.Primitives
/// </summary> /// </summary>
/// <param name="hsvColor">The <see cref="HsvColor"/> to round component values for.</param> /// <param name="hsvColor">The <see cref="HsvColor"/> to round component values for.</param>
/// <returns>A new <see cref="HsvColor"/> with rounded component values.</returns> /// <returns>A new <see cref="HsvColor"/> with rounded component values.</returns>
private HsvColor RoundComponentValues(HsvColor hsvColor) private static HsvColor RoundComponentValues(HsvColor hsvColor)
{ {
return new HsvColor( return new HsvColor(
Math.Round(hsvColor.A, 2, MidpointRounding.AwayFromZero), Math.Round(hsvColor.A, 2, MidpointRounding.AwayFromZero),
@ -147,7 +147,7 @@ namespace Avalonia.Controls.Primitives
if (IsRoundingEnabled) if (IsRoundingEnabled)
{ {
hsvColor = RoundComponentValues(hsvColor); hsvColor = ColorSlider.RoundComponentValues(hsvColor);
} }
// Note: Components converted into a usable range for the user // Note: Components converted into a usable range for the user
@ -272,7 +272,7 @@ namespace Avalonia.Controls.Primitives
if (IsRoundingEnabled) if (IsRoundingEnabled)
{ {
hsvColor = RoundComponentValues(hsvColor); hsvColor = ColorSlider.RoundComponentValues(hsvColor);
} }
return (rgbColor, hsvColor); return (rgbColor, hsvColor);

4
src/Avalonia.Controls.ColorPicker/ColorSpectrum/ColorSpectrum.cs

@ -1027,7 +1027,7 @@ namespace Avalonia.Controls.Primitives
{ {
for (int y = pixelDimension - 1; y >= 0; --y) for (int y = pixelDimension - 1; y >= 0; --y)
{ {
FillPixelForBox( ColorSpectrum.FillPixelForBox(
x, y, hsv, pixelDimension, components, minHue, maxHue, minSaturation, maxSaturation, minValue, maxValue, x, y, hsv, pixelDimension, components, minHue, maxHue, minSaturation, maxSaturation, minValue, maxValue,
bgraMinPixelData, bgraMiddle1PixelData, bgraMiddle2PixelData, bgraMiddle3PixelData, bgraMiddle4PixelData, bgraMaxPixelData, bgraMinPixelData, bgraMiddle1PixelData, bgraMiddle2PixelData, bgraMiddle3PixelData, bgraMiddle4PixelData, bgraMaxPixelData,
newHsvValues); newHsvValues);
@ -1099,7 +1099,7 @@ namespace Avalonia.Controls.Primitives
}); });
} }
private void FillPixelForBox( private static void FillPixelForBox(
double x, double x,
double y, double y,
Hsv baseHsv, Hsv baseHsv,

Loading…
Cancel
Save