Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename existing DatePicker control #4113

Merged
merged 1 commit into from
Jun 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion samples/ControlCatalog/MainView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<pages:DataGridPage/>
</TabItem>
<TabItem Header="DatePicker"><pages:DatePickerPage/></TabItem>
<TabItem Header="CalendarDatePicker">
<pages:CalendarDatePickerPage/></TabItem>
<TabItem Header="Drag+Drop"><pages:DragAndDropPage/></TabItem>
<TabItem Header="Expander"><pages:ExpanderPage/></TabItem>
<TabItem Header="Image"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="ControlCatalog.Pages.DatePickerPage">
x:Class="ControlCatalog.Pages.CalendarDatePickerPage">
<StackPanel Orientation="Vertical" Spacing="4">
<TextBlock Classes="h1">DatePicker</TextBlock>
<TextBlock Classes="h1">CalendarDatePicker</TextBlock>
<TextBlock Classes="h2">A control for selecting dates with a calendar drop-down</TextBlock>

<StackPanel Orientation="Horizontal"
Expand All @@ -12,34 +12,34 @@
<StackPanel Orientation="Vertical"
Width="200">
<TextBlock Text="SelectedDateFormat: Short"/>
<DatePicker Name="DatePicker1"
<CalendarDatePicker Name="DatePicker1"
SelectedDateFormat="Short"
Margin="0,0,0,8"/>

<TextBlock Text="SelectedDateFormat: Long"/>
<DatePicker Name="DatePicker2"
<CalendarDatePicker Name="DatePicker2"
SelectedDateFormat="Long"
Margin="0,0,0,8"/>

<TextBlock Text="SelectedDateFormat: Custom"/>
<DatePicker Name="DatePicker3"
<CalendarDatePicker Name="DatePicker3"
SelectedDateFormat="Custom"
CustomDateFormatString="ddd, MMM d"
Margin="0,0,0,8"/>

<TextBlock Text="Blackout Dates"/>
<DatePicker Name="DatePicker4"
<CalendarDatePicker Name="DatePicker4"
Margin="0,0,0,8"/>

<DatePicker Margin="0,0,0,8"
<CalendarDatePicker Margin="0,0,0,8"
Watermark="Watermark"/>
<DatePicker Margin="0,0,0,8"
<CalendarDatePicker Margin="0,0,0,8"
Name="DatePicker5"
Watermark="Floating Watermark"
UseFloatingWatermark="True"/>

<TextBlock Text="Disabled"/>
<DatePicker IsEnabled="False"/>
<CalendarDatePicker IsEnabled="False"/>
</StackPanel>

</StackPanel>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

namespace ControlCatalog.Pages
{
public class DatePickerPage : UserControl
public class CalendarDatePickerPage : UserControl
{
public DatePickerPage()
public CalendarDatePickerPage()
{
InitializeComponent();

var dp1 = this.FindControl<DatePicker>("DatePicker1");
var dp2 = this.FindControl<DatePicker>("DatePicker2");
var dp3 = this.FindControl<DatePicker>("DatePicker3");
var dp4 = this.FindControl<DatePicker>("DatePicker4");
var dp5 = this.FindControl<DatePicker>("DatePicker5");
var dp1 = this.FindControl<CalendarDatePicker>("DatePicker1");
var dp2 = this.FindControl<CalendarDatePicker>("DatePicker2");
var dp3 = this.FindControl<CalendarDatePicker>("DatePicker3");
var dp4 = this.FindControl<CalendarDatePicker>("DatePicker4");
var dp5 = this.FindControl<CalendarDatePicker>("DatePicker5");

dp1.SelectedDate = DateTime.Today;
dp2.SelectedDate = DateTime.Today.AddDays(10);
Expand Down
4 changes: 2 additions & 2 deletions src/Avalonia.Controls/Calendar/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -998,10 +998,10 @@ internal DateTime? HoverEnd


/// <summary>
/// Gets or sets a value indicating whether DatePicker should change its
/// Gets or sets a value indicating whether CalendarDatePicker should change its
/// DisplayDate because of a SelectedDate change on its Calendar.
/// </summary>
internal bool DatePickerDisplayDateFlag { get; set; }
internal bool CalendarDatePickerDisplayDateFlag { get; set; }

internal CalendarDayButton FindDayButtonFromDay(DateTime day)
{
Expand Down

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions src/Avalonia.Controls/Calendar/CalendarItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ internal void Cell_MouseEnter(object sender, PointerEventArgs e)
case CalendarSelectionMode.SingleDate:
{
DateTime selectedDate = (DateTime)b.DataContext;
Owner.DatePickerDisplayDateFlag = true;
Owner.CalendarDatePickerDisplayDateFlag = true;
if (Owner.SelectedDates.Count == 0)
{
Owner.SelectedDates.Add(selectedDate);
Expand Down Expand Up @@ -981,7 +981,7 @@ internal void Cell_MouseLeftButtonDown(object sender, PointerPressedEventArgs e)
}
case CalendarSelectionMode.SingleDate:
{
Owner.DatePickerDisplayDateFlag = true;
Owner.CalendarDatePickerDisplayDateFlag = true;
if (Owner.SelectedDates.Count == 0)
{
Owner.SelectedDates.Add(selectedDate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard">
<Style Selector="DatePicker">
<Style Selector="CalendarDatePicker">

<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
Expand Down Expand Up @@ -119,7 +119,7 @@
</Setter>
</Style>

<Style Selector="DatePicker:focus /template/ TextBox#PART_TextBox">
<Style Selector="CalendarDatePicker:focus /template/ TextBox#PART_TextBox">
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/>
</Style>

Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Themes.Default/DefaultTheme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<StyleInclude Source="resm:Avalonia.Themes.Default.CalendarDayButton.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.CalendarItem.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.Calendar.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.DatePicker.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.CalendarDatePicker.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.ButtonSpinner.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.NumericUpDown.xaml?assembly=Avalonia.Themes.Default"/>
<StyleInclude Source="resm:Avalonia.Themes.Default.AutoCompleteBox.xaml?assembly=Avalonia.Themes.Default"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=netstandard">
<Style Selector="DatePicker">
<Style Selector="CalendarDatePicker">

<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/>
Expand Down Expand Up @@ -119,7 +119,7 @@
</Setter>
</Style>

<Style Selector="DatePicker:focus /template/ TextBox#PART_TextBox">
<Style Selector="CalendarDatePicker:focus /template/ TextBox#PART_TextBox">
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}"/>
</Style>

Expand Down
2 changes: 1 addition & 1 deletion src/Avalonia.Themes.Fluent/FluentTheme.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<StyleInclude Source="resm:Avalonia.Themes.Fluent.CalendarDayButton.xaml?assembly=Avalonia.Themes.Fluent"/>
<StyleInclude Source="resm:Avalonia.Themes.Fluent.CalendarItem.xaml?assembly=Avalonia.Themes.Fluent"/>
<StyleInclude Source="resm:Avalonia.Themes.Fluent.Calendar.xaml?assembly=Avalonia.Themes.Fluent"/>
<StyleInclude Source="resm:Avalonia.Themes.Fluent.DatePicker.xaml?assembly=Avalonia.Themes.Fluent"/>
<StyleInclude Source="resm:Avalonia.Themes.Fluent.CalendarDatePicker.xaml?assembly=Avalonia.Themes.Fluent"/>
<StyleInclude Source="resm:Avalonia.Themes.Fluent.ButtonSpinner.xaml?assembly=Avalonia.Themes.Fluent"/>
<StyleInclude Source="resm:Avalonia.Themes.Fluent.NumericUpDown.xaml?assembly=Avalonia.Themes.Fluent"/>
<StyleInclude Source="resm:Avalonia.Themes.Fluent.AutoCompleteBox.xaml?assembly=Avalonia.Themes.Fluent"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Avalonia.Controls.UnitTests
{
public class DatePickerTests
public class CalendarDatePickerTests
{
private static bool CompareDates(DateTime first, DateTime second)
{
Expand All @@ -30,7 +30,7 @@ public void SelectedDateChanged_Should_Fire_When_SelectedDate_Set()
using (UnitTestApplication.Start(Services))
{
bool handled = false;
DatePicker datePicker = CreateControl();
CalendarDatePicker datePicker = CreateControl();
datePicker.SelectedDateChanged += (s,e) =>
{
handled = true;
Expand All @@ -47,7 +47,7 @@ public void Setting_Selected_Date_To_Blackout_Date_Should_Throw()
{
using (UnitTestApplication.Start(Services))
{
DatePicker datePicker = CreateControl();
CalendarDatePicker datePicker = CreateControl();
datePicker.BlackoutDates.AddDatesInPast();

DateTime goodValue = DateTime.Today.AddDays(1);
Expand All @@ -65,7 +65,7 @@ public void Adding_Blackout_Dates_Containing_Selected_Date_Should_Throw()
{
using (UnitTestApplication.Start(Services))
{
DatePicker datePicker = CreateControl();
CalendarDatePicker datePicker = CreateControl();
datePicker.SelectedDate = DateTime.Today.AddDays(5);

Assert.ThrowsAny<ArgumentOutOfRangeException>(
Expand All @@ -76,10 +76,10 @@ public void Adding_Blackout_Dates_Containing_Selected_Date_Should_Throw()
private static TestServices Services => TestServices.MockThreadingInterface.With(
standardCursorFactory: Mock.Of<IStandardCursorFactory>());

private DatePicker CreateControl()
private CalendarDatePicker CreateControl()
{
var datePicker =
new DatePicker
new CalendarDatePicker
{
Template = CreateTemplate()
};
Expand All @@ -90,7 +90,7 @@ private DatePicker CreateControl()

private IControlTemplate CreateTemplate()
{
return new FuncControlTemplate<DatePicker>((control, scope) =>
return new FuncControlTemplate<CalendarDatePicker>((control, scope) =>
{
var textBox =
new TextBox
Expand Down