feat: mock interaction.
This commit is contained in:
@@ -121,7 +121,7 @@
|
|||||||
</ControlTheme>
|
</ControlTheme>
|
||||||
|
|
||||||
<ControlTheme x:Key="{x:Type u:Calendar}" TargetType="u:Calendar">
|
<ControlTheme x:Key="{x:Type u:Calendar}" TargetType="u:Calendar">
|
||||||
<Setter Property="MinHeight" Value="300"></Setter>
|
<Setter Property="MinHeight" Value="300" />
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<ControlTemplate TargetType="u:Calendar">
|
<ControlTemplate TargetType="u:Calendar">
|
||||||
<Panel>
|
<Panel>
|
||||||
@@ -153,19 +153,31 @@
|
|||||||
Foreground="{DynamicResource CalendarItemIconForeground}" />
|
Foreground="{DynamicResource CalendarItemIconForeground}" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<Grid ColumnDefinitions="*, *" Grid.Column="2">
|
<Grid Grid.Column="2" ColumnDefinitions="*, *">
|
||||||
<Button Grid.Column="0"
|
<Button
|
||||||
Name="{x:Static u:Calendar.PART_YearButton}"
|
Name="{x:Static u:Calendar.PART_YearButton}"
|
||||||
|
Grid.Column="0"
|
||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
Content="2024"
|
Content="2024"
|
||||||
Foreground="{TemplateBinding Foreground}"
|
Foreground="{TemplateBinding Foreground}"
|
||||||
|
IsVisible="{TemplateBinding IsMonthMode}"
|
||||||
Theme="{DynamicResource BorderlessButton}" />
|
Theme="{DynamicResource BorderlessButton}" />
|
||||||
<Button Grid.Column="1"
|
<Button
|
||||||
Name="{x:Static u:Calendar.PART_MonthButton}"
|
Name="{x:Static u:Calendar.PART_MonthButton}"
|
||||||
|
Grid.Column="1"
|
||||||
HorizontalContentAlignment="Center"
|
HorizontalContentAlignment="Center"
|
||||||
Content="Apr"
|
Content="Apr"
|
||||||
Foreground="{TemplateBinding Foreground}"
|
Foreground="{TemplateBinding Foreground}"
|
||||||
|
IsVisible="{TemplateBinding IsMonthMode}"
|
||||||
Theme="{DynamicResource BorderlessButton}" />
|
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>
|
</Grid>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@@ -201,6 +213,8 @@
|
|||||||
<u:CalendarYearView
|
<u:CalendarYearView
|
||||||
Name="{x:Static u:Calendar.PART_YearView}"
|
Name="{x:Static u:Calendar.PART_YearView}"
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
|
Width="{Binding #PART_MonthView.Bounds.Width}"
|
||||||
|
Height="{Binding #PART_MonthView.Bounds.Height}"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
IsVisible="{TemplateBinding IsMonthMode,
|
IsVisible="{TemplateBinding IsMonthMode,
|
||||||
|
|||||||
@@ -108,11 +108,12 @@ public class Calendar: TemplatedControl
|
|||||||
}
|
}
|
||||||
Button.ClickEvent.RemoveHandler(OnYearButtonClick, _yearButton);
|
Button.ClickEvent.RemoveHandler(OnYearButtonClick, _yearButton);
|
||||||
Button.ClickEvent.RemoveHandler(OnMonthButtonClick, _monthButton);
|
Button.ClickEvent.RemoveHandler(OnMonthButtonClick, _monthButton);
|
||||||
|
Button.ClickEvent.RemoveHandler(OnHeaderButtonClick, _headerButton);
|
||||||
_monthView = e.NameScope.Find<CalendarMonthView>(PART_MonthView);
|
_monthView = e.NameScope.Find<CalendarMonthView>(PART_MonthView);
|
||||||
_yearView = e.NameScope.Find<CalendarYearView>(PART_YearView);
|
_yearView = e.NameScope.Find<CalendarYearView>(PART_YearView);
|
||||||
_yearButton = e.NameScope.Find<Button>(PART_YearButton);
|
_yearButton = e.NameScope.Find<Button>(PART_YearButton);
|
||||||
_monthButton = e.NameScope.Find<Button>(PART_MonthButton);
|
_monthButton = e.NameScope.Find<Button>(PART_MonthButton);
|
||||||
|
_headerButton = e.NameScope.Find<Button>(PART_HeaderButton);
|
||||||
if(_monthView is not null)
|
if(_monthView is not null)
|
||||||
{
|
{
|
||||||
_monthView.OnDateSelected += OnDateSelected;
|
_monthView.OnDateSelected += OnDateSelected;
|
||||||
@@ -125,6 +126,22 @@ public class Calendar: TemplatedControl
|
|||||||
}
|
}
|
||||||
Button.ClickEvent.AddHandler(OnYearButtonClick, _yearButton);
|
Button.ClickEvent.AddHandler(OnYearButtonClick, _yearButton);
|
||||||
Button.ClickEvent.AddHandler(OnMonthButtonClick, _monthButton);
|
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)
|
private void OnMonthSelected(object sender, CalendarYearButtonEventArgs e)
|
||||||
@@ -136,13 +153,16 @@ public class Calendar: TemplatedControl
|
|||||||
{
|
{
|
||||||
SetCurrentValue(IsMonthModeProperty, false);
|
SetCurrentValue(IsMonthModeProperty, false);
|
||||||
if (_yearView is null) return;
|
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)
|
private void OnYearButtonClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
if (_yearView is null) return;
|
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);
|
SetCurrentValue(IsMonthModeProperty, false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,11 +111,9 @@ 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