GithubHelp home page GithubHelp logo

drogoganor / colorpickerwpf Goto Github PK

View Code? Open in Web Editor NEW
96.0 4.0 27.0 3.65 MB

Simple color picker control for WPF

License: MIT License

C# 100.00%
wpf picker picker-component picker-library color-picker color

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

developerseva avatar drogoganor avatar jameak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

colorpickerwpf's Issues

What .net or assemblies does this target/require?

I have a WPF .net 4.5.2 project and I get errors when trying to add this package:

Could not install package 'ColorPickerWPF 1.0.6'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

Set initial color?

It would be nice if the initial selected color could be set when the dialog is invoked. Perhaps another argument, or use the value of the 'out color' arg?

Thanks for the handy control!

Support .NET 4?

Title says it all. We sometimes have reasons to be on older framework. Like application support for Windows XP(my mum uses it for work reasons)

Update Color in the UI, how?

so since the control cant really bind to a viewmodel property on its own Color Property i tried to use the SetColor method of the control but this doesnt seem to update the Control in the UI. I tried UpdateLayout() method too but still no refected change in the UI.

So question is how to propagate a value set in code to the UI? An example would be helpful here :)

regards

Markus

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.