diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2024-11-13 05:12:21 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2024-11-13 05:12:21 +0200 |
| commit | 331266b13685e16520ae5baa8a7aff50789c31df (patch) | |
| tree | e41c95c155aecccd43cac6498e4bd70a3e227f5a /Software/Visual_Studio/Utilities | |
| parent | 46978af63f2f683eefb0cadb87c1ce7540b0038d (diff) | |
| download | Tango-331266b13685e16520ae5baa8a7aff50789c31df.tar.gz Tango-331266b13685e16520ae5baa8a7aff50789c31df.zip | |
Inks Extension Support.
Diffstat (limited to 'Software/Visual_Studio/Utilities')
5 files changed, 251 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config new file mode 100644 index 000000000..4ef5218a0 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/App.config @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8"?> +<configuration> + <configSections> + <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --> + <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> + </configSections> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> + </startup> + <entityFramework> + <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> + <providers> + <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> + </providers> + </entityFramework> + <runtime> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> + <dependentAssembly> + <assemblyIdentity name="Microsoft.IdentityModel.Clients.ActiveDirectory" publicKeyToken="31bf3856ad364e35" culture="neutral" /> + <bindingRedirect oldVersion="0.0.0.0-5.0.5.0" newVersion="5.0.5.0" /> + </dependentAssembly> + </assemblyBinding> + </runtime> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs new file mode 100644 index 000000000..96b5023ec --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Program.cs @@ -0,0 +1,104 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.BL.Entities; +using Tango.ColorConversion; + +namespace Tango.ColorMeasurementsGenerator +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Generating Colors..."); + Console.WriteLine(); + + var colors = RGBGenerator.GenerateRGBValues(1000); + + List<ColorMeasurement> measurements = new List<ColorMeasurement>(); + + for (int i = 0; i < colors.Count; i++) + { + var color = colors[i]; + //color = DefaultColorConverter.BlendWithViolet((int)color.R, (int)color.G, (int)color.B, ((float)i) / 100f); + var rgb = new ColorMine.ColorSpaces.Rgb(color.R, color.G, color.B); + var cmyk = rgb.To<ColorMine.ColorSpaces.Cmyk>(); + var lab = rgb.To<ColorMine.ColorSpaces.Lab>(); + + ColorMeasurement m = new ColorMeasurement(); + m.C = cmyk.C * 100; + m.M = cmyk.M * 100; + m.Y = cmyk.Y * 100; + m.K = cmyk.K * 100; + m.V = 0; + m.L = lab.L; + m.A = lab.A; + m.B = lab.B; + + measurements.Add(m); + + Console.WriteLine(m.ToString()); + } + + Console.WriteLine(); + + using (var db = ObservablesContext.CreateDefault()) + { + Console.WriteLine("Clearing previous color measurements..."); + db.Database.ExecuteSqlCommand("DELETE FROM COLOR_MEASUREMENTS"); + } + + using (var db = ObservablesContext.CreateDefault()) + { + foreach (var m in measurements) + { + db.ColorMeasurements.Add(m); + } + + Console.WriteLine("Adding new measurements to database..."); + + db.SaveChanges(); + } + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine(); + Console.WriteLine("Done!"); + Console.ReadKey(); + Environment.Exit(0); + } + } + + public class RGBGenerator + { + public static List<RGB> GenerateRGBValues(int numberOfColors) + { + List<RGB> colors = new List<RGB>(); + int colorRange = (int)Math.Ceiling(Math.Pow(numberOfColors, 1.0 / 3.0)); + + for (int r = 0; r < colorRange; r++) + { + for (int g = 0; g < colorRange; g++) + { + for (int b = 0; b < colorRange; b++) + { + int red = (int)(r * 255.0 / (colorRange - 1)); + int green = (int)(g * 255.0 / (colorRange - 1)); + int blue = (int)(b * 255.0 / (colorRange - 1)); + + colors.Add(new RGB(red, green, blue)); + + if (colors.Count >= numberOfColors) + { + return colors; + } + } + } + } + + return colors; + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..150cfb8d4 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.ColorMeasurementsGenerator")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.ColorMeasurementsGenerator")] +[assembly: AssemblyCopyright("Copyright © 2024")] +[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("04fca0ba-a64b-4c6a-a011-a94ce335d616")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj new file mode 100644 index 000000000..89062149c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/Tango.ColorMeasurementsGenerator.csproj @@ -0,0 +1,83 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" 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>{04FCA0BA-A64B-4C6A-A011-A94CE335D616}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>Tango.ColorMeasurementsGenerator</RootNamespace> + <AssemblyName>Tango.ColorMeasurementsGenerator</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <Deterministic>true</Deterministic> + </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="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath> + </Reference> + <Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"> + <HintPath>..\..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.ComponentModel.DataAnnotations" /> + <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.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + <None Include="packages.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\SideChains\ColorMine\ColorMine.csproj"> + <Project>{37e4ceab-b54b-451f-b535-04cf7da9c459}</Project> + <Name>ColorMine</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj"> + <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.ColorConversion\Tango.ColorConversion.csproj"> + <Project>{b4fe6485-4161-4b36-bc08-67e0b53d01b7}</Project> + <Name>Tango.ColorConversion</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.CSV\Tango.CSV.csproj"> + <Project>{58e8825f-0c96-449c-b320-1e82b0aa876b}</Project> + <Name>Tango.CSV</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config new file mode 100644 index 000000000..b3daf0d6c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.ColorMeasurementsGenerator/packages.config @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="utf-8"?> +<packages> + <package id="EntityFramework" version="6.2.0" targetFramework="net461" /> +</packages>
\ No newline at end of file |
