GithubHelp home page GithubHelp logo

thestonehead / colorpickerwpf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from drogoganor/colorpickerwpf

0.0 0.0 0.0 3.76 MB

Simple color picker control for WPF

License: MIT License

C# 100.00%

colorpickerwpf's Introduction

ColorPickerWPF

A simple WPF color picker control for .NET 4.5.2 licensed under MIT. Contains two color gradient images to sample from, and custom palette support.

screenshot

You can invoke it as a dialog using:

Color color;

bool ok = ColorPickerWindow.ShowDialog(out color);

Or use the user control itself in your application: ColorPickerWPF.ColorPickerControl

screenshot

The user can define their own palette by selecting a color and ctrl+clicking a swatch in the custom colors section (lower right).

The custom palette can be saved to an XML file in the application folder or loaded from the same.

The dialog won't load the custom palette automatically by default, but you can tell it to with the optional flags to ColorPickerWindow.ShowDialog([...], ColorPickerDialogOptions flags, string customPaletteName)

You can specify to show the simple (collapsed) view with flags = ColorPickerDialogOptions.SimpleView

Or you can load the default palette file (specified in the app.config setting DefaultColorPaletteFilename) with flags = ColorPickerDialogOptions.LoadCustomPalette.

Or both using flags = ColorPickerDialogOptions.SimpleView | ColorPickerDialogOptions.LoadCustomPalette

Finally, you can specify a palette filename to load instead of the default with the final optional argument string customPaletteName

An example showing the simple view and loading a custom palette file:

ColorPickerWindow.ShowDialog(out color, ColorPickerDialogOptions.SimpleView | ColorPickerDialogOptions.LoadCustomPalette, "MyPalette.xml");

This would show the dialog in simple view, and load the palette file "MyPalette.xml".

If you are using the ColorPickerControl instead of the dialog, you can load custom palettes with: LoadDefaultCustomPalette() or LoadCustomPalette(string filename).

The palette file, default "ColorPalette.xml", contains both the custom palette colors and the inbuilt colors. You can create your own inbuilt palette if you create an instance of ColorPickerWPF.Code.ColorPalette, populate its data accordingly, and save to file using ColorPalette.SaveToXml(string filename). You can then distribute your application with this custom palette file.

Unfortunately there is no mechanism for customizing the color gradient sample images at this time, or indeed any other customization. If you require further customization I recommend cloning the repo and adding ColorPickerWPF to your solution.

ColorPickerWPF on Nuget Gallery

Thanks to

Fatcow Icons for the dialog window icon.

WriteableBitmapEx for image manipulation code.

colorpickerwpf's People

Contributors

drogoganor avatar thestonehead avatar jameak avatar developerseva avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.