This commit is contained in:
Stefan Nenchev 2020-02-19 14:33:20 +02:00
Родитель 8142de1baf
Коммит 69804565cb
7 изменённых файлов: 167 добавлений и 6 удалений

Просмотреть файл

@ -0,0 +1,70 @@
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
namespace Telerik.UI.Xaml.Controls.Input.Calendar
{
public class CalendarFooterControl : RadControl
{
/// <summary>
/// Identifies the <c cref=FooterControlButtonStyle"/> dependency property.
/// </summary>
public static readonly DependencyProperty FooterControlButtonStyleProperty =
DependencyProperty.Register(nameof(FooterControlButtonStyle), typeof(Style), typeof(CalendarFooterControl), new PropertyMetadata(null));
private Button calendarFooterButton;
public CalendarFooterControl()
{
this.DefaultStyleKey = typeof(CalendarFooterControl);
}
/// <summary>
/// Gets or sets the Style for the Button of the Footer control.
/// </summary>
public Style FooterControlButtonStyle
{
get
{
return (Style)this.GetValue(FooterControlButtonStyleProperty);
}
set
{
this.SetValue(FooterControlButtonStyleProperty, value);
}
}
internal RadCalendar Owner { get; set; }
protected override bool ApplyTemplateCore()
{
bool applied = base.ApplyTemplateCore();
this.calendarFooterButton = (Button)this.GetTemplateChild("calendarFooterButton");
return applied;
}
protected override void OnTemplateApplied()
{
base.OnTemplateApplied();
if (this.calendarFooterButton != null)
{
this.calendarFooterButton.Click += CalendarFooterButtonClick;
}
}
protected override void UnapplyTemplateCore()
{
base.UnapplyTemplateCore();
if (this.calendarFooterButton != null)
{
this.calendarFooterButton.Click -= CalendarFooterButtonClick;
}
}
private void CalendarFooterButtonClick(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
this.Owner.OnCalendarButtonClicked();
}
}
}

Просмотреть файл

@ -297,6 +297,12 @@ namespace Telerik.UI.Xaml.Controls.Input
public static readonly DependencyProperty HeaderVisibilityProperty =
DependencyProperty.Register(nameof(HeaderVisibility), typeof(Visibility), typeof(RadCalendar), new PropertyMetadata(Visibility.Visible));
/// <summary>
/// Identifies the <c cref="FooterVisibility"/> dependency property.
/// </summary>
public static readonly DependencyProperty FooterVisibilityProperty =
DependencyProperty.Register(nameof(FooterVisibility), typeof(Visibility), typeof(RadCalendar), new PropertyMetadata(Visibility.Collapsed));
/// <summary>
/// Identifies the <c cref="NavigationControlBorderStyle"/> dependency property.
/// </summary>
@ -323,6 +329,7 @@ namespace Telerik.UI.Xaml.Controls.Input
internal XamlMultiDayViewLayer timeRulerLayer;
internal XamlAllDayAreaLayer allDayAreaLayer;
internal CalendarNavigationControl navigationPanel;
internal CalendarFooterControl footerPanel;
internal List<CalendarDateRange> unattachedSelectedRanges;
internal CalendarViewHost calendarViewHost;
internal IAppointment pendingScrollToAppointment;
@ -341,6 +348,7 @@ namespace Telerik.UI.Xaml.Controls.Input
private const string CalendarViewHostPartName = "PART_CalendarViewHost";
private const string NavigationControlPanelName = "navigationControl";
private const string FooterControlPanelName = "footerControl";
private readonly HitTestService hitTestService;
private readonly InputService inputService;
@ -407,6 +415,11 @@ namespace Telerik.UI.Xaml.Controls.Input
this.model.multiDayViewSettings = multiDayViewSettings;
}
/// <summary>
/// Occurs when the <see cref="CalendarButton"/> is clicked.
/// </summary>
public event EventHandler<EventArgs> CalendarButtonClicked;
/// <summary>
/// Occurs when the <see cref="DisplayDate"/> property is changed.
/// </summary>
@ -1674,6 +1687,21 @@ namespace Telerik.UI.Xaml.Controls.Input
}
}
/// <summary>
/// Gets or sets the Visibility of the Calendar's Footer Row.
/// </summary>
public Visibility FooterVisibility
{
get
{
return (Visibility)this.GetValue(FooterVisibilityProperty);
}
set
{
this.SetValue(FooterVisibilityProperty, value);
}
}
/// <summary>
/// Gets or sets the Style for the Border of the Navigation control.
/// </summary>
@ -1829,7 +1857,7 @@ namespace Telerik.UI.Xaml.Controls.Input
this.timeRulerLayer?.ClearRealizedAppointmentVisuals();
this.timeRulerLayer?.ClearRealizedSlotVisuals();
}
this.Invalidate();
}
@ -2259,6 +2287,11 @@ namespace Telerik.UI.Xaml.Controls.Input
this.navigationPanel.HeaderContentTemplate = this.HeaderContentTemplate;
}
internal void OnCalendarButtonClicked()
{
this.CalendarButtonClicked?.Invoke(this, EventArgs.Empty);
}
/// <summary>
/// Called when the Framework <see cref="M:OnApplyTemplate" /> is called. Inheritors should override this method should they have some custom template-related logic.
@ -2273,6 +2306,8 @@ namespace Telerik.UI.Xaml.Controls.Input
this.navigationPanel = this.GetTemplateChild(NavigationControlPanelName) as CalendarNavigationControl;
this.footerPanel = this.GetTemplateChild(FooterControlPanelName) as CalendarFooterControl;
return applied;
}
@ -2300,6 +2335,11 @@ namespace Telerik.UI.Xaml.Controls.Input
this.UpdateNavigationPreviousNextButtonsState();
}
if (this.footerPanel != null)
{
this.footerPanel.Owner = this;
}
if (this.timeRulerLayer == null)
{
this.timeRulerLayer = new XamlMultiDayViewLayer();
@ -3031,6 +3071,11 @@ namespace Telerik.UI.Xaml.Controls.Input
this.navigationPanel.Owner = null;
}
if (this.footerPanel != null)
{
this.footerPanel.Owner = null;
}
this.calendarViewHost.SizeChanged -= this.CalendarViewHostSizeChanged;
this.calendarViewHost.PointerPressed -= this.OnCalendarViewHostPointerPressed;
@ -3657,6 +3702,11 @@ namespace Telerik.UI.Xaml.Controls.Input
availableSize.Height -= this.navigationPanel.ActualHeight;
}
if (this.footerPanel != null && this.FooterVisibility == Visibility.Visible)
{
availableSize.Height -= this.footerPanel.ActualHeight;
}
return availableSize;
}

Просмотреть файл

@ -70,6 +70,7 @@
<Compile Include="Calendar\Model\CalendarMultiDayViewModel.cs" />
<Compile Include="Calendar\Model\ICopyable.cs" />
<Compile Include="Calendar\Model\Slot.cs" />
<Compile Include="Calendar\View\CalendarFooterControl.cs" />
<Compile Include="Calendar\View\Layers\XamlAllDayAreaLayer.cs" />
<Compile Include="Calendar\View\Layers\XamlMultiDayViewLayer.cs" />
<Compile Include="Calendar\View\MultiDayView\MultiDayViewSettings.cs" />

Просмотреть файл

@ -1,10 +1,9 @@
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:localCalendar="using:Telerik.UI.Xaml.Controls.Input.Calendar"
xmlns:theming="using:Telerik.UI.Xaml.Controls"
xmlns:local="using:Telerik.UI.Xaml.Controls.Input"
xmlns:telerikCore="using:Telerik.Core"
xmlns:theming="using:Telerik.UI.Xaml.Controls">
xmlns:localCalendar="using:Telerik.UI.Xaml.Controls.Input.Calendar">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary>
@ -264,7 +263,41 @@
</Setter.Value>
</Setter>
</Style>
<Style TargetType="Button" x:Key="CalendarFooterControlButtonStyle">
<Setter Property="Width" Value="47"/>
<Setter Property="Content" Value="+"/>
<Setter Property="HorizontalAlignment" Value="Right"/>
<Setter Property="FontSize" Value="24"/>
<Setter Property="Foreground" Value="{ThemeResource TelerikCalendarFooterButtonForegroundBrush}" />
<Setter Property="Background" Value="Transparent"/>
</Style>
<Style TargetType="localCalendar:CalendarFooterControl" x:Key="CalendarFooterControlStyle">
<Setter Property="FooterControlButtonStyle">
<Setter.Value>
<Style BasedOn="{StaticResource CalendarFooterControlButtonStyle}" TargetType="Button"/>
</Setter.Value>
</Setter>
<Setter Property="Height" Value="48"/>
<Setter Property="IsTabStop" Value="False" />
<Setter Property="Background" Value="#F7F7F7" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="localCalendar:CalendarFooterControl">
<Grid x:Name="calendarFooterPanel"
Background="{TemplateBinding Background}">
<Button x:Name="calendarFooterButton"
Style="{TemplateBinding FooterControlButtonStyle}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="localCalendar:CalendarFooterControl" BasedOn="{StaticResource CalendarFooterControlStyle}"/>
<Style TargetType="local:RadCalendar">
<Setter Property="UseSystemFocusVisuals" Value="True" />
<Setter Property="MinHeight" Value="200" />
@ -347,6 +380,7 @@
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<localCalendar:CalendarNavigationControl x:Name="navigationControl"
Visibility="{TemplateBinding HeaderVisibility}"
@ -361,12 +395,15 @@
<ScaleTransform />
</Canvas.RenderTransform>
</localCalendar:CalendarViewHost>
<localCalendar:CalendarFooterControl x:Name="footerControl"
Grid.Row="2"
Visibility="{TemplateBinding FooterVisibility}"/>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

Просмотреть файл

@ -249,6 +249,7 @@
<SolidColorBrush x:Key="TelerikCalendarPreviousNextButtonPointerPressedForegroundBrush" Color="#FF3399FF" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonForegroundBrush" Color="{ThemeResource TelerikWhiteColor}" />
<SolidColorBrush x:Key="TelerikCalendarFooterButtonForegroundBrush" Color="{ThemeResource TelerikWhiteColor}" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonDisabledForegroundBrush" Color="#FF767676" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonPointerPressedForegroundBrush" Color="#FF3399FF" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonPointerOverForegroundBrush" Color="#FF3399FF" />

Просмотреть файл

@ -248,6 +248,7 @@
<SolidColorBrush x:Key="TelerikCalendarPreviousNextButtonPointerPressedForegroundBrush" Color="{ThemeResource SystemColorButtonTextColor}" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonForegroundBrush" Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="TelerikCalendarFooterButtonForegroundBrush" Color="{ThemeResource SystemColorHighlightTextColor}" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonDisabledForegroundBrush" Color="{ThemeResource SystemColorGrayTextColor}" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonPointerPressedForegroundBrush" Color="{ThemeResource SystemColorButtonTextColor}" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonPointerOverForegroundBrush" Color="{ThemeResource SystemColorHighlightTextColor}" />

Просмотреть файл

@ -249,6 +249,7 @@
<SolidColorBrush x:Key="TelerikCalendarPreviousNextButtonPointerPressedForegroundBrush" Color="#FF3399FF" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonForegroundBrush" Color="{ThemeResource TelerikBlackColor}" />
<SolidColorBrush x:Key="TelerikCalendarFooterButtonForegroundBrush" Color="{ThemeResource TelerikBlackColor}" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonDisabledForegroundBrush" Color="#FF767676" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonPointerPressedForegroundBrush" Color="#FF3399FF" />
<SolidColorBrush x:Key="TelerikCalendarHeaderButtonPointerOverForegroundBrush" Color="#FF3399FF" />