├── images ├── example-wpf-1.png ├── example-wpf-2.png ├── example-wpf-3.png ├── example-wpf-4.png ├── example-avalonia-1.png ├── example-avalonia-2.png ├── example-avalonia-3.png └── example-wpf-mahapps-1.png ├── src ├── WPF │ ├── Egorozh.ColorPicker.WPF │ │ ├── AssemblyInfo.cs │ │ ├── Resources │ │ │ ├── eyedropper.cur │ │ │ └── HsvWheelEffect.ps │ │ ├── GlobalUsings.cs │ │ ├── Helpers │ │ │ ├── ColorConvertExtensions.cs │ │ │ └── NativeMethods.cs │ │ ├── Controls │ │ │ ├── NumUpDowns │ │ │ │ ├── Hsv │ │ │ │ │ ├── HueColorNumUpDown.cs │ │ │ │ │ ├── ValueColorNumUpDown.cs │ │ │ │ │ └── SaturationColorNumUpDown.cs │ │ │ │ ├── Base │ │ │ │ │ └── LabelNumericUpDown.cs │ │ │ │ └── RgbaColorNumericUpDown.cs │ │ │ ├── Sliders │ │ │ │ └── Hsv │ │ │ │ │ ├── HueColorSlider.cs │ │ │ │ │ ├── ValueColorSlider.cs │ │ │ │ │ └── SaturationColorSlider.cs │ │ │ ├── ColorPickerButtonBase.cs │ │ │ ├── ColorPreview.cs │ │ │ └── ColorHexComboBox.cs │ │ ├── ValueConverters │ │ │ ├── ColorToSolidColorBrushConverter.cs │ │ │ ├── DivideDoubleToDoubleConverter.cs │ │ │ ├── BoolToVisibilityConverter.cs │ │ │ ├── DivideDoubleToCornerRadiusConverter.cs │ │ │ └── AccentColorShadeConverter.cs │ │ ├── Themes │ │ │ ├── Others │ │ │ │ └── Brushes.xaml │ │ │ ├── Generic.xaml │ │ │ └── Controls │ │ │ │ ├── ColorWheel.xaml │ │ │ │ ├── ColorPickerButton.xaml │ │ │ │ ├── ScreenColorPicker.xaml │ │ │ │ └── ModeListBox.xaml │ │ └── Egorozh.ColorPicker.WPF.csproj │ ├── Egorozh.ColorPicker.WPF.Dialog.MahApps │ │ ├── AssemblyInfo.cs │ │ ├── Controls │ │ │ ├── ColorPickerButton.cs │ │ │ ├── ColorPickerDialog.xaml │ │ │ └── ColorPickerDialog.xaml.cs │ │ ├── Egorozh.ColorPicker.WPF.Dialog.MahApps.csproj.DotSettings │ │ └── Egorozh.ColorPicker.WPF.Dialog.MahApps.csproj │ └── Egorozh.ColorPicker.WPF.Dialog │ │ ├── Controls │ │ ├── ColorPickerButton.cs │ │ ├── ColorPickerDialog.xaml │ │ └── ColorPickerDialog.xaml.cs │ │ ├── Egorozh.ColorPicker.WPF.Dialog.csproj.DotSettings │ │ └── Egorozh.ColorPicker.WPF.Dialog.csproj ├── Core │ └── ColorPicker.Shared │ │ ├── Enums │ │ └── RgbaChannel.cs │ │ ├── Core │ │ ├── IColorClient.cs │ │ └── IColorManager.cs │ │ ├── Helpers │ │ ├── HexComboBoxHelpers.cs │ │ └── ColorWheelHelpers.cs │ │ ├── Palette │ │ ├── ColorPaletteType.cs │ │ └── Serializers │ │ │ ├── Core │ │ │ └── IPaletteSerializer.cs │ │ │ └── RawPaletteSerializer.cs │ │ ├── Models │ │ └── NamedColor.cs │ │ ├── ColorPicker.Shared.shproj │ │ ├── ColorManager.cs │ │ ├── ColorPicker.Shared.projitems │ │ └── Colors │ │ ├── HsvColor.cs │ │ └── HslColor.cs ├── Samples │ ├── Egorozh.ColorPicker.Avalonia.Client │ │ ├── Assets │ │ │ └── avalonia-logo.ico │ │ ├── nuget.config │ │ ├── Program.cs │ │ ├── Egorozh.ColorPicker.Avalonia.Client.csproj.DotSettings │ │ ├── Egorozh.ColorPicker.Avalonia.Client.csproj │ │ ├── App.axaml.cs │ │ ├── App.axaml │ │ └── Views │ │ │ ├── MainWindow.axaml.cs │ │ │ └── MainWindow.axaml │ ├── Egorozh.ColorPicker.WPF.Client │ │ ├── MainWindow.xaml.cs │ │ ├── App.xaml.cs │ │ ├── App.xaml │ │ ├── Egorozh.ColorPicker.WPF.Client.csproj │ │ ├── AssemblyInfo.cs │ │ └── MainWindow.xaml │ └── Egorozh.ColorPicker.WPF.MahApps.Client │ │ ├── App.xaml.cs │ │ ├── MainWindow.xaml.cs │ │ ├── AssemblyInfo.cs │ │ ├── Egorozh.ColorPicker.WPF.MahApps.Client.csproj │ │ ├── App.xaml │ │ └── MainWindow.xaml ├── AvaloniaUI │ ├── Egorozh.ColorPicker.Avalonia │ │ ├── Controls │ │ │ ├── ColorListItem.cs │ │ │ ├── NumUpDowns │ │ │ │ ├── Hsv │ │ │ │ │ ├── HueColorNumUpDown.cs │ │ │ │ │ ├── ValueColorNumUpDown.cs │ │ │ │ │ └── SaturationColorNumUpDown.cs │ │ │ │ ├── Base │ │ │ │ │ └── LabelNumericUpDown.cs │ │ │ │ └── RgbaColorNumericUpDown.cs │ │ │ ├── Sliders │ │ │ │ ├── Hsv │ │ │ │ │ ├── HueColorSlider.cs │ │ │ │ │ ├── SaturationColorSlider.cs │ │ │ │ │ └── ValueColorSlider.cs │ │ │ │ └── Base │ │ │ │ │ └── ColorSlider.cs │ │ │ ├── ColorPickerButtonBase.cs │ │ │ ├── ColorPreview.cs │ │ │ ├── ColorHexComboBox.cs │ │ │ ├── ColorWheel.cs │ │ │ └── ColorEditor.cs │ │ ├── Helpers │ │ │ └── ColorConvertExtensions.cs │ │ ├── ValueConverters │ │ │ ├── ColorToSolidColorBrushConverter.cs │ │ │ ├── Base │ │ │ │ └── BaseValueConverter.cs │ │ │ ├── DivideDoubleToCornerRadiusConverter.cs │ │ │ ├── DivideDoubleToDoubleConverter.cs │ │ │ └── AccentColorShadeConverter.cs │ │ ├── GlobalUsings.cs │ │ ├── Egorozh.ColorPicker.Avalonia.csproj │ │ ├── Themes │ │ │ ├── Others │ │ │ │ └── Brushes.axaml │ │ │ ├── Fluent.axaml │ │ │ ├── Default.axaml │ │ │ └── Controls │ │ │ │ ├── Default │ │ │ │ ├── ColorWheel.axaml │ │ │ │ ├── LabelNumericUpDown.axaml │ │ │ │ ├── ModeListBox.axaml │ │ │ │ ├── Tabs.axaml │ │ │ │ └── ColorPreview.axaml │ │ │ │ ├── Fluent │ │ │ │ ├── ColorWheel.axaml │ │ │ │ ├── LabelNumericUpDown.axaml │ │ │ │ ├── ModeListBox.axaml │ │ │ │ ├── ColorPicker.axaml │ │ │ │ └── ColorPreview.axaml │ │ │ │ └── ColorPickerButton.axaml │ │ ├── Egorozh.ColorPicker.Avalonia.csproj.DotSettings │ │ └── ColorPickerControl.cs │ └── Egorozh.ColorPicker.Avalonia.Dialog │ │ ├── Themes │ │ ├── SimpleTheme.axaml.cs │ │ ├── FluentTheme.axaml.cs │ │ ├── FluentTheme.axaml │ │ └── SimpleTheme.axaml │ │ ├── Controls │ │ ├── ColorPickerButton.cs │ │ └── ColorPickerDialog.axaml │ │ ├── Egorozh.ColorPicker.Avalonia.Dialog.csproj.DotSettings │ │ └── Egorozh.ColorPicker.Avalonia.Dialog.csproj ├── Directory.Build.props └── LICENSE.md ├── LICENSE.md ├── .gitattributes └── README.md /images/example-wpf-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/images/example-wpf-1.png -------------------------------------------------------------------------------- /images/example-wpf-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/images/example-wpf-2.png -------------------------------------------------------------------------------- /images/example-wpf-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/images/example-wpf-3.png -------------------------------------------------------------------------------- /images/example-wpf-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/images/example-wpf-4.png -------------------------------------------------------------------------------- /images/example-avalonia-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/images/example-avalonia-1.png -------------------------------------------------------------------------------- /images/example-avalonia-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/images/example-avalonia-2.png -------------------------------------------------------------------------------- /images/example-avalonia-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/images/example-avalonia-3.png -------------------------------------------------------------------------------- /images/example-wpf-mahapps-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/images/example-wpf-mahapps-1.png -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Resources/eyedropper.cur: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/src/WPF/Egorozh.ColorPicker.WPF/Resources/eyedropper.cur -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Resources/HsvWheelEffect.ps: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/src/WPF/Egorozh.ColorPicker.WPF/Resources/HsvWheelEffect.ps -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF.Dialog.MahApps/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -------------------------------------------------------------------------------- /src/Core/ColorPicker.Shared/Enums/RgbaChannel.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker; 2 | 3 | public enum RgbaChannel 4 | { 5 | Red, 6 | 7 | Green, 8 | 9 | Blue, 10 | 11 | Alpha 12 | } -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.Avalonia.Client/Assets/avalonia-logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/egorozh/Egorozh.ColorPicker/HEAD/src/Samples/Egorozh.ColorPicker.Avalonia.Client/Assets/avalonia-logo.ico -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using System; 2 | global using System.Collections.Generic; 3 | global using System.Globalization; 4 | global using System.Linq; 5 | global using System.Runtime.InteropServices; 6 | global using System.Threading.Tasks; -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.Client/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker.WPF.Client 2 | { 3 | public partial class MainWindow 4 | { 5 | public MainWindow() 6 | { 7 | InitializeComponent(); 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /src/Core/ColorPicker.Shared/Core/IColorClient.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public interface IColorClient 6 | { 7 | void ColorUpdated(Color color, IColorClient client); 8 | 9 | void Init(IColorManager colorManager); 10 | } -------------------------------------------------------------------------------- /src/Core/ColorPicker.Shared/Helpers/HexComboBoxHelpers.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker; 2 | 3 | public static class HexComboBoxHelpers 4 | { 5 | public static List GetNamedColors() 6 | => ColorPalettes.NamedColors.Select(c => new NamedColor(c.Name, c)).ToList(); 7 | } -------------------------------------------------------------------------------- /src/Core/ColorPicker.Shared/Palette/ColorPaletteType.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker; 2 | 3 | public enum ColorPaletteType 4 | { 5 | None, 6 | 7 | Named, 8 | 9 | Office2010, 10 | 11 | Paint, 12 | 13 | Standard, 14 | 15 | WebSafe, 16 | 17 | Standard256 18 | } -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.Client/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Egorozh.ColorPicker.WPF.Client 4 | { 5 | /// 6 | /// Interaction logic for App.xaml 7 | /// 8 | public partial class App : Application 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.MahApps.Client/App.xaml.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | namespace Egorozh.ColorPicker.Client 4 | { 5 | /// 6 | /// Interaction logic for App.xaml 7 | /// 8 | public partial class App : Application 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Controls/ColorListItem.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker; 2 | 3 | public class ColorListItem : ListBoxItem 4 | { 5 | public ColorListItem(Avalonia.Media.Color color = default) 6 | { 7 | Background = new Avalonia.Media.SolidColorBrush(color); 8 | } 9 | } -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.MahApps.Client/MainWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | using MahApps.Metro.Controls; 2 | 3 | namespace Egorozh.ColorPicker.Client 4 | { 5 | public partial class MainWindow : MetroWindow 6 | { 7 | public MainWindow() 8 | { 9 | InitializeComponent(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Core/ColorPicker.Shared/Models/NamedColor.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public class NamedColor 6 | { 7 | public string Name { get; } 8 | public Color Color { get; } 9 | 10 | public NamedColor(string name, Color color) 11 | { 12 | Name = name; 13 | Color = color; 14 | } 15 | } -------------------------------------------------------------------------------- /src/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11.0.3 5 | 6 | Enable 7 | 8 | egorozh 9 | https://github.com/egorozh/Egorozh.ColorPicker 10 | https://github.com/egorozh/Egorozh.ColorPicker 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.Avalonia.Client/nuget.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.Client/App.xaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Core/ColorPicker.Shared/Core/IColorManager.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public interface IColorManager 6 | { 7 | event Action ColorChanged; 8 | 9 | Color CurrentColor { get; set; } 10 | 11 | void AddClient(params IColorClient?[] clients); 12 | 13 | void SetColorFromHsl(double hue, double saturation, double lightness); 14 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia.Dialog/Themes/SimpleTheme.axaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Avalonia.Controls; 3 | using Avalonia.Markup.Xaml; 4 | using Avalonia.Styling; 5 | 6 | namespace Egorozh.ColorPicker.Dialog; 7 | 8 | public class SimpleTheme : Styles, IResourceNode 9 | { 10 | public SimpleTheme(IServiceProvider? sp = null) 11 | { 12 | AvaloniaXamlLoader.Load(sp, this); 13 | } 14 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia.Dialog/Themes/FluentTheme.axaml.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Avalonia.Controls; 3 | using Avalonia.Markup.Xaml; 4 | using Avalonia.Styling; 5 | 6 | 7 | namespace Egorozh.ColorPicker.Dialog; 8 | 9 | 10 | public class FluentTheme : Styles, IResourceNode 11 | { 12 | public FluentTheme(IServiceProvider? sp = null) 13 | { 14 | AvaloniaXamlLoader.Load(sp, this); 15 | } 16 | } -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.Client/Egorozh.ColorPicker.WPF.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net7.0-windows 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Helpers/ColorConvertExtensions.cs: -------------------------------------------------------------------------------- 1 | using Avalonia.Media; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public static class ColorConvertExtensions 6 | { 7 | public static System.Drawing.Color ToColor(this Color color) 8 | => System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B); 9 | 10 | public static Color ToColor(this System.Drawing.Color color) 11 | => Color.FromArgb(color.A, color.R, color.G, color.B); 12 | } -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.Avalonia.Client/Program.cs: -------------------------------------------------------------------------------- 1 | using Avalonia; 2 | 3 | namespace Egorozh.ColorPicker.Avalonia.Client 4 | { 5 | internal class Program 6 | { 7 | public static void Main(string[] args) => BuildAvaloniaApp() 8 | .StartWithClassicDesktopLifetime(args); 9 | 10 | public static AppBuilder BuildAvaloniaApp() 11 | => AppBuilder.Configure() 12 | .UsePlatformDetect() 13 | .LogToTrace(); 14 | } 15 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia.Dialog/Themes/FluentTheme.axaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia.Dialog/Themes/SimpleTheme.axaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 11 | 12 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.Avalonia.Client/Egorozh.ColorPicker.Avalonia.Client.csproj.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Helpers/ColorConvertExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Windows.Media; 2 | 3 | namespace Egorozh.ColorPicker 4 | { 5 | public static class ColorConvertExtensions 6 | { 7 | public static System.Drawing.Color ToColor(this Color color) 8 | => System.Drawing.Color.FromArgb(color.A, color.R, color.G, color.B); 9 | 10 | public static Color ToColor(this System.Drawing.Color color) 11 | => Color.FromArgb(color.A, color.R, color.G, color.B); 12 | } 13 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/ValueConverters/ColorToSolidColorBrushConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker; 2 | 3 | using Avalonia.Media; 4 | 5 | public class ColorToSolidColorBrushConverter : BaseValueConverter 6 | { 7 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 8 | { 9 | if (value is System.Drawing.Color color) 10 | return new SolidColorBrush(color.ToColor()); 11 | 12 | return Brushes.White; 13 | } 14 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia.Dialog/Controls/ColorPickerButton.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Egorozh.ColorPicker.Dialog; 4 | 5 | public class ColorPickerButton : ColorPickerButtonBase 6 | { 7 | protected override async Task ChangeColor() 8 | { 9 | ColorPickerDialog dialog = new() 10 | { 11 | Color = Color, 12 | Colors = Colors 13 | }; 14 | 15 | var res = await dialog.ShowDialog(Owner); 16 | 17 | if (res) 18 | Color = dialog.Color; 19 | } 20 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/ValueConverters/Base/BaseValueConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker; 2 | 3 | public abstract class BaseValueConverter : MarkupExtension, IValueConverter 4 | { 5 | public override object ProvideValue(IServiceProvider serviceProvider) => this; 6 | 7 | public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture); 8 | 9 | public virtual object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 10 | { 11 | throw new NotImplementedException(); 12 | } 13 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF.Dialog/Controls/ColorPickerButton.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker.Dialog 2 | { 3 | public class ColorPickerButton : ColorPickerButtonBase 4 | { 5 | #region Private Methods 6 | 7 | protected override void ChangeColor() 8 | { 9 | var dialog = new ColorPickerDialog 10 | { 11 | Owner = Owner, 12 | Color = Color 13 | }; 14 | 15 | var res = dialog.ShowDialog(); 16 | 17 | if (res == true) 18 | Color = dialog.Color; 19 | } 20 | 21 | #endregion 22 | } 23 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF.Dialog/Egorozh.ColorPicker.WPF.Dialog.csproj.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF.Dialog.MahApps/Controls/ColorPickerButton.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker.Dialog 2 | { 3 | public class ColorPickerButton : ColorPickerButtonBase 4 | { 5 | #region Private Methods 6 | 7 | protected override void ChangeColor() 8 | { 9 | var dialog = new ColorPickerDialog 10 | { 11 | Owner = Owner, 12 | Color = Color 13 | }; 14 | 15 | var res = dialog.ShowDialog(); 16 | 17 | if (res == true) 18 | Color = dialog.Color; 19 | } 20 | 21 | #endregion 22 | } 23 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia.Dialog/Egorozh.ColorPicker.Avalonia.Dialog.csproj.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/ValueConverters/DivideDoubleToCornerRadiusConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker; 2 | 3 | public class DivideDoubleToCornerRadiusConverter : BaseValueConverter 4 | { 5 | public override object Convert(object value, Type targetType, object parameter, CultureInfo culture) 6 | { 7 | var divider = 2.0; 8 | 9 | if (parameter != null && double.TryParse(parameter.ToString(), out var div)) 10 | { 11 | divider = div; 12 | } 13 | 14 | if (value is double dividend) 15 | return new CornerRadius(dividend / divider); 16 | 17 | return 0; 18 | } 19 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF.Dialog.MahApps/Egorozh.ColorPicker.WPF.Dialog.MahApps.csproj.DotSettings: -------------------------------------------------------------------------------- 1 | 2 | True 3 | True -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.Client/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.MahApps.Client/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Windows; 2 | 3 | [assembly: ThemeInfo( 4 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located 5 | //(used if a resource is not found in the page, 6 | // or application resource dictionaries) 7 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located 8 | //(used if a resource is not found in the page, 9 | // app, or any theme specific resource dictionaries) 10 | )] 11 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.MahApps.Client/Egorozh.ColorPicker.WPF.MahApps.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WinExe 5 | net7.0-windows 6 | true 7 | Egorozh.ColorPicker.Client 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.Avalonia.Client/Egorozh.ColorPicker.Avalonia.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | WinExe 4 | net7.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.Avalonia.Client/App.axaml.cs: -------------------------------------------------------------------------------- 1 | using Avalonia; 2 | using Avalonia.Controls.ApplicationLifetimes; 3 | using Avalonia.Markup.Xaml; 4 | 5 | namespace Egorozh.ColorPicker.Avalonia.Client 6 | { 7 | public class App : Application 8 | { 9 | public override void Initialize() 10 | { 11 | AvaloniaXamlLoader.Load(this); 12 | } 13 | 14 | public override void OnFrameworkInitializationCompleted() 15 | { 16 | if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop) 17 | { 18 | desktop.MainWindow = new MainWindow(); 19 | } 20 | 21 | base.OnFrameworkInitializationCompleted(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.Avalonia.Client/App.axaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/GlobalUsings.cs: -------------------------------------------------------------------------------- 1 | global using Avalonia; 2 | global using Avalonia.Controls; 3 | global using Avalonia.Controls.Primitives; 4 | global using Avalonia.Controls.Shapes; 5 | global using Avalonia.Data.Converters; 6 | global using Avalonia.Input; 7 | global using Avalonia.Interactivity; 8 | global using Avalonia.Layout; 9 | global using Avalonia.Markup.Xaml; 10 | global using Avalonia.Markup.Xaml.Templates; 11 | global using Avalonia.Media.Imaging; 12 | global using Avalonia.Platform; 13 | global using Avalonia.Styling; 14 | global using Avalonia.VisualTree; 15 | global using System; 16 | global using System.Collections.Generic; 17 | global using System.Globalization; 18 | global using System.Linq; 19 | global using System.Runtime.InteropServices; 20 | global using System.Threading.Tasks; -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/ValueConverters/DivideDoubleToDoubleConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Egorozh.ColorPicker; 2 | 3 | public class DivideDoubleToDoubleConverter : MarkupExtension, IValueConverter 4 | { 5 | public override object ProvideValue(IServiceProvider serviceProvider) 6 | { 7 | return this; 8 | } 9 | 10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 11 | { 12 | var divider = 2.0; 13 | 14 | if (parameter != null && double.TryParse(parameter.ToString(), out var div)) 15 | divider = div; 16 | 17 | if (value is double dividend) 18 | return (dividend / divider); 19 | 20 | return 0; 21 | } 22 | 23 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 24 | { 25 | throw new NotImplementedException(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.Avalonia.Client/Views/MainWindow.axaml.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | using Avalonia.Controls; 3 | using Egorozh.ColorPicker.Dialog; 4 | 5 | namespace Egorozh.ColorPicker.Avalonia.Client 6 | { 7 | public partial class MainWindow : Window 8 | { 9 | public MainWindow() 10 | { 11 | InitializeComponent(); 12 | } 13 | } 14 | 15 | internal class CustomColorPickerButton : ColorPickerButtonBase 16 | { 17 | protected override async Task ChangeColor() 18 | { 19 | ColorPickerDialog dialog = new() 20 | { 21 | Color = Color, 22 | Colors = Colors, 23 | Title = "Custom Title" 24 | }; 25 | 26 | var res = await dialog.ShowDialog(Owner); 27 | 28 | if (res) 29 | Color = dialog.Color; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF.Dialog/Egorozh.ColorPicker.WPF.Dialog.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0-windows; 5 | 6 | true 7 | 8 | Egorozh.ColorPicker.Dialog 9 | 10 | 5.0.0 11 | true 12 | 13 | Color, ColorPicker, WPF 14 | LICENSE.md 15 | ColorPicker Dialog 16 | 17 | 18 | 19 | 20 | 21 | 22 | True 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.Client/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 14 | 15 | 17 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /src/Core/ColorPicker.Shared/ColorPicker.Shared.shproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {D4836EAB-E564-470A-9C12-9EE4E4D59F43} 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Controls/NumUpDowns/Hsv/HueColorNumUpDown.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public class HueColorNumUpDown : LabelNumericUpDown 6 | { 7 | #region Constructor 8 | 9 | public HueColorNumUpDown() 10 | { 11 | Minimum = 0; 12 | Maximum = 359; 13 | } 14 | 15 | #endregion 16 | 17 | #region Protected Methods 18 | 19 | protected override void UpdateColor(in Color color) 20 | { 21 | base.UpdateColor(in color); 22 | 23 | var hsv = new HsvColor(color); 24 | 25 | Value = (decimal) hsv.H; 26 | } 27 | 28 | protected override void OnValueChanged() 29 | { 30 | base.OnValueChanged(); 31 | 32 | if (Value.HasValue) 33 | { 34 | var hsv = new HsvColor(ColorManager.CurrentColor) 35 | { 36 | H = (double) Value.Value 37 | }; 38 | 39 | ColorManager.CurrentColor = hsv.ToRgbColor(); 40 | } 41 | } 42 | 43 | #endregion 44 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Controls/NumUpDowns/Hsv/HueColorNumUpDown.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker 4 | { 5 | public class HueColorNumUpDown : LabelNumericUpDown 6 | { 7 | #region Constructor 8 | 9 | public HueColorNumUpDown() 10 | { 11 | Minimum = 0; 12 | Maximum = 359; 13 | } 14 | 15 | #endregion 16 | 17 | #region Protected Methods 18 | 19 | protected override void UpdateColor(in Color color) 20 | { 21 | base.UpdateColor(in color); 22 | 23 | var hsv = new HsvColor(color); 24 | 25 | Value = hsv.H; 26 | } 27 | 28 | protected override void OnValueChanged() 29 | { 30 | base.OnValueChanged(); 31 | 32 | var hsv = new HsvColor(ColorManager.CurrentColor) 33 | { 34 | H = Value.Value 35 | }; 36 | 37 | ColorManager.CurrentColor = hsv.ToRgbColor(); 38 | } 39 | 40 | #endregion 41 | } 42 | } -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.Avalonia.Client/Views/MainWindow.axaml: -------------------------------------------------------------------------------- 1 | 16 | 17 | 19 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Controls/NumUpDowns/Hsv/ValueColorNumUpDown.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker 4 | { 5 | public class ValueColorNumUpDown : LabelNumericUpDown 6 | { 7 | #region Constructor 8 | 9 | public ValueColorNumUpDown() 10 | { 11 | Minimum = 0; 12 | Maximum = 100; 13 | } 14 | 15 | #endregion 16 | 17 | #region Protected Methods 18 | 19 | protected override void UpdateColor(in Color color) 20 | { 21 | base.UpdateColor(in color); 22 | 23 | var hsv = new HsvColor(color); 24 | 25 | Value = hsv.V * 100; 26 | } 27 | 28 | protected override void OnValueChanged() 29 | { 30 | base.OnValueChanged(); 31 | 32 | var hsv = new HsvColor(ColorManager.CurrentColor) 33 | { 34 | V = Value.Value / 100.0 35 | }; 36 | 37 | ColorManager.CurrentColor = hsv.ToRgbColor(); 38 | } 39 | 40 | #endregion 41 | } 42 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Controls/NumUpDowns/Hsv/ValueColorNumUpDown.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public class ValueColorNumUpDown : LabelNumericUpDown 6 | { 7 | #region Constructor 8 | 9 | public ValueColorNumUpDown() 10 | { 11 | Minimum = 0; 12 | Maximum = 100; 13 | } 14 | 15 | #endregion 16 | 17 | #region Protected Methods 18 | 19 | protected override void UpdateColor(in Color color) 20 | { 21 | base.UpdateColor(in color); 22 | 23 | var hsv = new HsvColor(color); 24 | 25 | Value = (decimal) (hsv.V * 100); 26 | } 27 | 28 | protected override void OnValueChanged() 29 | { 30 | base.OnValueChanged(); 31 | 32 | if (Value.HasValue) 33 | { 34 | var hsv = new HsvColor(ColorManager.CurrentColor) 35 | { 36 | V = (double) (Value.Value / 100.0M) 37 | }; 38 | 39 | ColorManager.CurrentColor = hsv.ToRgbColor(); 40 | } 41 | } 42 | 43 | #endregion 44 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/ValueConverters/ColorToSolidColorBrushConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Markup; 5 | using System.Windows.Media; 6 | using Brushes = System.Drawing.Brushes; 7 | using Color = System.Drawing.Color; 8 | 9 | 10 | namespace Egorozh.ColorPicker 11 | { 12 | internal class ColorToSolidColorBrushConverter : MarkupExtension, IValueConverter 13 | { 14 | public override object ProvideValue(IServiceProvider serviceProvider) 15 | { 16 | return this; 17 | } 18 | 19 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 20 | { 21 | if (value is Color color) 22 | return new SolidColorBrush(color.ToColor()); 23 | 24 | return Brushes.White; 25 | } 26 | 27 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 28 | { 29 | throw new NotImplementedException(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Controls/NumUpDowns/Hsv/SaturationColorNumUpDown.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker 4 | { 5 | public class SaturationColorNumUpDown : LabelNumericUpDown 6 | { 7 | #region Constructor 8 | 9 | public SaturationColorNumUpDown() 10 | { 11 | Minimum = 0; 12 | Maximum = 100; 13 | } 14 | 15 | #endregion 16 | 17 | #region Protected Methods 18 | 19 | protected override void UpdateColor(in Color color) 20 | { 21 | base.UpdateColor(in color); 22 | 23 | var hsv = new HsvColor(color); 24 | 25 | Value = hsv.S * 100; 26 | } 27 | 28 | protected override void OnValueChanged() 29 | { 30 | base.OnValueChanged(); 31 | 32 | var hsv = new HsvColor(ColorManager.CurrentColor) 33 | { 34 | S = Value.Value / 100.0 35 | }; 36 | 37 | ColorManager.CurrentColor = hsv.ToRgbColor(); 38 | } 39 | 40 | #endregion 41 | } 42 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Controls/NumUpDowns/Hsv/SaturationColorNumUpDown.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public class SaturationColorNumUpDown : LabelNumericUpDown 6 | { 7 | #region Constructor 8 | 9 | public SaturationColorNumUpDown() 10 | { 11 | Minimum = 0; 12 | Maximum = 100; 13 | } 14 | 15 | #endregion 16 | 17 | #region Protected Methods 18 | 19 | protected override void UpdateColor(in Color color) 20 | { 21 | base.UpdateColor(in color); 22 | 23 | var hsv = new HsvColor(color); 24 | 25 | Value = (decimal) (hsv.S * 100); 26 | } 27 | 28 | protected override void OnValueChanged() 29 | { 30 | base.OnValueChanged(); 31 | 32 | if (Value.HasValue) 33 | { 34 | var hsv = new HsvColor(ColorManager.CurrentColor) 35 | { 36 | S = (double) (Value.Value / 100.0M) 37 | }; 38 | 39 | ColorManager.CurrentColor = hsv.ToRgbColor(); 40 | } 41 | } 42 | 43 | #endregion 44 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Egorozh.ColorPicker.Avalonia.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0;net8.0 5 | 6 | Egorozh.ColorPicker 7 | 8 | true 9 | Color, ColorPicker, Avalonia, AvaloniaUI 10 | LICENSE.md 11 | README.md 12 | 13 | ColorPicker control for Avalonia 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Themes/Others/Brushes.axaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 29 | 30 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.MahApps.Client/App.xaml: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF.Dialog.MahApps/Egorozh.ColorPicker.WPF.Dialog.MahApps.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0-windows; 5 | 6 | true 7 | 8 | Egorozh.ColorPicker.Dialog 9 | 10 | 2.4.3.2 11 | true 12 | 13 | Color, ColorPicker, WPF, MahApps 14 | LICENSE.md 15 | ColorPicker dialog for MahApps 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | True 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/ValueConverters/DivideDoubleToDoubleConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows.Data; 4 | using System.Windows.Markup; 5 | 6 | namespace Egorozh.ColorPicker 7 | { 8 | public class DivideDoubleToDoubleConverter : MarkupExtension, IValueConverter 9 | { 10 | public override object ProvideValue(IServiceProvider serviceProvider) 11 | { 12 | return this; 13 | } 14 | 15 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 16 | { 17 | var divider = 2.0; 18 | 19 | if (parameter != null && double.TryParse(parameter.ToString(), out var div)) 20 | divider = div; 21 | 22 | if (value is double dividend) 23 | return (dividend / divider); 24 | 25 | return 0; 26 | } 27 | 28 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 29 | { 30 | throw new NotImplementedException(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Zheludkov Egor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Zheludkov Egor 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/ValueConverters/BoolToVisibilityConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | using System.Windows.Markup; 6 | 7 | namespace Egorozh.ColorPicker 8 | { 9 | public class BoolToVisibilityConverter : MarkupExtension, IValueConverter 10 | { 11 | public override object ProvideValue(IServiceProvider serviceProvider) 12 | { 13 | return this; 14 | } 15 | 16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | if (value is not bool canVisible) 19 | return Visibility.Visible; 20 | 21 | var invert = parameter != null; 22 | 23 | if (invert) 24 | return canVisible ? Visibility.Collapsed : Visibility.Visible; 25 | else 26 | return canVisible ? Visibility.Visible : Visibility.Collapsed; 27 | } 28 | 29 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 30 | { 31 | throw new NotImplementedException(); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/ValueConverters/DivideDoubleToCornerRadiusConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Windows; 4 | using System.Windows.Data; 5 | using System.Windows.Markup; 6 | 7 | namespace Egorozh.ColorPicker 8 | { 9 | public class DivideDoubleToCornerRadiusConverter : MarkupExtension, IValueConverter 10 | { 11 | public override object ProvideValue(IServiceProvider serviceProvider) 12 | { 13 | return this; 14 | } 15 | 16 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 17 | { 18 | var divider = 2.0; 19 | 20 | if (parameter != null && double.TryParse(parameter.ToString(), out var div)) 21 | { 22 | divider = div; 23 | } 24 | 25 | if (value is double dividend) 26 | return new CornerRadius(dividend / divider); 27 | 28 | return 0; 29 | } 30 | 31 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 32 | { 33 | throw new NotImplementedException(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Controls/Sliders/Hsv/HueColorSlider.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public class HueColorSlider : ColorSlider 6 | { 7 | #region Constructor 8 | 9 | public HueColorSlider() 10 | { 11 | Minimum = 0; 12 | Maximum = 359; 13 | UpdateBackgroundWhenColorUpdated = false; 14 | } 15 | 16 | #endregion 17 | 18 | #region Protected Methods 19 | 20 | protected override void UpdateColor(in Color color) 21 | { 22 | base.UpdateColor(in color); 23 | 24 | var hsv = new HsvColor(color); 25 | 26 | Value = hsv.H; 27 | } 28 | 29 | protected override void OnValueChanged() 30 | { 31 | base.OnValueChanged(); 32 | 33 | var hsv = new HsvColor(ColorManager.CurrentColor) 34 | { 35 | H = Value 36 | }; 37 | 38 | ColorManager.CurrentColor = hsv.ToRgbColor(); 39 | } 40 | 41 | protected override List CreateBackgroundColors(in Color color) => 42 | Enumerable.Range(0, 359) 43 | .Select(h => new HslColor(h, 1, 0.5).ToRgbColor()) 44 | .ToList(); 45 | 46 | #endregion 47 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Themes/Fluent.axaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia.Dialog/Egorozh.ColorPicker.Avalonia.Dialog.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0;net8.0 5 | 6 | Egorozh.ColorPicker.Dialog 7 | 8 | true 9 | 10 | Color, ColorPicker, Avalonia, AvaloniaUI 11 | LICENSE.md 12 | README.md 13 | ColorPicker dialog for Avalonia 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Samples/Egorozh.ColorPicker.WPF.MahApps.Client/MainWindow.xaml: -------------------------------------------------------------------------------- 1 | 15 | 16 | 18 | 22 | 23 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Themes/Default.axaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Themes/Others/Brushes.xaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Egorozh.ColorPicker.WPF.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0-windows; 5 | 6 | true 7 | 8 | true 9 | Egorozh.ColorPicker 10 | 11 | 5.0.0 12 | true 13 | 14 | Color, ColorPicker, WPF 15 | LICENSE.md 16 | ColorPicker Control 17 | 18 | 19 | 20 | 21 | 22 | True 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Themes/Controls/Default/ColorWheel.axaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 33 | 34 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Themes/Controls/Fluent/ColorWheel.axaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 33 | 34 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Controls/Sliders/Hsv/SaturationColorSlider.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public class SaturationColorSlider : ColorSlider 6 | { 7 | #region Constructor 8 | 9 | public SaturationColorSlider() 10 | { 11 | Minimum = 0; 12 | Maximum = 100; 13 | } 14 | 15 | #endregion 16 | 17 | #region Protected Methods 18 | 19 | protected override void UpdateColor(in Color color) 20 | { 21 | base.UpdateColor(in color); 22 | 23 | var hsv = new HsvColor(color); 24 | 25 | Value = hsv.S * 100; 26 | } 27 | 28 | protected override void OnValueChanged() 29 | { 30 | base.OnValueChanged(); 31 | 32 | var hsv = new HsvColor(ColorManager.CurrentColor) 33 | { 34 | S = Value / 100.0 35 | }; 36 | 37 | ColorManager.CurrentColor = hsv.ToRgbColor(); 38 | } 39 | 40 | protected override List CreateBackgroundColors(in Color color) 41 | { 42 | var colors = new List(); 43 | 44 | var hsv = new HsvColor(color) 45 | { 46 | S = 0 47 | }; 48 | colors.Add(hsv.ToRgbColor()); 49 | 50 | hsv.S = 1; 51 | 52 | colors.Add(hsv.ToRgbColor()); 53 | 54 | return colors; 55 | } 56 | 57 | #endregion 58 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Controls/Sliders/Hsv/ValueColorSlider.cs: -------------------------------------------------------------------------------- 1 | using Color = System.Drawing.Color; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public class ValueColorSlider : ColorSlider 6 | { 7 | #region Constructor 8 | 9 | public ValueColorSlider() 10 | { 11 | Minimum = 0; 12 | Maximum = 100; 13 | } 14 | 15 | #endregion 16 | 17 | #region Protected Methods 18 | 19 | protected override void UpdateColor(in Color color) 20 | { 21 | base.UpdateColor(in color); 22 | 23 | var hsv = new HsvColor(color); 24 | 25 | Value = hsv.V * 100; 26 | } 27 | 28 | protected override void OnValueChanged() 29 | { 30 | base.OnValueChanged(); 31 | 32 | var hsv = new HsvColor(ColorManager.CurrentColor) 33 | { 34 | V = Value / 100.0 35 | }; 36 | 37 | ColorManager.CurrentColor = hsv.ToRgbColor(); 38 | } 39 | 40 | protected override List CreateBackgroundColors(in Color color) 41 | { 42 | var colors = new List(); 43 | 44 | var hsv = new HsvColor(color) 45 | { 46 | V = 0 47 | }; 48 | colors.Add(hsv.ToRgbColor()); 49 | 50 | hsv.V = 1; 51 | 52 | colors.Add(hsv.ToRgbColor()); 53 | 54 | return colors; 55 | } 56 | 57 | #endregion 58 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Controls/Sliders/Hsv/HueColorSlider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Drawing; 3 | using System.Linq; 4 | 5 | namespace Egorozh.ColorPicker 6 | { 7 | public class HueColorSlider : ColorSlider 8 | { 9 | #region Constructor 10 | 11 | public HueColorSlider() 12 | { 13 | Minimum = 0; 14 | Maximum = 359; 15 | UpdateBackgroundWhenColorUpdated = false; 16 | } 17 | 18 | #endregion 19 | 20 | #region Protected Methods 21 | 22 | protected override void UpdateColor(in Color color) 23 | { 24 | base.UpdateColor(in color); 25 | 26 | var hsv = new HsvColor(color); 27 | 28 | Value = hsv.H; 29 | } 30 | 31 | protected override void OnValueChanged() 32 | { 33 | base.OnValueChanged(); 34 | 35 | var hsv = new HsvColor(ColorManager.CurrentColor) 36 | { 37 | H = Value 38 | }; 39 | 40 | ColorManager.CurrentColor = hsv.ToRgbColor(); 41 | } 42 | 43 | protected override List CreateBackgroundColors(in Color color) => 44 | Enumerable.Range(0, 359) 45 | .Select(h => new HslColor(h, 1, 0.5).ToRgbColor()) 46 | .ToList(); 47 | 48 | #endregion 49 | } 50 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Themes/Generic.xaml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia/Themes/Controls/ColorPickerButton.axaml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Controls/Sliders/Hsv/ValueColorSlider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Drawing; 3 | 4 | namespace Egorozh.ColorPicker 5 | { 6 | public class ValueColorSlider : ColorSlider 7 | { 8 | #region Constructor 9 | 10 | public ValueColorSlider() 11 | { 12 | Minimum = 0; 13 | Maximum = 100; 14 | } 15 | 16 | #endregion 17 | 18 | #region Protected Methods 19 | 20 | protected override void UpdateColor(in Color color) 21 | { 22 | base.UpdateColor(in color); 23 | 24 | var hsv = new HsvColor(color); 25 | 26 | Value = hsv.V * 100; 27 | } 28 | 29 | protected override void OnValueChanged() 30 | { 31 | base.OnValueChanged(); 32 | 33 | var hsv = new HsvColor(ColorManager.CurrentColor) 34 | { 35 | V = Value / 100.0 36 | }; 37 | 38 | ColorManager.CurrentColor = hsv.ToRgbColor(); 39 | } 40 | 41 | protected override List CreateBackgroundColors(in Color color) 42 | { 43 | var colors = new List(); 44 | 45 | var hsv = new HsvColor(color) 46 | { 47 | V = 0 48 | }; 49 | colors.Add(hsv.ToRgbColor()); 50 | 51 | hsv.V = 1; 52 | 53 | colors.Add(hsv.ToRgbColor()); 54 | 55 | return colors; 56 | } 57 | 58 | #endregion 59 | } 60 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Controls/Sliders/Hsv/SaturationColorSlider.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Drawing; 3 | 4 | namespace Egorozh.ColorPicker 5 | { 6 | public class SaturationColorSlider : ColorSlider 7 | { 8 | #region Constructor 9 | 10 | public SaturationColorSlider() 11 | { 12 | Minimum = 0; 13 | Maximum = 100; 14 | } 15 | 16 | #endregion 17 | 18 | #region Protected Methods 19 | 20 | protected override void UpdateColor(in Color color) 21 | { 22 | base.UpdateColor(in color); 23 | 24 | var hsv = new HsvColor(color); 25 | 26 | Value = hsv.S * 100; 27 | } 28 | 29 | protected override void OnValueChanged() 30 | { 31 | base.OnValueChanged(); 32 | 33 | var hsv = new HsvColor(ColorManager.CurrentColor) 34 | { 35 | S = Value / 100.0 36 | }; 37 | 38 | ColorManager.CurrentColor = hsv.ToRgbColor(); 39 | } 40 | 41 | protected override List CreateBackgroundColors(in Color color) 42 | { 43 | var colors = new List(); 44 | 45 | var hsv = new HsvColor(color) 46 | { 47 | S = 0 48 | }; 49 | colors.Add(hsv.ToRgbColor()); 50 | 51 | hsv.S = 1; 52 | 53 | colors.Add(hsv.ToRgbColor()); 54 | 55 | return colors; 56 | } 57 | 58 | #endregion 59 | } 60 | } -------------------------------------------------------------------------------- /src/WPF/Egorozh.ColorPicker.WPF/Themes/Controls/ColorWheel.xaml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 32 | 33 | -------------------------------------------------------------------------------- /src/Core/ColorPicker.Shared/ColorManager.cs: -------------------------------------------------------------------------------- 1 | using System.Drawing; 2 | 3 | namespace Egorozh.ColorPicker; 4 | 5 | public class ColorManager : IColorManager 6 | { 7 | #region Private Fields 8 | 9 | private readonly List _colorClients = new (); 10 | private Color _currentColor; 11 | 12 | #endregion 13 | 14 | #region Events 15 | 16 | public event Action? ColorChanged; 17 | 18 | #endregion 19 | 20 | #region Public Properties 21 | 22 | public Color CurrentColor 23 | { 24 | get => _currentColor; 25 | set => UpdateClients(value); 26 | } 27 | 28 | #endregion 29 | 30 | #region Public Methods 31 | 32 | public void AddClient(params IColorClient?[] clients) 33 | { 34 | foreach (var client in clients) 35 | { 36 | if (client == null) 37 | continue; 38 | 39 | _colorClients.Add(client); 40 | client.Init(this); 41 | } 42 | } 43 | 44 | public void SetColorFromHsl(double hue, double saturation, double lightness) 45 | { 46 | var alpha = CurrentColor.A; 47 | 48 | var hsl = new HslColor(alpha, hue, saturation, lightness); 49 | 50 | CurrentColor = hsl.ToRgbColor(); 51 | } 52 | 53 | #endregion 54 | 55 | #region Private Methods 56 | 57 | private void UpdateClients(Color color) 58 | { 59 | _currentColor = color; 60 | 61 | foreach (var colorClient in _colorClients) 62 | colorClient.ColorUpdated(color, colorClient); 63 | 64 | ColorChanged?.Invoke(color); 65 | } 66 | 67 | #endregion 68 | } -------------------------------------------------------------------------------- /src/AvaloniaUI/Egorozh.ColorPicker.Avalonia.Dialog/Controls/ColorPickerDialog.axaml: -------------------------------------------------------------------------------- 1 | 22 | 23 | 25 | 26 | 29 | 30 | 34 | 35 |