• Stars
    star
    150
  • Rank 247,323 (Top 5 %)
  • Language
    C#
  • License
    MIT License
  • Created over 11 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Color picker control suite for Windows Forms applications.

Icon Cyotek Color Picker Controls for Windows Forms

Build status NuGet

The Cyotek.Windows.Forms.ColorPickers library contains a series of custom controls and utility classes for Windows Forms applications that work with colours. Controls are available to allow colour selection via a HSL ColorWheel, a ColorGrid with many customisation options, a ColorEditor for entering colours via RGB or HSL, and a ScreenColorPicker for capturing colours from running applications.

Color palettes can be loaded and saved in a number of different formats, including Adobe PhotoShop Color Swatch files, JASC Palettes, Gimp Palettes and more (see Color Palettes and External Palette Files below).

For more information on these controls, see the articles tagged with colorpicker at cyotek.com.

Getting the library

The easiest way of obtaining the library is via NuGet.

Install-Package Cyotek.Windows.Forms.ColorPicker

If you don't use NuGet, pre-compiled binaries can be obtained from the GitHub Releases page.

Of course, you can always grab the source and build it yourself!

Controls

There are three primary controls (ColorGrid, ColorWheel and ColorEditor), along with 5 utility controls (ScreenColorPicker, RgbaColorSlider, HueColorSlider, LightnessColorSlider and SaturationColorSlider), a management component (ColorEditorManager) and one dialog (ColorPickerDialog). Combined together, these provide a decent array of tools for colour selection.

ColorGrid Control

ColorGrid control demonstration

This control displays a grid of colours, and supports both a primary palette, and a custom colour palette. Several properties are available for configuring the appearing of the control, and there are behaviour options too, such as built in editing of colours and support for automatically adding new colours not in the primary palette.

ColorWheel Control

ColorWheel control demonstration

This control displays a radial wheel of RGB colours and allows selection from any point in the wheel. The ShowAngleArrow, ShowCenterLines and ShowSaturationRing properties can be used to display useful adornments, while the Lightness and Alpha properties can be used to compose the final colour while not being directly editable on the wheel.

The SecondaryColors and SecondarySelectionSize properties allow you to display additional colours on the wheel, for example for showing relationships.

ColorSlider Controls

ColorSlider controls demonstration

A bunch of controls (inheriting from a single base) that allow selection of values via a colourful bar. Similar to the TrackBar control you have a few options for specifying the drag handle's position and bar orientation. You can also customise the fill and outline colour, or replace it completely with a custom image.

ColorEditor Control

ColorEditor control demonstration

This control allows the editing of a RGB or HSL colour via a standard interface. You can also enter colours via 6 or 8 character hexadecimal notation, or choose from named web and system colors.

Use of the alpha channel can be configured via the ShowAlphaChannel and PreserveAlphaChannel properties. The ShowHex, ShowHsl and ShowRgb properties can be used to show or hide groups of editors.

Alternatively, the NubSize, NubColor and NubOutlineColor properties can be used to customise the appearance of the sliders.

ScreenColorPicker Control

ScreenColorPicker control demonstration

This control allows the user to pick a colour from any pixel displayed on the screen. The user can either trigger the operation by clicking and dragging the control, or it can be done programmatically via the CaptureMouse method, allowing selections to be triggered via other actions, for example a hot key. The Zoom property can be used set the grid size of the preview.

ColorPickerDialog Form

ColorPickerDialog form demonstration

This form puts together the previous controls in a ready to use dialog.

Custom colours are supported via the CustomColors property, and users can also load or save external palette files into these. You can use the ShowLoad and ShowSave properties to enable or disable this, and the CustomColorsLoading and CustomColorsSavingevents to override the built-in behaviour and provide your own logic.

ColorEditorManager

ColorEditorManager compnent demonstration

This is a non-GUI component that you can drop onto a form, and bind to other controls in this library. When the Color property of one control changes, it is reflected in the others without having to lift a finger. Useful if you're creating composite displays from multiple controls.

Color Palettes and External Palette Files

The ColorGrid control has Colors and CustomColors properties which return a ColorCollection. These two properties make it easier as a developer to keep separate a primary palette whilst having the flexibility of custom colours, although it does complicate the control's internal logic a bit! The grid will automatically populate custom colours if you try and set the control's Color to a value not currently defined.

As well as manually populating ColorCollection instances, you can also load in external palette files. The following palette formats are supported:

  • Adobe Color Table (*.act)
  • Adobe PhotoShop Color Swatch (*.aco)
  • GIMP (*.gpl)
  • Deluxe Paint (*.bbm; *.lbm) [read only]
  • JASC (*.pal)
  • Paint.NET (*.txt)
  • Raw RGB Triplets (*.pal)

With the exception of the ILBM image format, all other formats can be exported as well as imported.

Additional palette serializers can be easily created by adding a class which implements IPaletteSerializer. The ColorPickerDialog (or any custom code using PaletteSerializer static methods) will automatically detect and make available custom palettes via reflection.

Keyboard Support

All GUI components, with the exception of the ScreenColorPicker include full keyboard/focus support. Many controls support SmallChange and LargeChange properties which influence how navigation keys are processed. Although in the case of the ColorWheel it's not really a bonus... but that's what the ColorEditor control is best suited for!

Requirements

.NET Framework 3.5 or later.

Pre-built binaries are available via a signed NuGet package containing the following targets.

  • .NET 3.5
  • .NET 4.0
  • .NET 4.5.2
  • .NET 4.6.2
  • .NET 4.7.2
  • .NET 4.8
  • .NET 5.0

Contributing to this code

Contributions accepted!

Alternatively, if you make use of this software and it saves you some time, donations are welcome.

PayPal Donation

By Me a Coffee Donation

Known Issues

  • XML documentation comments are incomplete

Related Reading

Acknowledgements

More Repositories

1

Cyotek.Windows.Forms.ImageBox

The ImageBox is a custom control for displaying images. It supports zooming, scrolling, panning, region selection and much more!
C#
190
star
2

Dithering

Image dithering techniques using C#
C#
99
star
3

Cyotek.Collections.Generic.CircularBuffer

The CircularBuffer<T> class is a data structure that uses a single, fixed-size buffer that behaves as if it were connected end-to-end. You can use it as a first-in, first-out collection of objects using a fixed buffer and automatic overwrite support.
C#
52
star
4

Cyotek.Drawing.BitmapFont

Component for parsing bitmap font files generated by AngelCode's BMFont utility
C#
43
star
5

Cyotek.Data.Nbt

C# library for reading and writing NBT files
C#
37
star
6

Cyotek.Windows.Forms.TabList

Cyotek.Windows.Forms.TabList, a multi-paged container control with design time support and a Visual Studio 2012+ appearance
C#
33
star
7

Cyotek.AddProjects

The Add Projects extension is a simple Visual Studio extension that makes it easy to add multiple projects to your solution.
C#
25
star
8

SimpleScreenshotCapture

Sample project for the "Capturing screenshots using C# and p/invoke" article on cyotek.com
C#
24
star
9

Cyotek.Windows.Forms.FontDialog

A drop in replacement for System.Windows.Forms.FontDialog, without the crash when selecting non-TrueType fonts
C#
19
star
10

ScannerTest

Sample application demonstrating using WIA from C# WinForms
C#
18
star
11

MantisSharp

A simple client for working with the MantisBT REST API
C#
17
star
12

RegistryComparer

C# application for creating and comparing registry key snapshots
C#
16
star
13

CyotekDownDetector

A simple application to keep on an eye on the availability of HTTP sites
C#
14
star
14

HttpCrawlerTestSite

A small PHP based website for testing the essentials of a web crawler
PHP
12
star
15

ScriptingHostDemo

Demonstration project for adding scripting to your .NET application
C#
12
star
16

WadDemo

Reading, writing and working with WAD files using C#
C#
10
star
17

Cyotek.QuickScan

Simple application for scanning images with as few user-interactions as possible.
C#
9
star
18

SkylineGenerator

A small program to generate simple city skylines
C#
8
star
19

vsstosvn

Visual SourceSafe to Subversion allows VSS databases to be imported into new or existing SVN repositories.
C#
8
star
20

Cyotek.Drawing.Imaging.Farbfeld

C# encoder/decoder for farbfeld images
C#
8
star
21

ColorEcho

Utility for displayed coloured text in batch scripts
C#
7
star
22

ScrollDemo

This repository contains a sample application demonstrating how to create a custom control that scrolls on a single axis.
C#
7
star
23

DoomPictureViewer

Decoding DOOM pictures using C#
C#
7
star
24

SvnGitMigrate

Simple tool to aid in doing partial migrations of an SVN repository to Git
C#
6
star
25

persistentwindows

Keep your apps where you left them!
C#
6
star
26

Cyotek.AzureContainerEcho

A simple program which sits in your tray and periodically downloads new files from Azure blob storage.
C#
6
star
27

Md5

Simple MD5 file hash utility
C#
6
star
28

ncpaintDemo

Using the WM_NCPAINT and WM_NCCALCSIZE messages in a C# Windows Forms application
C#
6
star
29

InternetGetCookieExDemo

Demonstration program for reading cookies from Internet Explorer using C#
C#
6
star
30

2dimagefilter

Automatically exported from code.google.com/p/2dimagefilter
C#
6
star
31

Cyotek.Data.Ini

A simple library for reading and writing .ini files in .NET applications
C#
5
star
32

LangtonsAntSimulator

A Langton's ant simulator written in C#
C#
5
star
33

SpriteSheetPacker

A bare bones tool that to pack all images in a given directory into a single graphic, optionally generating sufficient CSS to use the sprite sheet in HTML
C#
5
star
34

imagelistview

Automatically exported from code.google.com/p/imagelistview
C#
5
star
35

ChemotaxisSimulation

A sample application attempting to simulate Chemotaxis, the movement of an organism either toward or away from chemicals
C#
5
star
36

mpqtool

Automatically exported from code.google.com/p/mpqtool
C#
4
star
37

hqx-sharp

Automatically exported from code.google.com/p/hqx-sharp
C#
4
star
38

Markdig.Keyboard

Markdig extension for inserting kbd tags
C#
4
star
39

Cyotek.Drawing.PaletteFormat.Fractint

C#
4
star
40

MarkdigMantisLink

Markdig extension that automatically add links to MantisBT issue items
C#
4
star
41

Cyotek.Drawing.PaletteFormat.RgbTriplets18

Read/write 18-bit RGB VGA palettes using C#
C#
3
star
42

Cyotek.FixExif

Tool for adding or updating EXIF information. Not user friendly or ready to run, see readme.
C#
3
star
43

Cyotek.Drawing.PaletteFormat.Riff

Read/write Microsoft RIFF palettes using C#
C#
3
star
44

aeroshot

Automatically exported from code.google.com/p/aeroshot
C#
3
star
45

Cyotek.HistoricalDate

.NET library for working with historical dates
C#
3
star
46

fast-member

Automatically exported from code.google.com/p/fast-member
C#
3
star
47

todo

A simple todo application using ASP.NET Core
C#
3
star
48

gwen-dotnet

Automatically exported from code.google.com/p/gwen-dotnet
C#
3
star
49

ncrontab

Automatically exported from code.google.com/p/ncrontab
C#
2
star
50

go.cyotek.com

Simple PHP URL redirection service
PHP
2
star
51

translateclient

Automatically exported from code.google.com/p/translateclient
C#
2
star