PixiEditor.ColorPicker 3.4.1

The ID prefix of this package has been reserved for one of the owners of this package by NuGet.org. Prefix Reserved
dotnet add package PixiEditor.ColorPicker --version 3.4.1
NuGet\Install-Package PixiEditor.ColorPicker -Version 3.4.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PixiEditor.ColorPicker" Version="3.4.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add PixiEditor.ColorPicker --version 3.4.1
#r "nuget: PixiEditor.ColorPicker, 3.4.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install PixiEditor.ColorPicker as a Cake Addin
#addin nuget:?package=PixiEditor.ColorPicker&version=3.4.1

// Install PixiEditor.ColorPicker as a Cake Tool
#tool nuget:?package=PixiEditor.ColorPicker&version=3.4.1

Discord Server Download Downloads

About

A collection of various WPF controls used to select colors. Supports .NET Framework 4.5.1+, .NET Core 3.1+, .NET 5 - 7. Originally developed for PixiEditor.

screenshot

Included Controls

  • SquarePicker: A HSV/HSL Color Picker, consists of a circular hue slider and HV/HL square.
  • ColorSliders: A set of HSV/RGB + Alpha sliders
  • HexColorTextBox: An RGBA Hex text field
  • ColorDisplay: A Primary/Secondary Color display with a swap button
  • StandardColorPicker: Combines everything listed above in one control
  • PortableColorPicker: A collapsible version of StandardColorPicker
  • AlphaSlider: A separate alpha slider control

demo project

Example Usage

See ColorPickerDemo for an example project.

Basic usage:

Install the NuGet package, insert a reference to the ColorPicker namespace

<Window ...
xmlns:colorpicker="clr-namespace:ColorPicker;assembly=ColorPicker"
...>

Add the controls

<colorpicker:StandardColorPicker x:Name="main" Width="200" Height="380"/>
<colorpicker:PortableColorPicker ColorState="{Binding ElementName=main, Path=ColorState, Mode=TwoWay}" Width="40" Height="40"/>

Note: in some configurations such as using the package in .NET Framework 4.7 the XAML designer tends to break and not show the control.

Properties

All controls share these properties:

  • SelectedColor dependency property stores the current color as System.Windows.Media.Color
  • ColorChanged: An event that fires on SelectedColor change.
  • ColorState dependency property contains all info about the current state of the control. Use this property to bind controls together.
  • Color property contains nested properties you may bind to or use to retrieve the color in code-behind:
    • Color.A: Current Alpha, a double ranging from 0 to 255
    • Color.RGB_R, Color.RGB_G, Color.RGB_B: Dimensions of the RGB color space, each is a 0-255 double
    • Color.HSV_H: Hue in the HSV color space, a 0-360 double
    • Color.HSV_S: Saturation in the HSV color space, a 0-100 double
    • Color.HSV_V: Value in the HSV color space, a 0-100 double
    • Color.HSL_H: Hue in the HSL color space, a 0-360 double
    • Color.HSL_S: Saturation in the HSL color space, a 0-100 double
    • Color.HSL_L: Lightness in the HSL color space, a 0-100 double

Apart from those, some controls have unique properties:

  • SecondColorState, SecondColor, and SecondaryColor are functionally identical to ColorState, Color, and SelectedColor respectively. These are present on controls that have a secondary color.
  • HintColorState, HintNotifyableColor, and HintColor are functionally identical to ColorState, Color, and SelectedColor respectively. These are present on controls that have a hint color. The hint color is a color field that can be used to obtain the primary color from an external source when the user clicks a button.
  • UseHintColor enables the hint color or disables it (disabled by default).
  • SmallChange lets you change SmallChange of sliders, which is used as sensitivity for when the user turns the scroll wheel with the cursor over the sliders. Present on controls with sliders.
  • ShowAlpha lets you hide the alpha channel on various controls. Present on all controls containing either an alpha slider (apart from the AlphaSlider control itself) or a hex color textbox.
  • ShowFractionalPart lets you hide the digits after the "." in the textboxes showing HSV and HSL values. Present on ColorSliders and on other controls containing ColorSliders.
  • PickerType: HSV or HSL, present on SquarePicker or controls that contain SquarePicker.

Styling

Out of the box, the color picker uses the default WPF look:

Default ColorPicker look

You may use the included PixiEditor's dark theme by loading a resource dictionary in XAML:

<Window.Resources>
    <ResourceDictionary>
        <ResourceDictionary.MergedDictionaries>
            <ResourceDictionary Source="pack://application:,,,/ColorPicker;component/Styles/DefaultColorPickerStyle.xaml" />
        </ResourceDictionary.MergedDictionaries>
    </ResourceDictionary>
</Window.Resources>

and referencing DefaultColorPickerStyle in the style attribute of a control:

<colorpicker:StandardColorPicker Style="{StaticResource DefaultColorPickerStyle}" />

As an alternative, the same can be achieved programmatically:

var resourceDictionary = new ResourceDictionary();
resourceDictionary.Source = new System.Uri(
    "pack://application:,,,/ColorPicker;component/Styles/DefaultColorPickerStyle.xaml",
    System.UriKind.RelativeOrAbsolute);

StandardColorPicker picker = new StandardColorPicker()
{
    Style = (Style)resourceDictionary["DefaultColorPickerStyle"]
};

You may define your own styles, see DefaultColorPickerStyle for reference.

Other

Read flabbet's article on the theory behind the first version of this project on dev.to

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net5.0-windows7.0 is compatible.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net6.0-windows7.0 is compatible.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net7.0-windows7.0 is compatible.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp3.1 is compatible. 
.NET Framework net451 is compatible.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (5)

Showing the top 5 popular GitHub repositories that depend on PixiEditor.ColorPicker:

Repository Stars
BartoszCichecki/LenovoLegionToolkit
Lightweight Lenovo Vantage and Hotkeys replacement for Lenovo Legion laptops.
PixiEditor/PixiEditor
PixiEditor is a lightweight pixel art editor made with .NET 7
Valkirie/HandheldCompanion
ControllerService
WolvenKit/WolvenKit
Community Mod editor/creator for REDengine games.
Hofknecht/SystemTrayMenu
SystemTrayMenu - Browse and open your files easily
Version Downloads Last updated
3.4.1 27,604 9/6/2023
3.3.1 32,398 3/28/2022
3.2.0 11,275 2/9/2022
3.1.0 9,004 4/20/2021
3.0.0 384 4/11/2021
2.0.1 386 3/8/2021
2.0.0 675 12/23/2020
1.0.1 560 10/9/2020
1.0.0 678 7/28/2020