-1

So I have some sliders that I use to set an "argb" color. After the window is closed the color is saved and all is good.

Is there anyway I can then set the sliders to be set to that color the next time I initiate the window without having to save each slider as a setting? Since the color is already being saved as a setting, can't I use "FromArgb" backwards somehow to find the a, r, g and b values?

Dan Puzey
  • 33,626
  • 4
  • 73
  • 96
Adkit
  • 67
  • 1
  • 1
  • 7

1 Answers1

1

If you want the whole argb value then you are looking for Color.ToArgb() method, which will get the 32-bit ARGB value of the Color structure.

Or as @Clemens correctly pointed out, you can just get each byte from A, R, G and B properties of the Color structure

e.g. use MyColor.A to set the sliders value for A. use Mycolor.B to set the slider for B, etc.

Bolu
  • 8,696
  • 4
  • 38
  • 70
  • The question is about WPF, so you would access the `A`, `R`, `G` and `B` properties of the WPF [`Color`](http://msdn.microsoft.com/en-us/library/system.windows.media.color.aspx) structure. – Clemens Jan 07 '15 at 12:56
  • @Clemens, thanks for the info, I have edited it into my answer. – Bolu Jan 07 '15 at 13:00
  • I'm not sure how that works exactly in terms of syntax, could you give me an example? Sorry, I'm new. – Adkit Jan 07 '15 at 14:34
  • @Adkit, just use `Color.A`, `Color.B`... to set the value of your sliders. Updated. – Bolu Jan 07 '15 at 14:40