From f59d4fef5601f4624ed08f42cf25c94be7befedd Mon Sep 17 00:00:00 2001 From: miku-666 <74728189+NessieHax@users.noreply.github.com> Date: Sun, 19 Mar 2023 12:34:04 +0100 Subject: [PATCH] Moved color picker code to Vendor folder and Updated README --- PCK-Studio/PckStudio.csproj | 32 +- PCK_Studio.sln | 21 + README.md | 7 +- .../ColorBox2D}/ColorChangedEventArgs.cs | 0 .../MechanikaDesign/ColorBox2D}/ColorModes.cs | 0 .../ColorBox2D/ColorPicker.csproj | 88 ++ .../Controls/ColorBox2D.Designer.cs | 0 .../ColorBox2D}/Controls/ColorBox2D.cs | 0 .../Controls/ColorHexagon.Designer.cs | 0 .../ColorBox2D}/Controls/ColorHexagon.cs | 0 .../Controls/ColorSliderVertical.Designer.cs | 0 .../Controls/ColorSliderVertical.cs | 0 .../Controls/ColorSliderVertical.resx | 0 .../ColorBox2D}/Controls/ColorWheel.cs | 0 .../MechanikaDesign/ColorBox2D}/HslColor.cs | 0 .../ColorBox2D}/MathExtensions.cs | 0 .../ColorBox2D/Properties/AssemblyInfo.cs | 36 + .../ColorHexagon/ColorHexagon.csproj | 63 ++ .../ColorHexagon/Properties/AssemblyInfo.cs | 36 + .../ColorPicker.Demo/App.config | 6 + .../ColorPicker.Demo/ColorPicker.Demo.csproj | 99 ++ .../FormColorPickerDemo.Designer.cs | 412 ++++++++ .../ColorPicker.Demo/FormColorPickerDemo.cs | 196 ++++ .../ColorPicker.Demo/FormColorPickerDemo.resx | 120 +++ .../ColorPicker.Demo/Program.cs | 22 + .../Properties/AssemblyInfo.cs | 36 + .../Properties/Resources.Designer.cs | 63 ++ .../Properties/Resources.resx | 117 +++ .../Properties/Settings.Designer.cs | 26 + .../Properties/Settings.settings | 7 + .../MechanikaDesign/ColorPickerControls.sln | 28 + .../MechanikaDesign/ColorWheel/ColorHelper.cs | 122 +++ .../MechanikaDesign/ColorWheel/ColorWheel.cs | 884 ++++++++++++++++++ .../ColorWheel/ColorWheel.csproj | 60 ++ Vendor/MechanikaDesign/ColorWheel/HslColor.cs | 231 +++++ .../ColorWheel/Properties/AssemblyInfo.cs | 36 + 36 files changed, 2719 insertions(+), 29 deletions(-) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/ColorChangedEventArgs.cs (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/ColorModes.cs (100%) create mode 100644 Vendor/MechanikaDesign/ColorBox2D/ColorPicker.csproj rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/Controls/ColorBox2D.Designer.cs (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/Controls/ColorBox2D.cs (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/Controls/ColorHexagon.Designer.cs (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/Controls/ColorHexagon.cs (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/Controls/ColorSliderVertical.Designer.cs (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/Controls/ColorSliderVertical.cs (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/Controls/ColorSliderVertical.resx (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/Controls/ColorWheel.cs (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/HslColor.cs (100%) rename {PCK-Studio/Classes/COL => Vendor/MechanikaDesign/ColorBox2D}/MathExtensions.cs (100%) create mode 100644 Vendor/MechanikaDesign/ColorBox2D/Properties/AssemblyInfo.cs create mode 100644 Vendor/MechanikaDesign/ColorHexagon/ColorHexagon.csproj create mode 100644 Vendor/MechanikaDesign/ColorHexagon/Properties/AssemblyInfo.cs create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/App.config create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/ColorPicker.Demo.csproj create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.Designer.cs create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.cs create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.resx create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/Program.cs create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/Properties/AssemblyInfo.cs create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.Designer.cs create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.resx create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.Designer.cs create mode 100644 Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.settings create mode 100644 Vendor/MechanikaDesign/ColorPickerControls.sln create mode 100644 Vendor/MechanikaDesign/ColorWheel/ColorHelper.cs create mode 100644 Vendor/MechanikaDesign/ColorWheel/ColorWheel.cs create mode 100644 Vendor/MechanikaDesign/ColorWheel/ColorWheel.csproj create mode 100644 Vendor/MechanikaDesign/ColorWheel/HslColor.cs create mode 100644 Vendor/MechanikaDesign/ColorWheel/Properties/AssemblyInfo.cs diff --git a/PCK-Studio/PckStudio.csproj b/PCK-Studio/PckStudio.csproj index e6ee0bcd..0bd0caf8 100644 --- a/PCK-Studio/PckStudio.csproj +++ b/PCK-Studio/PckStudio.csproj @@ -171,31 +171,6 @@ - - - - UserControl - - - ColorBox2D.cs - - - UserControl - - - ColorHexagon.cs - - - UserControl - - - ColorSliderVertical.cs - - - Component - - - @@ -508,9 +483,6 @@ AddEntry.cs - - ColorSliderVertical.cs - AboutThisProgram.cs @@ -813,6 +785,10 @@ + + {38f99682-d013-4ae3-8334-4bf492a11ff9} + ColorPicker + {693AEBC1-293D-4DF0-BCAE-26A1099FE7BB} OMI Filetype Library diff --git a/PCK_Studio.sln b/PCK_Studio.sln index 4f8bb3be..3553979d 100644 --- a/PCK_Studio.sln +++ b/PCK_Studio.sln @@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OMI Filetype Library", "Ven EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Net Framework v4.8", "Vendor\CrEaTiiOn-Brotherhood-Official-C-Theme\Net_Framework_v4.8\Net Framework v4.8.csproj", "{C3D7B16C-C047-4BAA-884F-7A2308619C33}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorPicker", "Vendor\MechanikaDesign\ColorBox2D\ColorPicker.csproj", "{38F99682-D013-4AE3-8334-4BF492A11FF9}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -78,6 +80,24 @@ Global {C3D7B16C-C047-4BAA-884F-7A2308619C33}.ReleasePortable|x64.Build.0 = Release|Any CPU {C3D7B16C-C047-4BAA-884F-7A2308619C33}.ReleasePortable|x86.ActiveCfg = Release|Any CPU {C3D7B16C-C047-4BAA-884F-7A2308619C33}.ReleasePortable|x86.Build.0 = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Debug|x64.ActiveCfg = Debug|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Debug|x64.Build.0 = Debug|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Debug|x86.ActiveCfg = Debug|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Debug|x86.Build.0 = Debug|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Release|Any CPU.Build.0 = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Release|x64.ActiveCfg = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Release|x64.Build.0 = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Release|x86.ActiveCfg = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Release|x86.Build.0 = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.ReleasePortable|Any CPU.ActiveCfg = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.ReleasePortable|Any CPU.Build.0 = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.ReleasePortable|x64.ActiveCfg = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.ReleasePortable|x64.Build.0 = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.ReleasePortable|x86.ActiveCfg = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.ReleasePortable|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -85,6 +105,7 @@ Global GlobalSection(NestedProjects) = preSolution {693AEBC1-293D-4DF0-BCAE-26A1099FE7BB} = {FC87F3E5-B07E-4FFB-889F-66FA3A3CFCAA} {C3D7B16C-C047-4BAA-884F-7A2308619C33} = {FC87F3E5-B07E-4FFB-889F-66FA3A3CFCAA} + {38F99682-D013-4AE3-8334-4BF492A11FF9} = {FC87F3E5-B07E-4FFB-889F-66FA3A3CFCAA} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9A3BF1FB-950F-401E-9F58-EA7BBADCE6F2} diff --git a/README.md b/README.md index 48f1f058..d33ce75d 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Modify .PCK archives as you please! * Add / Remove / Replace skins, audios, textures, animations and much more. * Edit localization data to make your mods support every language supported by minecraft itself! * PNG previewing -* And much more!\ +* And much more! ## Supported File formats @@ -47,6 +47,11 @@ $ cd "-PCK-Studio" * Forms will not load in viewer until the solution is build _at least_ once +## Dependencies + > [OMI-Filetype-Library](https://github.com/PhoenixARC/-OMI-Filetype-Library) for Minecraft filetype handling.
+ > [CrEaTiiOn-Brotherhood-Official-C-Theme](https://github.com/EternalModz/CrEaTiiOn-Brotherhood-Official-C-Theme) for better User Interface.
+ > [MechanikaDesign.WinForms.UI.ColorPicker](https://www.mechanikadesign.com/software/colorpicker-controls-for-windows-forms/) for better color picking.
+ ## Active Dev Team: * [PhoenixARC](https://github.com/PhoenixARC) diff --git a/PCK-Studio/Classes/COL/ColorChangedEventArgs.cs b/Vendor/MechanikaDesign/ColorBox2D/ColorChangedEventArgs.cs similarity index 100% rename from PCK-Studio/Classes/COL/ColorChangedEventArgs.cs rename to Vendor/MechanikaDesign/ColorBox2D/ColorChangedEventArgs.cs diff --git a/PCK-Studio/Classes/COL/ColorModes.cs b/Vendor/MechanikaDesign/ColorBox2D/ColorModes.cs similarity index 100% rename from PCK-Studio/Classes/COL/ColorModes.cs rename to Vendor/MechanikaDesign/ColorBox2D/ColorModes.cs diff --git a/Vendor/MechanikaDesign/ColorBox2D/ColorPicker.csproj b/Vendor/MechanikaDesign/ColorBox2D/ColorPicker.csproj new file mode 100644 index 00000000..0e6dc108 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorBox2D/ColorPicker.csproj @@ -0,0 +1,88 @@ + + + + + Debug + AnyCPU + {38F99682-D013-4AE3-8334-4BF492A11FF9} + Library + Properties + MechanikaDesign.WinForms.UI.ColorPicker + ColorPicker + v4.8 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + false + + + + + + + + + + + + + + + UserControl + + + ColorBox2D.cs + + + + UserControl + + + ColorHexagon.cs + + + + UserControl + + + ColorSliderVertical.cs + + + Component + + + + + + + + + ColorSliderVertical.cs + + + + + \ No newline at end of file diff --git a/PCK-Studio/Classes/COL/Controls/ColorBox2D.Designer.cs b/Vendor/MechanikaDesign/ColorBox2D/Controls/ColorBox2D.Designer.cs similarity index 100% rename from PCK-Studio/Classes/COL/Controls/ColorBox2D.Designer.cs rename to Vendor/MechanikaDesign/ColorBox2D/Controls/ColorBox2D.Designer.cs diff --git a/PCK-Studio/Classes/COL/Controls/ColorBox2D.cs b/Vendor/MechanikaDesign/ColorBox2D/Controls/ColorBox2D.cs similarity index 100% rename from PCK-Studio/Classes/COL/Controls/ColorBox2D.cs rename to Vendor/MechanikaDesign/ColorBox2D/Controls/ColorBox2D.cs diff --git a/PCK-Studio/Classes/COL/Controls/ColorHexagon.Designer.cs b/Vendor/MechanikaDesign/ColorBox2D/Controls/ColorHexagon.Designer.cs similarity index 100% rename from PCK-Studio/Classes/COL/Controls/ColorHexagon.Designer.cs rename to Vendor/MechanikaDesign/ColorBox2D/Controls/ColorHexagon.Designer.cs diff --git a/PCK-Studio/Classes/COL/Controls/ColorHexagon.cs b/Vendor/MechanikaDesign/ColorBox2D/Controls/ColorHexagon.cs similarity index 100% rename from PCK-Studio/Classes/COL/Controls/ColorHexagon.cs rename to Vendor/MechanikaDesign/ColorBox2D/Controls/ColorHexagon.cs diff --git a/PCK-Studio/Classes/COL/Controls/ColorSliderVertical.Designer.cs b/Vendor/MechanikaDesign/ColorBox2D/Controls/ColorSliderVertical.Designer.cs similarity index 100% rename from PCK-Studio/Classes/COL/Controls/ColorSliderVertical.Designer.cs rename to Vendor/MechanikaDesign/ColorBox2D/Controls/ColorSliderVertical.Designer.cs diff --git a/PCK-Studio/Classes/COL/Controls/ColorSliderVertical.cs b/Vendor/MechanikaDesign/ColorBox2D/Controls/ColorSliderVertical.cs similarity index 100% rename from PCK-Studio/Classes/COL/Controls/ColorSliderVertical.cs rename to Vendor/MechanikaDesign/ColorBox2D/Controls/ColorSliderVertical.cs diff --git a/PCK-Studio/Classes/COL/Controls/ColorSliderVertical.resx b/Vendor/MechanikaDesign/ColorBox2D/Controls/ColorSliderVertical.resx similarity index 100% rename from PCK-Studio/Classes/COL/Controls/ColorSliderVertical.resx rename to Vendor/MechanikaDesign/ColorBox2D/Controls/ColorSliderVertical.resx diff --git a/PCK-Studio/Classes/COL/Controls/ColorWheel.cs b/Vendor/MechanikaDesign/ColorBox2D/Controls/ColorWheel.cs similarity index 100% rename from PCK-Studio/Classes/COL/Controls/ColorWheel.cs rename to Vendor/MechanikaDesign/ColorBox2D/Controls/ColorWheel.cs diff --git a/PCK-Studio/Classes/COL/HslColor.cs b/Vendor/MechanikaDesign/ColorBox2D/HslColor.cs similarity index 100% rename from PCK-Studio/Classes/COL/HslColor.cs rename to Vendor/MechanikaDesign/ColorBox2D/HslColor.cs diff --git a/PCK-Studio/Classes/COL/MathExtensions.cs b/Vendor/MechanikaDesign/ColorBox2D/MathExtensions.cs similarity index 100% rename from PCK-Studio/Classes/COL/MathExtensions.cs rename to Vendor/MechanikaDesign/ColorBox2D/MathExtensions.cs diff --git a/Vendor/MechanikaDesign/ColorBox2D/Properties/AssemblyInfo.cs b/Vendor/MechanikaDesign/ColorBox2D/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..427b5eb7 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorBox2D/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Mechanika Design Color Picker Controls")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Mechanika Design Color Picker Controls Library")] +[assembly: AssemblyCopyright("Copyright © 2015 Mechanika Design")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("53782a11-f0b6-4d1f-8365-2078a4133dfa")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Vendor/MechanikaDesign/ColorHexagon/ColorHexagon.csproj b/Vendor/MechanikaDesign/ColorHexagon/ColorHexagon.csproj new file mode 100644 index 00000000..9dc09e84 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorHexagon/ColorHexagon.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {ADC128AF-95A4-4BA9-B5D7-FE438E1E7A5C} + Library + Properties + ColorHexagon + ColorHexagon + v4.0 + 512 + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + UserControl + + + ColorHexagon.cs + + + + + + + + \ No newline at end of file diff --git a/Vendor/MechanikaDesign/ColorHexagon/Properties/AssemblyInfo.cs b/Vendor/MechanikaDesign/ColorHexagon/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..67efe5ac --- /dev/null +++ b/Vendor/MechanikaDesign/ColorHexagon/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ColorHexagon")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ColorHexagon")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("d53138c7-6021-4516-ada2-197f71459161")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/App.config b/Vendor/MechanikaDesign/ColorPicker.Demo/App.config new file mode 100644 index 00000000..74ade9db --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/App.config @@ -0,0 +1,6 @@ + + + + + + diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/ColorPicker.Demo.csproj b/Vendor/MechanikaDesign/ColorPicker.Demo/ColorPicker.Demo.csproj new file mode 100644 index 00000000..4479f43a --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/ColorPicker.Demo.csproj @@ -0,0 +1,99 @@ + + + + + Debug + AnyCPU + {DF274AA1-5380-4B84-B9F5-FF66E6A1D37B} + WinExe + Properties + ColorPicker.Demo + ColorPicker.Demo + v4.0 + 512 + + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + Form + + + FormColorPickerDemo.cs + + + + + FormColorPickerDemo.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + {38F99682-D013-4AE3-8334-4BF492A11FF9} + ColorPicker + + + + + \ No newline at end of file diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.Designer.cs b/Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.Designer.cs new file mode 100644 index 00000000..f8d9bad4 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.Designer.cs @@ -0,0 +1,412 @@ +namespace ColorHexagon.Demo +{ + partial class FormColorPickerDemo + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.labelCurrent = new System.Windows.Forms.Label(); + this.labelCurrentColor = new System.Windows.Forms.Label(); + this.labelHex = new System.Windows.Forms.Label(); + this.textboxHexColor = new System.Windows.Forms.TextBox(); + this.tabControlMain = new System.Windows.Forms.TabControl(); + this.tabHexagon = new System.Windows.Forms.TabPage(); + this.colorHexagon = new MechanikaDesign.WinForms.UI.ColorPicker.ColorHexagon(); + this.tabWheel = new System.Windows.Forms.TabPage(); + this.colorWheel = new MechanikaDesign.WinForms.UI.ColorPicker.ColorWheel(); + this.tabColorBox = new System.Windows.Forms.TabPage(); + this.numLuminance = new System.Windows.Forms.NumericUpDown(); + this.radioLuminance = new System.Windows.Forms.RadioButton(); + this.numSaturation = new System.Windows.Forms.NumericUpDown(); + this.radioSaturation = new System.Windows.Forms.RadioButton(); + this.numHue = new System.Windows.Forms.NumericUpDown(); + this.radioHue = new System.Windows.Forms.RadioButton(); + this.numBlue = new System.Windows.Forms.NumericUpDown(); + this.radioBlue = new System.Windows.Forms.RadioButton(); + this.numGreen = new System.Windows.Forms.NumericUpDown(); + this.radioGreen = new System.Windows.Forms.RadioButton(); + this.numRed = new System.Windows.Forms.NumericUpDown(); + this.radioRed = new System.Windows.Forms.RadioButton(); + this.colorSlider = new MechanikaDesign.WinForms.UI.ColorPicker.ColorSliderVertical(); + this.colorBox2D = new MechanikaDesign.WinForms.UI.ColorPicker.ColorBox2D(); + this.tabControlMain.SuspendLayout(); + this.tabHexagon.SuspendLayout(); + this.tabWheel.SuspendLayout(); + this.tabColorBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numLuminance)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numSaturation)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numHue)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numBlue)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numGreen)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRed)).BeginInit(); + this.SuspendLayout(); + // + // labelCurrent + // + this.labelCurrent.AutoSize = true; + this.labelCurrent.Location = new System.Drawing.Point(448, 22); + this.labelCurrent.Name = "labelCurrent"; + this.labelCurrent.Size = new System.Drawing.Size(41, 13); + this.labelCurrent.TabIndex = 1; + this.labelCurrent.Text = "Current"; + // + // labelCurrentColor + // + this.labelCurrentColor.BackColor = System.Drawing.Color.White; + this.labelCurrentColor.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.labelCurrentColor.Location = new System.Drawing.Point(451, 39); + this.labelCurrentColor.Name = "labelCurrentColor"; + this.labelCurrentColor.Size = new System.Drawing.Size(68, 32); + this.labelCurrentColor.TabIndex = 2; + // + // labelHex + // + this.labelHex.AutoSize = true; + this.labelHex.Location = new System.Drawing.Point(448, 98); + this.labelHex.Name = "labelHex"; + this.labelHex.Size = new System.Drawing.Size(26, 13); + this.labelHex.TabIndex = 3; + this.labelHex.Text = "Hex"; + // + // textboxHexColor + // + this.textboxHexColor.Location = new System.Drawing.Point(451, 114); + this.textboxHexColor.Name = "textboxHexColor"; + this.textboxHexColor.ReadOnly = true; + this.textboxHexColor.Size = new System.Drawing.Size(68, 20); + this.textboxHexColor.TabIndex = 4; + this.textboxHexColor.Text = "FFFFFF"; + // + // tabControlMain + // + this.tabControlMain.Controls.Add(this.tabHexagon); + this.tabControlMain.Controls.Add(this.tabWheel); + this.tabControlMain.Controls.Add(this.tabColorBox); + this.tabControlMain.Dock = System.Windows.Forms.DockStyle.Left; + this.tabControlMain.Location = new System.Drawing.Point(0, 0); + this.tabControlMain.Name = "tabControlMain"; + this.tabControlMain.SelectedIndex = 0; + this.tabControlMain.Size = new System.Drawing.Size(427, 370); + this.tabControlMain.TabIndex = 5; + // + // tabHexagon + // + this.tabHexagon.Controls.Add(this.colorHexagon); + this.tabHexagon.Location = new System.Drawing.Point(4, 22); + this.tabHexagon.Name = "tabHexagon"; + this.tabHexagon.Padding = new System.Windows.Forms.Padding(3); + this.tabHexagon.Size = new System.Drawing.Size(419, 344); + this.tabHexagon.TabIndex = 0; + this.tabHexagon.Text = "Color Hexagon"; + this.tabHexagon.UseVisualStyleBackColor = true; + // + // colorHexagon + // + this.colorHexagon.Dock = System.Windows.Forms.DockStyle.Fill; + this.colorHexagon.Location = new System.Drawing.Point(3, 3); + this.colorHexagon.Name = "colorHexagon"; + this.colorHexagon.Size = new System.Drawing.Size(413, 338); + this.colorHexagon.TabIndex = 1; + this.colorHexagon.ColorChanged += new MechanikaDesign.WinForms.UI.ColorPicker.ColorHexagon.ColorChangedEventHandler(this.colorHexagon_ColorChanged); + // + // tabWheel + // + this.tabWheel.Controls.Add(this.colorWheel); + this.tabWheel.Location = new System.Drawing.Point(4, 22); + this.tabWheel.Name = "tabWheel"; + this.tabWheel.Padding = new System.Windows.Forms.Padding(3); + this.tabWheel.Size = new System.Drawing.Size(419, 344); + this.tabWheel.TabIndex = 1; + this.tabWheel.Text = "Color Wheel"; + this.tabWheel.UseVisualStyleBackColor = true; + // + // colorWheel + // + this.colorWheel.Color = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(255))))); + this.colorWheel.Dock = System.Windows.Forms.DockStyle.Fill; + this.colorWheel.Location = new System.Drawing.Point(3, 3); + this.colorWheel.Name = "colorWheel"; + this.colorWheel.Size = new System.Drawing.Size(413, 338); + this.colorWheel.TabIndex = 0; + this.colorWheel.ColorChanged += new System.EventHandler(this.colorWheel_ColorChanged); + // + // tabColorBox + // + this.tabColorBox.Controls.Add(this.numLuminance); + this.tabColorBox.Controls.Add(this.radioLuminance); + this.tabColorBox.Controls.Add(this.numSaturation); + this.tabColorBox.Controls.Add(this.radioSaturation); + this.tabColorBox.Controls.Add(this.numHue); + this.tabColorBox.Controls.Add(this.radioHue); + this.tabColorBox.Controls.Add(this.numBlue); + this.tabColorBox.Controls.Add(this.radioBlue); + this.tabColorBox.Controls.Add(this.numGreen); + this.tabColorBox.Controls.Add(this.radioGreen); + this.tabColorBox.Controls.Add(this.numRed); + this.tabColorBox.Controls.Add(this.radioRed); + this.tabColorBox.Controls.Add(this.colorSlider); + this.tabColorBox.Controls.Add(this.colorBox2D); + this.tabColorBox.Location = new System.Drawing.Point(4, 22); + this.tabColorBox.Name = "tabColorBox"; + this.tabColorBox.Padding = new System.Windows.Forms.Padding(3); + this.tabColorBox.Size = new System.Drawing.Size(419, 344); + this.tabColorBox.TabIndex = 2; + this.tabColorBox.Text = "Color Box & Slider"; + this.tabColorBox.UseVisualStyleBackColor = true; + // + // numLuminance + // + this.numLuminance.Location = new System.Drawing.Point(349, 165); + this.numLuminance.Name = "numLuminance"; + this.numLuminance.Size = new System.Drawing.Size(54, 20); + this.numLuminance.TabIndex = 13; + this.numLuminance.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numLuminance.ValueChanged += new System.EventHandler(this.numLuminance_ValueChanged); + // + // radioLuminance + // + this.radioLuminance.AutoSize = true; + this.radioLuminance.Location = new System.Drawing.Point(306, 165); + this.radioLuminance.Name = "radioLuminance"; + this.radioLuminance.Size = new System.Drawing.Size(34, 17); + this.radioLuminance.TabIndex = 12; + this.radioLuminance.Text = "L:"; + this.radioLuminance.UseVisualStyleBackColor = true; + this.radioLuminance.CheckedChanged += new System.EventHandler(this.ColorModeChangedHandler); + // + // numSaturation + // + this.numSaturation.Location = new System.Drawing.Point(349, 139); + this.numSaturation.Name = "numSaturation"; + this.numSaturation.Size = new System.Drawing.Size(54, 20); + this.numSaturation.TabIndex = 11; + this.numSaturation.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.numSaturation.ValueChanged += new System.EventHandler(this.numSaturation_ValueChanged); + // + // radioSaturation + // + this.radioSaturation.AutoSize = true; + this.radioSaturation.Location = new System.Drawing.Point(306, 139); + this.radioSaturation.Name = "radioSaturation"; + this.radioSaturation.Size = new System.Drawing.Size(35, 17); + this.radioSaturation.TabIndex = 10; + this.radioSaturation.Text = "S:"; + this.radioSaturation.UseVisualStyleBackColor = true; + this.radioSaturation.CheckedChanged += new System.EventHandler(this.ColorModeChangedHandler); + // + // numHue + // + this.numHue.Location = new System.Drawing.Point(349, 113); + this.numHue.Maximum = new decimal(new int[] { + 359, + 0, + 0, + 0}); + this.numHue.Name = "numHue"; + this.numHue.Size = new System.Drawing.Size(54, 20); + this.numHue.TabIndex = 9; + this.numHue.ValueChanged += new System.EventHandler(this.numHue_ValueChanged); + // + // radioHue + // + this.radioHue.AutoSize = true; + this.radioHue.Checked = true; + this.radioHue.Location = new System.Drawing.Point(306, 113); + this.radioHue.Name = "radioHue"; + this.radioHue.Size = new System.Drawing.Size(36, 17); + this.radioHue.TabIndex = 8; + this.radioHue.TabStop = true; + this.radioHue.Text = "H:"; + this.radioHue.UseVisualStyleBackColor = true; + this.radioHue.CheckedChanged += new System.EventHandler(this.ColorModeChangedHandler); + // + // numBlue + // + this.numBlue.Location = new System.Drawing.Point(349, 69); + this.numBlue.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numBlue.Name = "numBlue"; + this.numBlue.Size = new System.Drawing.Size(54, 20); + this.numBlue.TabIndex = 7; + this.numBlue.ValueChanged += new System.EventHandler(this.numBlue_ValueChanged); + // + // radioBlue + // + this.radioBlue.AutoSize = true; + this.radioBlue.Location = new System.Drawing.Point(306, 69); + this.radioBlue.Name = "radioBlue"; + this.radioBlue.Size = new System.Drawing.Size(35, 17); + this.radioBlue.TabIndex = 6; + this.radioBlue.Text = "B:"; + this.radioBlue.UseVisualStyleBackColor = true; + this.radioBlue.CheckedChanged += new System.EventHandler(this.ColorModeChangedHandler); + // + // numGreen + // + this.numGreen.Location = new System.Drawing.Point(349, 43); + this.numGreen.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numGreen.Name = "numGreen"; + this.numGreen.Size = new System.Drawing.Size(54, 20); + this.numGreen.TabIndex = 5; + this.numGreen.ValueChanged += new System.EventHandler(this.numGreen_ValueChanged); + // + // radioGreen + // + this.radioGreen.AutoSize = true; + this.radioGreen.Location = new System.Drawing.Point(306, 43); + this.radioGreen.Name = "radioGreen"; + this.radioGreen.Size = new System.Drawing.Size(36, 17); + this.radioGreen.TabIndex = 4; + this.radioGreen.Text = "G:"; + this.radioGreen.UseVisualStyleBackColor = true; + this.radioGreen.CheckedChanged += new System.EventHandler(this.ColorModeChangedHandler); + // + // numRed + // + this.numRed.Location = new System.Drawing.Point(349, 17); + this.numRed.Maximum = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numRed.Name = "numRed"; + this.numRed.Size = new System.Drawing.Size(54, 20); + this.numRed.TabIndex = 3; + this.numRed.Value = new decimal(new int[] { + 255, + 0, + 0, + 0}); + this.numRed.ValueChanged += new System.EventHandler(this.numRed_ValueChanged); + // + // radioRed + // + this.radioRed.AutoSize = true; + this.radioRed.Location = new System.Drawing.Point(306, 17); + this.radioRed.Name = "radioRed"; + this.radioRed.Size = new System.Drawing.Size(36, 17); + this.radioRed.TabIndex = 2; + this.radioRed.Text = "R:"; + this.radioRed.UseVisualStyleBackColor = true; + this.radioRed.CheckedChanged += new System.EventHandler(this.ColorModeChangedHandler); + // + // colorSlider + // + this.colorSlider.ColorMode = MechanikaDesign.WinForms.UI.ColorPicker.ColorModes.Hue; + this.colorSlider.ColorRGB = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.colorSlider.Location = new System.Drawing.Point(259, 8); + this.colorSlider.Name = "colorSlider"; + this.colorSlider.NubColor = System.Drawing.Color.White; + this.colorSlider.Position = 142; + this.colorSlider.Size = new System.Drawing.Size(40, 252); + this.colorSlider.TabIndex = 1; + this.colorSlider.ColorChanged += new MechanikaDesign.WinForms.UI.ColorPicker.ColorSliderVertical.ColorChangedEventHandler(this.colorSlider_ColorChanged); + // + // colorBox2D + // + this.colorBox2D.ColorMode = MechanikaDesign.WinForms.UI.ColorPicker.ColorModes.Hue; + this.colorBox2D.ColorRGB = System.Drawing.Color.Red; + this.colorBox2D.Location = new System.Drawing.Point(8, 8); + this.colorBox2D.Name = "colorBox2D"; + this.colorBox2D.Size = new System.Drawing.Size(245, 252); + this.colorBox2D.TabIndex = 0; + this.colorBox2D.ColorChanged += new MechanikaDesign.WinForms.UI.ColorPicker.ColorBox2D.ColorChangedEventHandler(this.colorBox2D_ColorChanged); + // + // FormColorPickerDemo + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(535, 370); + this.Controls.Add(this.tabControlMain); + this.Controls.Add(this.textboxHexColor); + this.Controls.Add(this.labelHex); + this.Controls.Add(this.labelCurrentColor); + this.Controls.Add(this.labelCurrent); + this.MaximizeBox = false; + this.Name = "FormColorPickerDemo"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Color Picker UI Control Demo"; + this.tabControlMain.ResumeLayout(false); + this.tabHexagon.ResumeLayout(false); + this.tabWheel.ResumeLayout(false); + this.tabColorBox.ResumeLayout(false); + this.tabColorBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.numLuminance)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numSaturation)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numHue)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numBlue)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numGreen)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numRed)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Label labelCurrent; + private System.Windows.Forms.Label labelCurrentColor; + private System.Windows.Forms.Label labelHex; + private System.Windows.Forms.TextBox textboxHexColor; + private System.Windows.Forms.TabControl tabControlMain; + private System.Windows.Forms.TabPage tabHexagon; + private MechanikaDesign.WinForms.UI.ColorPicker.ColorHexagon colorHexagon; + private System.Windows.Forms.TabPage tabWheel; + private MechanikaDesign.WinForms.UI.ColorPicker.ColorWheel colorWheel; + private System.Windows.Forms.TabPage tabColorBox; + private MechanikaDesign.WinForms.UI.ColorPicker.ColorBox2D colorBox2D; + private MechanikaDesign.WinForms.UI.ColorPicker.ColorSliderVertical colorSlider; + private System.Windows.Forms.NumericUpDown numBlue; + private System.Windows.Forms.RadioButton radioBlue; + private System.Windows.Forms.NumericUpDown numGreen; + private System.Windows.Forms.RadioButton radioGreen; + private System.Windows.Forms.NumericUpDown numRed; + private System.Windows.Forms.RadioButton radioRed; + private System.Windows.Forms.NumericUpDown numLuminance; + private System.Windows.Forms.RadioButton radioLuminance; + private System.Windows.Forms.NumericUpDown numSaturation; + private System.Windows.Forms.RadioButton radioSaturation; + private System.Windows.Forms.NumericUpDown numHue; + private System.Windows.Forms.RadioButton radioHue; + + } +} + diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.cs b/Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.cs new file mode 100644 index 00000000..ba14a936 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.cs @@ -0,0 +1,196 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using MechanikaDesign.WinForms.UI.ColorPicker; + +namespace ColorHexagon.Demo +{ + public partial class FormColorPickerDemo : Form + { + #region Fields + + private HslColor colorHsl = HslColor.FromAhsl(0xff); + private ColorModes colorMode = ColorModes.Hue; + private Color colorRgb = Color.Empty; + private bool lockUpdates = false; + + #endregion + + public FormColorPickerDemo() + { + InitializeComponent(); + this.colorBox2D.ColorMode = this.colorMode; + this.colorSlider.ColorMode = this.colorMode; + } + + private void colorHexagon_ColorChanged(object sender, ColorChangedEventArgs args) + { + labelCurrentColor.BackColor = colorHexagon.SelectedColor; + textboxHexColor.Text = ColorTranslator.ToHtml(colorHexagon.SelectedColor); + } + + private void colorWheel_ColorChanged(object sender, EventArgs e) + { + labelCurrentColor.BackColor = colorWheel.Color; + textboxHexColor.Text = ColorTranslator.ToHtml(colorWheel.Color); + } + + private void colorSlider_ColorChanged(object sender, ColorChangedEventArgs args) + { + if (!this.lockUpdates) + { + HslColor colorHSL = this.colorSlider.ColorHSL; + this.colorHsl = colorHSL; + this.colorRgb = this.colorHsl.RgbValue; + this.lockUpdates = true; + this.colorBox2D.ColorHSL = this.colorHsl; + this.lockUpdates = false; + labelCurrentColor.BackColor = this.colorRgb; + textboxHexColor.Text = ColorTranslator.ToHtml(this.colorRgb); + UpdateColorFields(); + } + } + + private void colorBox2D_ColorChanged(object sender, ColorChangedEventArgs args) + { + if (!this.lockUpdates) + { + HslColor colorHSL = this.colorBox2D.ColorHSL; + this.colorHsl = colorHSL; + this.colorRgb = this.colorHsl.RgbValue; + this.lockUpdates = true; + this.colorSlider.ColorHSL = this.colorHsl; + this.lockUpdates = false; + labelCurrentColor.BackColor = this.colorRgb; + textboxHexColor.Text = ColorTranslator.ToHtml(this.colorRgb); + UpdateColorFields(); + } + } + + private void ColorModeChangedHandler(object sender, EventArgs e) + { + if (sender == this.radioRed) + { + this.colorMode = ColorModes.Red; + } + else if (sender == this.radioGreen) + { + this.colorMode = ColorModes.Green; + } + else if (sender == this.radioBlue) + { + this.colorMode = ColorModes.Blue; + } + else if (sender == this.radioHue) + { + this.colorMode = ColorModes.Hue; + } + else if (sender == this.radioSaturation) + { + this.colorMode = ColorModes.Saturation; + } + else if (sender == this.radioLuminance) + { + this.colorMode = ColorModes.Luminance; + } + this.colorSlider.ColorMode = this.colorMode; + this.colorBox2D.ColorMode = this.colorMode; + } + + private void UpdateColorFields() + { + this.lockUpdates = true; + this.numRed.Value = this.colorRgb.R; + this.numGreen.Value = this.colorRgb.G; + this.numBlue.Value = this.colorRgb.B; + this.numHue.Value = (int)(((decimal)this.colorHsl.H) * 360M); + this.numSaturation.Value = (int)(((decimal)this.colorHsl.S) * 100M); + this.numLuminance.Value = (int)(((decimal)this.colorHsl.L) * 100M); + this.lockUpdates = false; + } + + private void UpdateRgbFields(Color newColor) + { + this.colorHsl = HslColor.FromColor(newColor); + this.colorRgb = newColor; + this.lockUpdates = true; + this.numHue.Value = (int)(((decimal)this.colorHsl.H) * 360M); + this.numSaturation.Value = (int)(((decimal)this.colorHsl.S) * 100M); + this.numLuminance.Value = (int)(((decimal)this.colorHsl.L) * 100M); + this.lockUpdates = false; + this.colorSlider.ColorHSL = this.colorHsl; + this.colorBox2D.ColorHSL = this.colorHsl; + } + + private void UpdateHslFields(HslColor newColor) + { + this.colorHsl = newColor; + this.colorRgb = newColor.RgbValue; + this.lockUpdates = true; + this.numRed.Value = this.colorRgb.R; + this.numGreen.Value = this.colorRgb.G; + this.numBlue.Value = this.colorRgb.B; + this.lockUpdates = false; + this.colorSlider.ColorHSL = this.colorHsl; + this.colorBox2D.ColorHSL = this.colorHsl; + } + + private void numRed_ValueChanged(object sender, EventArgs e) + { + if (!this.lockUpdates) + { + UpdateRgbFields(Color.FromArgb((int)this.numRed.Value, (int)this.numGreen.Value, (int)this.numBlue.Value)); + } + } + + private void numGreen_ValueChanged(object sender, EventArgs e) + { + if (!this.lockUpdates) + { + UpdateRgbFields(Color.FromArgb((int)this.numRed.Value, (int)this.numGreen.Value, (int)this.numBlue.Value)); + } + } + + private void numBlue_ValueChanged(object sender, EventArgs e) + { + if (!this.lockUpdates) + { + UpdateRgbFields(Color.FromArgb((int)this.numRed.Value, (int)this.numGreen.Value, (int)this.numBlue.Value)); + } + } + + private void numHue_ValueChanged(object sender, EventArgs e) + { + if (!this.lockUpdates) + { + HslColor newColor = HslColor.FromAhsl((double)(((float)((int)this.numHue.Value)) / 360f), this.colorHsl.S, this.colorHsl.L); + this.UpdateHslFields(newColor); + } + } + + private void numSaturation_ValueChanged(object sender, EventArgs e) + { + if (!this.lockUpdates) + { + HslColor newColor = HslColor.FromAhsl(this.colorHsl.A, this.colorHsl.H, (double)(((float)((int)this.numSaturation.Value)) / 100f), this.colorHsl.L); + this.UpdateHslFields(newColor); + } + + } + + private void numLuminance_ValueChanged(object sender, EventArgs e) + { + if (!this.lockUpdates) + { + HslColor newColor = HslColor.FromAhsl(this.colorHsl.A, this.colorHsl.H, this.colorHsl.S, (double)(((float)((int)this.numLuminance.Value)) / 100f)); + this.UpdateHslFields(newColor); + } + } + } +} diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.resx b/Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/Program.cs b/Vendor/MechanikaDesign/ColorPicker.Demo/Program.cs new file mode 100644 index 00000000..51cc771b --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/Program.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace ColorHexagon.Demo +{ + static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new FormColorPickerDemo()); + } + } +} diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/AssemblyInfo.cs b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..34e5af2b --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Color Picker Controls Demonstration")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Mechanika Design Color Picker Controls Library")] +[assembly: AssemblyCopyright("Copyright © 2015 Mechanika Design")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("9cefab06-ff46-44ec-867f-50faeb88222a")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.Designer.cs b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.Designer.cs new file mode 100644 index 00000000..49e20c84 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.Designer.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ColorPicker.Demo.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ColorPicker.Demo.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + } +} diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.resx b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.Designer.cs b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.Designer.cs new file mode 100644 index 00000000..0ac9ff03 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.34209 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace ColorPicker.Demo.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.settings b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.settings new file mode 100644 index 00000000..39645652 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Vendor/MechanikaDesign/ColorPickerControls.sln b/Vendor/MechanikaDesign/ColorPickerControls.sln new file mode 100644 index 00000000..95194a5a --- /dev/null +++ b/Vendor/MechanikaDesign/ColorPickerControls.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorPicker.Demo", "ColorPicker.Demo\ColorPicker.Demo.csproj", "{DF274AA1-5380-4B84-B9F5-FF66E6A1D37B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorPicker", "ColorBox2D\ColorPicker.csproj", "{38F99682-D013-4AE3-8334-4BF492A11FF9}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {DF274AA1-5380-4B84-B9F5-FF66E6A1D37B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DF274AA1-5380-4B84-B9F5-FF66E6A1D37B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DF274AA1-5380-4B84-B9F5-FF66E6A1D37B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DF274AA1-5380-4B84-B9F5-FF66E6A1D37B}.Release|Any CPU.Build.0 = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {38F99682-D013-4AE3-8334-4BF492A11FF9}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Vendor/MechanikaDesign/ColorWheel/ColorHelper.cs b/Vendor/MechanikaDesign/ColorWheel/ColorHelper.cs new file mode 100644 index 00000000..4911b025 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorWheel/ColorHelper.cs @@ -0,0 +1,122 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Runtime.InteropServices; + +namespace MechanikaDesign.WinForms.UI.ColorPicker +{ + public static class ColorHelper + { + // r,g,b values are from 0 to 1 + // h = [0,360], s = [0,1], v = [0,1] + // if s == 0, then h = -1 (undefined) + /// + /// Generates the Hue, Saturation, and Value for a given color + /// + /// The Color to generate the values for + /// Out value for Hue + /// Out value for Saturation + /// Out value for Value + public static void HSVFromRGB(Color color, out double hue, out double saturation, out double value) + { + double min, max, delta, r, g, b; + r = (double)color.R / 255d; + g = (double)color.G / 255d; + b = (double)color.B / 255d; + + min = Math.Min(r, Math.Min(g, b)); + max = Math.Max(r, Math.Max(g, b)); + value = max; // v + delta = max - min; + if (max != 0) + saturation = delta / max; // s + else + { + // r = g = b = 0 // s = 0, v is undefined + saturation = 0; + hue = -1; + return; + } + if (r == max) + hue = (g - b) / delta; // between yellow & magenta + else if (g == max) + hue = 2 + (b - r) / delta; // between cyan & yellow + else + hue = 4 + (r - g) / delta; // between magenta & cyan + hue *= 60; // degrees + if (hue < 0) + hue += 360; + } + + + /// + /// Generates a Color from a Hue, Saturation, and Value combination + /// + /// Hue to use for the Color. (Max 360) + /// Saturation to use for the Color. (Max 1.0) + /// Value to use for the Color. (Max 1.0) + /// Generated Color + public static Color ColorFromHSV(double hue, double saturation, double value) + { + try + { + int i; + double f, p, q, t, r, g, b; + + if (saturation == 0) + { + // achromatic (grey) + r = g = b = value; + return Color.FromArgb((int)(255 * r), (int)(255 * g), (int)(255 * b)); + } + hue /= 60; // sector 0 to 5 + i = (int)Math.Floor(hue); + f = hue - i; // factorial part of h + p = value * (1 - saturation); + q = value * (1 - saturation * f); + t = value * (1 - saturation * (1 - f)); + switch (i) + { + case 0: + r = value; + g = t; + b = p; + break; + case 1: + r = q; + g = value; + b = p; + break; + case 2: + r = p; + g = value; + b = t; + break; + case 3: + r = p; + g = q; + b = value; + break; + case 4: + r = t; + g = p; + b = value; + break; + default: // case 5: + r = value; + g = p; + b = q; + break; + } + return Color.FromArgb((int)(255 * r), (int)(255 * g), (int)(255 * b)); + } + catch + { + + } + return Color.Empty; + } + + + } +} diff --git a/Vendor/MechanikaDesign/ColorWheel/ColorWheel.cs b/Vendor/MechanikaDesign/ColorWheel/ColorWheel.cs new file mode 100644 index 00000000..eb6a8874 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorWheel/ColorWheel.cs @@ -0,0 +1,884 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.Drawing.Drawing2D; +using System.Data; +using System.Windows.Forms; + +namespace MechanikaDesign.WinForms.UI.ColorPicker +{ + + [DefaultProperty("Color")] + [DefaultEvent("ColorChanged")] + public partial class ColorWheel: Control + { + private const int PADDING = 10; + private const int INNER_RADIUS = 200; + private const int OUTER_RADIUS = INNER_RADIUS + 50; + + #region Fields + + private Brush _brush; + private PointF _centerPoint; + private Color _color; + private int _colorStep; + private bool _dragStartedWithinWheel; + private HslColor _hslColor; + private int _largeChange; + private float _radius; + private int _selectionSize; + private int _smallChange; + private int _updateCount; + + #endregion + + #region Constructors + + /// + /// Initializes a new instance of the class. + /// + public ColorWheel() + { + this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick, true); + this.Color = Color.Black; + this.ColorStep = 4; + this.SelectionSize = 10; + this.SmallChange = 1; + this.LargeChange = 5; + this.SelectionGlyph = this.CreateSelectionGlyph(); + } + + #endregion + + #region Events + + /// + /// Occurs when the Color property value changes + /// + [Category("Property Changed")] + public event EventHandler ColorChanged; + + /// + /// Occurs when the ColorStep property value changes + /// + [Category("Property Changed")] + public event EventHandler ColorStepChanged; + + /// + /// Occurs when the HslColor property value changes + /// + [Category("Property Changed")] + public event EventHandler HslColorChanged; + + /// + /// Occurs when the LargeChange property value changes + /// + [Category("Property Changed")] + public event EventHandler LargeChangeChanged; + + /// + /// Occurs when the SelectionSize property value changes + /// + [Category("Property Changed")] + public event EventHandler SelectionSizeChanged; + + /// + /// Occurs when the SmallChange property value changes + /// + [Category("Property Changed")] + public event EventHandler SmallChangeChanged; + + #endregion + + #region Overridden Methods + /// + /// Releases the unmanaged resources used by the and its child controls and optionally releases the managed resources. + /// + /// true to release both managed and unmanaged resources; false to release only unmanaged resources. + protected override void Dispose(bool disposing) + { + if (disposing) + { + if (_brush != null) + { + _brush.Dispose(); + } + + if (this.SelectionGlyph != null) + { + this.SelectionGlyph.Dispose(); + } + } + + base.Dispose(disposing); + } + + /// + /// Determines whether the specified key is a regular input key or a special key that requires preprocessing. + /// + /// One of the values. + /// true if the specified key is a regular input key; otherwise, false. + protected override bool IsInputKey(Keys keyData) + { + bool result; + + if ((keyData & Keys.Left) == Keys.Left || (keyData & Keys.Up) == Keys.Up || (keyData & Keys.Down) == Keys.Down || (keyData & Keys.Right) == Keys.Right || (keyData & Keys.PageUp) == Keys.PageUp || (keyData & Keys.PageDown) == Keys.PageDown) + { + result = true; + } + else + { + result = base.IsInputKey(keyData); + } + + return result; + } + /// + /// Raises the event. + /// + /// An that contains the event data. + protected override void OnGotFocus(EventArgs e) + { + base.OnGotFocus(e); + + this.Invalidate(); + } + + /// + /// Raises the event. + /// + /// A that contains the event data. + protected override void OnKeyDown(KeyEventArgs e) + { + HslColor color; + double hue; + int step; + + color = this.HslColor; + hue = color.H; + + step = e.Shift ? this.LargeChange : this.SmallChange; + + switch (e.KeyCode) + { + case Keys.Right: + case Keys.Up: + hue += step; + break; + case Keys.Left: + case Keys.Down: + hue -= step; + break; + case Keys.PageUp: + hue += this.LargeChange; + break; + case Keys.PageDown: + hue -= this.LargeChange; + break; + } + + if (hue >= 360) + { + hue = 0; + } + if (hue < 0) + { + hue = 359; + } + + if (hue != color.H) + { + color.H = hue; + + // As the Color and HslColor properties update each other, need to temporarily disable this and manually set both + // otherwise the wheel "sticks" due to imprecise conversion from RGB to HSL + this.LockUpdates = true; + this.Color = color.ToRgbColor(); + this.HslColor = color; + this.LockUpdates = false; + + e.Handled = true; + } + + base.OnKeyDown(e); + } + + /// + /// Raises the event. + /// + /// An that contains the event data. + protected override void OnLostFocus(EventArgs e) + { + base.OnLostFocus(e); + + this.Invalidate(); + } + + /// + /// Raises the event. + /// + /// A that contains the event data. + protected override void OnMouseDown(MouseEventArgs e) + { + base.OnMouseDown(e); + + if (!this.Focused && this.TabStop) + { + this.Focus(); + } + + if (e.Button == MouseButtons.Left && this.IsPointInWheel(e.Location)) + { + _dragStartedWithinWheel = true; + this.SetColor(e.Location); + } + } + + /// + /// Raises the event. + /// + /// A that contains the event data. + protected override void OnMouseMove(MouseEventArgs e) + { + base.OnMouseMove(e); + + if (e.Button == MouseButtons.Left && _dragStartedWithinWheel) + { + this.SetColor(e.Location); + } + } + + /// + /// Raises the event. + /// + /// A that contains the event data. + protected override void OnMouseUp(MouseEventArgs e) + { + base.OnMouseUp(e); + + _dragStartedWithinWheel = false; + } + + /// + /// Raises the event. + /// + /// A that contains the event data. + protected override void OnPaddingChanged(EventArgs e) + { + base.OnPaddingChanged(e); + + this.RefreshWheel(); + } + + /// + /// Raises the event. + /// + /// A that contains the event data. + protected override void OnPaint(PaintEventArgs e) + { + base.OnPaint(e); + + if (this.AllowPainting) + { + base.OnPaintBackground(e); + + if (this.BackgroundImage == null && this.Parent != null && (this.BackColor == this.Parent.BackColor || this.Parent.BackColor.A != 255)) + { + ButtonRenderer.DrawParentBackground(e.Graphics, this.DisplayRectangle, this); + } + + if (_brush != null) + { + e.Graphics.FillPie(_brush, this.ClientRectangle, 0, 360); + } + + // smooth out the edge of the wheel + e.Graphics.SmoothingMode = SmoothingMode.AntiAlias; + using (Pen pen = new Pen(this.BackColor, 2)) + { + e.Graphics.DrawEllipse(pen, new RectangleF(_centerPoint.X - _radius, _centerPoint.Y - _radius, _radius * 2, _radius * 2)); + } + + if (!this.Color.IsEmpty) + { + this.PaintCurrentColor(e); + } + } + } + + /// + /// Raises the event. + /// + /// An that contains the event data. + protected override void OnResize(EventArgs e) + { + base.OnResize(e); + + this.RefreshWheel(); + } + + #endregion + + #region Public Properties + + /// + /// Gets or sets the component color. + /// + /// The component color. + [Category("Appearance")] + [DefaultValue(typeof(Color), "Black")] + public virtual Color Color + { + get { return _color; } + set + { + if (this.Color != value) + { + _color = value; + + this.OnColorChanged(EventArgs.Empty); + } + } + } + + /// + /// Gets or sets the increment for rendering the color wheel. + /// + /// The color step. + /// Value must be between 1 and 359 + [Category("Appearance")] + [DefaultValue(4)] + public virtual int ColorStep + { + get { return _colorStep; } + set + { + if (value < 1 || value > 359) + { + throw new ArgumentOutOfRangeException("value", value, "Value must be between 1 and 359"); + } + + if (this.ColorStep != value) + { + _colorStep = value; + + this.OnColorStepChanged(EventArgs.Empty); + } + } + } + + /// + /// Gets or sets the component color. + /// + /// The component color. + [Category("Appearance")] + [DefaultValue(typeof(HslColor), "0, 0, 0")] + [Browsable(false) /* disable editing until I write a proper type convertor */] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public virtual HslColor HslColor + { + get { return _hslColor; } + set + { + if (this.HslColor != value) + { + _hslColor = value; + + this.OnHslColorChanged(EventArgs.Empty); + } + } + } + + /// + /// Gets or sets a value to be added to or subtracted from the property when the wheel selection is moved a large distance. + /// + /// A numeric value. The default value is 5. + [Category("Behavior")] + [DefaultValue(5)] + public virtual int LargeChange + { + get { return _largeChange; } + set + { + if (this.LargeChange != value) + { + _largeChange = value; + + this.OnLargeChangeChanged(EventArgs.Empty); + } + } + } + + /// + /// Gets or sets the size of the selection handle. + /// + /// The size of the selection handle. + [Category("Appearance")] + [DefaultValue(10)] + public virtual int SelectionSize + { + get { return _selectionSize; } + set + { + if (this.SelectionSize != value) + { + _selectionSize = value; + + this.OnSelectionSizeChanged(EventArgs.Empty); + } + } + } + + /// + /// Gets or sets a value to be added to or subtracted from the property when the wheel selection is moved a small distance. + /// + /// A numeric value. The default value is 1. + [Category("Behavior")] + [DefaultValue(1)] + public virtual int SmallChange + { + get { return _smallChange; } + set + { + if (this.SmallChange != value) + { + _smallChange = value; + + this.OnSmallChangeChanged(EventArgs.Empty); + } + } + } + + #endregion + + #region Protected Properties + + /// + /// Gets a value indicating whether painting of the control is allowed. + /// + /// + /// true if painting of the control is allowed; otherwise, false. + /// + protected virtual bool AllowPainting + { + get { return _updateCount == 0; } + } + + protected Color[] Colors { get; set; } + + protected bool LockUpdates { get; set; } + + protected PointF[] Points { get; set; } + + protected Image SelectionGlyph { get; set; } + + #endregion + + #region Public Members + + /// + /// Disables any redrawing of the image box + /// + public virtual void BeginUpdate() + { + _updateCount++; + } + + /// + /// Enables the redrawing of the image box + /// + public virtual void EndUpdate() + { + if (_updateCount > 0) + { + _updateCount--; + } + + if (this.AllowPainting) + { + this.Invalidate(); + } + } + + #endregion + + #region Protected Members + + /// + /// Calculates wheel attributes. + /// + protected virtual void CalculateWheel() + { + List points; + List colors; + + points = new List(); + colors = new List(); + + // Only define the points if the control is above a minimum size, otherwise if it's too small, + // you get an "out of memory" exceptions (of all things) when creating the brush + if (this.ClientSize.Width > 16 && this.ClientSize.Height > 16) + { + int w; + int h; + + w = this.ClientSize.Width; + h = this.ClientSize.Height; + + _centerPoint = new PointF(w / 2.0F, h / 2.0F); + _radius = this.GetRadius(_centerPoint); + + for (double angle = 0; angle < 360; angle += this.ColorStep) + { + double angleR; + PointF location; + + angleR = angle * (Math.PI / 180); + location = this.GetColorLocation(angleR, _radius); + + points.Add(location); + colors.Add(new HslColor(angle, 1, 0.5).ToRgbColor()); + } + } + + this.Points = points.ToArray(); + this.Colors = colors.ToArray(); + } + + /// + /// Creates the gradient brush used to paint the wheel. + /// + protected virtual Brush CreateGradientBrush() + { + Brush result; + + if (this.Points.Length != 0 && this.Points.Length == this.Colors.Length) + { + result = new PathGradientBrush(this.Points, WrapMode.Clamp) + { + CenterPoint = _centerPoint, + CenterColor = Color.White, + SurroundColors = this.Colors + }; + } + else + { + result = null; + } + + return result; + } + + /// + /// Creates the selection glyph. + /// + protected virtual Image CreateSelectionGlyph() + { + Image image; + int halfSize; + + halfSize = this.SelectionSize / 2; + image = new Bitmap(this.SelectionSize + 1, this.SelectionSize + 1); + + using (Graphics g = Graphics.FromImage(image)) + { + Point[] diamondOuter; + + diamondOuter = new[] + { + new Point(halfSize, 0), new Point(this.SelectionSize, halfSize), new Point(halfSize, this.SelectionSize), new Point(0, halfSize) + }; + + g.FillPolygon(SystemBrushes.Control, diamondOuter); + g.DrawPolygon(SystemPens.ControlDark, diamondOuter); + + using (Pen pen = new Pen(Color.FromArgb(128, SystemColors.ControlDark))) + { + g.DrawLine(pen, halfSize, 1, this.SelectionSize - 1, halfSize); + g.DrawLine(pen, halfSize, 2, this.SelectionSize - 2, halfSize); + g.DrawLine(pen, halfSize, this.SelectionSize - 1, this.SelectionSize - 2, halfSize + 1); + g.DrawLine(pen, halfSize, this.SelectionSize - 2, this.SelectionSize - 3, halfSize + 1); + } + + using (Pen pen = new Pen(Color.FromArgb(196, SystemColors.ControlLightLight))) + { + g.DrawLine(pen, halfSize, this.SelectionSize - 1, 1, halfSize); + } + + g.DrawLine(SystemPens.ControlLightLight, 1, halfSize, halfSize, 1); + } + + return image; + } + + /// + /// Gets the point within the wheel representing the source color. + /// + /// The color. + protected PointF GetColorLocation(Color color) + { + return this.GetColorLocation(new HslColor(color)); + } + + /// + /// Gets the point within the wheel representing the source color. + /// + /// The color. + protected virtual PointF GetColorLocation(HslColor color) + { + double angle; + double radius; + + angle = color.H * Math.PI / 180; + radius = _radius * color.S; + + return this.GetColorLocation(angle, radius); + } + + protected PointF GetColorLocation(double angleR, double radius) + { + double x; + double y; + + x = this.Padding.Left + _centerPoint.X + Math.Cos(angleR) * radius; + y = this.Padding.Top + _centerPoint.Y - Math.Sin(angleR) * radius; + + return new PointF((float)x, (float)y); + } + + protected float GetRadius(PointF centerPoint) + { + return Math.Min(centerPoint.X, centerPoint.Y) - (Math.Max(this.Padding.Horizontal, this.Padding.Vertical) + (this.SelectionSize / 2)); + } + + /// + /// Determines whether the specified point is within the bounds of the color wheel. + /// + /// The point. + /// true if the specified point is within the bounds of the color wheel; otherwise, false. + protected bool IsPointInWheel(Point point) + { + PointF normalized; + + // http://my.safaribooksonline.com/book/programming/csharp/9780672331985/graphics-with-windows-forms-and-gdiplus/ch17lev1sec21 + + normalized = new PointF(point.X - _centerPoint.X, point.Y - _centerPoint.Y); + + return (normalized.X * normalized.X + normalized.Y * normalized.Y) <= (_radius * _radius); + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected virtual void OnColorChanged(EventArgs e) + { + EventHandler handler; + + if (!this.LockUpdates) + { + this.HslColor = new HslColor(this.Color); + } + this.Refresh(); + + handler = this.ColorChanged; + + if (handler != null) + { + handler(this, e); + } + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected virtual void OnColorStepChanged(EventArgs e) + { + EventHandler handler; + + this.RefreshWheel(); + + handler = this.ColorStepChanged; + + if (handler != null) + { + handler(this, e); + } + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected virtual void OnHslColorChanged(EventArgs e) + { + EventHandler handler; + + if (!this.LockUpdates) + { + this.Color = this.HslColor.ToRgbColor(); + } + this.Invalidate(); + + handler = this.HslColorChanged; + + if (handler != null) + { + handler(this, e); + } + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected virtual void OnLargeChangeChanged(EventArgs e) + { + EventHandler handler; + + handler = this.LargeChangeChanged; + + if (handler != null) + { + handler(this, e); + } + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected virtual void OnSelectionSizeChanged(EventArgs e) + { + EventHandler handler; + + if (this.SelectionGlyph != null) + { + this.SelectionGlyph.Dispose(); + } + + this.SelectionGlyph = this.CreateSelectionGlyph(); + this.RefreshWheel(); + + handler = this.SelectionSizeChanged; + + if (handler != null) + { + handler(this, e); + } + } + + /// + /// Raises the event. + /// + /// The instance containing the event data. + protected virtual void OnSmallChangeChanged(EventArgs e) + { + EventHandler handler; + + handler = this.SmallChangeChanged; + + if (handler != null) + { + handler(this, e); + } + } + + protected void PaintColor(PaintEventArgs e, HslColor color) + { + this.PaintColor(e, color, false); + } + + protected virtual void PaintColor(PaintEventArgs e, HslColor color, bool includeFocus) + { + PointF location; + + location = this.GetColorLocation(color); + + if (!float.IsNaN(location.X) && !float.IsNaN(location.Y)) + { + int x; + int y; + + x = (int)location.X - (this.SelectionSize / 2); + y = (int)location.Y - (this.SelectionSize / 2); + + if (this.SelectionGlyph == null) + { + e.Graphics.DrawRectangle(Pens.Black, x, y, this.SelectionSize, this.SelectionSize); + } + else + { + e.Graphics.DrawImage(this.SelectionGlyph, x, y); + } + + if (this.Focused && includeFocus) + { + ControlPaint.DrawFocusRectangle(e.Graphics, new Rectangle(x - 1, y - 1, this.SelectionSize + 2, this.SelectionSize + 2)); + } + } + } + + protected virtual void PaintCurrentColor(PaintEventArgs e) + { + this.PaintColor(e, this.HslColor, true); + } + + protected virtual void SetColor(Point point) + { + double dx; + double dy; + double angle; + double distance; + double saturation; + + dx = Math.Abs(point.X - _centerPoint.X - this.Padding.Left); + dy = Math.Abs(point.Y - _centerPoint.Y - this.Padding.Top); + angle = Math.Atan(dy / dx) / Math.PI * 180; + distance = Math.Pow((Math.Pow(dx, 2) + (Math.Pow(dy, 2))), 0.5); + saturation = distance / _radius; + + if (distance < 6) + { + saturation = 0; // snap to center + } + + if (point.X < _centerPoint.X) + { + angle = 180 - angle; + } + if (point.Y > _centerPoint.Y) + { + angle = 360 - angle; + } + + this.LockUpdates = true; + this.HslColor = new HslColor(angle, saturation, 0.5); + this.Color = this.HslColor.ToRgbColor(); + this.LockUpdates = false; + } + + #endregion + + #region Private Members + + /// + /// Refreshes the wheel attributes and then repaints the control + /// + private void RefreshWheel() + { + if (_brush != null) + { + _brush.Dispose(); + } + + this.CalculateWheel(); + _brush = this.CreateGradientBrush(); + this.Invalidate(); + } + + #endregion + } +} diff --git a/Vendor/MechanikaDesign/ColorWheel/ColorWheel.csproj b/Vendor/MechanikaDesign/ColorWheel/ColorWheel.csproj new file mode 100644 index 00000000..2f208643 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorWheel/ColorWheel.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {A9F7F23D-AE72-4FC9-9B55-FCF21F0AE333} + Library + Properties + ColorWheel + ColorWheel + v4.5 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + Component + + + + + + + + + \ No newline at end of file diff --git a/Vendor/MechanikaDesign/ColorWheel/HslColor.cs b/Vendor/MechanikaDesign/ColorWheel/HslColor.cs new file mode 100644 index 00000000..3a804536 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorWheel/HslColor.cs @@ -0,0 +1,231 @@ +using System; +using System.ComponentModel; +using System.Drawing; +using System.Text; + +namespace MechanikaDesign.WinForms.UI.ColorPicker +{ + [Serializable] + public struct HslColor + { + #region Constants + + public static readonly HslColor Empty; + + #endregion + + #region Fields + + private double hue; + private double saturation; + private double luminance; + private int alpha; + private bool isEmpty; + + #endregion + + #region Static Constructors + + static HslColor() + { + Empty = new HslColor + { + IsEmpty = true + }; + } + + #endregion + + #region Public Constructors + + public HslColor(double h, double s, double l) + : this(255, h, s, l) + { } + + public HslColor(int a, double h, double s, double l) + { + this.alpha = a; + this.hue = Math.Min(359, h); + this.saturation = Math.Min(1, s); + this.luminance = Math.Min(1, l); + isEmpty = false; + } + + public HslColor(Color color) + { + this.alpha = color.A; + this.hue = color.GetHue(); + this.saturation = color.GetSaturation(); + this.luminance = color.GetBrightness(); + isEmpty = false; + } + + #endregion + + #region Operators + + public static bool operator ==(HslColor left, HslColor right) + { + return (((left.A == right.A) && (left.H == right.H)) && ((left.S == right.S) && (left.L == right.L))); + } + + public static bool operator !=(HslColor left, HslColor right) + { + return !(left == right); + } + + public static implicit operator HslColor(Color color) + { + return new HslColor(color); + } + + public static implicit operator Color(HslColor color) + { + return color.ToRgbColor(); + } + + #endregion + + #region Overridden Methods + + public override bool Equals(object obj) + { + if (obj is HslColor) + { + HslColor color = (HslColor)obj; + if (((this.A == color.A) && (this.H == color.H)) && ((this.S == color.S) && (this.L == color.L))) + { + return true; + } + } + return false; + } + + public override int GetHashCode() + { + return (((this.alpha.GetHashCode() ^ this.hue.GetHashCode()) ^ this.saturation.GetHashCode()) ^ this.luminance.GetHashCode()); + } + + public override string ToString() + { + StringBuilder builder; + + builder = new StringBuilder(); + builder.Append(this.GetType().Name); + builder.Append(" ["); + builder.Append("H="); + builder.Append(this.H); + builder.Append(", S="); + builder.Append(this.S); + builder.Append(", L="); + builder.Append(this.L); + builder.Append("]"); + + return builder.ToString(); + } + + #endregion + + #region Public Members + + public double H + { + get { return this.hue; } + set + { + this.hue = value; + this.hue = (this.hue > 359.0) ? 0 : ((this.hue < 0.0) ? 359 : this.hue); + } + } + + public double S + { + get { return this.saturation; } + set { this.saturation = Math.Min(1, Math.Max(0, value)); } + } + + public double L + { + get { return this.luminance; } + set { this.luminance = Math.Min(1, Math.Max(0, value)); } + } + + public int A + { + get { return this.alpha; } + set { this.alpha = Math.Min(0, Math.Max(255, value)); } + } + + public bool IsEmpty + { + get { return isEmpty; } + internal set { isEmpty = value; } + } + + public Color ToRgbColor() + { + return this.ToRgbColor(this.A); + } + + public Color ToRgbColor(int alpha) + { + double q; + if (this.L < 0.5) + { + q = this.L * (1 + this.S); + } + else + { + q = this.L + this.S - (this.L * this.S); + } + double p = 2 * this.L - q; + double hk = this.H / 360; + + // r,g,b colors + double[] tc = new[] + { + hk + (1d / 3d), hk, hk - (1d / 3d) + }; + double[] colors = new[] + { + 0.0, 0.0, 0.0 + }; + + for (int color = 0; color < colors.Length; color++) + { + if (tc[color] < 0) + { + tc[color] += 1; + } + if (tc[color] > 1) + { + tc[color] -= 1; + } + + if (tc[color] < (1d / 6d)) + { + colors[color] = p + ((q - p) * 6 * tc[color]); + } + else if (tc[color] >= (1d / 6d) && tc[color] < (1d / 2d)) + { + colors[color] = q; + } + else if (tc[color] >= (1d / 2d) && tc[color] < (2d / 3d)) + { + colors[color] = p + ((q - p) * 6 * (2d / 3d - tc[color])); + } + else + { + colors[color] = p; + } + + colors[color] *= 255; + } + + return Color.FromArgb(alpha, (int)colors[0], (int)colors[1], (int)colors[2]); + } + + #endregion + + } +} diff --git a/Vendor/MechanikaDesign/ColorWheel/Properties/AssemblyInfo.cs b/Vendor/MechanikaDesign/ColorWheel/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..52c4ae58 --- /dev/null +++ b/Vendor/MechanikaDesign/ColorWheel/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("ColorWheel")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ColorWheel")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("0bfcd6ed-a4f8-47f9-b101-836ee495cd96")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]