This project is read-only.

ColorPicker 1.5.1 setting the color fails

Feb 27, 2012 at 1:09 AM

I'm using the ColorPicker in a popup and when I set the color it sometimes fails (it sets the colof to #FF000000 instead of what I wanted it to).  Setting the color a second time on the next line of code seems to alwasy work (well, so far at least ;).

Anyone else see this issue?

Feb 27, 2012 at 1:59 AM

Hey Greg, I've seen this as well but issue is it is very hard to repo.

Feb 27, 2012 at 3:25 AM

I've got a really consitant failure (in that I know the order to do things to get it to fail), let me see if I can pull it out of my project for you to look at.

Feb 27, 2012 at 3:36 AM

If you could create a consistent repo, that will help me fix it.

Feb 27, 2012 at 3:54 AM

...annnndddd as soon as I pull the code out of my app and in to a test framework it works just fine :(

I'll try and do some more testing in my app and see if I can't figure out what's the cause.

Feb 27, 2012 at 4:07 AM

so I've never seen this on the colorpicker actually, i've only seen this behavor on Color Hexagon.  This could be an issue with the base class.  This could be an inherit issue with how the base class was designed since it was a tad organic when that got built out.

Feb 27, 2012 at 4:20 AM

Sorry, this might seem like an obvious question, but I download the source code, how do I get Visual Studio to use it to debug the code?

Feb 27, 2012 at 4:33 AM

Remove the reference to the dlls you got, add existing project to the solution, add reference where you point to the project in the solution

Feb 27, 2012 at 3:36 PM

Ok, I found the issue and it's quite easy to reproduce once you know what it is ;)

The problem is when you set a new color that is outside of the current color space being displayed by the color picker. What happens is that OnColorChanged() is being called when you set the new color, which calls UpdateLayoutBasedOnColor(), which in turns sets ColorSlider.Color, which then calls OnColorChanged() again. This starts the process all over again and breaks because the first call isn't completed yet and corrupts the color being set.

To reproduce the issue, set the color to any value that will have to move outside the color space and update the color slider. The second call to update the color succeeds because the slider doesn't have to be update again as it has already been moved to the correct location by the first call.


Feb 27, 2012 at 5:37 PM

Can you create an issue with a repo attached?

Feb 27, 2012 at 5:58 PM

Can do.

Feb 27, 2012 at 7:04 PM


Feb 27, 2012 at 9:31 PM

I found a solution as well, see the issue ticket, I've attached a new ColorPicker.cs file and explination to it.

Feb 28, 2012 at 2:29 AM

...which didn't work, I've added a new fix that seems to catch all the cases.