Skip to content

Commit 46ac9ef

Browse files
authored
Merge pull request #78 from MaterialDesignInXAML/master
Update
2 parents ef85c81 + 8304e64 commit 46ac9ef

File tree

85 files changed

+9649
-132
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+9649
-132
lines changed

.github/workflows/get_versions.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ jobs:
2323
getting_versions:
2424
env:
2525
#Update these base version numbers
26-
mdix-version: "5.3.0"
27-
mdix-colors-version: "5.3.0"
28-
mdix-mahapps-version: "5.3.0"
26+
mdix-version: "5.3.1"
27+
mdix-colors-version: "5.3.1"
28+
mdix-mahapps-version: "5.3.1"
2929
name: Set version numbers
3030
runs-on: ubuntu-latest
3131
defaults:

.github/workflows/pr_verification.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
contents: write
3030

3131
steps:
32-
- uses: fastify/github-action-merge-dependabot@v3.11.1
32+
- uses: fastify/github-action-merge-dependabot@v3.11.2

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ jobs:
305305
Update-Version -Prefix "mdix-mahapps-version"
306306
307307
- name: Open Pull Request
308+
env:
309+
GH_TOKEN: ${{ secrets.SA_PAT }}
308310
run: |
309311
git config --local user.email "github-actions[bot]@users.noreply.github.com"
310312
git config --local user.name "github-actions[bot]"

Directory.packages.props

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,8 @@
2929
<PackageVersion Include="TUnit" Version="0.25.21" />
3030
<PackageVersion Include="VirtualizingWrapPanel" Version="1.5.8" />
3131
<PackageVersion Include="XAMLTest" Version="1.3.0-ci616" />
32+
<PackageVersion Include="System.Memory" Version="4.6.3" />
33+
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
34+
<PackageVersion Include="Polyfill" Version="8.8.1" />
3235
</ItemGroup>
3336
</Project>

MaterialDesignToolkit.Full.sln

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MaterialDesign3Demo", "src\
6363
EndProject
6464
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialDesignDemo.Shared", "src\MaterialDesignDemo.Shared\MaterialDesignDemo.Shared.csproj", "{B39795A7-D66A-4F2F-9F41-050838D14048}"
6565
EndProject
66+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialColorUtilities", "src\MaterialDesign3.MaterialColorUtilities\MaterialColorUtilities.csproj", "{2C29B80E-1689-43CE-85AC-71799666B4AC}"
67+
EndProject
68+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MaterialColorUtilities.Tests", "tests\MaterialColorUtilities.Tests\MaterialColorUtilities.Tests.csproj", "{91485BEA-759F-406E-87B7-68D94CF66DE4}"
69+
EndProject
6670
Global
6771
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6872
Debug|Any CPU = Debug|Any CPU
@@ -251,6 +255,38 @@ Global
251255
{B39795A7-D66A-4F2F-9F41-050838D14048}.Release|x64.Build.0 = Release|Any CPU
252256
{B39795A7-D66A-4F2F-9F41-050838D14048}.Release|x86.ActiveCfg = Release|Any CPU
253257
{B39795A7-D66A-4F2F-9F41-050838D14048}.Release|x86.Build.0 = Release|Any CPU
258+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
259+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
260+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Debug|ARM.ActiveCfg = Debug|Any CPU
261+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Debug|ARM.Build.0 = Debug|Any CPU
262+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Debug|x64.ActiveCfg = Debug|Any CPU
263+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Debug|x64.Build.0 = Debug|Any CPU
264+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Debug|x86.ActiveCfg = Debug|Any CPU
265+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Debug|x86.Build.0 = Debug|Any CPU
266+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
267+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Release|Any CPU.Build.0 = Release|Any CPU
268+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Release|ARM.ActiveCfg = Release|Any CPU
269+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Release|ARM.Build.0 = Release|Any CPU
270+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Release|x64.ActiveCfg = Release|Any CPU
271+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Release|x64.Build.0 = Release|Any CPU
272+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Release|x86.ActiveCfg = Release|Any CPU
273+
{2C29B80E-1689-43CE-85AC-71799666B4AC}.Release|x86.Build.0 = Release|Any CPU
274+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
275+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Debug|Any CPU.Build.0 = Debug|Any CPU
276+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Debug|ARM.ActiveCfg = Debug|Any CPU
277+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Debug|ARM.Build.0 = Debug|Any CPU
278+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Debug|x64.ActiveCfg = Debug|Any CPU
279+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Debug|x64.Build.0 = Debug|Any CPU
280+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Debug|x86.ActiveCfg = Debug|Any CPU
281+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Debug|x86.Build.0 = Debug|Any CPU
282+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Release|Any CPU.ActiveCfg = Release|Any CPU
283+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Release|Any CPU.Build.0 = Release|Any CPU
284+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Release|ARM.ActiveCfg = Release|Any CPU
285+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Release|ARM.Build.0 = Release|Any CPU
286+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Release|x64.ActiveCfg = Release|Any CPU
287+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Release|x64.Build.0 = Release|Any CPU
288+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Release|x86.ActiveCfg = Release|Any CPU
289+
{91485BEA-759F-406E-87B7-68D94CF66DE4}.Release|x86.Build.0 = Release|Any CPU
254290
EndGlobalSection
255291
GlobalSection(SolutionProperties) = preSolution
256292
HideSolutionNode = FALSE
@@ -262,6 +298,8 @@ Global
262298
{18401177-A30E-4330-8F6B-101DF876CE99} = {55087897-5F09-45CA-8E12-12B36B45F262}
263299
{98627CBE-F009-482E-97E9-C69C7135E91F} = {D34BE232-DE51-43C1-ABDC-B69003BB50FF}
264300
{B39795A7-D66A-4F2F-9F41-050838D14048} = {D34BE232-DE51-43C1-ABDC-B69003BB50FF}
301+
{2C29B80E-1689-43CE-85AC-71799666B4AC} = {9E303A4A-3712-44B9-91EE-830FDC087795}
302+
{91485BEA-759F-406E-87B7-68D94CF66DE4} = {9E303A4A-3712-44B9-91EE-830FDC087795}
265303
EndGlobalSection
266304
GlobalSection(ExtensibilityGlobals) = postSolution
267305
SolutionGuid = {730B2F9E-74AE-46CE-9E61-89AA5C6D5DD3}

src/MainDemo.Wpf/Fields.xaml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<sys:Double x:Key="FieldWidth">200</sys:Double>
2020
<Thickness x:Key="IconMargin">0,0,8,0</Thickness>
2121
<converters:ColorToBrushConverter x:Key="ColorToBrushConverter" />
22+
<converters:BoolToTextWrappingConverter x:Key="BoolToTextWrappingConverter" />
2223

2324
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource MaterialDesignTextBox}">
2425
<Setter Property="Margin" Value="0,8" />
@@ -172,15 +173,28 @@
172173

173174
<StackPanel>
174175
<smtx:XamlDisplay Margin="0,0,0,32" UniqueKey="fields_3">
175-
<TextBox Height="80"
176-
MinWidth="280"
177-
VerticalAlignment="Stretch"
178-
materialDesign:HintAssist.Hint="Multiline text"
179-
AcceptsReturn="True"
180-
SpellCheck.IsEnabled="True"
181-
Text="Multiline. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. The quick brown fox jumps over the lazy dog. War and peace. Keep going. Go on. For how long? Not long. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
182-
TextWrapping="Wrap"
183-
VerticalScrollBarVisibility="Auto" />
176+
<Grid>
177+
<Grid.RowDefinitions>
178+
<RowDefinition Height="Auto" />
179+
<RowDefinition />
180+
</Grid.RowDefinitions>
181+
182+
<CheckBox x:Name="TextBoxWrapTextCheckBox"
183+
Content="Wrap text"
184+
IsChecked="True" />
185+
186+
<TextBox Grid.Row="1"
187+
Height="80"
188+
MinWidth="280"
189+
VerticalAlignment="Stretch"
190+
materialDesign:HintAssist.Hint="Multiline text"
191+
AcceptsReturn="True"
192+
SpellCheck.IsEnabled="True"
193+
Text="Multiline. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. The quick brown fox jumps over the lazy dog. War and peace. Keep going. Go on. For how long? Not long. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
194+
TextWrapping="{Binding ElementName=TextBoxWrapTextCheckBox, Path=IsChecked, Converter={StaticResource BoolToTextWrappingConverter}}"
195+
VerticalScrollBarVisibility="Auto"
196+
HorizontalScrollBarVisibility="Auto"/>
197+
</Grid>
184198
</smtx:XamlDisplay>
185199

186200
<smtx:XamlDisplay UniqueKey="fields_32">

src/MainDemo.Wpf/Pickers.xaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@
441441
Margin="0 0 0 8" />
442442

443443
<smtx:XamlDisplay UniqueKey="calendar_1">
444-
<Calendar />
444+
<Calendar IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" />
445445
</smtx:XamlDisplay>
446446
</StackPanel>
447447

@@ -470,6 +470,7 @@
470470
</Grid.Resources>
471471
<Calendar materialDesign:CalendarAssist.HeaderBackground="{DynamicResource PrimaryHueDarkBrush}"
472472
materialDesign:CalendarAssist.HeaderForeground="{DynamicResource PrimaryHueDarkForegroundBrush}"
473+
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
473474
Background="{DynamicResource PrimaryHueLightBrush}"
474475
CalendarButtonStyle="{StaticResource SecondaryCalendarButton}"
475476
CalendarDayButtonStyle="{StaticResource SecondaryCalendarDayButton}"
@@ -502,6 +503,7 @@
502503
</Style>
503504
</Grid.Resources>
504505
<Calendar materialDesign:CalendarAssist.HeaderBackground="#A2E9FF"
506+
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
505507
materialDesign:CalendarAssist.HeaderForeground="Black"
506508
Background="#343C3F"
507509
CalendarButtonStyle="{StaticResource CustomCalendarButton}"
@@ -515,7 +517,7 @@
515517
<TextBlock Text="Horizontal"
516518
Margin=" 0 0 0 8" />
517519
<smtx:XamlDisplay UniqueKey="calendar_4">
518-
<Calendar materialDesign:CalendarAssist.Orientation="Horizontal" />
520+
<Calendar materialDesign:CalendarAssist.Orientation="Horizontal" IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" />
519521
</smtx:XamlDisplay>
520522
</StackPanel>
521523

@@ -524,6 +526,7 @@
524526
Margin="0 0 0 8" />
525527
<smtx:XamlDisplay UniqueKey="calendar_5">
526528
<Calendar materialDesign:ElevationAssist.Elevation="Dp8"
529+
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
527530
Style="{StaticResource MaterialDesignCalendarPortraitForeground}" />
528531
</smtx:XamlDisplay>
529532
</StackPanel>

src/MaterialDesign3.Demo.Wpf/Pickers.xaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@
341341
</Grid.RowDefinitions>
342342

343343
<StackPanel Grid.Row="0" Orientation="Horizontal">
344-
<Calendar x:Name="CombinedCalendar" Margin="-1,-4,-1,0" />
344+
<Calendar x:Name="CombinedCalendar"
345+
Margin="-1,-4,-1,0"
346+
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" />
345347

346348
<materialDesign:Clock x:Name="CombinedClock"
347349
DisplayAutomation="CycleWithSeconds"
@@ -378,7 +380,7 @@
378380
Header="Default"
379381
Style="{StaticResource MaterialDesignCardGroupBox}">
380382
<smtx:XamlDisplay UniqueKey="calendar_1">
381-
<Calendar />
383+
<Calendar IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" />
382384
</smtx:XamlDisplay>
383385
</GroupBox>
384386

@@ -405,6 +407,7 @@
405407
</Grid.Resources>
406408
<Calendar materialDesign:CalendarAssist.HeaderBackground="{DynamicResource MaterialDesign.Brush.Primary.Dark}"
407409
materialDesign:CalendarAssist.HeaderForeground="{DynamicResource MaterialDesign.Brush.Primary.Dark.Foreground}"
410+
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
408411
Background="{DynamicResource MaterialDesign.Brush.Primary.Light}"
409412
CalendarButtonStyle="{StaticResource SecondaryCalendarButton}"
410413
CalendarDayButtonStyle="{StaticResource SecondaryCalendarDayButton}"
@@ -436,6 +439,7 @@
436439
</Grid.Resources>
437440
<Calendar materialDesign:CalendarAssist.HeaderBackground="#A2E9FF"
438441
materialDesign:CalendarAssist.HeaderForeground="Black"
442+
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}"
439443
Background="#343C3F"
440444
CalendarButtonStyle="{StaticResource CustomCalendarButton}"
441445
CalendarDayButtonStyle="{StaticResource CustomCalendarDayButton}"
@@ -451,7 +455,7 @@
451455
Header="Horizontal"
452456
Style="{StaticResource MaterialDesignCardGroupBox}">
453457
<smtx:XamlDisplay UniqueKey="calendar_4">
454-
<Calendar materialDesign:CalendarAssist.Orientation="Horizontal" />
458+
<Calendar materialDesign:CalendarAssist.Orientation="Horizontal" IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" />
455459
</smtx:XamlDisplay>
456460
</GroupBox>
457461

@@ -463,7 +467,9 @@
463467
Header="Transparent Header and shadow"
464468
Style="{StaticResource MaterialDesignCardGroupBox}">
465469
<smtx:XamlDisplay UniqueKey="calendar_5">
466-
<Calendar materialDesign:ElevationAssist.Elevation="Dp8" Style="{StaticResource MaterialDesignCalendarPortraitForeground}" />
470+
<Calendar materialDesign:ElevationAssist.Elevation="Dp8"
471+
Style="{StaticResource MaterialDesignCalendarPortraitForeground}"
472+
IsEnabled="{Binding DataContext.ControlsEnabled, RelativeSource={RelativeSource FindAncestor, AncestorType=Window}}" />
467473
</smtx:XamlDisplay>
468474
</GroupBox>
469475

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
using static System.Math;
2+
using static MaterialColorUtilities.MathUtils;
3+
4+
namespace MaterialColorUtilities;
5+
6+
/// <summary>
7+
/// Functions for blending in HCT and CAM16.
8+
/// </summary>
9+
public static class Blend
10+
{
11+
/// <summary>
12+
/// Blend the design color's HCT hue towards the key color's HCT hue, in a way that
13+
/// leaves the original color recognizable and recognizably shifted towards the key color.
14+
/// </summary>
15+
/// <param name="designColor">ARGB representation of an arbitrary color.</param>
16+
/// <param name="sourceColor">ARGB representation of the main theme color.</param>
17+
/// <returns>
18+
/// The design color with a hue shifted towards the system's color, a slightly
19+
/// warmer/cooler variant of the design color's hue.
20+
/// </returns>
21+
public static int Harmonize(int designColor, int sourceColor)
22+
{
23+
var fromHct = Hct.FromInt(designColor);
24+
var toHct = Hct.FromInt(sourceColor);
25+
double differenceDegrees = DifferenceDegrees(fromHct.Hue, toHct.Hue);
26+
double rotationDegrees = Min(differenceDegrees * 0.5, 15.0);
27+
double outputHue = SanitizeDegreesDouble(
28+
fromHct.Hue + rotationDegrees * RotationDirection(fromHct.Hue, toHct.Hue));
29+
return Hct.From(outputHue, fromHct.Chroma, fromHct.Tone).Argb;
30+
}
31+
32+
/// <summary>
33+
/// Blends hue from one color into another. The chroma and tone of the original color are maintained.
34+
/// </summary>
35+
/// <param name="from">ARGB representation of color.</param>
36+
/// <param name="to">ARGB representation of color.</param>
37+
/// <param name="amount">How much blending to perform; 0.0 &gt;= and &lt;= 1.0.</param>
38+
/// <returns>
39+
/// <paramref name="from"/> with a hue blended towards <paramref name="to"/>.
40+
/// Chroma and tone are constant.
41+
/// </returns>
42+
public static int HctHue(int from, int to, double amount)
43+
{
44+
int ucs = Cam16Ucs(from, to, amount);
45+
var ucsCam = Cam16.FromInt(ucs);
46+
var fromCam = Cam16.FromInt(from);
47+
var blended = Hct.From(ucsCam.GetHue(), fromCam.GetChroma(), ColorUtils.LstarFromArgb(from));
48+
return blended.Argb;
49+
}
50+
51+
/// <summary>
52+
/// Blend in CAM16-UCS space.
53+
/// </summary>
54+
/// <param name="from">ARGB representation of color.</param>
55+
/// <param name="to">ARGB representation of color.</param>
56+
/// <param name="amount">How much blending to perform; 0.0 &gt;= and &lt;= 1.0.</param>
57+
/// <returns>
58+
/// <paramref name="from"/>, blended towards <paramref name="to"/>. Hue, chroma, and tone will change.
59+
/// </returns>
60+
public static int Cam16Ucs(int from, int to, double amount)
61+
{
62+
var fromCam = Cam16.FromInt(from);
63+
var toCam = Cam16.FromInt(to);
64+
double fromJ = fromCam.GetJstar();
65+
double fromA = fromCam.GetAstar();
66+
double fromB = fromCam.GetBstar();
67+
double toJ = toCam.GetJstar();
68+
double toA = toCam.GetAstar();
69+
double toB = toCam.GetBstar();
70+
double jstar = fromJ + (toJ - fromJ) * amount;
71+
double astar = fromA + (toA - fromA) * amount;
72+
double bstar = fromB + (toB - fromB) * amount;
73+
return Cam16.FromUcs(jstar, astar, bstar).ToInt();
74+
}
75+
}

0 commit comments

Comments
 (0)