There are several bugs in ColorPicker source code.
\src\xceed.wpf.toolkit\core\utilities\colorutilities.cs
```
public static HsvColor ConvertRgbToHsv( int r, int b, int g ) – b and g parameters are swapped that cause incorrect conversion.
```
That will lead to changes in \src\xceed.wpf.toolkit\colorcanvas\implementation\colorcanvas.cs
```
private void UpdateColorShadeSelectorPosition( Color? color )
…
HsvColor hsv = ColorUtilities.ConvertRgbToHsv( color.Value.R, color.Value.G, color.Value.B );
if( _updateSpectrumSliderValue )
{
_spectrumSlider.Value = 360 - hsv.H; // here 360 -
}
```
Also generation of spectrum have bug \Src\Xceed.Wpf.Toolkit\ColorCanvas\Implementation\ColorSpectrumSlider.cs
```
private void CreateSpectrum()
…
List<Color> colorsList = ColorUtilities.GenerateHsvSpectrum();
double stopIncrement = ( double )1 / (colorsList.Count - 1); // Here colorsList.Count - 1
```
and ColorUtilities.GenerateHsvSpectrum have additional unnecessary gradient stops due to this bug. Code may be
```
public static List<Color> GenerateHsvSpectrum()
{
List<Color> colorsList = new List<Color>();
int hStep = 60;
for (int h = 0; h < 360; h += hStep)
{
colorsList.Add(ColorUtilities.ConvertHsvToRgb(h, 1, 1));
}
colorsList.Add(ColorUtilities.ConvertHsvToRgb(0, 1, 1));
return colorsList;
}
```
Or even make it in pure XAML…
\src\xceed.wpf.toolkit\core\utilities\colorutilities.cs
```
public static HsvColor ConvertRgbToHsv( int r, int b, int g ) – b and g parameters are swapped that cause incorrect conversion.
```
That will lead to changes in \src\xceed.wpf.toolkit\colorcanvas\implementation\colorcanvas.cs
```
private void UpdateColorShadeSelectorPosition( Color? color )
…
HsvColor hsv = ColorUtilities.ConvertRgbToHsv( color.Value.R, color.Value.G, color.Value.B );
if( _updateSpectrumSliderValue )
{
_spectrumSlider.Value = 360 - hsv.H; // here 360 -
}
```
Also generation of spectrum have bug \Src\Xceed.Wpf.Toolkit\ColorCanvas\Implementation\ColorSpectrumSlider.cs
```
private void CreateSpectrum()
…
List<Color> colorsList = ColorUtilities.GenerateHsvSpectrum();
double stopIncrement = ( double )1 / (colorsList.Count - 1); // Here colorsList.Count - 1
```
and ColorUtilities.GenerateHsvSpectrum have additional unnecessary gradient stops due to this bug. Code may be
```
public static List<Color> GenerateHsvSpectrum()
{
List<Color> colorsList = new List<Color>();
int hStep = 60;
for (int h = 0; h < 360; h += hStep)
{
colorsList.Add(ColorUtilities.ConvertHsvToRgb(h, 1, 1));
}
colorsList.Add(ColorUtilities.ConvertHsvToRgb(0, 1, 1));
return colorsList;
}
```
Or even make it in pure XAML…