Skip to content

Commit 8742c6e

Browse files
committed
Merge pull request #89 from l1pton17/DateTimePickerAnimation
Animate DatePicker
2 parents c3c1634 + 61d435c commit 8742c6e

File tree

6 files changed

+290
-103
lines changed

6 files changed

+290
-103
lines changed

MaterialDesignThemes.Wpf/MaterialDateDisplay.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public class MaterialDateDisplay : Control
2222
private readonly IDictionary<char, string> _formats = new Dictionary<char, string>
2323
{
2424
{'d', "dd"},
25-
{'m', "MMM"},
25+
{'m', "ddd, MMM"},
2626
{'y', "yyyy"}
2727
};
2828

@@ -122,7 +122,7 @@ private void UpdateComponents()
122122
{
123123
if (component.index == 0)
124124
IsDayInFirstComponent = component.code == 'd';
125-
_setters[component.index](DisplayDate.ToString(_formats[component.code], CultureInfo.CurrentUICulture).ToUpper());
125+
_setters[component.index](DisplayDate.ToString(_formats[component.code], CultureInfo.CurrentUICulture).ToTitleCase());
126126
}
127127
}
128128

MaterialDesignThemes.Wpf/MaterialDesignThemes.Wpf.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,7 @@
251251
<Compile Include="RatingBar.cs" />
252252
<Compile Include="RatingBarButton.cs" />
253253
<Compile Include="ShadowAssist.cs" />
254+
<Compile Include="StringExtensions.cs" />
254255
<Compile Include="TextFieldAssist.cs" />
255256
<Compile Include="Converters\TextFieldHintVisibilityConverter.cs" />
256257
<Compile Include="TimePicker.cs" />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace MaterialDesignThemes.Wpf
9+
{
10+
internal static class StringExtensions
11+
{
12+
public static string ToTitleCase(this string text, string separator = " ")
13+
{
14+
TextInfo textInfo = CultureInfo.CurrentUICulture.TextInfo;
15+
16+
string lowerText = textInfo.ToLower(text);
17+
string[] words = lowerText.Split(new[] { separator }, StringSplitOptions.None);
18+
19+
return String.Join(separator, words.Select(v => textInfo.ToTitleCase(v)));
20+
}
21+
}
22+
}

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -202,34 +202,33 @@
202202
<Border Background="{TemplateBinding Background}"
203203
BorderBrush="{TemplateBinding BorderBrush}"
204204
BorderThickness="{TemplateBinding BorderThickness}">
205-
<StackPanel>
206-
<TextBlock Text="{TemplateBinding ComponentOneContent}" HorizontalAlignment="Center" Margin="0 12 0 0" FontSize="24" FontWeight="Normal" />
207-
<TextBlock Text="{TemplateBinding ComponentTwoContent}" HorizontalAlignment="Center" Margin="0 -6 0 0" FontSize="60" FontWeight="Normal" />
208-
<TextBlock Text="{TemplateBinding ComponentThreeContent}" HorizontalAlignment="Center" Margin="0 -4 0 10" FontSize="24" Opacity=".56" FontWeight="Normal" />
205+
<StackPanel Orientation="Vertical"
206+
Margin="0">
207+
<TextBlock x:Name="ComponentThreeTextBlock"
208+
Text="{TemplateBinding ComponentThreeContent}"
209+
HorizontalAlignment="Left"
210+
FontSize="15" FontWeight="Normal" />
211+
<StackPanel x:Name="ComponentOneTwoWrapper" Orientation="Horizontal"
212+
HorizontalAlignment="Left">
213+
<TextBlock Text="{TemplateBinding ComponentTwoContent}" FontSize="30" FontWeight="Normal" />
214+
<TextBlock Text="{TemplateBinding ComponentOneContent}" Margin="10 0 0 0" FontSize="30" FontWeight="Normal" />
215+
</StackPanel>
209216
</StackPanel>
210217
</Border>
218+
<ControlTemplate.Triggers>
219+
<Trigger Property="IsDayInFirstComponent" Value="True">
220+
<Setter TargetName="ComponentThreeTextBlock" Property="Opacity" Value=".56"/>
221+
</Trigger>
222+
<Trigger Property="IsEnabled" Value="False">
223+
<Setter TargetName="ComponentThreeTextBlock" Property="Opacity" Value="1"/>
224+
<Setter TargetName="ComponentOneTwoWrapper" Property="Opacity" Value=".56"/>
225+
</Trigger>
226+
</ControlTemplate.Triggers>
211227
</ControlTemplate>
212228
</Setter.Value>
213229
</Setter>
214230
<Style.Triggers>
215-
<Trigger Property="IsDayInFirstComponent" Value="True">
216-
<Setter Property="Template">
217-
<Setter.Value>
218-
<ControlTemplate TargetType="{x:Type local:MaterialDateDisplay}">
219-
<Border Background="{TemplateBinding Background}"
220-
BorderBrush="{TemplateBinding BorderBrush}"
221-
BorderThickness="{TemplateBinding BorderThickness}">
222-
<StackPanel>
223-
<TextBlock Text="{TemplateBinding ComponentOneContent}" HorizontalAlignment="Center" Margin="0 4 0 0" FontSize="60" FontWeight="Normal" />
224-
<TextBlock Text="{TemplateBinding ComponentTwoContent}" HorizontalAlignment="Center" Margin="0 -4 0 0" FontSize="24" FontWeight="Normal" />
225-
<TextBlock Text="{TemplateBinding ComponentThreeContent}" HorizontalAlignment="Center" Margin="0 4 0 10" FontSize="24" Opacity=".56" FontWeight="Normal" />
226-
</StackPanel>
227-
</Border>
228-
</ControlTemplate>
229-
</Setter.Value>
230-
</Setter>
231-
</Trigger>
232-
</Style.Triggers>
231+
</Style.Triggers>
233232
</Style>
234233

235234
<Style TargetType="{x:Type local:ListSortDirectionIndicator}">

0 commit comments

Comments
 (0)