This is control for Windows Forms, which allows to select colors to create gradients.
To install GradientColorPicker control, run the following command in the Package Manager Console:
Install-Package GradientColorPicker
Install the GradientColorPicker package in your Windows Forms project.
Or download an archive file containing binary assemblies, unpack it and add to your project a reference to the assembly of the version of .NET Framework that you are using.
Now you can create an instance of the GradientColorPicker and add to the form:
// create a new instance of GradientColorPicker
var gradientColorPicker = new GradientColorPicker();
// for example, set the minimum number of items (colors)
gradientColorPicker.MinimumColorCount = 4;
// for example, randomize the postion and color of the items
gradientColorPicker1.Randomize(true, true);
// add the GradientColorPicker to the form
Controls.Add(gradientColorPicker);
// use the DrawLinearGradientToImage method to drawing linear gradient image
// for example, draw a gradient in the background image of the form
// create image
BackgroundImage = new Bitmap(ClientSize.Width, ClientSize.Height);
// draw a linear gradient
gradientColorPicker1.DrawLinearGradientToImage(BackgroundImage);
// or DrawRadialGradientToImage method to drawing radial gradient image
// we need to specify a central point
var centerPoint = new PointF(ClientSize.Width / 2, ClientSize.Height / 2);
// draw a radial gradient
gradientColorPicker1.DrawRadialGradientToImage(BackgroundImage, ClientRectangle, centerPoint);
If you can not find the control on the toolbox in designer mode, you need to add GradientColorPicker to the toolbox:
- Right-click on toolbox.
- Select "Choose Items".
- Browse the GradientColorPicker assembly on your computer.
- Add the item.
- Enjoy!
- .NET Framework 3.5/4.0/4.5/4.6/4.7 or later;
- Windows Forms.
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright © 2018, @meet-aleksey