feat: mock interaction.
This commit is contained in:
@@ -121,7 +121,7 @@
|
||||
</ControlTheme>
|
||||
|
||||
<ControlTheme x:Key="{x:Type u:Calendar}" TargetType="u:Calendar">
|
||||
<Setter Property="MinHeight" Value="300"></Setter>
|
||||
<Setter Property="MinHeight" Value="300" />
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:Calendar">
|
||||
<Panel>
|
||||
@@ -153,19 +153,31 @@
|
||||
Foreground="{DynamicResource CalendarItemIconForeground}" />
|
||||
</Button>
|
||||
|
||||
<Grid ColumnDefinitions="*, *" Grid.Column="2">
|
||||
<Button Grid.Column="0"
|
||||
<Grid Grid.Column="2" ColumnDefinitions="*, *">
|
||||
<Button
|
||||
Name="{x:Static u:Calendar.PART_YearButton}"
|
||||
Grid.Column="0"
|
||||
HorizontalContentAlignment="Center"
|
||||
Content="2024"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
IsVisible="{TemplateBinding IsMonthMode}"
|
||||
Theme="{DynamicResource BorderlessButton}" />
|
||||
<Button Grid.Column="1"
|
||||
<Button
|
||||
Name="{x:Static u:Calendar.PART_MonthButton}"
|
||||
Grid.Column="1"
|
||||
HorizontalContentAlignment="Center"
|
||||
Content="Apr"
|
||||
Foreground="{TemplateBinding Foreground}"
|
||||
IsVisible="{TemplateBinding IsMonthMode}"
|
||||
Theme="{DynamicResource BorderlessButton}" />
|
||||
<Button
|
||||
Name="{x:Static u:Calendar.PART_HeaderButton}"
|
||||
Grid.Column="0"
|
||||
Grid.ColumnSpan="2"
|
||||
IsVisible="{TemplateBinding IsMonthMode, Converter={x:Static BoolConverters.Not}}"
|
||||
HorizontalAlignment="Stretch"
|
||||
HorizontalContentAlignment="Center"
|
||||
Content="2020-2030" />
|
||||
</Grid>
|
||||
|
||||
<Button
|
||||
@@ -201,6 +213,8 @@
|
||||
<u:CalendarYearView
|
||||
Name="{x:Static u:Calendar.PART_YearView}"
|
||||
Grid.Row="1"
|
||||
Width="{Binding #PART_MonthView.Bounds.Width}"
|
||||
Height="{Binding #PART_MonthView.Bounds.Height}"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
IsVisible="{TemplateBinding IsMonthMode,
|
||||
|
||||
@@ -108,11 +108,12 @@ public class Calendar: TemplatedControl
|
||||
}
|
||||
Button.ClickEvent.RemoveHandler(OnYearButtonClick, _yearButton);
|
||||
Button.ClickEvent.RemoveHandler(OnMonthButtonClick, _monthButton);
|
||||
Button.ClickEvent.RemoveHandler(OnHeaderButtonClick, _headerButton);
|
||||
_monthView = e.NameScope.Find<CalendarMonthView>(PART_MonthView);
|
||||
_yearView = e.NameScope.Find<CalendarYearView>(PART_YearView);
|
||||
_yearButton = e.NameScope.Find<Button>(PART_YearButton);
|
||||
_monthButton = e.NameScope.Find<Button>(PART_MonthButton);
|
||||
|
||||
_headerButton = e.NameScope.Find<Button>(PART_HeaderButton);
|
||||
if(_monthView is not null)
|
||||
{
|
||||
_monthView.OnDateSelected += OnDateSelected;
|
||||
@@ -125,6 +126,22 @@ public class Calendar: TemplatedControl
|
||||
}
|
||||
Button.ClickEvent.AddHandler(OnYearButtonClick, _yearButton);
|
||||
Button.ClickEvent.AddHandler(OnMonthButtonClick, _monthButton);
|
||||
Button.ClickEvent.AddHandler(OnHeaderButtonClick, _headerButton);
|
||||
}
|
||||
|
||||
private void OnHeaderButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_yearView?.Mode == CalendarYearViewMode.Month)
|
||||
{
|
||||
_headerButton?.SetValue(ContentControl.ContentProperty, _yearView.ContextDate.Year);
|
||||
_yearView?.UpdateMode(CalendarYearViewMode.Year);
|
||||
}
|
||||
else if (_yearView?.Mode == CalendarYearViewMode.Year)
|
||||
{
|
||||
_headerButton?.SetCurrentValue(ContentControl.ContentProperty,
|
||||
_yearView.ContextDate.Year + "-" + (_yearView.ContextDate.Year + 100));
|
||||
_yearView?.UpdateMode(CalendarYearViewMode.YearRange);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMonthSelected(object sender, CalendarYearButtonEventArgs e)
|
||||
@@ -136,13 +153,16 @@ public class Calendar: TemplatedControl
|
||||
{
|
||||
SetCurrentValue(IsMonthModeProperty, false);
|
||||
if (_yearView is null) return;
|
||||
_yearView.Mode = CalendarYearViewMode.Month;
|
||||
_headerButton?.SetValue(Button.ContentProperty, _yearView.ContextDate.Year);
|
||||
_yearView?.UpdateMode(CalendarYearViewMode.Month);
|
||||
}
|
||||
|
||||
private void OnYearButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_yearView is null) return;
|
||||
_yearView.Mode = CalendarYearViewMode.Year;
|
||||
_headerButton?.SetValue(Button.ContentProperty,
|
||||
_yearView?.ContextDate.Year + "-" + (_yearView?.ContextDate.Year + 10));
|
||||
_yearView?.UpdateMode(CalendarYearViewMode.Year);
|
||||
SetCurrentValue(IsMonthModeProperty, false);
|
||||
|
||||
}
|
||||
|
||||
@@ -110,12 +110,10 @@ public class CalendarYearView: TemplatedControl
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ShiftMode()
|
||||
|
||||
internal void UpdateMode(CalendarYearViewMode mode)
|
||||
{
|
||||
if (Mode == CalendarYearViewMode.Month)
|
||||
{
|
||||
|
||||
}
|
||||
Mode = mode;
|
||||
RefreshButtons();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user