Updated
This commit is contained in:
Родитель
46f18018c9
Коммит
00e2bc5f32
|
@ -275,7 +275,7 @@ __pycache__/
|
|||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
|
|
|
@ -11,27 +11,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{9B03B35A
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorBlender", "src\ColorBlender\ColorBlender.csproj", "{B52C44BA-D099-42E8-94A7-5234E08480FD}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ColorBlenderWPF", "samples\ColorBlenderWPF\ColorBlenderWPF.csproj", "{F42E593E-39A3-4C44-A909-1AE1FEBAFA37}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorBlenderAvalonia", "samples\ColorBlenderAvalonia\ColorBlenderAvalonia.csproj", "{D6EC3C00-F0B9-4531-9563-3487B7ED3512}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ColorBlender.UnitTests", "tests\ColorBlender.UnitTests\ColorBlender.UnitTests.csproj", "{81B01D79-7142-4C77-84FC-26FAACC0D308}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls.ColorBlender", "src\Avalonia.Controls.ColorBlender\Avalonia.Controls.ColorBlender.csproj", "{7EF0D71E-080B-489D-A56B-1C219386EE0A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WPF.Controls.ColorBlender", "src\WPF.Controls.ColorBlender\WPF.Controls.ColorBlender.csproj", "{F01508BB-C309-48EC-B7BC-E8F05A1C2885}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{C912A930-AFF7-441F-ACDE-66F073A8BA9D}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
.editorconfig = .editorconfig
|
||||
_config.yml = _config.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ci", "ci", "{638657F5-4F59-4781-8A7E-295F82D6C905}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
_config.yml = _config.yml
|
||||
appveyor.yml = appveyor.yml
|
||||
azure-pipelines.yml = azure-pipelines.yml
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "git", "git", "{53EC0C5C-8300-4040-A8AC-F6A4B1A55529}"
|
||||
|
@ -49,9 +37,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "props", "props", "{F71DD6BF
|
|||
ProjectSection(SolutionItems) = preProject
|
||||
build\Avalonia.Desktop.props = build\Avalonia.Desktop.props
|
||||
build\Avalonia.props = build\Avalonia.props
|
||||
build\NETCore.props = build\NETCore.props
|
||||
build\NetFX.props = build\NetFX.props
|
||||
build\Rx.props = build\Rx.props
|
||||
build\XUnit.props = build\XUnit.props
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
@ -75,10 +60,6 @@ Global
|
|||
{B52C44BA-D099-42E8-94A7-5234E08480FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B52C44BA-D099-42E8-94A7-5234E08480FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B52C44BA-D099-42E8-94A7-5234E08480FD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F42E593E-39A3-4C44-A909-1AE1FEBAFA37}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F42E593E-39A3-4C44-A909-1AE1FEBAFA37}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F42E593E-39A3-4C44-A909-1AE1FEBAFA37}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F42E593E-39A3-4C44-A909-1AE1FEBAFA37}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D6EC3C00-F0B9-4531-9563-3487B7ED3512}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D6EC3C00-F0B9-4531-9563-3487B7ED3512}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D6EC3C00-F0B9-4531-9563-3487B7ED3512}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -91,10 +72,6 @@ Global
|
|||
{7EF0D71E-080B-489D-A56B-1C219386EE0A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7EF0D71E-080B-489D-A56B-1C219386EE0A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7EF0D71E-080B-489D-A56B-1C219386EE0A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F01508BB-C309-48EC-B7BC-E8F05A1C2885}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F01508BB-C309-48EC-B7BC-E8F05A1C2885}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F01508BB-C309-48EC-B7BC-E8F05A1C2885}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F01508BB-C309-48EC-B7BC-E8F05A1C2885}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{225BA82D-B228-44D0-B8BA-2C5462394F2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{225BA82D-B228-44D0-B8BA-2C5462394F2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{225BA82D-B228-44D0-B8BA-2C5462394F2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
@ -109,12 +86,9 @@ Global
|
|||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{B52C44BA-D099-42E8-94A7-5234E08480FD} = {BE9A54A0-F80F-43A7-90F4-98A147169F9B}
|
||||
{F42E593E-39A3-4C44-A909-1AE1FEBAFA37} = {D57E2975-0E47-4153-B3ED-3C4D0252EB22}
|
||||
{D6EC3C00-F0B9-4531-9563-3487B7ED3512} = {D57E2975-0E47-4153-B3ED-3C4D0252EB22}
|
||||
{81B01D79-7142-4C77-84FC-26FAACC0D308} = {9B03B35A-F57E-4BCB-9990-36FB6D1E8787}
|
||||
{7EF0D71E-080B-489D-A56B-1C219386EE0A} = {BE9A54A0-F80F-43A7-90F4-98A147169F9B}
|
||||
{F01508BB-C309-48EC-B7BC-E8F05A1C2885} = {BE9A54A0-F80F-43A7-90F4-98A147169F9B}
|
||||
{638657F5-4F59-4781-8A7E-295F82D6C905} = {C912A930-AFF7-441F-ACDE-66F073A8BA9D}
|
||||
{53EC0C5C-8300-4040-A8AC-F6A4B1A55529} = {C912A930-AFF7-441F-ACDE-66F073A8BA9D}
|
||||
{6F4F7170-82A1-4C01-A681-7F12ACE72652} = {C912A930-AFF7-441F-ACDE-66F073A8BA9D}
|
||||
{F71DD6BF-C572-4222-82E2-0F0C68F8AA90} = {C912A930-AFF7-441F-ACDE-66F073A8BA9D}
|
||||
|
|
212
README.md
212
README.md
|
@ -1,92 +1,186 @@
|
|||
# ColorBlender
|
||||
# PanAndZoom
|
||||
|
||||
[![Build status](https://ci.appveyor.com/api/projects/status/79btr6li6w4blngf/branch/master?svg=true)](https://ci.appveyor.com/project/wieslawsoltes/colorblender/branch/master)
|
||||
[![Build Status](https://dev.azure.com/wieslawsoltes/ColorBlender/_apis/build/status/wieslawsoltes.ColorBlender)](https://dev.azure.com/wieslawsoltes/ColorBlender/_build/latest?definitionId=1)
|
||||
[![Gitter](https://badges.gitter.im/wieslawsoltes/PanAndZoom.svg)](https://gitter.im/wieslawsoltes/PanAndZoom?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
|
||||
|
||||
[![NuGet](https://img.shields.io/nuget/v/ColorBlender.svg)](https://www.nuget.org/packages/ColorBlender)
|
||||
[![Build status](https://dev.azure.com/wieslawsoltes/GitHub/_apis/build/status/Sources/PanAndZoom)](https://dev.azure.com/wieslawsoltes/GitHub/_build/latest?definitionId=58)
|
||||
|
||||
A .NET library for color matching and palette design.
|
||||
[![NuGet](https://img.shields.io/nuget/v/Avalonia.Controls.PanAndZoom.svg)](https://www.nuget.org/packages/Avalonia.Controls.PanAndZoom)
|
||||
[![NuGet](https://img.shields.io/nuget/dt/Avalonia.Controls.PanAndZoom.svg)](https://www.nuget.org/packages/Avalonia.Controls.PanAndZoom)
|
||||
[![MyGet](https://img.shields.io/myget/panandzoom-nightly/vpre/Avalonia.Controls.PanAndZoom.svg?label=myget)](https://www.myget.org/gallery/panandzoom-nightly)
|
||||
|
||||
## About
|
||||
PanAndZoom control for Avalonia
|
||||
|
||||
ColorBlender is a .NET library for color matching and palette design.
|
||||
|
||||
ColorBlender .NET version is based on sources from: http://www.colorblender.com/
|
||||
|
||||
The old version of ColorBlender can be found here: http://www.colormatch5k.com/
|
||||
The new version of ColorBlender can be found here: http://www.colorexplorer.com/colormatch.aspx
|
||||
|
||||
## Algorithms
|
||||
|
||||
Color matching algorithms:
|
||||
* classic - ColorMatch 5K Classic
|
||||
* colorexplorer - ColorExplorer - "Sweet Spot Offset"
|
||||
* singlehue - Single Hue
|
||||
* complementary - Complementary
|
||||
* splitcomplementary - Split-Complementary
|
||||
* analogue - Analogue
|
||||
* triadic - Triadic
|
||||
* square - Square
|
||||
|
||||
All work is done in HSV color space, because all
|
||||
calculations are based on hue, saturation and value of the working color.
|
||||
|
||||
The hue spectrum is divided into sections, are the matching colors are
|
||||
calculated differently depending on the hue of the color.
|
||||
<a href='https://youtu.be/BFLF1WPZWCQ' target='_blank'>![](images/PanAndZoom.png)<a/>
|
||||
|
||||
## NuGet
|
||||
|
||||
ColorBlender is delivered as a NuGet package.
|
||||
PanAndZoom is delivered as a NuGet package.
|
||||
|
||||
You can find the package [here](https://www.nuget.org/packages/ColorBlender/).
|
||||
You can find the NuGet packages here for [Avalonia](https://www.nuget.org/packages/Avalonia.Controls.PanAndZoom/) or by using nightly build feed:
|
||||
* Add `https://www.myget.org/F/panandzoom-nightly/api/v2` to your package sources
|
||||
* Alternative nightly build feed `https://pkgs.dev.azure.com/wieslawsoltes/GitHub/_packaging/Nightly/nuget/v3/index.json`
|
||||
* Update your package using `PanAndZoom` feed
|
||||
|
||||
You can install the package like this:
|
||||
You can install the package for `Avalonia` based projects like this:
|
||||
|
||||
`Install-Package ColorBlender`
|
||||
`Install-Package Avalonia.Controls.PanAndZoom -Pre`
|
||||
|
||||
## Sample
|
||||
### Package Dependencies
|
||||
|
||||
* [Avalonia](https://www.nuget.org/packages/Avalonia/)
|
||||
|
||||
### Package Sources
|
||||
|
||||
* https://api.nuget.org/v3/index.json
|
||||
* https://www.myget.org/F/panandzoom-nightly/api/v2
|
||||
|
||||
## Resources
|
||||
|
||||
* [GitHub source code repository.](https://github.com/wieslawsoltes/PanAndZoom)
|
||||
|
||||
## Using PanAndZoom
|
||||
|
||||
### Avalonia
|
||||
|
||||
`MainWindow.xaml`
|
||||
```XAML
|
||||
<Window x:Class="AvaloniaDemo.MainWindow"
|
||||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:paz="using:Avalonia.Controls.PanAndZoom"
|
||||
WindowStartupLocation="CenterScreen" UseLayoutRounding="True"
|
||||
Title="PanAndZoom" Height="640" Width="640">
|
||||
<Grid RowDefinitions="Auto,12,Auto,12,*,12" ColumnDefinitions="50,*,50">
|
||||
<StackPanel Orientation="Vertical"
|
||||
HorizontalAlignment="Center" Grid.Row="0" Grid.Column="1">
|
||||
<TextBlock Text="F - Fill"/>
|
||||
<TextBlock Text="U - Uniform"/>
|
||||
<TextBlock Text="R - Reset"/>
|
||||
<TextBlock Text="T - Toggle Stretch Mode"/>
|
||||
<TextBlock Text="Mouse Wheel - Zoom to Point"/>
|
||||
<TextBlock Text="Mouse Left Button Down - Pan"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal"
|
||||
HorizontalAlignment="Center" Grid.Row="2" Grid.Column="1">
|
||||
<TextBlock Text="PanButton:" VerticalAlignment="Center"/>
|
||||
<ComboBox Items="{x:Static paz:ZoomBorder.ButtonNames}"
|
||||
SelectedItem="{Binding #ZoomBorder.PanButton, Mode=TwoWay}"
|
||||
Margin="2">
|
||||
</ComboBox>
|
||||
<TextBlock Text="Stretch:" VerticalAlignment="Center"/>
|
||||
<ComboBox Items="{x:Static paz:ZoomBorder.StretchModes}"
|
||||
SelectedItem="{Binding #ZoomBorder.Stretch, Mode=TwoWay}"
|
||||
Margin="2">
|
||||
</ComboBox>
|
||||
<TextBlock Text="ZoomSpeed:" VerticalAlignment="Center"/>
|
||||
<TextBox Text="{Binding #ZoomBorder.ZoomSpeed, Mode=TwoWay}"
|
||||
TextAlignment="Center" Width="50" Margin="2"/>
|
||||
<CheckBox IsChecked="{Binding #ZoomBorder.EnablePan}"
|
||||
Content="EnablePan" VerticalAlignment="Center"/>
|
||||
<CheckBox IsChecked="{Binding #ZoomBorder.EnableZoom}"
|
||||
Content="EnableZoom" VerticalAlignment="Center"/>
|
||||
</StackPanel>
|
||||
<ScrollViewer Grid.Row="4" Grid.Column="1"
|
||||
VerticalScrollBarVisibility="Auto"
|
||||
HorizontalScrollBarVisibility="Auto">
|
||||
<paz:ZoomBorder Name="ZoomBorder" Stretch="None" ZoomSpeed="1.2"
|
||||
Background="SlateBlue" ClipToBounds="True" Focusable="True"
|
||||
VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
|
||||
<Canvas Background="LightGray" Width="300" Height="300">
|
||||
<Rectangle Canvas.Left="100" Canvas.Top="100" Width="50" Height="50" Fill="Red"/>
|
||||
<StackPanel Canvas.Left="100" Canvas.Top="200">
|
||||
<TextBlock Text="Text1" Width="100" Background="Red" Foreground="WhiteSmoke"/>
|
||||
<TextBlock Text="Text2" Width="100" Background="Red" Foreground="WhiteSmoke"/>
|
||||
</StackPanel>
|
||||
</Canvas>
|
||||
</paz:ZoomBorder>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
</Window>
|
||||
```
|
||||
|
||||
`MainWindow.xaml.cs`
|
||||
```C#
|
||||
using System;
|
||||
using ColorBlender;
|
||||
using ColorBlender.Colors;
|
||||
using ColorBlender.Algorithms;
|
||||
using System.Diagnostics;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.PanAndZoom;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace ColorBlenderConsole
|
||||
namespace AvaloniaDemo
|
||||
{
|
||||
class Program
|
||||
public class MainWindow : Window
|
||||
{
|
||||
static void Main(string[] args)
|
||||
private readonly ZoomBorder? _zoomBorder;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
Console.WriteLine("Classic");
|
||||
Match(new Classic(), new HSV(213, 46, 49));
|
||||
Console.WriteLine("ColorExplorer");
|
||||
Match(new ColorExplorer(), new HSV(213, 46, 49));
|
||||
Console.ReadKey();
|
||||
this.InitializeComponent();
|
||||
this.AttachDevTools();
|
||||
|
||||
_zoomBorder = this.Find<ZoomBorder>("ZoomBorder");
|
||||
if (_zoomBorder != null)
|
||||
{
|
||||
_zoomBorder.KeyDown += ZoomBorder_KeyDown;
|
||||
|
||||
_zoomBorder.ZoomChanged += ZoomBorder_ZoomChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Match(IAlgorithm algorithm, HSV hsv)
|
||||
private void InitializeComponent()
|
||||
{
|
||||
var blend = algorithm.Match(hsv);
|
||||
foreach (var color in blend.Colors)
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
private void ZoomBorder_KeyDown(object? sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
var rgb = color.ToRGB();
|
||||
var html = string.Format(
|
||||
"#{0:X2}{1:X2}{2:X2}",
|
||||
(byte)rgb.R, (byte)rgb.G, (byte)rgb.B);
|
||||
Console.WriteLine(html);
|
||||
case Key.F:
|
||||
_zoomBorder?.Fill();
|
||||
break;
|
||||
case Key.U:
|
||||
_zoomBorder?.Uniform();
|
||||
break;
|
||||
case Key.R:
|
||||
_zoomBorder?.ResetMatrix();
|
||||
break;
|
||||
case Key.T:
|
||||
_zoomBorder?.ToggleStretchMode();
|
||||
_zoomBorder?.AutoFit();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void ZoomBorder_ZoomChanged(object sender, ZoomChangedEventArgs e)
|
||||
{
|
||||
Debug.WriteLine($"[ZoomChanged] {e.ZoomX} {e.ZoomY} {e.OffsetX} {e.OffsetY}");
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Screenshots
|
||||
### Getting zoom ratio
|
||||
|
||||
![](images/avalonia.png)
|
||||
To get current zoom ratio use `ZoomX` and `ZoomY` properties.
|
||||
|
||||
![](images/wpf.png)
|
||||
### Getting pan offset
|
||||
|
||||
To get current pan offset use `OffsetX` and `OffsetY` properties.
|
||||
|
||||
### Constrain zoom ratio
|
||||
|
||||
To constrain zoom ratio use `MinZoomX`, `MaxZoomX`, `MinZoomY` and `MaxZoomY` properties.
|
||||
|
||||
### Constrain pan offset
|
||||
|
||||
To constrain pan offset use `MinOffsetX`, `MaxOffsetX`, `MinOffsetY` and `MaxOffsetY` properties.
|
||||
|
||||
### Enable or disable constrains
|
||||
|
||||
To enable or disable constrains use `EnableConstrains` flag.
|
||||
|
||||
## License
|
||||
|
||||
ColorBlender is licensed under the [MIT license](LICENSE.TXT).
|
||||
PanAndZoom is licensed under the [MIT license](LICENSE.TXT).
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
theme: jekyll-theme-cayman
|
14
appveyor.yml
14
appveyor.yml
|
@ -1,14 +0,0 @@
|
|||
environment:
|
||||
APPVEYOR_BLOCK_DOTNETCORE_TESTS_AUTORUN: true
|
||||
version: '{build}'
|
||||
image: Visual Studio 2017
|
||||
configuration: Release
|
||||
platform: Any CPU
|
||||
install:
|
||||
- cmd: appveyor DownloadFile https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
|
||||
before_build:
|
||||
- cmd: nuget restore
|
||||
build:
|
||||
parallel: true
|
||||
project: ColorBlender.sln
|
||||
verbosity: minimal
|
|
@ -1,23 +0,0 @@
|
|||
jobs:
|
||||
- job: Windows
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
variables:
|
||||
solution: '**/*.sln'
|
||||
buildPlatform: 'Any CPU'
|
||||
buildConfiguration: 'Release'
|
||||
steps:
|
||||
- task: DotNetCoreInstaller@0
|
||||
inputs:
|
||||
version: '2.1.401'
|
||||
- task: NuGetToolInstaller@0
|
||||
- task: NuGetCommand@2
|
||||
inputs:
|
||||
restoreSolution: '$(solution)'
|
||||
feedsToUse: 'config'
|
||||
nugetConfigPath: 'NuGet.Config'
|
||||
- task: VSBuild@1
|
||||
inputs:
|
||||
solution: '$(solution)'
|
||||
platform: '$(buildPlatform)'
|
||||
configuration: '$(buildConfiguration)'
|
|
@ -1,19 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.7.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SharpDX" Version="4.0.1" />
|
||||
<PackageReference Include="SharpDX.Direct2D1" Version="4.0.1" />
|
||||
<PackageReference Include="SharpDX.Direct3D11" Version="4.0.1" />
|
||||
<PackageReference Include="SharpDX.DXGI" Version="4.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SkiaSharp" Version="1.60.0" />
|
||||
<PackageReference Include="Avalonia.Skia.Linux.Natives" Version="1.60.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog.Sinks.Trace" Version="2.1.0" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="0.10.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,14 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="0.7.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Serilog" Version="2.5.0" />
|
||||
<PackageReference Include="System.Memory" Version="4.5.1" />
|
||||
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
|
||||
<PackageReference Include="Avalonia" Version="0.10.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.Runtime.CoreCLR" Version="2.0.8" />
|
||||
<PackageReference Include="Microsoft.NETCore.DotNetHostPolicy" Version="2.1.5" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -1,6 +0,0 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition=" '$(TargetFramework)' == 'net461' and '$(OS)' == 'Unix' ">
|
||||
<FrameworkPathOverride>/usr/lib/mono/4.6.1-api</FrameworkPathOverride>
|
||||
<FrameworkPathOverride Condition="$([MSBuild]::IsOsPlatform('OSX'))">/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.6.1-api</FrameworkPathOverride>
|
||||
</PropertyGroup>
|
||||
</Project>
|
|
@ -1,10 +0,0 @@
|
|||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Reactive" Version="4.0.0" />
|
||||
<PackageReference Include="System.Reactive.Core" Version="4.0.0" />
|
||||
<PackageReference Include="System.Reactive.Interfaces" Version="4.0.0" />
|
||||
<PackageReference Include="System.Reactive.Linq" Version="4.0.0" />
|
||||
<PackageReference Include="System.Reactive.PlatformServices" Version="4.0.0" />
|
||||
<PackageReference Condition="$(TargetFramework.StartsWith('net4'))" Include="System.Reactive.Windows.Threading" Version="4.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -9,8 +9,6 @@
|
|||
<PackageReference Include="xunit.runner.console" Version="2.4.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
|
||||
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.8.0" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
xmlns="https://github.com/avaloniaui"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Application.Styles>
|
||||
<StyleInclude Source="resm:Avalonia.Themes.Default.DefaultTheme.xaml?assembly=Avalonia.Themes.Default"/>
|
||||
<StyleInclude Source="resm:Avalonia.Themes.Default.Accents.BaseLight.xaml?assembly=Avalonia.Themes.Default"/>
|
||||
<StyleInclude Source="avares://Avalonia.Themes.Fluent/FluentLight.xaml" />
|
||||
<StyleInclude Source="avares://Avalonia.Themes.Fluent/DensityStyles/Compact.xaml" />
|
||||
</Application.Styles>
|
||||
</Application>
|
|
@ -2,10 +2,9 @@
|
|||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System;
|
||||
using Avalonia;
|
||||
using Avalonia.Logging.Serilog;
|
||||
using Avalonia.Controls.ApplicationLifetimes;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using ColorBlender;
|
||||
using Serilog;
|
||||
|
||||
namespace ColorBlenderAvalonia
|
||||
{
|
||||
|
@ -13,36 +12,28 @@ namespace ColorBlenderAvalonia
|
|||
{
|
||||
public static ColorMatch Design { get; } = new ColorMatch(213, 46, 49);
|
||||
|
||||
static void Print(Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex.Message);
|
||||
Console.WriteLine(ex.StackTrace);
|
||||
if (ex.InnerException != null)
|
||||
{
|
||||
Print(ex.InnerException);
|
||||
}
|
||||
}
|
||||
[STAThread]
|
||||
public static void Main(string[] args) => BuildAvaloniaApp()
|
||||
.StartWithClassicDesktopLifetime(args);
|
||||
|
||||
public static AppBuilder BuildAvaloniaApp()
|
||||
=> AppBuilder.Configure<App>()
|
||||
.UsePlatformDetect()
|
||||
.LogToDebug();
|
||||
|
||||
static void Main(string[] args)
|
||||
{
|
||||
try
|
||||
{
|
||||
BuildAvaloniaApp().Start<MainWindow>(() => new ColorMatch(213, 46, 49));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Print(ex);
|
||||
}
|
||||
}
|
||||
.UsePlatformDetect()
|
||||
.LogToTrace();
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
}
|
||||
|
||||
public override void OnFrameworkInitializationCompleted()
|
||||
{
|
||||
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
|
||||
{
|
||||
desktop.MainWindow = new MainWindow();
|
||||
}
|
||||
|
||||
base.OnFrameworkInitializationCompleted();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,9 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
<RuntimeIdentifiers>win7-x64;ubuntu.14.04-x64;osx.10.12-x64</RuntimeIdentifiers>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
|
||||
<EnableDefaultCompileItems>False</EnableDefaultCompileItems>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
|
@ -13,23 +11,9 @@
|
|||
<Authors>Wiesław Šoltés</Authors>
|
||||
<Company>Wiesław Šoltés</Company>
|
||||
<Description>A sample Avalonia application for .NET library for color matching and palette design.</Description>
|
||||
<Copyright>Copyright © Wiesław Šoltés 2018</Copyright>
|
||||
<Copyright>Copyright © Wiesław Šoltés 2021</Copyright>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" Exclude="obj\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="**\*.xaml.cs">
|
||||
<DependentUpon>%(Filename)</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="**\*.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\NETCore.props" />
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Rx.props" />
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Avalonia.props" />
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Avalonia.Desktop.props" />
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<!-- Copyright (c) Wiesław Šoltés. All rights reserved. -->
|
||||
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
||||
<Application x:Class="ColorBlenderWPF.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
</Application>
|
|
@ -1,21 +0,0 @@
|
|||
// Copyright (c) Wiesław Šoltés. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System.Windows;
|
||||
using ColorBlender;
|
||||
|
||||
namespace ColorBlenderWPF
|
||||
{
|
||||
public partial class App : Application
|
||||
{
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
|
||||
new MainWindow()
|
||||
{
|
||||
DataContext = new ColorMatch(213, 46, 49)
|
||||
}
|
||||
.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{F42E593E-39A3-4C44-A909-1AE1FEBAFA37}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ColorBlenderWPF</RootNamespace>
|
||||
<AssemblyName>ColorBlenderWPF</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Xaml">
|
||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||
</Reference>
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="MainWindow.xaml.cs">
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<None Include="app.config" />
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\ColorBlender.Colors\ColorBlender.Colors.csproj">
|
||||
<Project>{225ba82d-b228-44d0-b8ba-2c5462394f2c}</Project>
|
||||
<Name>ColorBlender.Colors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\ColorBlender\ColorBlender.csproj">
|
||||
<Project>{b52c44ba-d099-42e8-94a7-5234e08480fd}</Project>
|
||||
<Name>ColorBlender</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\src\WPF.Controls.ColorBlender\WPF.Controls.ColorBlender.csproj">
|
||||
<Project>{f01508bb-c309-48ec-b7bc-e8f05a1c2885}</Project>
|
||||
<Name>WPF.Controls.ColorBlender</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,13 +0,0 @@
|
|||
<!-- Copyright (c) Wiesław Šoltés. All rights reserved. -->
|
||||
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
||||
<Window x:Class="ColorBlenderWPF.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:cb="clr-namespace:WPF.Controls.ColorBlender;assembly=WPF.Controls.ColorBlender"
|
||||
Title="ColorBlender .NET"
|
||||
Width="800" Height="480"
|
||||
Background="White"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
UseLayoutRounding="True" SnapsToDevicePixels="True" TextOptions.TextFormattingMode="Display">
|
||||
<cb:ColorBlender/>
|
||||
</Window>
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright (c) Wiesław Šoltés. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System.Windows;
|
||||
|
||||
namespace ColorBlenderWPF
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (c) Wiesław Šoltés. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
[assembly: AssemblyTitle("ColorBlenderWPF")]
|
||||
[assembly: AssemblyDescription("A sample WPF application for .NET library for color matching and palette design.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Wiesław Šoltés")]
|
||||
[assembly: AssemblyProduct("ColorBlenderWPF")]
|
||||
[assembly: AssemblyCopyright("Copyright © Wiesław Šoltés 2017")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyVersion("0.2.0")]
|
||||
[assembly: AssemblyFileVersion("0.2.0")]
|
||||
[assembly: AssemblyInformationalVersion("0.2.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
|
||||
</startup>
|
||||
</configuration>
|
|
@ -1,9 +1,8 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net5.0;net461</TargetFrameworks>
|
||||
<OutputType>Library</OutputType>
|
||||
<EnableDefaultCompileItems>False</EnableDefaultCompileItems>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -12,25 +11,12 @@
|
|||
<Authors>Wiesław Šoltés</Authors>
|
||||
<Company>Wiesław Šoltés</Company>
|
||||
<Description>An avalonia control for color matching and palette design.</Description>
|
||||
<Copyright>Copyright © Wiesław Šoltés 2018</Copyright>
|
||||
<Copyright>Copyright © Wiesław Šoltés 2021</Copyright>
|
||||
<PackageLicenseUrl>https://github.com/wieslawsoltes/ColorBlender/blob/master/LICENSE.TXT</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://github.com/wieslawsoltes/ColorBlender</PackageProjectUrl>
|
||||
<PackageTags>color;colorblender;palette;design;colors;hsv;rgb;avalonia;controls;xaml</PackageTags>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" Exclude="obj\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="**\*.xaml.cs">
|
||||
<DependentUpon>%(Filename)</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="**\*.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Rx.props" />
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Avalonia.props" />
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -39,7 +25,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Swatch.xaml.cs">
|
||||
<Compile Update="Swatch.axaml.cs">
|
||||
<DependentUpon>%(Filename)</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net5.0;net461</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
|||
<Authors>Wiesław Šoltés</Authors>
|
||||
<Company>Wiesław Šoltés</Company>
|
||||
<Description>A .NET library with basic color types.</Description>
|
||||
<Copyright>Copyright © Wiesław Šoltés 2018</Copyright>
|
||||
<Copyright>Copyright © Wiesław Šoltés 2021</Copyright>
|
||||
<PackageLicenseUrl>https://github.com/wieslawsoltes/ColorBlender/blob/master/LICENSE.TXT</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://github.com/wieslawsoltes/ColorBlender</PackageProjectUrl>
|
||||
<PackageTags>color;colors;hsv;rgb</PackageTags>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks>netstandard2.0;net5.0;net461</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
|||
<Authors>Wiesław Šoltés</Authors>
|
||||
<Company>Wiesław Šoltés</Company>
|
||||
<Description>A .NET library for color matching and palette design.</Description>
|
||||
<Copyright>Copyright © Wiesław Šoltés 2018</Copyright>
|
||||
<Copyright>Copyright © Wiesław Šoltés 2021</Copyright>
|
||||
<PackageLicenseUrl>https://github.com/wieslawsoltes/ColorBlender/blob/master/LICENSE.TXT</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://github.com/wieslawsoltes/ColorBlender</PackageProjectUrl>
|
||||
<PackageTags>color;colorblender;palette;design;colors;hsv;rgb</PackageTags>
|
||||
|
|
|
@ -1,137 +0,0 @@
|
|||
<!-- Copyright (c) Wiesław Šoltés. All rights reserved. -->
|
||||
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
||||
<UserControl x:Class="WPF.Controls.ColorBlender.ColorBlender"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:WPF.Controls.ColorBlender">
|
||||
<Grid Name="layout" Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Column="0" Grid.Row="0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="Current Blend" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Margin="5,2,5,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<TextBlock Text="algorithm:" Grid.Column="2" Grid.Row="0" Grid.ColumnSpan="2" Margin="5,2,5,2" HorizontalAlignment="Right" VerticalAlignment="Center" />
|
||||
<ComboBox x:Name="algorithm" Grid.Column="4" Grid.Row="0" Grid.ColumnSpan="2" ItemsSource="{Binding Algorithms}" SelectedItem="{Binding CurrentAlgorithm}"/>
|
||||
</Grid>
|
||||
<Grid x:Name="swatches" Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<local:Swatch x:Name="swatch1" Grid.Column="0" Margin="2" />
|
||||
<local:Swatch x:Name="swatch2" Grid.Column="1" Margin="2" />
|
||||
<local:Swatch x:Name="swatch3" Grid.Column="2" Margin="2" />
|
||||
<local:Swatch x:Name="swatch4" Grid.Column="3" Margin="2" />
|
||||
<local:Swatch x:Name="swatch5" Grid.Column="4" Margin="2" />
|
||||
<local:Swatch x:Name="swatch6" Grid.Column="5" Margin="2" />
|
||||
</Grid>
|
||||
<TextBlock Text="Edit Red / Green / Blue" Grid.Column="0" Grid.Row="2" Margin="5,2,5,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<Grid x:Name="colorsRGB" Grid.Row="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="70"/>
|
||||
<ColumnDefinition Width="40*"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="inputLabelR" Text="Red" Grid.Column="0" Grid.Row="0" Margin="5,2,5,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<TextBlock x:Name="inputLabelG" Text="Green" Grid.Column="0" Grid.Row="1" Margin="5,2,5,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<TextBlock x:Name="inputLabelB" Text="Blue" Grid.Column="0" Grid.Row="2" Margin="5,2,5,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<Slider x:Name="sliderR" Grid.Column="1" Grid.Row="0" Margin="5,2,5,2" Value="0" Maximum="255" LargeChange="1" SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
<Slider x:Name="sliderG" Grid.Column="1" Grid.Row="1" Margin="5,2,5,2" Value="0" Maximum="255" LargeChange="1" SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
<Slider x:Name="sliderB" Grid.Column="1" Grid.Row="2" Margin="5,2,5,2" Value="0" Maximum="255" LargeChange="1" SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
<TextBox x:Name="inputR" Text="{Binding ElementName=sliderR, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" Grid.Row="0" Margin="5,2,5,2" TextAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
|
||||
<TextBox x:Name="inputG" Text="{Binding ElementName=sliderG, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" Grid.Row="1" Margin="5,2,5,2" TextAlignment="Center" VerticalAlignment="Center" />
|
||||
<TextBox x:Name="inputB" Text="{Binding ElementName=sliderB, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" Grid.Row="2" Margin="5,2,5,2" TextAlignment="Center" VerticalAlignment="Center" />
|
||||
<Grid x:Name="variationsRGB" Grid.Row="0" Grid.Column="4" Grid.RowSpan="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle x:Name="rgbvar1" Cursor="Hand" Fill="Gray" Grid.Column="0" Grid.Row="0" Margin="22,2,22,2" Grid.ColumnSpan="2" />
|
||||
<Rectangle x:Name="rgbvar2" Cursor="Hand" Fill="Gray" Grid.Column="1" Grid.Row="0" Margin="22,2,22,2" Grid.ColumnSpan="2" />
|
||||
<Rectangle x:Name="rgbvar3" Cursor="Hand" Fill="Gray" Grid.Column="0" Grid.Row="1" Margin="2" />
|
||||
<Rectangle x:Name="rgbvar4" Cursor="Hand" Fill="Gray" Grid.Column="1" Grid.Row="1" Margin="2" />
|
||||
<Rectangle x:Name="rgbvar5" Cursor="Hand" Fill="Gray" Grid.Column="2" Grid.Row="1" Margin="2" />
|
||||
<Rectangle x:Name="rgbvar6" Cursor="Hand" Fill="Gray" Grid.Column="0" Grid.Row="2" Margin="22,2,22,2" Grid.ColumnSpan="2" />
|
||||
<Rectangle x:Name="rgbvar7" Cursor="Hand" Fill="Gray" Grid.Column="1" Grid.Row="2" Margin="22,2,22,2" Grid.ColumnSpan="2" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
<TextBlock Text="Edit Hue / Saturation / Lightness" Grid.Column="0" Grid.Row="4" Margin="5,2,5,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<Grid x:Name="colorsHSV" Grid.Row="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="70"/>
|
||||
<ColumnDefinition Width="40*"/>
|
||||
<ColumnDefinition Width="50"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
<ColumnDefinition Width="120"/>
|
||||
<ColumnDefinition Width="20"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock x:Name="inputLabelH" Text="Hue" Grid.Column="0" Grid.Row="0" Margin="5,2,5,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<TextBlock x:Name="inputLabelS" Text="Saturation" Grid.Column="0" Grid.Row="1" Margin="5,2,5,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<TextBlock x:Name="inputLabelV" Text="Lightness" Grid.Column="0" Grid.Row="2" Margin="5,2,5,2" HorizontalAlignment="Left" VerticalAlignment="Center" />
|
||||
<Slider x:Name="sliderH" Grid.Column="1" Grid.Row="0" Margin="5,2,5,2" Value="0" Maximum="359" LargeChange="1" SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
<Slider x:Name="sliderS" Grid.Column="1" Grid.Row="1" Margin="5,2,5,2" Value="0" Maximum="100" LargeChange="1" SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
<Slider x:Name="sliderV" Grid.Column="1" Grid.Row="2" Margin="5,2,5,2" Value="0" Maximum="100" LargeChange="1" SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
<TextBox x:Name="inputH" Text="{Binding ElementName=sliderH, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" Grid.Row="0" Margin="5,2,5,2" TextAlignment="Center" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
|
||||
<TextBox x:Name="inputS" Text="{Binding ElementName=sliderS, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" Grid.Row="1" Margin="5,2,5,2" TextAlignment="Center" VerticalAlignment="Center" />
|
||||
<TextBox x:Name="inputV" Text="{Binding ElementName=sliderV, Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" Grid.Row="2" Margin="5,2,5,2" TextAlignment="Center" VerticalAlignment="Center" />
|
||||
<Grid x:Name="variationsHSV" Grid.Row="0" Grid.Column="4" Grid.RowSpan="3">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle x:Name="hsvvar1" Cursor="Hand" Fill="Gray" Grid.Column="0" Grid.Row="0" Margin="2" />
|
||||
<Rectangle x:Name="hsvvar2" Cursor="Hand" Fill="Gray" Grid.Column="1" Grid.Row="0" Margin="2" />
|
||||
<Rectangle x:Name="hsvvar3" Cursor="Hand" Fill="Gray" Grid.Column="2" Grid.Row="0" Margin="2" />
|
||||
<Rectangle x:Name="hsvvar4" Cursor="Hand" Fill="Gray" Grid.Column="0" Grid.Row="1" Margin="2" />
|
||||
<Rectangle x:Name="hsvvar5" Cursor="Hand" Fill="Gray" Grid.Column="1" Grid.Row="1" Margin="2" />
|
||||
<Rectangle x:Name="hsvvar6" Cursor="Hand" Fill="Gray" Grid.Column="2" Grid.Row="1" Margin="2" />
|
||||
<Rectangle x:Name="hsvvar7" Cursor="Hand" Fill="Gray" Grid.Column="0" Grid.Row="2" Margin="2" />
|
||||
<Rectangle x:Name="hsvvar8" Cursor="Hand" Fill="Gray" Grid.Column="1" Grid.Row="2" Margin="2" />
|
||||
<Rectangle x:Name="hsvvar9" Cursor="Hand" Fill="Gray" Grid.Column="2" Grid.Row="2" Margin="2" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -1,226 +0,0 @@
|
|||
// Copyright (c) Wiesław Šoltés. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
using ColorBlender;
|
||||
using ColorBlender.Colors;
|
||||
|
||||
namespace WPF.Controls.ColorBlender
|
||||
{
|
||||
public partial class ColorBlender : UserControl
|
||||
{
|
||||
private bool _updatingSliders = false;
|
||||
|
||||
public ColorBlender()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
sliderR.ValueChanged += SliderRGB_ValueChanged;
|
||||
sliderG.ValueChanged += SliderRGB_ValueChanged;
|
||||
sliderB.ValueChanged += SliderRGB_ValueChanged;
|
||||
sliderH.ValueChanged += SliderHSV_ValueChanged;
|
||||
sliderS.ValueChanged += SliderHSV_ValueChanged;
|
||||
sliderV.ValueChanged += SliderHSV_ValueChanged;
|
||||
|
||||
rgbvar1.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
rgbvar2.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
rgbvar3.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
rgbvar4.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
rgbvar5.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
rgbvar6.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
rgbvar7.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
|
||||
hsvvar1.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
hsvvar2.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
hsvvar3.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
hsvvar4.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
hsvvar5.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
hsvvar6.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
hsvvar7.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
hsvvar8.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
hsvvar9.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
|
||||
swatch1.col.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
swatch2.col.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
swatch3.col.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
swatch4.col.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
swatch5.col.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
swatch6.col.MouseLeftButtonDown += Rectangle_MouseLeftButtonDown;
|
||||
|
||||
algorithm.SelectionChanged += Algorithm_SelectionChanged;
|
||||
|
||||
this.Loaded += UserControl_Loaded;
|
||||
}
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
UpdateVariations();
|
||||
UpdateSwatches();
|
||||
UpdateSliderRGB();
|
||||
UpdateSliderHSV();
|
||||
}
|
||||
|
||||
private void UpdateVariations()
|
||||
{
|
||||
var vm = DataContext as ColorMatch;
|
||||
if (vm != null)
|
||||
{
|
||||
rgbvar1.Fill = vm.VariationsRGB[0].ToSolidColorBrush();
|
||||
rgbvar2.Fill = vm.VariationsRGB[1].ToSolidColorBrush();
|
||||
rgbvar3.Fill = vm.VariationsRGB[2].ToSolidColorBrush();
|
||||
rgbvar4.Fill = vm.VariationsRGB[3].ToSolidColorBrush();
|
||||
rgbvar5.Fill = vm.VariationsRGB[4].ToSolidColorBrush();
|
||||
rgbvar6.Fill = vm.VariationsRGB[5].ToSolidColorBrush();
|
||||
rgbvar7.Fill = vm.VariationsRGB[6].ToSolidColorBrush();
|
||||
|
||||
hsvvar1.Fill = vm.VariationsHSV[0].ToSolidColorBrush();
|
||||
hsvvar2.Fill = vm.VariationsHSV[1].ToSolidColorBrush();
|
||||
hsvvar3.Fill = vm.VariationsHSV[2].ToSolidColorBrush();
|
||||
hsvvar4.Fill = vm.VariationsHSV[3].ToSolidColorBrush();
|
||||
hsvvar5.Fill = vm.VariationsHSV[4].ToSolidColorBrush();
|
||||
hsvvar6.Fill = vm.VariationsHSV[5].ToSolidColorBrush();
|
||||
hsvvar7.Fill = vm.VariationsHSV[6].ToSolidColorBrush();
|
||||
hsvvar8.Fill = vm.VariationsHSV[7].ToSolidColorBrush();
|
||||
hsvvar9.Fill = vm.VariationsHSV[8].ToSolidColorBrush();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSwatches()
|
||||
{
|
||||
var vm = DataContext as ColorMatch;
|
||||
if (vm != null)
|
||||
{
|
||||
swatch1.col.Fill = vm.CurrentBlend.Colors[0].ToSolidColorBrush();
|
||||
swatch2.col.Fill = vm.CurrentBlend.Colors[1].ToSolidColorBrush();
|
||||
swatch3.col.Fill = vm.CurrentBlend.Colors[2].ToSolidColorBrush();
|
||||
swatch4.col.Fill = vm.CurrentBlend.Colors[3].ToSolidColorBrush();
|
||||
swatch5.col.Fill = vm.CurrentBlend.Colors[4].ToSolidColorBrush();
|
||||
swatch6.col.Fill = vm.CurrentBlend.Colors[5].ToSolidColorBrush();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSliderRGB()
|
||||
{
|
||||
_updatingSliders = true;
|
||||
|
||||
var vm = DataContext as ColorMatch;
|
||||
if (vm != null)
|
||||
{
|
||||
sliderR.Value = vm.CurrentRGB.R;
|
||||
sliderG.Value = vm.CurrentRGB.G;
|
||||
sliderB.Value = vm.CurrentRGB.B;
|
||||
}
|
||||
|
||||
_updatingSliders = false;
|
||||
}
|
||||
|
||||
private void UpdateSliderHSV()
|
||||
{
|
||||
_updatingSliders = true;
|
||||
|
||||
var vm = DataContext as ColorMatch;
|
||||
if (vm != null)
|
||||
{
|
||||
sliderH.Value = vm.CurrentHSV.H;
|
||||
sliderS.Value = vm.CurrentHSV.S;
|
||||
sliderV.Value = vm.CurrentHSV.V;
|
||||
}
|
||||
|
||||
_updatingSliders = false;
|
||||
}
|
||||
|
||||
private void Algorithm_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
var vm = DataContext as ColorMatch;
|
||||
if (vm != null)
|
||||
{
|
||||
vm.Update();
|
||||
}
|
||||
|
||||
UpdateVariations();
|
||||
UpdateSwatches();
|
||||
}
|
||||
|
||||
private void SliderRGB_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (_updatingSliders == false)
|
||||
{
|
||||
HandleSliderValueChangedRGB();
|
||||
}
|
||||
}
|
||||
|
||||
private void SliderHSV_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (_updatingSliders == false)
|
||||
{
|
||||
HandleSliderValueChangedHSV();
|
||||
}
|
||||
}
|
||||
|
||||
private void Rectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
HandleRectangleClick((sender as Rectangle).Fill as SolidColorBrush);
|
||||
}
|
||||
|
||||
private void HandleRectangleClick(SolidColorBrush b)
|
||||
{
|
||||
var vm = DataContext as ColorMatch;
|
||||
if (vm != null)
|
||||
{
|
||||
vm.CurrentRGB = b.Color.ToRGB();
|
||||
vm.CurrentHSV = vm.CurrentRGB.ToHSV();
|
||||
|
||||
vm.Update();
|
||||
}
|
||||
|
||||
UpdateVariations();
|
||||
UpdateSwatches();
|
||||
UpdateSliderRGB();
|
||||
UpdateSliderHSV();
|
||||
}
|
||||
|
||||
private void HandleSliderValueChangedRGB()
|
||||
{
|
||||
var vm = DataContext as ColorMatch;
|
||||
if (vm != null)
|
||||
{
|
||||
vm.CurrentRGB = new RGB(
|
||||
sliderR.Value,
|
||||
sliderG.Value,
|
||||
sliderB.Value);
|
||||
|
||||
vm.CurrentHSV = vm.CurrentRGB.ToHSV();
|
||||
vm.CurrentRGB = vm.CurrentHSV.ToRGB();
|
||||
|
||||
vm.Update();
|
||||
}
|
||||
|
||||
UpdateVariations();
|
||||
UpdateSwatches();
|
||||
UpdateSliderHSV();
|
||||
}
|
||||
|
||||
private void HandleSliderValueChangedHSV()
|
||||
{
|
||||
var vm = DataContext as ColorMatch;
|
||||
if (vm != null)
|
||||
{
|
||||
vm.CurrentHSV = new HSV(
|
||||
sliderH.Value,
|
||||
sliderS.Value,
|
||||
sliderV.Value);
|
||||
|
||||
vm.CurrentRGB = vm.CurrentHSV.ToRGB();
|
||||
|
||||
vm.Update();
|
||||
}
|
||||
|
||||
UpdateVariations();
|
||||
UpdateSwatches();
|
||||
UpdateSliderRGB();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
// Copyright (c) Wiesław Šoltés. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System;
|
||||
using System.Windows.Media;
|
||||
using ColorBlender.Colors;
|
||||
|
||||
namespace WPF.Controls.ColorBlender
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static RGB ToRGB(this Color c)
|
||||
{
|
||||
return new RGB(c.R, c.G, c.B);
|
||||
}
|
||||
|
||||
public static HSV ToHSV(this Color c)
|
||||
{
|
||||
return ToRGB(c).ToHSV();
|
||||
}
|
||||
|
||||
public static Color ToColor(this HSV hsv)
|
||||
{
|
||||
return ToColor(hsv.ToRGB());
|
||||
}
|
||||
|
||||
public static Color ToColor(this RGB rgb)
|
||||
{
|
||||
return Color.FromRgb(
|
||||
(byte)Math.Round(rgb.R),
|
||||
(byte)Math.Round(rgb.G),
|
||||
(byte)Math.Round(rgb.B));
|
||||
}
|
||||
|
||||
public static SolidColorBrush ToSolidColorBrush(this RGB rgb)
|
||||
{
|
||||
return new SolidColorBrush(ToColor(rgb));
|
||||
}
|
||||
|
||||
public static SolidColorBrush ToSolidColorBrush(this HSV hsv)
|
||||
{
|
||||
return new SolidColorBrush(ToColor(hsv));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
// Copyright (c) Wiesław Šoltés. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace WPF.Controls.ColorBlender
|
||||
{
|
||||
public class HtmlColorConverter : IMultiValueConverter
|
||||
{
|
||||
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return $"#{((byte)values[0]).ToString("X2")}{((byte)values[1]).ToString("X2")}{((byte)values[2]).ToString("X2")}";
|
||||
}
|
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
|
||||
{
|
||||
object[] bytes = new object[3];
|
||||
string html = value as string;
|
||||
bytes[0] = byte.Parse(html.Substring(1, 2), NumberStyles.HexNumber);
|
||||
bytes[1] = byte.Parse(html.Substring(3, 2), NumberStyles.HexNumber);
|
||||
bytes[2] = byte.Parse(html.Substring(5, 2), NumberStyles.HexNumber);
|
||||
return bytes;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
// Copyright (c) Wiesław Šoltés. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
[assembly: AssemblyTitle("WPF.Controls.ColorBlender")]
|
||||
[assembly: AssemblyDescription("An avalonia control for color matching and palette design.")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Wiesław Šoltés")]
|
||||
[assembly: AssemblyProduct("WPF.Controls.ColorBlender")]
|
||||
[assembly: AssemblyCopyright("Copyright © Wiesław Šoltés 2018")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyVersion("0.3.0")]
|
||||
[assembly: AssemblyFileVersion("0.3.0")]
|
||||
[assembly: AssemblyInformationalVersion("0.3.0")]
|
||||
[assembly: ComVisible(false)]
|
||||
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
|
|
@ -1,40 +0,0 @@
|
|||
<!-- Copyright (c) Wiesław Šoltés. All rights reserved. -->
|
||||
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
||||
<UserControl x:Class="WPF.Controls.ColorBlender.Swatch"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:WPF.Controls.ColorBlender">
|
||||
<UserControl.Resources>
|
||||
<local:HtmlColorConverter x:Key="HtmlColorConverterKey" />
|
||||
</UserControl.Resources>
|
||||
<Grid x:Name="swatch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Rectangle x:Name="col" Cursor="Hand" Fill="Gray" Grid.Column="0" Grid.Row="0" Margin="3,3,3,3" />
|
||||
<TextBox x:Name="HTML" Grid.Column="0" Grid.Row="1" Margin="3,1,3,3" TextAlignment="Center" IsReadOnly="True" >
|
||||
<TextBox.Text>
|
||||
<MultiBinding Converter="{StaticResource HtmlColorConverterKey}">
|
||||
<Binding ElementName="col" Path="Fill.Color.R" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" />
|
||||
<Binding ElementName="col" Path="Fill.Color.G" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" />
|
||||
<Binding ElementName="col" Path="Fill.Color.B" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" />
|
||||
</MultiBinding>
|
||||
</TextBox.Text>
|
||||
</TextBox>
|
||||
<Grid Grid.Column="0" Grid.Row="2" Margin="3,1,3,4" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox x:Name="R" Text="{Binding ElementName=col, Path=Fill.Color.R, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="0" TextAlignment="Center" IsReadOnly="True" />
|
||||
<TextBox x:Name="G" Text="{Binding ElementName=col, Path=Fill.Color.G, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="1" TextAlignment="Center" IsReadOnly="True" />
|
||||
<TextBox x:Name="B" Text="{Binding ElementName=col, Path=Fill.Color.B, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Column="2" TextAlignment="Center" IsReadOnly="True" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</UserControl>
|
|
@ -1,14 +0,0 @@
|
|||
// Copyright (c) Wiesław Šoltés. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace WPF.Controls.ColorBlender
|
||||
{
|
||||
public partial class Swatch : UserControl
|
||||
{
|
||||
public Swatch()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
<?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>{F01508BB-C309-48EC-B7BC-E8F05A1C2885}</ProjectGuid>
|
||||
<OutputType>library</OutputType>
|
||||
<RootNamespace>WPF.Controls.ColorBlender</RootNamespace>
|
||||
<AssemblyName>WPF.Controls.ColorBlender</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<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.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xaml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ColorBlender.xaml.cs">
|
||||
<DependentUpon>ColorBlender.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Extensions.cs" />
|
||||
<Compile Include="HtmlColorConverter.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Swatch.xaml.cs">
|
||||
<DependentUpon>Swatch.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Page Include="ColorBlender.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Swatch.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ColorBlender.Colors\ColorBlender.Colors.csproj">
|
||||
<Project>{225ba82d-b228-44d0-b8ba-2c5462394f2c}</Project>
|
||||
<Name>ColorBlender.Colors</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\ColorBlender\ColorBlender.csproj">
|
||||
<Project>{b52c44ba-d099-42e8-94a7-5234e08480fd}</Project>
|
||||
<Name>ColorBlender</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -1,11 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks>net5.0;net461</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Rx.props" />
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\XUnit.props" />
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
|
||||
<TargetFrameworks>net5.0;net461</TargetFrameworks>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\Rx.props" />
|
||||
<Import Project="$(MSBuildThisFileDirectory)..\..\build\XUnit.props" />
|
||||
|
||||
<ItemGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче