mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-05-22 17:25:09 +00:00
Updated CBH Theme repo link and removed MechanikaDesign from Vendors
This commit is contained in:
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -1,6 +1,6 @@
|
||||
[submodule "OMI-Lib"]
|
||||
path = Vendor/OMI-Lib
|
||||
url = https://github.com/PhoenixARC/-OMI-Filetype-Library.git
|
||||
[submodule "Vendor/CrEaTiiOn-Brotherhood-Official-C-Theme"]
|
||||
path = Vendor/CrEaTiiOn-Brotherhood-Official-C-Theme
|
||||
url = https://github.com/NessieHax/CrEaTiiOn-Brotherhood-Official-C-Theme.git
|
||||
[submodule "CrEaTiiOn-Brotherhood-Theme-Library"]
|
||||
path = Vendor/CrEaTiiOn-Brotherhood-Theme-Library-Net
|
||||
url = https://github.com/EternalModz/CrEaTiiOn-Brotherhood-Theme-Library-NET.git
|
||||
|
||||
12
PCK-Studio/Forms/Editor/COLEditor.Designer.cs
generated
12
PCK-Studio/Forms/Editor/COLEditor.Designer.cs
generated
@@ -73,8 +73,8 @@ namespace PckStudio.Forms.Editor
|
||||
this.fogTab = new System.Windows.Forms.TabPage();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.SetColorButton = new CBH.Ultimate.Controls.CrEaTiiOn_Ultimate_GradientButton();
|
||||
this.colorSliderVertical1 = new MechanikaDesign.WinForms.UI.ColorPicker.ColorSliderVertical();
|
||||
this.colorBox2D1 = new MechanikaDesign.WinForms.UI.ColorPicker.ColorBox2D();
|
||||
this.colorSliderVertical1 = new CBH.Controls.CrEaTiiOn_ColorSliderVertical();
|
||||
this.colorBox2D1 = new CBH.Controls.CrEaTiiOn_ColorBox2D();
|
||||
this.blueUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.greenUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.redUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
@@ -473,7 +473,7 @@ namespace PckStudio.Forms.Editor
|
||||
// colorSliderVertical1
|
||||
//
|
||||
this.colorSliderVertical1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.colorSliderVertical1.ColorMode = MechanikaDesign.WinForms.UI.ColorPicker.ColorModes.Hue;
|
||||
this.colorSliderVertical1.ColorMode = CBH.Controls.ColorModes.Hue;
|
||||
this.colorSliderVertical1.ColorRGB = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
|
||||
resources.ApplyResources(this.colorSliderVertical1, "colorSliderVertical1");
|
||||
this.colorSliderVertical1.Name = "colorSliderVertical1";
|
||||
@@ -482,7 +482,7 @@ namespace PckStudio.Forms.Editor
|
||||
//
|
||||
// colorBox2D1
|
||||
//
|
||||
this.colorBox2D1.ColorMode = MechanikaDesign.WinForms.UI.ColorPicker.ColorModes.Hue;
|
||||
this.colorBox2D1.ColorMode = CBH.Controls.ColorModes.Hue;
|
||||
this.colorBox2D1.ColorRGB = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
|
||||
resources.ApplyResources(this.colorBox2D1, "colorBox2D1");
|
||||
this.colorBox2D1.Name = "colorBox2D1";
|
||||
@@ -697,8 +697,8 @@ namespace PckStudio.Forms.Editor
|
||||
private ToolStripMenuItem copyColorToolStripMenuItem;
|
||||
private ToolStripMenuItem pasteColorToolStripMenuItem;
|
||||
private Panel panel1;
|
||||
private MechanikaDesign.WinForms.UI.ColorPicker.ColorSliderVertical colorSliderVertical1;
|
||||
private MechanikaDesign.WinForms.UI.ColorPicker.ColorBox2D colorBox2D1;
|
||||
private CBH.Controls.CrEaTiiOn_ColorSliderVertical colorSliderVertical1;
|
||||
private CBH.Controls.CrEaTiiOn_ColorBox2D colorBox2D1;
|
||||
private NumericUpDown blueUpDown;
|
||||
private NumericUpDown greenUpDown;
|
||||
private NumericUpDown redUpDown;
|
||||
|
||||
@@ -781,21 +781,15 @@
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Vendor\MechanikaDesign\ColorBox2D\ColorPicker.csproj">
|
||||
<Project>{38f99682-d013-4ae3-8334-4bf492a11ff9}</Project>
|
||||
<Name>ColorPicker</Name>
|
||||
<ProjectReference Include="..\Vendor\CrEaTiiOn-Brotherhood-Theme-Library-Net\CBH-WinForm-Theme-NET\CBH-WinForm-Theme-NET-.csproj">
|
||||
<Project>{4f287251-7f2a-4b47-9102-4a1aabd41f20}</Project>
|
||||
<Name>CBH-WinForm-Theme-NET-</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Vendor\OMI-Lib\OMI Filetypes Library\OMI Filetype Library.csproj">
|
||||
<Project>{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}</Project>
|
||||
<Name>OMI Filetype Library</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Vendor\CrEaTiiOn-Brotherhood-Official-C-Theme\Net_Framework_v4.8\Net Framework v4.8.csproj">
|
||||
<Project>{c3d7b16c-c047-4baa-884f-7a2308619c33}</Project>
|
||||
<Name>Net Framework v4.8</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -9,9 +9,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Vendor", "Vendor", "{FC87F3
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OMI Filetype Library", "Vendor\OMI-Lib\OMI Filetypes Library\OMI Filetype Library.csproj", "{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}"
|
||||
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}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CBH-WinForm-Theme-NET-", "Vendor\CrEaTiiOn-Brotherhood-Theme-Library-Net\CBH-WinForm-Theme-NET\CBH-WinForm-Theme-NET-.csproj", "{4F287251-7F2A-4B47-9102-4A1AABD41F20}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -62,50 +60,31 @@ Global
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.ReleasePortable|x64.Build.0 = Release|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.ReleasePortable|x86.ActiveCfg = Release|Any CPU
|
||||
{693AEBC1-293D-4DF0-BCAE-26A1099FE7BB}.ReleasePortable|x86.Build.0 = Release|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Release|x64.Build.0 = Release|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.Release|x86.Build.0 = Release|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.ReleasePortable|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.ReleasePortable|Any CPU.Build.0 = Release|Any CPU
|
||||
{C3D7B16C-C047-4BAA-884F-7A2308619C33}.ReleasePortable|x64.ActiveCfg = Release|Any CPU
|
||||
{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
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.Release|x86.Build.0 = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.ReleasePortable|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.ReleasePortable|Any CPU.Build.0 = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.ReleasePortable|x64.ActiveCfg = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.ReleasePortable|x64.Build.0 = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.ReleasePortable|x86.ActiveCfg = Release|Any CPU
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20}.ReleasePortable|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
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}
|
||||
{4F287251-7F2A-4B47-9102-4A1AABD41F20} = {FC87F3E5-B07E-4FFB-889F-66FA3A3CFCAA}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {9A3BF1FB-950F-401E-9F58-EA7BBADCE6F2}
|
||||
|
||||
Submodule Vendor/CrEaTiiOn-Brotherhood-Official-C-Theme deleted from b8ce1fe075
1
Vendor/CrEaTiiOn-Brotherhood-Theme-Library-Net
vendored
Submodule
1
Vendor/CrEaTiiOn-Brotherhood-Theme-Library-Net
vendored
Submodule
Submodule Vendor/CrEaTiiOn-Brotherhood-Theme-Library-Net added at 6b978e9ab5
@@ -1,39 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
public class ColorChangedEventArgs : EventArgs
|
||||
{
|
||||
private Color selectedColor;
|
||||
private HslColor selectedHslColor;
|
||||
|
||||
public ColorChangedEventArgs(Color selectedColor)
|
||||
{
|
||||
this.selectedColor = selectedColor;
|
||||
this.selectedHslColor = HslColor.FromColor(selectedColor);
|
||||
}
|
||||
|
||||
public ColorChangedEventArgs(HslColor selectedHslColor)
|
||||
{
|
||||
this.selectedColor = selectedHslColor.RgbValue;
|
||||
this.selectedHslColor = selectedHslColor;
|
||||
}
|
||||
|
||||
public Color SelectedColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.selectedColor;
|
||||
}
|
||||
}
|
||||
|
||||
public HslColor SelectedHslColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.selectedHslColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
19
Vendor/MechanikaDesign/ColorBox2D/ColorModes.cs
vendored
19
Vendor/MechanikaDesign/ColorBox2D/ColorModes.cs
vendored
@@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
public enum ColorModes
|
||||
{
|
||||
Red,
|
||||
Green,
|
||||
Blue,
|
||||
Hue,
|
||||
Saturation,
|
||||
Luminance
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{38F99682-D013-4AE3-8334-4BF492A11FF9}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>MechanikaDesign.WinForms.UI.ColorPicker</RootNamespace>
|
||||
<AssemblyName>ColorPicker</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\ColorBox2D.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ColorBox2D.Designer.cs">
|
||||
<DependentUpon>ColorBox2D.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ColorChangedEventArgs.cs" />
|
||||
<Compile Include="Controls\ColorHexagon.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ColorHexagon.Designer.cs">
|
||||
<DependentUpon>ColorHexagon.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ColorModes.cs" />
|
||||
<Compile Include="Controls\ColorSliderVertical.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ColorSliderVertical.Designer.cs">
|
||||
<DependentUpon>ColorSliderVertical.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Controls\ColorWheel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="HslColor.cs" />
|
||||
<Compile Include="MathExtensions.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Controls\ColorSliderVertical.resx">
|
||||
<DependentUpon>ColorSliderVertical.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
37
Vendor/MechanikaDesign/ColorBox2D/Controls/ColorBox2D.Designer.cs
generated
vendored
37
Vendor/MechanikaDesign/ColorBox2D/Controls/ColorBox2D.Designer.cs
generated
vendored
@@ -1,37 +0,0 @@
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
partial class ColorBox2D
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,309 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
[DefaultEvent("ColorChanged")]
|
||||
public partial class ColorBox2D: UserControl
|
||||
{
|
||||
|
||||
#region Events
|
||||
public delegate void ColorChangedEventHandler(object sender, ColorChangedEventArgs args);
|
||||
public event ColorChangedEventHandler ColorChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private HslColor colorHSL;
|
||||
private ColorModes colorMode;
|
||||
private Color colorRGB = Color.Empty;
|
||||
private Point markerPoint = Point.Empty;
|
||||
private bool mouseMoving;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
public ColorModes ColorMode
|
||||
{
|
||||
get { return this.colorMode; }
|
||||
set
|
||||
{
|
||||
this.colorMode = value;
|
||||
this.ResetMarker();
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public HslColor ColorHSL
|
||||
{
|
||||
get { return this.colorHSL; }
|
||||
set
|
||||
{
|
||||
this.colorHSL = value;
|
||||
this.colorRGB = this.colorHSL.RgbValue;
|
||||
this.ResetMarker();
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public Color ColorRGB
|
||||
{
|
||||
get { return this.colorRGB; }
|
||||
set
|
||||
{
|
||||
this.colorRGB = value;
|
||||
this.colorHSL = HslColor.FromColor(this.colorRGB);
|
||||
this.ResetMarker();
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ColorBox2D()
|
||||
{
|
||||
InitializeComponent();
|
||||
base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
|
||||
|
||||
this.colorHSL = HslColor.FromAhsl(1.0, 1.0, 1.0);
|
||||
this.colorRGB = this.colorHSL.RgbValue;
|
||||
this.colorMode = ColorModes.Hue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overriden Methods
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
this.mouseMoving = true;
|
||||
this.SetMarker(e.X, e.Y);
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
if (this.mouseMoving)
|
||||
{
|
||||
this.SetMarker(e.X, e.Y);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
this.mouseMoving = false;
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
HslColor color = HslColor.FromAhsl(0xff);
|
||||
HslColor color2 = HslColor.FromAhsl(0xff);
|
||||
switch (this.ColorMode)
|
||||
{
|
||||
case ColorModes.Hue:
|
||||
color.H = this.ColorHSL.H;
|
||||
color2.H = this.ColorHSL.H;
|
||||
color.S = 0.0;
|
||||
color2.S = 1.0;
|
||||
break;
|
||||
|
||||
case ColorModes.Saturation:
|
||||
color.S = this.ColorHSL.S;
|
||||
color2.S = this.ColorHSL.S;
|
||||
color.L = 1.0;
|
||||
color2.L = 0.0;
|
||||
break;
|
||||
|
||||
case ColorModes.Luminance:
|
||||
color.L = this.ColorHSL.L;
|
||||
color2.L = this.ColorHSL.L;
|
||||
color.S = 1.0;
|
||||
color2.S = 0.0;
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < (base.Height - 4); i++)
|
||||
{
|
||||
int green = MathExtensions.Round(255.0 - ((255.0 * i) / ((double)(base.Height - 4))));
|
||||
Color empty = Color.Empty;
|
||||
Color rgbValue = Color.Empty;
|
||||
switch (this.ColorMode)
|
||||
{
|
||||
case ColorModes.Red:
|
||||
empty = Color.FromArgb(this.ColorRGB.R, green, 0);
|
||||
rgbValue = Color.FromArgb(this.ColorRGB.R, green, 0xff);
|
||||
break;
|
||||
|
||||
case ColorModes.Green:
|
||||
empty = Color.FromArgb(green, this.ColorRGB.G, 0);
|
||||
rgbValue = Color.FromArgb(green, this.ColorRGB.G, 0xff);
|
||||
break;
|
||||
|
||||
case ColorModes.Blue:
|
||||
empty = Color.FromArgb(0, green, this.ColorRGB.B);
|
||||
rgbValue = Color.FromArgb(0xff, green, this.ColorRGB.B);
|
||||
break;
|
||||
|
||||
case ColorModes.Hue:
|
||||
color2.L = color.L = 1.0 - (((double)i) / ((double)(base.Height - 4)));
|
||||
empty = color.RgbValue;
|
||||
rgbValue = color2.RgbValue;
|
||||
break;
|
||||
|
||||
case ColorModes.Saturation:
|
||||
case ColorModes.Luminance:
|
||||
color2.H = color.H = ((double)i) / ((double)(base.Width - 4));
|
||||
empty = color.RgbValue;
|
||||
rgbValue = color2.RgbValue;
|
||||
break;
|
||||
}
|
||||
|
||||
Rectangle rect = new Rectangle(2, 2, base.Width - 4, 1);
|
||||
Rectangle rectangle2 = new Rectangle(2, i + 2, base.Width - 4, 1);
|
||||
if ((this.ColorMode == ColorModes.Saturation) || (this.ColorMode == ColorModes.Luminance))
|
||||
{
|
||||
rect = new Rectangle(2, 2, 1, base.Height - 4);
|
||||
rectangle2 = new Rectangle(i + 2, 2, 1, base.Height - 4);
|
||||
using (LinearGradientBrush brush = new LinearGradientBrush(rect, empty, rgbValue, 90f, false))
|
||||
{
|
||||
e.Graphics.FillRectangle(brush, rectangle2);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
using (LinearGradientBrush brush2 = new LinearGradientBrush(rect, empty, rgbValue, 0f, false))
|
||||
{
|
||||
e.Graphics.FillRectangle(brush2, rectangle2);
|
||||
}
|
||||
}
|
||||
Pen white = Pens.White;
|
||||
if (this.colorHSL.L >= 0.78431372549019607)
|
||||
{
|
||||
if ((this.colorHSL.H < 0.072222222222222215) || (this.colorHSL.H > 0.55555555555555558))
|
||||
{
|
||||
if (this.colorHSL.S <= 0.27450980392156865)
|
||||
{
|
||||
white = Pens.Black;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
white = Pens.Black;
|
||||
}
|
||||
}
|
||||
e.Graphics.DrawEllipse(white, this.markerPoint.X - 5, this.markerPoint.Y - 5, 10, 10);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private HslColor GetColor(int x, int y)
|
||||
{
|
||||
int num;
|
||||
int num2;
|
||||
int num3;
|
||||
HslColor color = HslColor.FromAhsl(0xff);
|
||||
switch (this.ColorMode)
|
||||
{
|
||||
case ColorModes.Red:
|
||||
num2 = MathExtensions.Round(255.0 * (1.0 - (((double)y) / ((double)(base.Height - 4)))));
|
||||
num3 = MathExtensions.Round((255.0 * x) / ((double)(base.Width - 4)));
|
||||
return HslColor.FromColor(Color.FromArgb(this.colorRGB.R, num2, num3));
|
||||
|
||||
case ColorModes.Green:
|
||||
num = MathExtensions.Round(255.0 * (1.0 - (((double)y) / ((double)(base.Height - 4)))));
|
||||
num3 = MathExtensions.Round((255.0 * x) / ((double)(base.Width - 4)));
|
||||
return HslColor.FromColor(Color.FromArgb(num, this.colorRGB.G, num3));
|
||||
|
||||
case ColorModes.Blue:
|
||||
num = MathExtensions.Round((255.0 * x) / ((double)(base.Width - 4)));
|
||||
num2 = MathExtensions.Round(255.0 * (1.0 - (((double)y) / ((double)(base.Height - 4)))));
|
||||
return HslColor.FromColor(Color.FromArgb(num, num2, this.colorRGB.B));
|
||||
|
||||
case ColorModes.Hue:
|
||||
color.H = this.colorHSL.H;
|
||||
color.S = ((double)x) / ((double)(base.Width - 4));
|
||||
color.L = 1.0 - (((double)y) / ((double)(base.Height - 4)));
|
||||
return color;
|
||||
|
||||
case ColorModes.Saturation:
|
||||
color.S = this.colorHSL.S;
|
||||
color.H = ((double)x) / ((double)(base.Width - 4));
|
||||
color.L = 1.0 - (((double)y) / ((double)(base.Height - 4)));
|
||||
return color;
|
||||
|
||||
case ColorModes.Luminance:
|
||||
color.L = this.colorHSL.L;
|
||||
color.H = ((double)x) / ((double)(base.Width - 4));
|
||||
color.S = 1.0 - (((double)y) / ((double)(base.Height - 4)));
|
||||
return color;
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
private void ResetMarker()
|
||||
{
|
||||
switch (this.colorMode)
|
||||
{
|
||||
case ColorModes.Red:
|
||||
this.markerPoint.X = MathExtensions.Round(((base.Width - 4) * this.colorRGB.B) / 255.0);
|
||||
this.markerPoint.Y = MathExtensions.Round((base.Height - 4) * (1.0 - (((double)this.colorRGB.G) / 255.0)));
|
||||
return;
|
||||
|
||||
case ColorModes.Green:
|
||||
this.markerPoint.X = MathExtensions.Round(((base.Width - 4) * this.colorRGB.B) / 255.0);
|
||||
this.markerPoint.Y = MathExtensions.Round((base.Height - 4) * (1.0 - (((double)this.colorRGB.R) / 255.0)));
|
||||
return;
|
||||
|
||||
case ColorModes.Blue:
|
||||
this.markerPoint.X = MathExtensions.Round(((base.Width - 4) * this.colorRGB.R) / 255.0);
|
||||
this.markerPoint.Y = MathExtensions.Round((base.Height - 4) * (1.0 - (((double)this.colorRGB.G) / 255.0)));
|
||||
return;
|
||||
|
||||
case ColorModes.Hue:
|
||||
this.markerPoint.X = MathExtensions.Round((base.Width - 4) * this.colorHSL.S);
|
||||
this.markerPoint.Y = MathExtensions.Round((base.Height - 4) * (1.0 - this.colorHSL.L));
|
||||
return;
|
||||
|
||||
case ColorModes.Saturation:
|
||||
this.markerPoint.X = MathExtensions.Round((base.Width - 4) * this.colorHSL.H);
|
||||
this.markerPoint.Y = MathExtensions.Round((base.Height - 4) * (1.0 - this.colorHSL.L));
|
||||
return;
|
||||
|
||||
case ColorModes.Luminance:
|
||||
this.markerPoint.X = MathExtensions.Round((base.Width - 4) * this.colorHSL.H);
|
||||
this.markerPoint.Y = MathExtensions.Round((base.Height - 4) * (1.0 - this.colorHSL.S));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void SetMarker(int x, int y)
|
||||
{
|
||||
x = MathExtensions.LimitToRange(x, 0, base.Width - 4);
|
||||
y = MathExtensions.LimitToRange(y, 0, base.Height - 4);
|
||||
if ((this.markerPoint.X != x) || (this.markerPoint.Y != y))
|
||||
{
|
||||
this.markerPoint = new Point(x, y);
|
||||
this.colorHSL = this.GetColor(x, y);
|
||||
this.colorRGB = this.colorHSL.RgbValue;
|
||||
this.Refresh();
|
||||
if (this.ColorChanged != null)
|
||||
{
|
||||
this.ColorChanged(this, new ColorChangedEventArgs(this.colorRGB));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
36
Vendor/MechanikaDesign/ColorBox2D/Controls/ColorHexagon.Designer.cs
generated
vendored
36
Vendor/MechanikaDesign/ColorBox2D/Controls/ColorHexagon.Designer.cs
generated
vendored
@@ -1,36 +0,0 @@
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
partial class ColorHexagon
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,402 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
[DefaultEvent("ColorChanged")]
|
||||
public partial class ColorHexagon: UserControl
|
||||
{
|
||||
# region Fields
|
||||
private const float COEFFCIENT = 0.824f;
|
||||
private ColorHexagonElement[] hexagonElements = new ColorHexagonElement[0x93];
|
||||
private float[] matrix1 = new float[] { -0.5f, -1f, -0.5f, 0.5f, 1f, 0.5f };
|
||||
private float[] matrix2 = new float[] { 0.824f, 0f, -0.824f, -0.824f, 0f, 0.824f };
|
||||
private int oldSelectedHexagonIndex = -1;
|
||||
private int sectorMaximum = 7;
|
||||
private int selectedHexagonIndex = -1;
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
public delegate void ColorChangedEventHandler(object sender, ColorChangedEventArgs args);
|
||||
public event ColorChangedEventHandler ColorChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
public Color SelectedColor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.selectedHexagonIndex < 0)
|
||||
{
|
||||
return Color.Empty;
|
||||
}
|
||||
return this.hexagonElements[this.selectedHexagonIndex].CurrentColor;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public ColorHexagon()
|
||||
{
|
||||
base.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
|
||||
base.SetStyle(ControlStyles.UserPaint, true);
|
||||
base.SetStyle(ControlStyles.Opaque, true);
|
||||
base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
|
||||
base.SetStyle(ControlStyles.ResizeRedraw, true);
|
||||
base.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
|
||||
for (int i = 0; i < this.hexagonElements.Length; i++)
|
||||
{
|
||||
this.hexagonElements[i] = new ColorHexagonElement();
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Methods/Functions
|
||||
private void DrawHexagonHighlighter(int selectedHexagonIndex)
|
||||
{
|
||||
if (selectedHexagonIndex != this.oldSelectedHexagonIndex)
|
||||
{
|
||||
if (this.oldSelectedHexagonIndex >= 0)
|
||||
{
|
||||
this.hexagonElements[this.oldSelectedHexagonIndex].IsHovered = false;
|
||||
base.Invalidate(this.hexagonElements[this.oldSelectedHexagonIndex].BoundingRectangle);
|
||||
}
|
||||
this.oldSelectedHexagonIndex = selectedHexagonIndex;
|
||||
if (this.oldSelectedHexagonIndex >= 0)
|
||||
{
|
||||
this.hexagonElements[this.oldSelectedHexagonIndex].IsHovered = true;
|
||||
base.Invalidate(this.hexagonElements[this.oldSelectedHexagonIndex].BoundingRectangle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int GetHexagonIndexFromCoordinates(int xCoordinate, int yCoordinate)
|
||||
{
|
||||
for (int i = 0; i < this.hexagonElements.Length; i++)
|
||||
{
|
||||
if (this.hexagonElements[i].BoundingRectangle.Contains(xCoordinate, yCoordinate))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
private int GetHexgaonWidth(int availableHeight)
|
||||
{
|
||||
int num = availableHeight / (2 * this.sectorMaximum);
|
||||
if ((((int) Math.Floor((double) (((double) num) / 2.0))) * 2) < num)
|
||||
{
|
||||
num--;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
private void InitializeGrayscaleHexagons(ref Rectangle clientRectangle, int hexagonWidth,
|
||||
ref int centerOfMiddleHexagonX, ref int centerOfMiddleHexagonY,
|
||||
ref int index)
|
||||
{
|
||||
int red = 0xff;
|
||||
int num4 = 0x11;
|
||||
int num3 = 0x10;
|
||||
int num5 = (((clientRectangle.Width - (7 * hexagonWidth)) / 2) + clientRectangle.X) - (hexagonWidth / 3);
|
||||
|
||||
centerOfMiddleHexagonX = num5;
|
||||
centerOfMiddleHexagonY = clientRectangle.Bottom;
|
||||
for (int i = 0; i < num3; i++)
|
||||
{
|
||||
this.hexagonElements[index].CurrentColor = Color.FromArgb(red, red, red);
|
||||
this.hexagonElements[index].SetHexagonPoints((float)centerOfMiddleHexagonX, (float)centerOfMiddleHexagonY, hexagonWidth);
|
||||
centerOfMiddleHexagonX += hexagonWidth;
|
||||
index++;
|
||||
if (i == 7)
|
||||
{
|
||||
centerOfMiddleHexagonX = num5 + (hexagonWidth / 2);
|
||||
centerOfMiddleHexagonY += (int)(hexagonWidth * 0.824f);
|
||||
}
|
||||
red -= num4;
|
||||
}
|
||||
}
|
||||
|
||||
private void InitializeHexagons()
|
||||
{
|
||||
Rectangle clientRectangle = base.ClientRectangle;
|
||||
clientRectangle.Offset(0, -8);
|
||||
if (clientRectangle.Height < clientRectangle.Width)
|
||||
{
|
||||
clientRectangle.Inflate(-(clientRectangle.Width - clientRectangle.Height) / 2, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
clientRectangle.Inflate(0, -(clientRectangle.Height - clientRectangle.Width) / 2);
|
||||
}
|
||||
|
||||
int hexagonWidth = this.GetHexgaonWidth(Math.Min(clientRectangle.Height, clientRectangle.Width));
|
||||
int centerOfMiddleHexagonX = (clientRectangle.Left + clientRectangle.Right) / 2;
|
||||
int centerOfMiddleHexagonY = (clientRectangle.Top + clientRectangle.Bottom) / 2;
|
||||
|
||||
centerOfMiddleHexagonY -= hexagonWidth;
|
||||
this.hexagonElements[0].CurrentColor = Color.White;
|
||||
this.hexagonElements[0].SetHexagonPoints((float)centerOfMiddleHexagonX, (float)centerOfMiddleHexagonY, hexagonWidth);
|
||||
int index = 1;
|
||||
for (int i = 1; i < this.sectorMaximum; i++)
|
||||
{
|
||||
float yCoordinate = centerOfMiddleHexagonY;
|
||||
float xCoordinate = centerOfMiddleHexagonX + (hexagonWidth * i);
|
||||
for (int j = 0; j < (this.sectorMaximum - 1); j++)
|
||||
{
|
||||
int num9 = (int)(hexagonWidth * this.matrix2[j]);
|
||||
int num10 = (int)(hexagonWidth * this.matrix1[j]);
|
||||
for (int k = 0; k < i; k++)
|
||||
{
|
||||
double num12 = ((0.936 * (this.sectorMaximum - i)) / ((double)this.sectorMaximum)) + 0.12;
|
||||
float colorQuotient = GetColorQuotient(xCoordinate - centerOfMiddleHexagonX, yCoordinate - centerOfMiddleHexagonY);
|
||||
this.hexagonElements[index].SetHexagonPoints(xCoordinate, yCoordinate, hexagonWidth);
|
||||
this.hexagonElements[index].CurrentColor = ColorFromRGBRatios((double)colorQuotient, num12, 1.0);
|
||||
yCoordinate += num9;
|
||||
xCoordinate += num10;
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
clientRectangle.Y -= hexagonWidth + (hexagonWidth / 2);
|
||||
this.InitializeGrayscaleHexagons(ref clientRectangle, hexagonWidth, ref centerOfMiddleHexagonX, ref centerOfMiddleHexagonY, ref index);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (this.selectedHexagonIndex >= 0)
|
||||
{
|
||||
this.hexagonElements[this.selectedHexagonIndex].IsSelected = false;
|
||||
base.Invalidate(this.hexagonElements[this.selectedHexagonIndex].BoundingRectangle);
|
||||
}
|
||||
this.selectedHexagonIndex = -1;
|
||||
if (this.oldSelectedHexagonIndex >= 0)
|
||||
{
|
||||
this.selectedHexagonIndex = this.oldSelectedHexagonIndex;
|
||||
this.hexagonElements[this.selectedHexagonIndex].IsSelected = true;
|
||||
if (this.ColorChanged != null)
|
||||
{
|
||||
this.ColorChanged(this, new ColorChangedEventArgs(this.SelectedColor));
|
||||
}
|
||||
base.Invalidate(this.hexagonElements[this.selectedHexagonIndex].BoundingRectangle);
|
||||
}
|
||||
}
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
||||
protected override void OnMouseLeave(EventArgs e)
|
||||
{
|
||||
base.OnMouseLeave(e);
|
||||
this.DrawHexagonHighlighter(-1);
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
this.DrawHexagonHighlighter(this.GetHexagonIndexFromCoordinates(e.X, e.Y));
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
if (this.BackColor == Color.Transparent)
|
||||
{
|
||||
base.OnPaintBackground(e);
|
||||
}
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
using (SolidBrush brush = new SolidBrush(this.BackColor))
|
||||
{
|
||||
g.FillRectangle(brush, base.ClientRectangle);
|
||||
}
|
||||
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
foreach (ColorHexagonElement element in this.hexagonElements)
|
||||
{
|
||||
element.Paint(g);
|
||||
}
|
||||
|
||||
if (this.oldSelectedHexagonIndex >= 0)
|
||||
{
|
||||
this.hexagonElements[this.oldSelectedHexagonIndex].Paint(g);
|
||||
}
|
||||
if (this.selectedHexagonIndex >= 0)
|
||||
{
|
||||
this.hexagonElements[this.selectedHexagonIndex].Paint(g);
|
||||
}
|
||||
base.OnPaint(e);
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
this.InitializeHexagons();
|
||||
base.OnResize(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Color Helper Functions
|
||||
private static float GetColorQuotient(float value1, float value2)
|
||||
{
|
||||
return (float)((Math.Atan2((double)value2, (double)value1) * 180.0) / 3.1415926535897931);
|
||||
}
|
||||
|
||||
private static int GetColorChannelValue(float value1, float value2, float value3)
|
||||
{
|
||||
if (value3 > 360f)
|
||||
{
|
||||
value3 -= 360f;
|
||||
}
|
||||
else if (value3 < 0f)
|
||||
{
|
||||
value3 += 360f;
|
||||
}
|
||||
if (value3 < 60f)
|
||||
{
|
||||
value1 += ((value2 - value1) * value3) / 60f;
|
||||
}
|
||||
else if (value3 < 180f)
|
||||
{
|
||||
value1 = value2;
|
||||
}
|
||||
else if (value3 < 240f)
|
||||
{
|
||||
value1 += ((value2 - value1) * (240f - value3)) / 60f;
|
||||
}
|
||||
return (int)(value1 * 255f);
|
||||
}
|
||||
|
||||
private static Color ColorFromRGBRatios(double value1, double value2, double value3)
|
||||
{
|
||||
int num;
|
||||
int num2;
|
||||
int num3;
|
||||
if (value3 == 0.0)
|
||||
{
|
||||
num = num2 = num3 = (int)(value2 * 255.0);
|
||||
}
|
||||
else
|
||||
{
|
||||
float num4;
|
||||
if (value2 <= 0.5)
|
||||
{
|
||||
num4 = (float)(value2 + (value2 * value3));
|
||||
}
|
||||
else
|
||||
{
|
||||
num4 = (float)((value2 + value3) - (value2 * value3));
|
||||
}
|
||||
float num5 = ((float)(2.0 * value2)) - num4;
|
||||
num = GetColorChannelValue(num5, num4, (float)(value1 + 120.0));
|
||||
num2 = GetColorChannelValue(num5, num4, (float)value1);
|
||||
num3 = GetColorChannelValue(num5, num4, (float)(value1 - 120.0));
|
||||
}
|
||||
return Color.FromArgb(num, num2, num3);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
#region HexagaonElement Class
|
||||
internal class ColorHexagonElement
|
||||
{
|
||||
#region Fields
|
||||
|
||||
private Rectangle boundingRect = Rectangle.Empty;
|
||||
private Color hexagonColor = Color.Empty;
|
||||
private Point[] hexagonPoints = new Point[6];
|
||||
private bool isHovered;
|
||||
private bool isSelected;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
public void Paint(Graphics g)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddPolygon(this.hexagonPoints);
|
||||
path.CloseAllFigures();
|
||||
using (SolidBrush brush = new SolidBrush(this.hexagonColor))
|
||||
{
|
||||
g.FillPath(brush, path);
|
||||
}
|
||||
if (this.isHovered || this.isSelected)
|
||||
{
|
||||
SmoothingMode smoothingMode = g.SmoothingMode;
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
using (Pen pen = new Pen(Color.FromArgb(0x2a, 0x5b, 150), 2f))
|
||||
{
|
||||
g.DrawPath(pen, path);
|
||||
}
|
||||
using (Pen pen2 = new Pen(Color.FromArgb(150, 0xb1, 0xef), 1f))
|
||||
{
|
||||
g.DrawPath(pen2, path);
|
||||
}
|
||||
g.SmoothingMode = smoothingMode;
|
||||
}
|
||||
path.Dispose();
|
||||
}
|
||||
|
||||
public void SetHexagonPoints(float xCoordinate, float yCoordinate, int hexagonWidth)
|
||||
{
|
||||
float num = hexagonWidth * 0.5773503f;
|
||||
this.hexagonPoints[0] = new Point((int)Math.Floor((double)(xCoordinate - (hexagonWidth / 2))), ((int)Math.Floor((double)(yCoordinate - (num / 2f)))) - 1);
|
||||
this.hexagonPoints[1] = new Point((int)Math.Floor((double)xCoordinate), ((int)Math.Floor((double)(yCoordinate - (hexagonWidth / 2)))) - 1);
|
||||
this.hexagonPoints[2] = new Point((int)Math.Floor((double)(xCoordinate + (hexagonWidth / 2))), ((int)Math.Floor((double)(yCoordinate - (num / 2f)))) - 1);
|
||||
this.hexagonPoints[3] = new Point((int)Math.Floor((double)(xCoordinate + (hexagonWidth / 2))), ((int)Math.Floor((double)(yCoordinate + (num / 2f)))) + 1);
|
||||
this.hexagonPoints[4] = new Point((int)Math.Floor((double)xCoordinate), ((int)Math.Floor((double)(yCoordinate + (hexagonWidth / 2)))) + 1);
|
||||
this.hexagonPoints[5] = new Point((int)Math.Floor((double)(xCoordinate - (hexagonWidth / 2))), ((int)Math.Floor((double)(yCoordinate + (num / 2f)))) + 1);
|
||||
using (GraphicsPath path = new GraphicsPath())
|
||||
{
|
||||
path.AddPolygon(this.hexagonPoints);
|
||||
this.boundingRect = Rectangle.Round(path.GetBounds());
|
||||
this.boundingRect.Inflate(2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public Rectangle BoundingRectangle
|
||||
{
|
||||
get { return this.boundingRect; }
|
||||
}
|
||||
|
||||
public Color CurrentColor
|
||||
{
|
||||
get { return this.hexagonColor; }
|
||||
set { this.hexagonColor = value; }
|
||||
}
|
||||
|
||||
public bool IsHovered
|
||||
{
|
||||
get { return this.isHovered; }
|
||||
set { this.isHovered = value; }
|
||||
}
|
||||
|
||||
public bool IsSelected
|
||||
{
|
||||
get { return this.isSelected; }
|
||||
set { this.isSelected = value; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
45
Vendor/MechanikaDesign/ColorBox2D/Controls/ColorSliderVertical.Designer.cs
generated
vendored
45
Vendor/MechanikaDesign/ColorBox2D/Controls/ColorSliderVertical.Designer.cs
generated
vendored
@@ -1,45 +0,0 @@
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
partial class ColorSliderVertical
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ColorSlider
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Name = "ColorSlider";
|
||||
this.Size = new System.Drawing.Size(25, 150);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,325 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
[DefaultEvent("ColorChanged")]
|
||||
public partial class ColorSliderVertical : UserControl
|
||||
{
|
||||
#region Events
|
||||
|
||||
public delegate void ColorChangedEventHandler(object sender, ColorChangedEventArgs args);
|
||||
public event ColorChangedEventHandler ColorChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private HslColor colorHSL = HslColor.FromAhsl(0xff);
|
||||
private ColorModes colorMode;
|
||||
private Color colorRGB = Color.Empty;
|
||||
private bool mouseMoving;
|
||||
private int position;
|
||||
private bool setHueSilently;
|
||||
private Color nubColor;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public Color ColorRGB
|
||||
{
|
||||
get { return this.colorRGB; }
|
||||
set
|
||||
{
|
||||
this.colorRGB = value;
|
||||
if (!this.setHueSilently)
|
||||
{
|
||||
this.colorHSL = HslColor.FromColor(this.ColorRGB);
|
||||
}
|
||||
this.ResetSlider();
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public HslColor ColorHSL
|
||||
{
|
||||
get { return this.colorHSL; }
|
||||
set
|
||||
{
|
||||
this.colorHSL = value;
|
||||
this.colorRGB = this.colorHSL.RgbValue;
|
||||
this.ResetSlider();
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
public ColorModes ColorMode
|
||||
{
|
||||
get { return this.colorMode; }
|
||||
set
|
||||
{
|
||||
this.colorMode = value;
|
||||
this.ResetSlider();
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the selection nub.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The color of the nub.
|
||||
/// </value>
|
||||
[Category("Appearance")]
|
||||
[DefaultValue(typeof(Color), "Black")]
|
||||
public Color NubColor
|
||||
{
|
||||
get { return this.nubColor; }
|
||||
set { this.nubColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position of the selection nub.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The position.
|
||||
/// </value>
|
||||
public int Position
|
||||
{
|
||||
get { return this.position; }
|
||||
set
|
||||
{
|
||||
int num = value;
|
||||
num = MathExtensions.LimitToRange(num, 0, base.Height - 9);
|
||||
if (num != this.position)
|
||||
{
|
||||
this.position = num;
|
||||
this.ResetHSLRGB();
|
||||
this.Refresh();
|
||||
if (this.ColorChanged != null)
|
||||
{
|
||||
this.ColorChanged(this, new ColorChangedEventArgs(this.colorRGB));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
public ColorSliderVertical()
|
||||
{
|
||||
InitializeComponent();
|
||||
base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
|
||||
|
||||
this.colorHSL = HslColor.FromAhsl(1.0, 1.0, 1.0);
|
||||
this.colorRGB = this.colorHSL.RgbValue;
|
||||
this.colorMode = ColorModes.Hue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
|
||||
protected override void OnMouseDown(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseDown(e);
|
||||
this.mouseMoving = true;
|
||||
this.Position = e.Y - 4;
|
||||
}
|
||||
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
this.mouseMoving = false;
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
if (this.mouseMoving)
|
||||
{
|
||||
this.Position = e.Y - 4;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
HslColor color = HslColor.FromAhsl(0xff);
|
||||
switch (this.ColorMode)
|
||||
{
|
||||
case ColorModes.Hue:
|
||||
color.L = color.S = 1.0;
|
||||
break;
|
||||
|
||||
case ColorModes.Saturation:
|
||||
color.H = this.ColorHSL.H;
|
||||
color.L = this.ColorHSL.L;
|
||||
break;
|
||||
|
||||
case ColorModes.Luminance:
|
||||
color.H = this.ColorHSL.H;
|
||||
color.S = this.ColorHSL.S;
|
||||
break;
|
||||
}
|
||||
for (int i = 0; i < (base.Height - 8); i++)
|
||||
{
|
||||
double num2 = 0.0;
|
||||
if (this.ColorMode < ColorModes.Hue)
|
||||
{
|
||||
num2 = 255.0 - MathExtensions.Round((255.0 * i) / (base.Height - 8.0));
|
||||
}
|
||||
else
|
||||
{
|
||||
num2 = 1.0 - (((double)i) / ((double)(base.Height - 8)));
|
||||
}
|
||||
Color empty = Color.Empty;
|
||||
switch (this.ColorMode)
|
||||
{
|
||||
case ColorModes.Red:
|
||||
empty = Color.FromArgb((int)num2, this.ColorRGB.G, this.ColorRGB.B);
|
||||
break;
|
||||
|
||||
case ColorModes.Green:
|
||||
empty = Color.FromArgb(this.ColorRGB.R, (int)num2, this.ColorRGB.B);
|
||||
break;
|
||||
|
||||
case ColorModes.Blue:
|
||||
empty = Color.FromArgb(this.ColorRGB.R, this.ColorRGB.G, (int)num2);
|
||||
break;
|
||||
|
||||
case ColorModes.Hue:
|
||||
color.H = num2;
|
||||
empty = color.RgbValue;
|
||||
break;
|
||||
|
||||
case ColorModes.Saturation:
|
||||
color.S = num2;
|
||||
empty = color.RgbValue;
|
||||
break;
|
||||
|
||||
case ColorModes.Luminance:
|
||||
color.L = num2;
|
||||
empty = color.RgbValue;
|
||||
break;
|
||||
}
|
||||
|
||||
using (Pen pen = new Pen(empty))
|
||||
{
|
||||
e.Graphics.DrawLine(pen, 11, i + 4, base.Width - 11, i + 4);
|
||||
}
|
||||
}
|
||||
this.DrawSlider(e.Graphics);
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void DrawSlider(Graphics g)
|
||||
{
|
||||
using (Pen pen = new Pen(Color.FromArgb(0x74, 0x72, 0x6a)))
|
||||
{
|
||||
SolidBrush fill = new SolidBrush(this.nubColor);
|
||||
Point[] points = new Point[] { new Point(1, this.position), new Point(3, this.position), new Point(7, this.position + 4), new Point(3, this.position + 8), new Point(1, this.position + 8), new Point(0, this.position + 7), new Point(0, this.position + 1) };
|
||||
g.FillPolygon(fill, points);
|
||||
g.DrawPolygon(pen, points);
|
||||
|
||||
points[0] = new Point(base.Width - 2, this.position);
|
||||
points[1] = new Point(base.Width - 4, this.position);
|
||||
points[2] = new Point(base.Width - 8, this.position + 4);
|
||||
points[3] = new Point(base.Width - 4, this.position + 8);
|
||||
points[4] = new Point(base.Width - 2, this.position + 8);
|
||||
points[5] = new Point(base.Width - 1, this.position + 7);
|
||||
points[6] = new Point(base.Width - 1, this.position + 1);
|
||||
|
||||
g.FillPolygon(fill, points);
|
||||
g.DrawPolygon(pen, points);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetSlider()
|
||||
{
|
||||
double h = 0.0;
|
||||
switch (this.ColorMode)
|
||||
{
|
||||
case ColorModes.Red:
|
||||
h = ((double)this.colorRGB.R) / 255.0;
|
||||
break;
|
||||
|
||||
case ColorModes.Green:
|
||||
h = ((double)this.colorRGB.G) / 255.0;
|
||||
break;
|
||||
|
||||
case ColorModes.Blue:
|
||||
h = ((double)this.colorRGB.B) / 255.0;
|
||||
break;
|
||||
|
||||
case ColorModes.Hue:
|
||||
h = this.colorHSL.H;
|
||||
break;
|
||||
|
||||
case ColorModes.Saturation:
|
||||
h = this.colorHSL.S;
|
||||
break;
|
||||
|
||||
case ColorModes.Luminance:
|
||||
h = this.colorHSL.L;
|
||||
break;
|
||||
}
|
||||
this.position = (base.Height - 8) - MathExtensions.Round((base.Height - 8) * h);
|
||||
}
|
||||
|
||||
private void ResetHSLRGB()
|
||||
{
|
||||
this.setHueSilently = true;
|
||||
switch (this.ColorMode)
|
||||
{
|
||||
case ColorModes.Red:
|
||||
this.ColorRGB = Color.FromArgb(0xff - MathExtensions.Round((255.0 * this.position) / ((double)(base.Height - 9))), this.ColorRGB.G, this.ColorRGB.B);
|
||||
this.ColorHSL = HslColor.FromColor(this.ColorRGB);
|
||||
break;
|
||||
|
||||
case ColorModes.Green:
|
||||
this.ColorRGB = Color.FromArgb(this.ColorRGB.R, 0xff - MathExtensions.Round((255.0 * this.position) / ((double)(base.Height - 9))), this.ColorRGB.B);
|
||||
this.ColorHSL = HslColor.FromColor(this.ColorRGB);
|
||||
break;
|
||||
|
||||
case ColorModes.Blue:
|
||||
this.ColorRGB = Color.FromArgb(this.ColorRGB.R, this.ColorRGB.G, 0xff - MathExtensions.Round((255.0 * this.position) / ((double)(base.Height - 9))));
|
||||
this.ColorHSL = HslColor.FromColor(this.ColorRGB);
|
||||
break;
|
||||
|
||||
case ColorModes.Hue:
|
||||
this.colorHSL.H = 1.0 - (((double)this.position) / ((double)(base.Height - 9)));
|
||||
this.ColorRGB = this.ColorHSL.RgbValue;
|
||||
break;
|
||||
|
||||
case ColorModes.Saturation:
|
||||
this.colorHSL.S = 1.0 - (((double)this.position) / ((double)(base.Height - 9)));
|
||||
this.ColorRGB = this.ColorHSL.RgbValue;
|
||||
break;
|
||||
|
||||
case ColorModes.Luminance:
|
||||
this.colorHSL.L = 1.0 - (((double)this.position) / ((double)(base.Height - 9)));
|
||||
this.ColorRGB = this.ColorHSL.RgbValue;
|
||||
break;
|
||||
}
|
||||
this.setHueSilently = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,884 +0,0 @@
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ColorWheel"/> class.
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the Color property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler ColorChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the ColorStep property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler ColorStepChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the HslColor property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler HslColorChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the LargeChange property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler LargeChangeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the SelectionSize property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler SelectionSizeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the SmallChange property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler SmallChangeChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
/// <summary>
|
||||
/// Releases the unmanaged resources used by the <see cref="T:System.Windows.Forms.Control" /> and its child controls and optionally releases the managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_brush != null)
|
||||
{
|
||||
_brush.Dispose();
|
||||
}
|
||||
|
||||
if (this.SelectionGlyph != null)
|
||||
{
|
||||
this.SelectionGlyph.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified key is a regular input key or a special key that requires preprocessing.
|
||||
/// </summary>
|
||||
/// <param name="keyData">One of the <see cref="T:System.Windows.Forms.Keys" /> values.</param>
|
||||
/// <returns>true if the specified key is a regular input key; otherwise, false.</returns>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.GotFocus" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.KeyDown" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.KeyEventArgs" /> that contains the event data.</param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.LostFocus" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseDown" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseMove" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.</param>
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (e.Button == MouseButtons.Left && _dragStartedWithinWheel)
|
||||
{
|
||||
this.SetColor(e.Location);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data. </param>
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
_dragStartedWithinWheel = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.PaddingChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.EventArgs" /> that contains the event data.</param>
|
||||
protected override void OnPaddingChanged(EventArgs e)
|
||||
{
|
||||
base.OnPaddingChanged(e);
|
||||
|
||||
this.RefreshWheel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.Resize" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
this.RefreshWheel();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the component color.
|
||||
/// </summary>
|
||||
/// <value>The component color.</value>
|
||||
[Category("Appearance")]
|
||||
[DefaultValue(typeof(Color), "Black")]
|
||||
public virtual Color Color
|
||||
{
|
||||
get { return _color; }
|
||||
set
|
||||
{
|
||||
if (this.Color != value)
|
||||
{
|
||||
_color = value;
|
||||
|
||||
this.OnColorChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the increment for rendering the color wheel.
|
||||
/// </summary>
|
||||
/// <value>The color step.</value>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">Value must be between 1 and 359</exception>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the component color.
|
||||
/// </summary>
|
||||
/// <value>The component color.</value>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value to be added to or subtracted from the <see cref="Color"/> property when the wheel selection is moved a large distance.
|
||||
/// </summary>
|
||||
/// <value>A numeric value. The default value is 5.</value>
|
||||
[Category("Behavior")]
|
||||
[DefaultValue(5)]
|
||||
public virtual int LargeChange
|
||||
{
|
||||
get { return _largeChange; }
|
||||
set
|
||||
{
|
||||
if (this.LargeChange != value)
|
||||
{
|
||||
_largeChange = value;
|
||||
|
||||
this.OnLargeChangeChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the selection handle.
|
||||
/// </summary>
|
||||
/// <value>The size of the selection handle.</value>
|
||||
[Category("Appearance")]
|
||||
[DefaultValue(10)]
|
||||
public virtual int SelectionSize
|
||||
{
|
||||
get { return _selectionSize; }
|
||||
set
|
||||
{
|
||||
if (this.SelectionSize != value)
|
||||
{
|
||||
_selectionSize = value;
|
||||
|
||||
this.OnSelectionSizeChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value to be added to or subtracted from the <see cref="Color"/> property when the wheel selection is moved a small distance.
|
||||
/// </summary>
|
||||
/// <value>A numeric value. The default value is 1.</value>
|
||||
[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
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether painting of the control is allowed.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if painting of the control is allowed; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Disables any redrawing of the image box
|
||||
/// </summary>
|
||||
public virtual void BeginUpdate()
|
||||
{
|
||||
_updateCount++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the redrawing of the image box
|
||||
/// </summary>
|
||||
public virtual void EndUpdate()
|
||||
{
|
||||
if (_updateCount > 0)
|
||||
{
|
||||
_updateCount--;
|
||||
}
|
||||
|
||||
if (this.AllowPainting)
|
||||
{
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Members
|
||||
|
||||
/// <summary>
|
||||
/// Calculates wheel attributes.
|
||||
/// </summary>
|
||||
protected virtual void CalculateWheel()
|
||||
{
|
||||
List<PointF> points;
|
||||
List<Color> colors;
|
||||
|
||||
points = new List<PointF>();
|
||||
colors = new List<Color>();
|
||||
|
||||
// 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, 0.5).ToRgbColor());
|
||||
}
|
||||
}
|
||||
|
||||
this.Points = points.ToArray();
|
||||
this.Colors = colors.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the gradient brush used to paint the wheel.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the selection glyph.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point within the wheel representing the source color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color.</param>
|
||||
protected PointF GetColorLocation(Color color)
|
||||
{
|
||||
return this.GetColorLocation(new HslColor(color));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point within the wheel representing the source color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color.</param>
|
||||
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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified point is within the bounds of the color wheel.
|
||||
/// </summary>
|
||||
/// <param name="point">The point.</param>
|
||||
/// <returns><c>true</c> if the specified point is within the bounds of the color wheel; otherwise, <c>false</c>.</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="ColorChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="ColorStepChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected virtual void OnColorStepChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler;
|
||||
|
||||
this.RefreshWheel();
|
||||
|
||||
handler = this.ColorStepChanged;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="HslColorChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="LargeChangeChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected virtual void OnLargeChangeChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler;
|
||||
|
||||
handler = this.LargeChangeChanged;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="SelectionSizeChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="SmallChangeChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the wheel attributes and then repaints the control
|
||||
/// </summary>
|
||||
private void RefreshWheel()
|
||||
{
|
||||
if (_brush != null)
|
||||
{
|
||||
_brush.Dispose();
|
||||
}
|
||||
|
||||
this.CalculateWheel();
|
||||
_brush = this.CreateGradientBrush();
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
353
Vendor/MechanikaDesign/ColorBox2D/HslColor.cs
vendored
353
Vendor/MechanikaDesign/ColorBox2D/HslColor.cs
vendored
@@ -1,353 +0,0 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct HslColor
|
||||
{
|
||||
public static readonly HslColor Empty;
|
||||
private double hue;
|
||||
private double saturation;
|
||||
private double luminance;
|
||||
private int alpha;
|
||||
|
||||
public HslColor(int a, double h, double s, double l)
|
||||
{
|
||||
this.alpha = a;
|
||||
this.hue = h;
|
||||
this.saturation = s;
|
||||
this.luminance = l;
|
||||
this.A = a;
|
||||
this.H = this.hue;
|
||||
this.S = this.saturation;
|
||||
this.L = this.luminance;
|
||||
}
|
||||
|
||||
public HslColor(double h, double s, double l)
|
||||
{
|
||||
this.alpha = 0xff;
|
||||
this.hue = h;
|
||||
this.saturation = s;
|
||||
this.luminance = l;
|
||||
}
|
||||
|
||||
public HslColor(Color color)
|
||||
{
|
||||
this.alpha = color.A;
|
||||
this.hue = 0.0;
|
||||
this.saturation = 0.0;
|
||||
this.luminance = 0.0;
|
||||
this.RGBtoHSL(color);
|
||||
}
|
||||
|
||||
public static HslColor FromArgb(int a, int r, int g, int b)
|
||||
{
|
||||
return new HslColor(Color.FromArgb(a, r, g, b));
|
||||
}
|
||||
|
||||
public static HslColor FromColor(Color color)
|
||||
{
|
||||
return new HslColor(color);
|
||||
}
|
||||
|
||||
public static HslColor FromAhsl(int a)
|
||||
{
|
||||
return new HslColor(a, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
public static HslColor FromAhsl(int a, HslColor hsl)
|
||||
{
|
||||
return new HslColor(a, hsl.hue, hsl.saturation, hsl.luminance);
|
||||
}
|
||||
|
||||
public static HslColor FromAhsl(double h, double s, double l)
|
||||
{
|
||||
return new HslColor(0xff, h, s, l);
|
||||
}
|
||||
|
||||
public static HslColor FromAhsl(int a, double h, double s, double l)
|
||||
{
|
||||
return new HslColor(a, h, s, l);
|
||||
}
|
||||
|
||||
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 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());
|
||||
}
|
||||
|
||||
[DefaultValue((double)0.0), Category("Appearance"), Description("H Channel value")]
|
||||
public double H
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.hue;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.hue = value;
|
||||
this.hue = (this.hue > 1.0) ? 1.0 : ((this.hue < 0.0) ? 0.0 : this.hue);
|
||||
}
|
||||
}
|
||||
[Category("Appearance"), Description("S Channel value"), DefaultValue((double)0.0)]
|
||||
public double S
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.saturation;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.saturation = value;
|
||||
this.saturation = (this.saturation > 1.0) ? 1.0 : ((this.saturation < 0.0) ? 0.0 : this.saturation);
|
||||
}
|
||||
}
|
||||
[Category("Appearance"), Description("L Channel value"), DefaultValue((double)0.0)]
|
||||
public double L
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.luminance;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.luminance = value;
|
||||
this.luminance = (this.luminance > 1.0) ? 1.0 : ((this.luminance < 0.0) ? 0.0 : this.luminance);
|
||||
}
|
||||
}
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
|
||||
public Color RgbValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.HSLtoRGB();
|
||||
}
|
||||
set
|
||||
{
|
||||
this.RGBtoHSL(value);
|
||||
}
|
||||
}
|
||||
public int A
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.alpha;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.alpha = (value > 0xff) ? 0xff : ((value < 0) ? 0 : value);
|
||||
}
|
||||
}
|
||||
public bool IsEmpty
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((((this.alpha == 0) && (this.H == 0.0)) && (this.S == 0.0)) && (this.L == 0.0));
|
||||
}
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
|
||||
private Color HSLtoRGB()
|
||||
{
|
||||
int num2;
|
||||
int red = this.Round(this.luminance * 255.0);
|
||||
int blue = this.Round(((1.0 - this.saturation) * (this.luminance / 1.0)) * 255.0);
|
||||
double num4 = ((double)(red - blue)) / 255.0;
|
||||
if ((this.hue >= 0.0) && (this.hue <= 0.16666666666666666))
|
||||
{
|
||||
num2 = this.Round((((this.hue - 0.0) * num4) * 1530.0) + blue);
|
||||
return Color.FromArgb(this.alpha, red, num2, blue);
|
||||
}
|
||||
if (this.hue <= 0.33333333333333331)
|
||||
{
|
||||
num2 = this.Round((-((this.hue - 0.16666666666666666) * num4) * 1530.0) + red);
|
||||
return Color.FromArgb(this.alpha, num2, red, blue);
|
||||
}
|
||||
if (this.hue <= 0.5)
|
||||
{
|
||||
num2 = this.Round((((this.hue - 0.33333333333333331) * num4) * 1530.0) + blue);
|
||||
return Color.FromArgb(this.alpha, blue, red, num2);
|
||||
}
|
||||
if (this.hue <= 0.66666666666666663)
|
||||
{
|
||||
num2 = this.Round((-((this.hue - 0.5) * num4) * 1530.0) + red);
|
||||
return Color.FromArgb(this.alpha, blue, num2, red);
|
||||
}
|
||||
if (this.hue <= 0.83333333333333337)
|
||||
{
|
||||
num2 = this.Round((((this.hue - 0.66666666666666663) * num4) * 1530.0) + blue);
|
||||
return Color.FromArgb(this.alpha, num2, blue, red);
|
||||
}
|
||||
if (this.hue <= 1.0)
|
||||
{
|
||||
num2 = this.Round((-((this.hue - 0.83333333333333337) * num4) * 1530.0) + red);
|
||||
return Color.FromArgb(this.alpha, red, blue, num2);
|
||||
}
|
||||
return Color.FromArgb(this.alpha, 0, 0, 0);
|
||||
}
|
||||
|
||||
private void RGBtoHSL(Color color)
|
||||
{
|
||||
int r;
|
||||
int g;
|
||||
double num4;
|
||||
this.alpha = color.A;
|
||||
if (color.R > color.G)
|
||||
{
|
||||
r = color.R;
|
||||
g = color.G;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = color.G;
|
||||
g = color.R;
|
||||
}
|
||||
if (color.B > r)
|
||||
{
|
||||
r = color.B;
|
||||
}
|
||||
else if (color.B < g)
|
||||
{
|
||||
g = color.B;
|
||||
}
|
||||
int num3 = r - g;
|
||||
this.luminance = ((double)r) / 255.0;
|
||||
if (r == 0)
|
||||
{
|
||||
this.saturation = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.saturation = ((double)num3) / ((double)r);
|
||||
}
|
||||
if (num3 == 0)
|
||||
{
|
||||
num4 = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
num4 = 60.0 / ((double)num3);
|
||||
}
|
||||
if (r == color.R)
|
||||
{
|
||||
if (color.G < color.B)
|
||||
{
|
||||
this.hue = (360.0 + (num4 * (color.G - color.B))) / 360.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hue = (num4 * (color.G - color.B)) / 360.0;
|
||||
}
|
||||
}
|
||||
else if (r == color.G)
|
||||
{
|
||||
this.hue = (120.0 + (num4 * (color.B - color.R))) / 360.0;
|
||||
}
|
||||
else if (r == color.B)
|
||||
{
|
||||
this.hue = (240.0 + (num4 * (color.R - color.G))) / 360.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.hue = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
private int Round(double val)
|
||||
{
|
||||
return (int)(val + 0.5);
|
||||
}
|
||||
|
||||
static HslColor()
|
||||
{
|
||||
Empty = new HslColor();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace MechanikaDesign.WinForms.UI.ColorPicker
|
||||
{
|
||||
internal static class MathExtensions
|
||||
{
|
||||
public static int Round(double val)
|
||||
{
|
||||
int num = (int)val;
|
||||
int num2 = (int)(val * 100.0);
|
||||
if ((num2 % 100) >= 50)
|
||||
{
|
||||
num++;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
public static int LimitToRange(int value, int inclusiveMinimum, int inclusiveMaximum)
|
||||
{
|
||||
if (value < inclusiveMinimum) { return inclusiveMinimum; }
|
||||
if (value > inclusiveMaximum) { return inclusiveMaximum; }
|
||||
return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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")]
|
||||
@@ -1,63 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{ADC128AF-95A4-4BA9-B5D7-FE438E1E7A5C}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ColorHexagon</RootNamespace>
|
||||
<AssemblyName>ColorHexagon</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ColorHexagon.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ColorHexagon.Designer.cs">
|
||||
<DependentUpon>ColorHexagon.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="HslColor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -1,36 +0,0 @@
|
||||
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")]
|
||||
@@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
|
||||
</startup>
|
||||
</configuration>
|
||||
@@ -1,99 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{DF274AA1-5380-4B84-B9F5-FF66E6A1D37B}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ColorPicker.Demo</RootNamespace>
|
||||
<AssemblyName>ColorPicker.Demo</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<TargetFrameworkProfile />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Management" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Telerik.WinControls, Version=2015.1.331.40, Culture=neutral, PublicKeyToken=5bb2a467cbec794e, processorArchitecture=MSIL" />
|
||||
<Reference Include="TelerikCommon, Version=2015.1.331.40, Culture=neutral, PublicKeyToken=5bb2a467cbec794e" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="FormColorPickerDemo.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FormColorPickerDemo.Designer.cs">
|
||||
<DependentUpon>FormColorPickerDemo.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="FormColorPickerDemo.resx">
|
||||
<DependentUpon>FormColorPickerDemo.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
<DesignTime>True</DesignTime>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ColorBox2D\ColorPicker.csproj">
|
||||
<Project>{38F99682-D013-4AE3-8334-4BF492A11FF9}</Project>
|
||||
<Name>ColorPicker</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
412
Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.Designer.cs
generated
vendored
412
Vendor/MechanikaDesign/ColorPicker.Demo/FormColorPickerDemo.Designer.cs
generated
vendored
@@ -1,412 +0,0 @@
|
||||
namespace ColorHexagon.Demo
|
||||
{
|
||||
partial class FormColorPickerDemo
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,22 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ColorHexagon.Demo
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new FormColorPickerDemo());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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")]
|
||||
63
Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.Designer.cs
generated
vendored
63
Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Resources.Designer.cs
generated
vendored
@@ -1,63 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ColorPicker.Demo.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// A strongly-typed resource class, for looking up localized strings, etc.
|
||||
/// </summary>
|
||||
// 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() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the cached ResourceManager instance used by this class.
|
||||
/// </summary>
|
||||
[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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Overrides the current thread's CurrentUICulture property for all
|
||||
/// resource lookups using this strongly typed resource class.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
26
Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.Designer.cs
generated
vendored
26
Vendor/MechanikaDesign/ColorPicker.Demo/Properties/Settings.Designer.cs
generated
vendored
@@ -1,26 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
28
Vendor/MechanikaDesign/ColorPickerControls.sln
vendored
28
Vendor/MechanikaDesign/ColorPickerControls.sln
vendored
@@ -1,28 +0,0 @@
|
||||
|
||||
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
|
||||
122
Vendor/MechanikaDesign/ColorWheel/ColorHelper.cs
vendored
122
Vendor/MechanikaDesign/ColorWheel/ColorHelper.cs
vendored
@@ -1,122 +0,0 @@
|
||||
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)
|
||||
/// <summary>
|
||||
/// Generates the Hue, Saturation, and Value for a given color
|
||||
/// </summary>
|
||||
/// <param name="color">The Color to generate the values for</param>
|
||||
/// <param name="hue">Out value for Hue</param>
|
||||
/// <param name="saturation">Out value for Saturation</param>
|
||||
/// <param name="value">Out value for Value</param>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Generates a Color from a Hue, Saturation, and Value combination
|
||||
/// </summary>
|
||||
/// <param name="hue">Hue to use for the Color. (Max 360)</param>
|
||||
/// <param name="saturation">Saturation to use for the Color. (Max 1.0)</param>
|
||||
/// <param name="value">Value to use for the Color. (Max 1.0)</param>
|
||||
/// <returns>Generated Color</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
884
Vendor/MechanikaDesign/ColorWheel/ColorWheel.cs
vendored
884
Vendor/MechanikaDesign/ColorWheel/ColorWheel.cs
vendored
@@ -1,884 +0,0 @@
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ColorWheel"/> class.
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the Color property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler ColorChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the ColorStep property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler ColorStepChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the HslColor property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler HslColorChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the LargeChange property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler LargeChangeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the SelectionSize property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler SelectionSizeChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the SmallChange property value changes
|
||||
/// </summary>
|
||||
[Category("Property Changed")]
|
||||
public event EventHandler SmallChangeChanged;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overridden Methods
|
||||
/// <summary>
|
||||
/// Releases the unmanaged resources used by the <see cref="T:System.Windows.Forms.Control" /> and its child controls and optionally releases the managed resources.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_brush != null)
|
||||
{
|
||||
_brush.Dispose();
|
||||
}
|
||||
|
||||
if (this.SelectionGlyph != null)
|
||||
{
|
||||
this.SelectionGlyph.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified key is a regular input key or a special key that requires preprocessing.
|
||||
/// </summary>
|
||||
/// <param name="keyData">One of the <see cref="T:System.Windows.Forms.Keys" /> values.</param>
|
||||
/// <returns>true if the specified key is a regular input key; otherwise, false.</returns>
|
||||
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;
|
||||
}
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.GotFocus" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
|
||||
protected override void OnGotFocus(EventArgs e)
|
||||
{
|
||||
base.OnGotFocus(e);
|
||||
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.KeyDown" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.KeyEventArgs" /> that contains the event data.</param>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.LostFocus" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
|
||||
protected override void OnLostFocus(EventArgs e)
|
||||
{
|
||||
base.OnLostFocus(e);
|
||||
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseDown" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseMove" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs" /> that contains the event data.</param>
|
||||
protected override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
|
||||
if (e.Button == MouseButtons.Left && _dragStartedWithinWheel)
|
||||
{
|
||||
this.SetColor(e.Location);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"/> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data. </param>
|
||||
protected override void OnMouseUp(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseUp(e);
|
||||
|
||||
_dragStartedWithinWheel = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.PaddingChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.EventArgs" /> that contains the event data.</param>
|
||||
protected override void OnPaddingChanged(EventArgs e)
|
||||
{
|
||||
base.OnPaddingChanged(e);
|
||||
|
||||
this.RefreshWheel();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.Paint" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs" /> that contains the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="E:System.Windows.Forms.Control.Resize" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">An <see cref="T:System.EventArgs" /> that contains the event data.</param>
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
|
||||
this.RefreshWheel();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Public Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the component color.
|
||||
/// </summary>
|
||||
/// <value>The component color.</value>
|
||||
[Category("Appearance")]
|
||||
[DefaultValue(typeof(Color), "Black")]
|
||||
public virtual Color Color
|
||||
{
|
||||
get { return _color; }
|
||||
set
|
||||
{
|
||||
if (this.Color != value)
|
||||
{
|
||||
_color = value;
|
||||
|
||||
this.OnColorChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the increment for rendering the color wheel.
|
||||
/// </summary>
|
||||
/// <value>The color step.</value>
|
||||
/// <exception cref="System.ArgumentOutOfRangeException">Value must be between 1 and 359</exception>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the component color.
|
||||
/// </summary>
|
||||
/// <value>The component color.</value>
|
||||
[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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value to be added to or subtracted from the <see cref="Color"/> property when the wheel selection is moved a large distance.
|
||||
/// </summary>
|
||||
/// <value>A numeric value. The default value is 5.</value>
|
||||
[Category("Behavior")]
|
||||
[DefaultValue(5)]
|
||||
public virtual int LargeChange
|
||||
{
|
||||
get { return _largeChange; }
|
||||
set
|
||||
{
|
||||
if (this.LargeChange != value)
|
||||
{
|
||||
_largeChange = value;
|
||||
|
||||
this.OnLargeChangeChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the selection handle.
|
||||
/// </summary>
|
||||
/// <value>The size of the selection handle.</value>
|
||||
[Category("Appearance")]
|
||||
[DefaultValue(10)]
|
||||
public virtual int SelectionSize
|
||||
{
|
||||
get { return _selectionSize; }
|
||||
set
|
||||
{
|
||||
if (this.SelectionSize != value)
|
||||
{
|
||||
_selectionSize = value;
|
||||
|
||||
this.OnSelectionSizeChanged(EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value to be added to or subtracted from the <see cref="Color"/> property when the wheel selection is moved a small distance.
|
||||
/// </summary>
|
||||
/// <value>A numeric value. The default value is 1.</value>
|
||||
[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
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether painting of the control is allowed.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// <c>true</c> if painting of the control is allowed; otherwise, <c>false</c>.
|
||||
/// </value>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Disables any redrawing of the image box
|
||||
/// </summary>
|
||||
public virtual void BeginUpdate()
|
||||
{
|
||||
_updateCount++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the redrawing of the image box
|
||||
/// </summary>
|
||||
public virtual void EndUpdate()
|
||||
{
|
||||
if (_updateCount > 0)
|
||||
{
|
||||
_updateCount--;
|
||||
}
|
||||
|
||||
if (this.AllowPainting)
|
||||
{
|
||||
this.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Protected Members
|
||||
|
||||
/// <summary>
|
||||
/// Calculates wheel attributes.
|
||||
/// </summary>
|
||||
protected virtual void CalculateWheel()
|
||||
{
|
||||
List<PointF> points;
|
||||
List<Color> colors;
|
||||
|
||||
points = new List<PointF>();
|
||||
colors = new List<Color>();
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the gradient brush used to paint the wheel.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the selection glyph.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point within the wheel representing the source color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color.</param>
|
||||
protected PointF GetColorLocation(Color color)
|
||||
{
|
||||
return this.GetColorLocation(new HslColor(color));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the point within the wheel representing the source color.
|
||||
/// </summary>
|
||||
/// <param name="color">The color.</param>
|
||||
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));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified point is within the bounds of the color wheel.
|
||||
/// </summary>
|
||||
/// <param name="point">The point.</param>
|
||||
/// <returns><c>true</c> if the specified point is within the bounds of the color wheel; otherwise, <c>false</c>.</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="ColorChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="ColorStepChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected virtual void OnColorStepChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler;
|
||||
|
||||
this.RefreshWheel();
|
||||
|
||||
handler = this.ColorStepChanged;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="HslColorChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="LargeChangeChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
protected virtual void OnLargeChangeChanged(EventArgs e)
|
||||
{
|
||||
EventHandler handler;
|
||||
|
||||
handler = this.LargeChangeChanged;
|
||||
|
||||
if (handler != null)
|
||||
{
|
||||
handler(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="SelectionSizeChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raises the <see cref="SmallChangeChanged" /> event.
|
||||
/// </summary>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the wheel attributes and then repaints the control
|
||||
/// </summary>
|
||||
private void RefreshWheel()
|
||||
{
|
||||
if (_brush != null)
|
||||
{
|
||||
_brush.Dispose();
|
||||
}
|
||||
|
||||
this.CalculateWheel();
|
||||
_brush = this.CreateGradientBrush();
|
||||
this.Invalidate();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{A9F7F23D-AE72-4FC9-9B55-FCF21F0AE333}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ColorWheel</RootNamespace>
|
||||
<AssemblyName>ColorWheel</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ColorWheel.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="ColorHelper.cs" />
|
||||
<Compile Include="HslColor.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
231
Vendor/MechanikaDesign/ColorWheel/HslColor.cs
vendored
231
Vendor/MechanikaDesign/ColorWheel/HslColor.cs
vendored
@@ -1,231 +0,0 @@
|
||||
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
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
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")]
|
||||
Reference in New Issue
Block a user