1
- # WPFColorLib
2
-
3
- This library is created for "WPF/.NET FW 4.8" and intended to work with colors.
4
-
5
- -------------------------------------------------------------------------------------
6
- Standard WPF lacks of color selection dialog and WPFColorLib fills this niche with brand new approach:
7
-
8
- ![ Picture of dialog] ( https://i.imgur.com/yeyOuX5_d.webp?maxwidth=760&fidelity=grand )
9
-
10
- Description of functionality:
11
-
1
+ # WPFColorLib
2
+
3
+ This library is created for "WPF/.NET FW 4.8" and intended to work with colors.
4
+
5
+ -------------------------------------------------------------------------------------
6
+ Standard WPF lacks of color selection dialog and WPFColorLib fills this niche with brand new approach:
7
+
8
+ ![ Picture of dialog] ( https://i.imgur.com/yeyOuX5_d.webp?maxwidth=760&fidelity=grand )
9
+
10
+ Description of functionality:
11
+
12
12
- First, user selects desirable Hue level using top slider
13
13
- Saturation/Luminosity gradient below shows color variations of current hue
14
14
- Clicking/moving mouse on gradient selects one specific color (and button ` OK ` become enabled)
@@ -17,9 +17,9 @@ Description of functionality:
17
17
- Right from "New color" block there is "Old color" if dialog was called with some original color (to compare)
18
18
- Each value, hex or dec, can be typed directly (and confirmed with ` Enter ` ) or pasted from
19
19
Clipboard (using button on the left of the field)
20
- > Note that pasted text can be any free text taken from CSS, for example. Strings like
21
- ` #p1 {background-color: #ff0000;} /* red */ ` will be correctly parsed, catchig first matching
22
- RGB hex value (here ` ff0000 ` )
20
+ > Note that pasted text can be any free text taken from CSS, for example. Strings like
21
+ ` #p1 {background-color: #ff0000;} /* red */ ` will be correctly parsed, catchig first matching
22
+ RGB hex value (here ` ff0000 ` )
23
23
- Right from Dec/Hex fields there is ❍ (copy to Clipboard) button. Old color also can be copied
24
24
- Once color is selected, "Luminosity palette" is filled with 11 variations of current color,
25
25
where H/S is the same and "Luminosity" level vary from 0 to 100 with step 10 - these
@@ -28,28 +28,31 @@ Description of functionality:
28
28
- When you click with * left* mouse button on "Favorite color" sample, its color become selected.
29
29
* Right* click deletes this sample
30
30
- "Favorite colors" also can be * generated* : right click on favorite area and select 16-color
31
- Apple's palette or click "Standard 6 level" to generate 216-colors palette, where each
32
- color has 6-level variations of RGB components /easier to try than explain :) /.
33
- From the same popup you can clear favorites
31
+ Apple's palette or click "Standard 6 level" to generate 216-colors palette, where each
32
+ color has 6-level variations of RGB components /easier to try than explain :) /.
33
+ From the same popup you can clear favorites
34
34
- "Favorite colors" are saved between dialog calls, but lost when you exit application
35
35
36
36
Usage:
37
37
38
+ Reference necessary DLLs: [ System.Memory] ( https://www.nuget.org/packages/System.Memory )
39
+ and [ System.Runtime.CompilerServices.Unsafe] ( https://www.nuget.org/packages/System.Runtime.CompilerServices.Unsafe/ )
40
+
38
41
``` C#
39
42
var dlg = new SelectColorDlg (Colors .Bisque ) { Owner = this };
40
43
if (dlg .ShowDialog () == true ) {
41
44
var color = dlg .SelectedColor ;// as Color struct
42
45
var brush = dlg .SelectedBrush ;// the same, but as SolidColorBrush
43
46
}
44
47
```
45
-
46
- -------------------------------------------------------------------------------------
47
-
48
- WPFColorLib also contains a few helpers in a static class ` ClrHlp ` :
49
-
48
+
49
+ -------------------------------------------------------------------------------------
50
+
51
+ WPFColorLib also contains a few helpers in a static class ` ClrHlp ` :
52
+
50
53
- ColorToHSL - convert ` Color ` struct to (H, S, L) presentation (H=0..359, S=0..100, L=0..100)
51
54
- Hex2color - takes free text with hex RGB presentation and returns created ` Color `
52
55
- Color2hex - takes ` Color ` and returns hex RGB presentation
53
56
- Hex2Byte - parse hex byte presentation to native ` byte ` type
54
57
- HSL2RGB - convert (H,S,L) color to its RGB presentation (as array of 3 ` int ` s)
55
- - HSL2RGBInt - the same as ` HSL2RGB ` , but returns RGB components packed into integer
58
+ - HSL2RGBInt - the same as ` HSL2RGB ` , but returns RGB components packed into integer
0 commit comments