Skip to content

Commit

Permalink
Fix Clock, CalendarWithClock and DateTimePicker
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1372 committed Dec 21, 2024
1 parent ef6c5d4 commit d340390
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
namespace DevWinUI;
public partial class CalendarWithClock
{
public CornerRadius ClockCornerRadius
{
get { return (CornerRadius)GetValue(ClockCornerRadiusProperty); }
set { SetValue(ClockCornerRadiusProperty, value); }
}

public static readonly DependencyProperty ClockCornerRadiusProperty =
DependencyProperty.Register(nameof(ClockCornerRadius), typeof(CornerRadius), typeof(CalendarWithClock), new PropertyMetadata(new CornerRadius(0, 4, 4, 0)));

public CornerRadius CalendarViewCornerRadius
{
get { return (CornerRadius)GetValue(CalendarViewCornerRadiusProperty); }
set { SetValue(CalendarViewCornerRadiusProperty, value); }
}

public static readonly DependencyProperty CalendarViewCornerRadiusProperty =
DependencyProperty.Register(nameof(CalendarViewCornerRadius), typeof(CornerRadius), typeof(CalendarWithClock), new PropertyMetadata(new CornerRadius(4, 0, 0, 4)));

public ClockMode ClockMode
{
get { return (ClockMode)GetValue(ClockModeProperty); }
Expand Down
8 changes: 8 additions & 0 deletions dev/DevWinUI.Controls/Controls/Date/Clock/Clock.Property.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
namespace DevWinUI;
public partial class Clock
{
public static readonly DependencyProperty ClockCornerRadiusProperty =
DependencyProperty.Register(nameof(ClockCornerRadius), typeof(CornerRadius), typeof(Clock), new PropertyMetadata(new CornerRadius(0)));
public CornerRadius ClockCornerRadius
{
get { return (CornerRadius)GetValue(ClockCornerRadiusProperty); }
set { SetValue(ClockCornerRadiusProperty, value); }
}

public static readonly DependencyProperty SelectedTimeProperty = DependencyProperty.Register(
nameof(SelectedTime), typeof(DateTime), typeof(Clock), new PropertyMetadata(DateTime.Now, OnSelectedTimeChanged));
public DateTime SelectedTime
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,16 @@ public bool ShowConfirmButton
}

public static readonly DependencyProperty ShowConfirmButtonProperty =
DependencyProperty.Register(nameof(ShowConfirmButton), typeof(bool), typeof(DateTimePicker), new PropertyMetadata(true));
DependencyProperty.Register(nameof(ShowConfirmButton), typeof(bool), typeof(DateTimePicker), new PropertyMetadata(true, OnShowConfirmButtonChanged));

private static void OnShowConfirmButtonChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (DateTimePicker)d;
if (ctl != null)
{
ctl.UpdateTemplate();
}
}

public TimeSpan? SelectedTime
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,23 @@ private void UpdateTemplate()
{
FlyoutBorderThickness = new Thickness(1);
FlyoutCornerRadius = new CornerRadius(4);
calendarWithClock.CalendarViewCornerRadius = new CornerRadius(4, 0, 0, 4);
calendarWithClock.ClockCornerRadius = new CornerRadius(0, 4, 4, 0);
}
else
{
FlyoutBorderThickness = new Thickness(0);
FlyoutCornerRadius = new CornerRadius(0);
if (ShowConfirmButton)
{
calendarWithClock.CalendarViewCornerRadius = new CornerRadius(4, 0, 0, 0);
calendarWithClock.ClockCornerRadius = new CornerRadius(0, 4, 0, 0);
}
else
{
calendarWithClock.CalendarViewCornerRadius = new CornerRadius(4, 0, 0, 4);
calendarWithClock.ClockCornerRadius = new CornerRadius(0, 4, 4, 0);
}
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions dev/DevWinUI.Controls/Themes/Generic.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ Themes\Styles\Win2D\Watermark.xaml
<Setter Property="Margin" Value="8,0" />
<Setter Property="BorderBrush" Value="{ThemeResource CalendarViewBorderBrush}" />
<Setter Property="Background" Value="{ThemeResource CalendarViewBackground}" />
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
<Setter Property="ClockCornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
<Setter Property="TitleBorderCornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
<Setter Property="TitleBorderBackground" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
<Setter Property="MinuteHandBackground" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
Expand All @@ -459,7 +459,7 @@ Themes\Styles\Win2D\Watermark.xaml
<Setter.Value>
<ControlTemplate TargetType="local:Clock">
<Grid HorizontalAlignment="{TemplateBinding HorizontalAlignment}" VerticalAlignment="{TemplateBinding VerticalAlignment}">
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding CornerRadius}" />
<Border Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding ClockCornerRadius}" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="53" />
Expand Down Expand Up @@ -3378,8 +3378,8 @@ Themes\Styles\Win2D\Watermark.xaml
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="Background" Grid.Column="0" Grid.ColumnSpan="2" MinHeight="32" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Control.IsTemplateFocusTarget="True" CornerRadius="{TemplateBinding CornerRadius}" />
<CalendarView x:Name="PART_CalendarView" Grid.Column="0" Margin="{TemplateBinding CalendarViewMargin}" BorderThickness="{TemplateBinding CalendarViewBorderThickness}" CalendarIdentifier="{TemplateBinding CalendarIdentifier}" CornerRadius="4,0,0,4" DayOfWeekFormat="{TemplateBinding DayOfWeekFormat}" DisplayMode="{TemplateBinding DisplayMode}" FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}" IsGroupLabelVisible="{TemplateBinding IsGroupLabelVisible}" IsOutOfScopeEnabled="{TemplateBinding IsOutOfScopeEnabled}" IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" MaxDate="{TemplateBinding MaxDate}" MinDate="{TemplateBinding MinDate}" Style="{TemplateBinding CalendarViewStyle}" />
<local:Clock x:Name="PART_Clock" Grid.Column="1" Margin="{TemplateBinding ClockMargin}" BorderThickness="{TemplateBinding ClockBorderThickness}" CornerRadius="0,4,4,0" />
<CalendarView x:Name="PART_CalendarView" Grid.Column="0" Margin="{TemplateBinding CalendarViewMargin}" BorderThickness="{TemplateBinding CalendarViewBorderThickness}" CalendarIdentifier="{TemplateBinding CalendarIdentifier}" CornerRadius="{TemplateBinding CalendarViewCornerRadius}" DayOfWeekFormat="{TemplateBinding DayOfWeekFormat}" DisplayMode="{TemplateBinding DisplayMode}" FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}" IsGroupLabelVisible="{TemplateBinding IsGroupLabelVisible}" IsOutOfScopeEnabled="{TemplateBinding IsOutOfScopeEnabled}" IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}" MaxDate="{TemplateBinding MaxDate}" MinDate="{TemplateBinding MinDate}" Style="{TemplateBinding CalendarViewStyle}" />
<local:Clock x:Name="PART_Clock" Grid.Column="1" Margin="{TemplateBinding ClockMargin}" BorderThickness="{TemplateBinding ClockBorderThickness}" ClockCornerRadius="{TemplateBinding ClockCornerRadius}" />
</Grid>
</ControlTemplate>
<ControlTemplate x:Key="CalendarWithTimePickerTemplate" TargetType="local:CalendarWithClock">
Expand Down Expand Up @@ -6201,6 +6201,8 @@ Themes\Styles\Win2D\Watermark.xaml
<Setter Property="CalendarViewBorderThickness" Value="1" />
<Setter Property="ClockBorderThickness" Value="0,1,1,1" />
<Setter Property="ClockMode" Value="AnalogClock" />
<Setter Property="CalendarViewCornerRadius" Value="4,0,0,4" />
<Setter Property="ClockCornerRadius" Value="0,4,4,0" />
<Setter Property="Template" Value="{StaticResource CalendarWithAnalogClockTemplate}" />
</Style>
<Style BasedOn="{StaticResource DefaultCopyButtonStyle}" TargetType="local:CopyButton">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
<Setter Property="CalendarViewBorderThickness" Value="1" />
<Setter Property="ClockBorderThickness" Value="0,1,1,1" />
<Setter Property="ClockMode" Value="AnalogClock" />
<Setter Property="CalendarViewCornerRadius" Value="4,0,0,4" />
<Setter Property="ClockCornerRadius" Value="0,4,4,0" />
<Setter Property="Template" Value="{StaticResource CalendarWithAnalogClockTemplate}" />
</Style>

Expand Down Expand Up @@ -123,7 +125,7 @@
Margin="{TemplateBinding CalendarViewMargin}"
BorderThickness="{TemplateBinding CalendarViewBorderThickness}"
CalendarIdentifier="{TemplateBinding CalendarIdentifier}"
CornerRadius="4,0,0,4"
CornerRadius="{TemplateBinding CalendarViewCornerRadius}"
DayOfWeekFormat="{TemplateBinding DayOfWeekFormat}"
DisplayMode="{TemplateBinding DisplayMode}"
FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}"
Expand All @@ -137,7 +139,7 @@
Grid.Column="1"
Margin="{TemplateBinding ClockMargin}"
BorderThickness="{TemplateBinding ClockBorderThickness}"
CornerRadius="0,4,4,0" />
ClockCornerRadius="{TemplateBinding ClockCornerRadius}" />
</Grid>
</ControlTemplate>

Expand Down
4 changes: 2 additions & 2 deletions dev/DevWinUI.Controls/Themes/Styles/Controls/Clock.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<Setter Property="Margin" Value="8,0" />
<Setter Property="BorderBrush" Value="{ThemeResource CalendarViewBorderBrush}" />
<Setter Property="Background" Value="{ThemeResource CalendarViewBackground}" />
<Setter Property="CornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
<Setter Property="ClockCornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
<Setter Property="TitleBorderCornerRadius" Value="{ThemeResource OverlayCornerRadius}" />
<Setter Property="TitleBorderBackground" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
<Setter Property="MinuteHandBackground" Value="{ThemeResource SystemControlHighlightAccentBrush}" />
Expand All @@ -59,7 +59,7 @@
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" />
CornerRadius="{TemplateBinding ClockCornerRadius}" />
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="53" />
Expand Down

0 comments on commit d340390

Please sign in to comment.