Skip to content

Commit 973d124

Browse files
committed
Palette utilities, and sample selector. C#6.0. Colors are now v1!!!
1 parent b4eacf6 commit 973d124

19 files changed

+663
-35
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props" Condition="Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" />
4+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
5+
<PropertyGroup>
6+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8+
<ProjectGuid>{FD1D557A-251C-4D00-9FDE-6FF9FFA747B8}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>MaterialDesignColors.Wpf.Fixture</RootNamespace>
12+
<AssemblyName>MaterialDesignColors.Wpf.Fixture</AssemblyName>
13+
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<NuGetPackageImportStamp>
16+
</NuGetPackageImportStamp>
17+
</PropertyGroup>
18+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19+
<DebugSymbols>true</DebugSymbols>
20+
<DebugType>full</DebugType>
21+
<Optimize>false</Optimize>
22+
<OutputPath>bin\Debug\</OutputPath>
23+
<DefineConstants>DEBUG;TRACE</DefineConstants>
24+
<ErrorReport>prompt</ErrorReport>
25+
<WarningLevel>4</WarningLevel>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="Shouldly, Version=2.5.0.0, Culture=neutral, PublicKeyToken=6042cbcb05cbc941, processorArchitecture=MSIL">
37+
<HintPath>..\packages\Shouldly.2.5.0\lib\net40\Shouldly.dll</HintPath>
38+
<Private>True</Private>
39+
</Reference>
40+
<Reference Include="System" />
41+
<Reference Include="System.Core" />
42+
<Reference Include="System.Xml.Linq" />
43+
<Reference Include="System.Data.DataSetExtensions" />
44+
<Reference Include="Microsoft.CSharp" />
45+
<Reference Include="System.Data" />
46+
<Reference Include="System.Net.Http" />
47+
<Reference Include="System.Xml" />
48+
<Reference Include="xunit.abstractions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
49+
<HintPath>..\packages\xunit.abstractions.2.0.0\lib\net35\xunit.abstractions.dll</HintPath>
50+
<Private>True</Private>
51+
</Reference>
52+
<Reference Include="xunit.assert, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
53+
<HintPath>..\packages\xunit.assert.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.assert.dll</HintPath>
54+
<Private>True</Private>
55+
</Reference>
56+
<Reference Include="xunit.core, Version=2.0.0.2929, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
57+
<HintPath>..\packages\xunit.extensibility.core.2.0.0\lib\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.dll</HintPath>
58+
<Private>True</Private>
59+
</Reference>
60+
</ItemGroup>
61+
<ItemGroup>
62+
<Compile Include="ResourceProviderFixture.cs" />
63+
<Compile Include="Properties\AssemblyInfo.cs" />
64+
</ItemGroup>
65+
<ItemGroup>
66+
<None Include="packages.config" />
67+
</ItemGroup>
68+
<ItemGroup>
69+
<ProjectReference Include="..\MaterialDesignColors.Wpf\MaterialDesignColors.Wpf.csproj">
70+
<Project>{90B53209-C60C-4655-B28D-A1B3E1044BA3}</Project>
71+
<Name>MaterialDesignColors.Wpf</Name>
72+
</ProjectReference>
73+
</ItemGroup>
74+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
75+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
76+
<PropertyGroup>
77+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
78+
</PropertyGroup>
79+
<Error Condition="!Exists('..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\xunit.core.2.0.0\build\portable-net45+win+wpa81+wp80+monotouch+monoandroid+Xamarin.iOS\xunit.core.props'))" />
80+
</Target>
81+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
82+
Other similar extension points exist, see Microsoft.Common.targets.
83+
<Target Name="BeforeBuild">
84+
</Target>
85+
<Target Name="AfterBuild">
86+
</Target>
87+
-->
88+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("MaterialDesignColors.Wpf.Fixture")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("MaterialDesignColors.Wpf.Fixture")]
13+
[assembly: AssemblyCopyright("Copyright © 2015")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("fd1d557a-251c-4d00-9fde-6ff9ffa747b8")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using Shouldly;
7+
using Xunit;
8+
9+
namespace MaterialDesignColors.Wpf.Fixture
10+
{
11+
public class ResourceProviderFixture
12+
{
13+
[Fact]
14+
public void ExcludesBlack()
15+
{
16+
var swatchesProvider = new SwatchesProvider();
17+
18+
var containsBlack = swatchesProvider.Swatches.Any(
19+
swatch => string.Compare(swatch.Name, "Black", StringComparison.InvariantCultureIgnoreCase) == 0);
20+
21+
containsBlack.ShouldBe(false);
22+
}
23+
24+
[Fact]
25+
public void IncludesGrey()
26+
{
27+
var swatchesProvider = new SwatchesProvider();
28+
29+
var containsBlack = swatchesProvider.Swatches.Any(
30+
swatch => string.Compare(swatch.Name, "Grey", StringComparison.InvariantCultureIgnoreCase) == 0);
31+
32+
containsBlack.ShouldBe(true);
33+
}
34+
35+
[Fact]
36+
public void BrownHasNoAccents()
37+
{
38+
var swatchesProvider = new SwatchesProvider();
39+
40+
var brownSwatch = swatchesProvider.Swatches.Single(
41+
swatch => swatch.Name == "brown");
42+
43+
brownSwatch.IsAccented.ShouldBe(false);
44+
brownSwatch.AccentHues.ShouldNotBe(null);
45+
brownSwatch.AccentHues.Count().ShouldBe(0);
46+
}
47+
48+
[Fact]
49+
public void BrownHasPrimaries()
50+
{
51+
var swatchesProvider = new SwatchesProvider();
52+
53+
var brownSwatch = swatchesProvider.Swatches.Single(
54+
swatch => swatch.Name == "brown");
55+
56+
brownSwatch.IsAccented.ShouldBe(false);
57+
brownSwatch.PrimaryHues.ShouldNotBe(null);
58+
brownSwatch.PrimaryHues.Count().ShouldBe(10);
59+
}
60+
61+
[Fact]
62+
public void IndigoHasAccents()
63+
{
64+
var swatchesProvider = new SwatchesProvider();
65+
66+
var brownSwatch = swatchesProvider.Swatches.Single(
67+
swatch => swatch.Name == "indigo");
68+
69+
brownSwatch.IsAccented.ShouldBe(true);
70+
brownSwatch.AccentHues.ShouldNotBe(null);
71+
brownSwatch.AccentHues.Count().ShouldBe(4);
72+
}
73+
}
74+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Shouldly" version="2.5.0" targetFramework="net452" />
4+
<package id="xunit" version="2.0.0" targetFramework="net452" />
5+
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
6+
<package id="xunit.assert" version="2.0.0" targetFramework="net452" />
7+
<package id="xunit.core" version="2.0.0" targetFramework="net452" />
8+
<package id="xunit.extensibility.core" version="2.0.0" targetFramework="net452" />
9+
</packages>

MaterialDesignColors.Wpf/Hue.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using System.Windows.Media;
3+
4+
namespace MaterialDesignColors
5+
{
6+
public class Hue
7+
{
8+
public Hue(string name, Color color, Color foreground)
9+
{
10+
if (name == null) throw new ArgumentNullException(nameof(name));
11+
12+
Name = name;
13+
Color = color;
14+
Foreground = foreground;
15+
}
16+
17+
public string Name { get; }
18+
19+
public Color Color { get; }
20+
21+
public Color Foreground { get; }
22+
23+
public override string ToString()
24+
{
25+
return Name;
26+
}
27+
}
28+
}

MaterialDesignColors.Wpf/MaterialDesignColors.Wpf.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
<Reference Include="PresentationFramework" />
5858
</ItemGroup>
5959
<ItemGroup>
60+
<Compile Include="Hue.cs" />
6061
<Compile Include="Properties\AssemblyInfo.cs">
6162
<SubType>Code</SubType>
6263
</Compile>
@@ -70,6 +71,8 @@
7071
<DependentUpon>Settings.settings</DependentUpon>
7172
<DesignTimeSharedInput>True</DesignTimeSharedInput>
7273
</Compile>
74+
<Compile Include="Swatch.cs" />
75+
<Compile Include="SwatchesProvider.cs" />
7376
<EmbeddedResource Include="Properties\Resources.resx">
7477
<Generator>ResXFileCodeGenerator</Generator>
7578
<LastGenOutput>Resources.Designer.cs</LastGenOutput>

MaterialDesignColors.Wpf/Properties/AssemblyInfo.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// set of attributes. Change these attribute values to modify the information
99
// associated with an assembly.
1010
[assembly: AssemblyTitle("MaterialDesignColors.Wpf")]
11-
[assembly: AssemblyDescription("")]
11+
[assembly: AssemblyDescription("Material Design in XAML Toolkit - Colors")]
1212
[assembly: AssemblyConfiguration("")]
13-
[assembly: AssemblyCompany("")]
13+
[assembly: AssemblyCompany("Mulholland Software/James Willock")]
1414
[assembly: AssemblyProduct("MaterialDesignColors.Wpf")]
15-
[assembly: AssemblyCopyright("Copyright © 2015")]
15+
[assembly: AssemblyCopyright("Copyright © 2015")]
1616
[assembly: AssemblyTrademark("")]
1717
[assembly: AssemblyCulture("")]
1818

@@ -50,6 +50,5 @@
5050
//
5151
// You can specify all the values or you can default the Build and Revision Numbers
5252
// by using the '*' as shown below:
53-
// [assembly: AssemblyVersion("1.0.*")]
54-
[assembly: AssemblyVersion("1.0.0.0")]
55-
[assembly: AssemblyFileVersion("1.0.0.0")]
53+
// [assembly: AssemblyVersion("1.0.*")]
54+
[assembly: AssemblyVersion("1.0.0.*")]

MaterialDesignColors.Wpf/Swatch.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Runtime.InteropServices;
5+
using System.Text;
6+
using System.Windows;
7+
8+
namespace MaterialDesignColors
9+
{
10+
public class Swatch
11+
{
12+
public Swatch(string name, IEnumerable<Hue> primaryHues, IEnumerable<Hue> accentHues)
13+
{
14+
if (name == null) throw new ArgumentNullException(nameof(name));
15+
if (primaryHues == null) throw new ArgumentNullException(nameof(primaryHues));
16+
if (accentHues == null) throw new ArgumentNullException(nameof(accentHues));
17+
18+
var primaryHuesList = primaryHues.ToList();
19+
if (primaryHuesList.Count == 0) throw new ArgumentException("Non primary hues provided.", nameof(primaryHues));
20+
21+
Name = name;
22+
PrimaryHues = primaryHuesList;
23+
var accentHuesList = accentHues.ToList();
24+
AccentHues = accentHuesList;
25+
ExemplarHue = primaryHuesList[Math.Min(5, primaryHuesList.Count-1)];
26+
if (IsAccented)
27+
AccentExemplarHue = accentHuesList[Math.Min(2, accentHuesList.Count - 1)];
28+
}
29+
30+
public string Name { get; }
31+
32+
public Hue ExemplarHue { get; }
33+
34+
public Hue AccentExemplarHue { get; }
35+
36+
public IEnumerable<Hue> PrimaryHues { get; }
37+
38+
public IEnumerable<Hue> AccentHues { get; }
39+
40+
public bool IsAccented => AccentHues.Any();
41+
}
42+
}

0 commit comments

Comments
 (0)