fix: fix some status logic.
This commit is contained in:
@@ -76,7 +76,7 @@ public class CalendarDayButton : ContentControl
|
||||
set
|
||||
{
|
||||
_isStartDate = value;
|
||||
SetPseudoClass(PC_StartDate);
|
||||
SetPseudoClass(PC_StartDate, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class CalendarDayButton : ContentControl
|
||||
set
|
||||
{
|
||||
_isEndDate = value;
|
||||
SetPseudoClass(PC_EndDate);
|
||||
SetPseudoClass(PC_EndDate, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ public class CalendarDayButton : ContentControl
|
||||
set
|
||||
{
|
||||
_isPreviewStartDate = value;
|
||||
PseudoClasses.Set(PC_PreviewStartDate, value);
|
||||
SetPseudoClass(PC_PreviewStartDate, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ public class CalendarDayButton : ContentControl
|
||||
set
|
||||
{
|
||||
_isPreviewEndDate = value;
|
||||
PseudoClasses.Set(PC_PreviewEndDate, value);
|
||||
SetPseudoClass(PC_PreviewEndDate, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class CalendarDayButton : ContentControl
|
||||
set
|
||||
{
|
||||
_isInRange = value;
|
||||
PseudoClasses.Set(PC_InRange, value);
|
||||
SetPseudoClass(PC_InRange, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class CalendarDayButton : ContentControl
|
||||
set
|
||||
{
|
||||
_isSelected = value;
|
||||
SetPseudoClass(PseudoClassName.PC_Selected);
|
||||
SetPseudoClass(PseudoClassName.PC_Selected, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,15 +191,15 @@ public class CalendarDayButton : ContentControl
|
||||
}
|
||||
}
|
||||
|
||||
private void SetPseudoClass(string s)
|
||||
private void SetPseudoClass(string s, bool value)
|
||||
{
|
||||
if (_pseudoClasses.Contains(s))
|
||||
if (_pseudoClasses.Contains(s) && value)
|
||||
{
|
||||
foreach (var pc in _pseudoClasses)
|
||||
{
|
||||
PseudoClasses.Set(pc, false);
|
||||
}
|
||||
}
|
||||
PseudoClasses.Set(s, true);
|
||||
PseudoClasses.Set(s, value);
|
||||
}
|
||||
}
|
||||
@@ -552,21 +552,38 @@ public class CalendarView : TemplatedControl
|
||||
if (d == startDate && d == endDate) button.IsSelected = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearSelection()
|
||||
|
||||
public void ClearSelection(bool start = true, bool end = true)
|
||||
{
|
||||
_start = null;
|
||||
_end = null;
|
||||
_previewStart = null;
|
||||
_previewEnd = null;
|
||||
if (start)
|
||||
{
|
||||
_previewStart = null;
|
||||
_start = null;
|
||||
}
|
||||
|
||||
if (end)
|
||||
{
|
||||
_previewEnd = null;
|
||||
_end = null;
|
||||
}
|
||||
|
||||
if (_monthGrid?.Children is null) return;
|
||||
foreach (var child in _monthGrid.Children)
|
||||
{
|
||||
if (child is not CalendarDayButton button) continue;
|
||||
button.IsStartDate = false;
|
||||
button.IsEndDate = false;
|
||||
button.IsInRange = false;
|
||||
if (start)
|
||||
{
|
||||
button.IsPreviewStartDate = false;
|
||||
button.IsStartDate = false;
|
||||
}
|
||||
if (end)
|
||||
{
|
||||
button.IsEndDate = false;
|
||||
button.IsInRange = false;
|
||||
}
|
||||
button.IsPreviewEndDate = false;
|
||||
}
|
||||
UpdateDayButtons();
|
||||
}
|
||||
|
||||
protected override void OnPointerExited(PointerEventArgs e)
|
||||
|
||||
@@ -114,7 +114,7 @@ public class DatePicker: DatePickerBase, IClearControl
|
||||
}
|
||||
SetCurrentValue(IsDropdownOpenProperty, true);
|
||||
}
|
||||
|
||||
|
||||
private void OnTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_textBox?.Text))
|
||||
|
||||
@@ -302,8 +302,8 @@ public class DateRangePicker : DatePickerBase
|
||||
if (string.IsNullOrEmpty(textBox?.Text))
|
||||
{
|
||||
SetCurrentValue(property, null);
|
||||
_startCalendar?.ClearSelection();
|
||||
_endCalendar?.ClearSelection();
|
||||
_startCalendar?.ClearSelection(start: true);
|
||||
_endCalendar?.ClearSelection(end: true);
|
||||
}
|
||||
else if (DisplayFormat is null || DisplayFormat.Length == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user