feat: clean up warnings.
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Mixins;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Irihi.Avalonia.Shared.Common;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
@@ -167,7 +166,7 @@ public class CalendarView : TemplatedControl
|
||||
UpdateYearButtons();
|
||||
}
|
||||
|
||||
private void OnFastNext(object sender, RoutedEventArgs e)
|
||||
private void OnFastNext(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Mode == CalendarViewMode.Month)
|
||||
{
|
||||
@@ -176,7 +175,7 @@ public class CalendarView : TemplatedControl
|
||||
}
|
||||
}
|
||||
|
||||
private void OnNext(object sender, RoutedEventArgs e)
|
||||
private void OnNext(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Mode == CalendarViewMode.Month)
|
||||
{
|
||||
@@ -200,7 +199,7 @@ public class CalendarView : TemplatedControl
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPrevious(object sender, RoutedEventArgs e)
|
||||
private void OnPrevious(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Mode == CalendarViewMode.Month)
|
||||
{
|
||||
@@ -224,7 +223,7 @@ public class CalendarView : TemplatedControl
|
||||
}
|
||||
}
|
||||
|
||||
private void OnFastPrevious(object sender, RoutedEventArgs e)
|
||||
private void OnFastPrevious(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (Mode == CalendarViewMode.Month)
|
||||
{
|
||||
@@ -238,7 +237,7 @@ public class CalendarView : TemplatedControl
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnHeaderButtonClick(object sender, RoutedEventArgs e)
|
||||
private void OnHeaderButtonClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
// Header button should be hidden in Month mode.
|
||||
if (Mode == CalendarViewMode.Month) return;
|
||||
@@ -319,7 +318,7 @@ public class CalendarView : TemplatedControl
|
||||
if (_monthGrid is null || Mode != CalendarViewMode.Month) return;
|
||||
var children = _monthGrid.Children;
|
||||
var info = DateTimeHelper.GetCurrentDateTimeFormatInfo();
|
||||
var date = new DateTime(ContextDate.Year ?? ContextDate.StartYear.Value, ContextDate.Month.Value, 1);
|
||||
var date = new DateTime(ContextDate.Year ?? ContextDate.StartYear!.Value, ContextDate.Month!.Value, 1);
|
||||
var dayBefore = PreviousMonthDays(date);
|
||||
var dateToSet = date.GetFirstDayOfMonth().AddDays(-dayBefore);
|
||||
for (var i = 7; i < children.Count; i++)
|
||||
@@ -412,12 +411,12 @@ public class CalendarView : TemplatedControl
|
||||
return i == 0 ? DateTimeHelper.NumberOfDaysPerWeek : i;
|
||||
}
|
||||
|
||||
private void OnCellDatePreviewed(object sender, CalendarDayButtonEventArgs e)
|
||||
private void OnCellDatePreviewed(object? sender, CalendarDayButtonEventArgs e)
|
||||
{
|
||||
DatePreviewed?.Invoke(this, e);
|
||||
}
|
||||
|
||||
private void OnCellDateSelected(object sender, CalendarDayButtonEventArgs e)
|
||||
private void OnCellDateSelected(object? sender, CalendarDayButtonEventArgs e)
|
||||
{
|
||||
if (e.Date.HasValue && e.Date.Value.Month != ContextDate.Month)
|
||||
{
|
||||
@@ -432,7 +431,7 @@ public class CalendarView : TemplatedControl
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnHeaderMonthButtonClick(object sender, RoutedEventArgs e)
|
||||
private void OnHeaderMonthButtonClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
SetCurrentValue(ModeProperty, CalendarViewMode.Year);
|
||||
UpdateYearButtons();
|
||||
@@ -443,7 +442,7 @@ public class CalendarView : TemplatedControl
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnHeaderYearButtonClick(object sender, RoutedEventArgs e)
|
||||
private void OnHeaderYearButtonClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (_yearGrid is null) return;
|
||||
SetCurrentValue(ModeProperty, CalendarViewMode.Decade);
|
||||
@@ -464,10 +463,9 @@ public class CalendarView : TemplatedControl
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void OnYearItemSelected(object sender, CalendarYearButtonEventArgs e)
|
||||
private void OnYearItemSelected(object? sender, CalendarYearButtonEventArgs e)
|
||||
{
|
||||
if (_yearGrid is null) return;
|
||||
var buttons = _yearGrid.Children.OfType<CalendarYearButton>().ToList();
|
||||
if (Mode == CalendarViewMode.Century)
|
||||
{
|
||||
Mode = CalendarViewMode.Decade;
|
||||
@@ -481,7 +479,7 @@ public class CalendarView : TemplatedControl
|
||||
else if (Mode == CalendarViewMode.Year)
|
||||
{
|
||||
Mode = CalendarViewMode.Month;
|
||||
ContextDate = ContextDate.With(null, e.Context.Month, null, null);
|
||||
ContextDate = ContextDate.With(null, e.Context.Month);
|
||||
UpdateDayButtons();
|
||||
}
|
||||
else if (Mode == CalendarViewMode.Month)
|
||||
@@ -600,7 +598,7 @@ public class CalendarView : TemplatedControl
|
||||
DatePreviewed?.Invoke(this, new CalendarDayButtonEventArgs(null));
|
||||
}
|
||||
|
||||
private bool _dateContextSyncing = false;
|
||||
private bool _dateContextSyncing;
|
||||
/// <summary>
|
||||
/// Used for syncing the context date for DateRangePicker. mark a flag to avoid infinitely loop.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Diagnostics;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Mixins;
|
||||
|
||||
@@ -23,7 +23,6 @@ public class DatePicker: DatePickerBase, IClearControl
|
||||
public const string PART_TextBox = "PART_TextBox";
|
||||
public const string PART_Calendar = "PART_Calendar";
|
||||
private Button? _button;
|
||||
private Popup? _popup;
|
||||
private TextBox? _textBox;
|
||||
private CalendarView? _calendar;
|
||||
|
||||
@@ -79,7 +78,7 @@ public class DatePicker: DatePickerBase, IClearControl
|
||||
}
|
||||
|
||||
_button = e.NameScope.Find<Button>(PART_Button);
|
||||
_popup = e.NameScope.Find<Popup>(PART_Popup);
|
||||
e.NameScope.Find<Popup>(PART_Popup);
|
||||
_textBox = e.NameScope.Find<TextBox>(PART_TextBox);
|
||||
_calendar = e.NameScope.Find<CalendarView>(PART_Calendar);
|
||||
|
||||
@@ -94,19 +93,19 @@ public class DatePicker: DatePickerBase, IClearControl
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDateSelected(object sender, CalendarDayButtonEventArgs e)
|
||||
private void OnDateSelected(object? sender, CalendarDayButtonEventArgs e)
|
||||
{
|
||||
SetCurrentValue(SelectedDateProperty, e.Date);
|
||||
SetCurrentValue(IsDropdownOpenProperty, false);
|
||||
}
|
||||
|
||||
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||
private void OnButtonClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Focus(NavigationMethod.Pointer);
|
||||
SetCurrentValue(IsDropdownOpenProperty, !IsDropdownOpen);
|
||||
}
|
||||
|
||||
private void OnTextBoxPointerPressed(object sender, PointerPressedEventArgs e)
|
||||
private void OnTextBoxPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (_calendar is not null)
|
||||
{
|
||||
@@ -118,7 +117,7 @@ public class DatePicker: DatePickerBase, IClearControl
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
private void OnTextChanged(object sender, TextChangedEventArgs e)
|
||||
private void OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
SetSelectedDate(true);
|
||||
}
|
||||
@@ -146,7 +145,6 @@ public class DatePicker: DatePickerBase, IClearControl
|
||||
SetCurrentValue(SelectedDateProperty, date);
|
||||
if (_calendar is not null)
|
||||
{
|
||||
var d = SelectedDate ?? DateTime.Today;
|
||||
_calendar.ContextDate = _calendar.ContextDate.With(year: date.Year, month: date.Month);
|
||||
_calendar.UpdateDayButtons();
|
||||
}
|
||||
@@ -164,7 +162,7 @@ public class DatePicker: DatePickerBase, IClearControl
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTextBoxGetFocus(object sender, GotFocusEventArgs e)
|
||||
private void OnTextBoxGetFocus(object? sender, GotFocusEventArgs e)
|
||||
{
|
||||
if (_calendar is not null)
|
||||
{
|
||||
|
||||
@@ -43,7 +43,6 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
private Button? _button;
|
||||
private CalendarView? _endCalendar;
|
||||
private TextBox? _endTextBox;
|
||||
private Popup? _popup;
|
||||
private DateTime? _previewEnd;
|
||||
|
||||
private DateTime? _previewStart;
|
||||
@@ -140,7 +139,7 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
}
|
||||
|
||||
_button = e.NameScope.Find<Button>(PART_Button);
|
||||
_popup = e.NameScope.Find<Popup>(PART_Popup);
|
||||
e.NameScope.Find<Popup>(PART_Popup);
|
||||
_startCalendar = e.NameScope.Find<CalendarView>(PART_StartCalendar);
|
||||
_endCalendar = e.NameScope.Find<CalendarView>(PART_EndCalendar);
|
||||
_startTextBox = e.NameScope.Find<TextBox>(PART_StartTextBox);
|
||||
@@ -168,28 +167,28 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTextBoxLostFocus(object sender, RoutedEventArgs e)
|
||||
private void OnTextBoxLostFocus(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (sender == _startTextBox)
|
||||
if (Equals(sender, _startTextBox))
|
||||
OnTextChangedInternal(_startTextBox, SelectedStartDateProperty);
|
||||
else if (sender == _endTextBox) OnTextChangedInternal(_endTextBox, SelectedEndDateProperty);
|
||||
else if (Equals(sender, _endTextBox)) OnTextChangedInternal(_endTextBox, SelectedEndDateProperty);
|
||||
}
|
||||
|
||||
private void OnContextDateChanged(object sender, CalendarContext e)
|
||||
private void OnContextDateChanged(object? sender, CalendarContext e)
|
||||
{
|
||||
if (sender == _startCalendar && _startCalendar?.Mode == CalendarViewMode.Month)
|
||||
if (Equals(sender, _startCalendar) && _startCalendar?.Mode == CalendarViewMode.Month)
|
||||
{
|
||||
var needsUpdate = EnableMonthSync || _startCalendar?.ContextDate.CompareTo(_endCalendar?.ContextDate) >= 0;
|
||||
if (needsUpdate) _endCalendar?.SyncContextDate(_startCalendar?.ContextDate.NextMonth());
|
||||
}
|
||||
else if (sender == _endCalendar && _endCalendar?.Mode == CalendarViewMode.Month)
|
||||
else if (Equals(sender, _endCalendar) && _endCalendar?.Mode == CalendarViewMode.Month)
|
||||
{
|
||||
var needsUpdate = EnableMonthSync || _endCalendar?.ContextDate.CompareTo(_startCalendar?.ContextDate) <= 0;
|
||||
if (needsUpdate) _startCalendar?.SyncContextDate(_endCalendar?.ContextDate.PreviousMonth());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDatePreviewed(object sender, CalendarDayButtonEventArgs e)
|
||||
private void OnDatePreviewed(object? sender, CalendarDayButtonEventArgs e)
|
||||
{
|
||||
if (_start == true)
|
||||
{
|
||||
@@ -205,7 +204,7 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDateSelected(object sender, CalendarDayButtonEventArgs e)
|
||||
private void OnDateSelected(object? sender, CalendarDayButtonEventArgs e)
|
||||
{
|
||||
if (_start == true)
|
||||
{
|
||||
@@ -241,16 +240,16 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
}
|
||||
}
|
||||
|
||||
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||
private void OnButtonClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Focus(NavigationMethod.Pointer);
|
||||
SetCurrentValue(IsDropdownOpenProperty, !IsDropdownOpen);
|
||||
_start = true;
|
||||
}
|
||||
|
||||
private void OnTextBoxPointerPressed(object sender, PointerPressedEventArgs e)
|
||||
private void OnTextBoxPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (sender == _startTextBox)
|
||||
if (Equals(sender, _startTextBox))
|
||||
{
|
||||
_start = true;
|
||||
if (_startCalendar is not null)
|
||||
@@ -270,11 +269,11 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
date2 = date2.Value.AddMonths(1);
|
||||
}
|
||||
|
||||
_endCalendar.ContextDate = new CalendarContext(date2?.Year, date2?.Month);
|
||||
_endCalendar.ContextDate = new CalendarContext(date2.Value.Year, date2.Value.Month);
|
||||
_endCalendar.UpdateDayButtons();
|
||||
}
|
||||
}
|
||||
else if (sender == _endTextBox)
|
||||
else if (Equals(sender, _endTextBox))
|
||||
{
|
||||
_start = false;
|
||||
if (_endCalendar is not null)
|
||||
@@ -294,7 +293,7 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
date2 = date2.Value.AddMonths(-1);
|
||||
}
|
||||
|
||||
_startCalendar.ContextDate = new CalendarContext(date2?.Year, date2?.Month);
|
||||
_startCalendar.ContextDate = new CalendarContext(date2.Value.Year, date2.Value.Month);
|
||||
_startCalendar.UpdateDayButtons();
|
||||
}
|
||||
}
|
||||
@@ -302,11 +301,11 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
SetCurrentValue(IsDropdownOpenProperty, true);
|
||||
}
|
||||
|
||||
private void OnTextChanged(object sender, TextChangedEventArgs e)
|
||||
private void OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
if (sender == _startTextBox)
|
||||
if (Equals(sender, _startTextBox))
|
||||
OnTextChangedInternal(_startTextBox, SelectedStartDateProperty, true);
|
||||
else if (sender == _endTextBox) OnTextChangedInternal(_endTextBox, SelectedEndDateProperty, true);
|
||||
else if (Equals(sender, _endTextBox)) OnTextChangedInternal(_endTextBox, SelectedEndDateProperty, true);
|
||||
}
|
||||
|
||||
private void OnTextChangedInternal(TextBox? textBox, AvaloniaProperty property, bool fromText = false)
|
||||
@@ -314,12 +313,12 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
if (string.IsNullOrEmpty(textBox?.Text))
|
||||
{
|
||||
SetCurrentValue(property, null);
|
||||
_startCalendar?.ClearSelection(true);
|
||||
_startCalendar?.ClearSelection();
|
||||
_endCalendar?.ClearSelection(end: true);
|
||||
}
|
||||
else if (DisplayFormat is null || DisplayFormat.Length == 0)
|
||||
{
|
||||
if (DateTime.TryParse(textBox?.Text, out var defaultTime))
|
||||
if (DateTime.TryParse(textBox.Text, out var defaultTime))
|
||||
{
|
||||
SetCurrentValue(property, defaultTime);
|
||||
_startCalendar?.MarkDates(defaultTime, defaultTime);
|
||||
@@ -328,7 +327,7 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
}
|
||||
else
|
||||
{
|
||||
if (DateTime.TryParseExact(textBox?.Text, DisplayFormat, CultureInfo.CurrentUICulture, DateTimeStyles.None,
|
||||
if (DateTime.TryParseExact(textBox.Text, DisplayFormat, CultureInfo.CurrentUICulture, DateTimeStyles.None,
|
||||
out var date))
|
||||
{
|
||||
SetCurrentValue(property, date);
|
||||
@@ -356,19 +355,18 @@ public class DateRangePicker : DatePickerBase, IClearControl
|
||||
if (!fromText)
|
||||
{
|
||||
SetCurrentValue(property, null);
|
||||
textBox?.SetValue(TextBox.TextProperty, null);
|
||||
_startCalendar?.ClearSelection(true);
|
||||
textBox.SetValue(TextBox.TextProperty, null);
|
||||
_startCalendar?.ClearSelection();
|
||||
_endCalendar?.ClearSelection(end: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTextBoxGetFocus(object sender, GotFocusEventArgs e)
|
||||
private void OnTextBoxGetFocus(object? sender, GotFocusEventArgs e)
|
||||
{
|
||||
if (_startCalendar is not null && _startCalendar?.Mode == CalendarViewMode.Month)
|
||||
{
|
||||
var date = SelectedStartDate ?? DateTime.Today;
|
||||
//_startCalendar.ContextDate = new CalendarContext(date.Year, date.Month);
|
||||
//_startCalendar.UpdateDayButtons();
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ internal static class DateTimeHelper
|
||||
public static DateTimeFormatInfo GetCurrentDateTimeFormatInfo()
|
||||
{
|
||||
if (CultureInfo.CurrentCulture.Calendar is GregorianCalendar) return CultureInfo.CurrentCulture.DateTimeFormat;
|
||||
System.Globalization.Calendar? calendar =
|
||||
Calendar? calendar =
|
||||
CultureInfo.CurrentCulture.OptionalCalendars.OfType<GregorianCalendar>().FirstOrDefault();
|
||||
string cultureName = calendar is null ? CultureInfo.InvariantCulture.Name : CultureInfo.CurrentCulture.Name;
|
||||
var dt = new CultureInfo(cultureName).DateTimeFormat;
|
||||
|
||||
@@ -30,7 +30,6 @@ public class TimePicker : TimePickerBase, IClearControl
|
||||
nameof(Watermark));
|
||||
|
||||
private Button? _button;
|
||||
private Popup? _popup;
|
||||
private TimePickerPresenter? _presenter;
|
||||
private TextBox? _textBox;
|
||||
|
||||
@@ -42,10 +41,11 @@ public class TimePicker : TimePickerBase, IClearControl
|
||||
DisplayFormatProperty.Changed.AddClassHandler<TimePicker, string?>((picker, args) => picker.OnDisplayFormatChanged(args));
|
||||
}
|
||||
|
||||
private void OnDisplayFormatChanged(AvaloniaPropertyChangedEventArgs<string?> args)
|
||||
private void OnDisplayFormatChanged(AvaloniaPropertyChangedEventArgs<string?> _)
|
||||
{
|
||||
if (_textBox is null) return;
|
||||
var time = SelectedTime;
|
||||
if (time is null) return;
|
||||
var date = new DateTime( 1, 1, 1, time.Value.Hours, time.Value.Minutes, time.Value.Seconds);
|
||||
var text = date.ToString(DisplayFormat);
|
||||
_textBox.Text = text;
|
||||
@@ -79,7 +79,7 @@ public class TimePicker : TimePickerBase, IClearControl
|
||||
Button.ClickEvent.RemoveHandler(OnButtonClick, _button);
|
||||
|
||||
_textBox = e.NameScope.Find<TextBox>(PART_TextBox);
|
||||
_popup = e.NameScope.Find<Popup>(PartNames.PART_Popup);
|
||||
e.NameScope.Find<Popup>(PartNames.PART_Popup);
|
||||
_presenter = e.NameScope.Find<TimePickerPresenter>(PART_Presenter);
|
||||
_button = e.NameScope.Find<Button>(PART_Button);
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class TimePickerPresenter : TemplatedControl
|
||||
private DateTimePickerPanel? _secondSelector;
|
||||
private Control? _secondSeparator;
|
||||
private Control? _thirdSeparator;
|
||||
internal TimeSpan _timeHolder;
|
||||
internal TimeSpan TimeHolder;
|
||||
private bool _updateFromTimeChange;
|
||||
private bool _use12Clock;
|
||||
|
||||
@@ -172,7 +172,7 @@ public class TimePickerPresenter : TemplatedControl
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,11 +224,11 @@ public class TimePickerPresenter : TemplatedControl
|
||||
UpdatePanelsFromSelectedTime(Time);
|
||||
}
|
||||
|
||||
private void OnPanelSelectionChanged(object sender, System.EventArgs e)
|
||||
private void OnPanelSelectionChanged(object? sender, System.EventArgs e)
|
||||
{
|
||||
if (_updateFromTimeChange) return;
|
||||
if (!_use12Clock && sender == _ampmSelector) return;
|
||||
var time = NeedsConfirmation ? _timeHolder : Time ?? DateTime.Now.TimeOfDay;
|
||||
if (!_use12Clock && Equals(sender, _ampmSelector)) return;
|
||||
var time = NeedsConfirmation ? TimeHolder : Time ?? DateTime.Now.TimeOfDay;
|
||||
var hour = _hourSelector?.SelectedValue ?? time.Hours;
|
||||
var minute = _minuteSelector?.SelectedValue ?? time.Minutes;
|
||||
var second = _secondSelector?.SelectedValue ?? time.Seconds;
|
||||
@@ -251,7 +251,7 @@ public class TimePickerPresenter : TemplatedControl
|
||||
}
|
||||
var newTime = new TimeSpan(hour, minute, second);
|
||||
if (NeedsConfirmation)
|
||||
_timeHolder = newTime;
|
||||
TimeHolder = newTime;
|
||||
else
|
||||
SetCurrentValue(TimeProperty, newTime);
|
||||
}
|
||||
@@ -314,7 +314,7 @@ public class TimePickerPresenter : TemplatedControl
|
||||
|
||||
public void Confirm()
|
||||
{
|
||||
if (NeedsConfirmation) SetCurrentValue(TimeProperty, _timeHolder);
|
||||
if (NeedsConfirmation) SetCurrentValue(TimeProperty, TimeHolder);
|
||||
}
|
||||
|
||||
private void SetIfChanged(DateTimePickerPanel? panel, int index)
|
||||
|
||||
@@ -45,7 +45,6 @@ public class TimeRangePicker : TimePickerBase, IClearControl
|
||||
private Button? _button;
|
||||
private TimePickerPresenter? _endPresenter;
|
||||
private TextBox? _endTextBox;
|
||||
private Popup? _popup;
|
||||
private TimePickerPresenter? _startPresenter;
|
||||
|
||||
private TextBox? _startTextBox;
|
||||
@@ -114,7 +113,7 @@ public class TimeRangePicker : TimePickerBase, IClearControl
|
||||
PointerPressedEvent.RemoveHandler(OnTextBoxPointerPressed, _startTextBox, _endTextBox);
|
||||
Button.ClickEvent.RemoveHandler(OnButtonClick, _button);
|
||||
|
||||
_popup = e.NameScope.Find<Popup>(PartNames.PART_Popup);
|
||||
e.NameScope.Find<Popup>(PartNames.PART_Popup);
|
||||
_startTextBox = e.NameScope.Find<TextBox>(PART_StartTextBox);
|
||||
_endTextBox = e.NameScope.Find<TextBox>(PART_EndTextBox);
|
||||
_startPresenter = e.NameScope.Find<TimePickerPresenter>(PART_StartPresenter);
|
||||
@@ -127,18 +126,18 @@ public class TimeRangePicker : TimePickerBase, IClearControl
|
||||
Button.ClickEvent.AddHandler(OnButtonClick, _button);
|
||||
}
|
||||
|
||||
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||
private void OnButtonClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Focus(NavigationMethod.Pointer);
|
||||
SetCurrentValue(IsDropdownOpenProperty, !IsDropdownOpen);
|
||||
}
|
||||
|
||||
private void OnTextBoxPointerPressed(object sender, PointerPressedEventArgs e)
|
||||
private void OnTextBoxPointerPressed(object? sender, PointerPressedEventArgs e)
|
||||
{
|
||||
SetCurrentValue(IsDropdownOpenProperty, true);
|
||||
}
|
||||
|
||||
private void OnTextBoxGetFocus(object sender, GotFocusEventArgs e)
|
||||
private void OnTextBoxGetFocus(object? sender, GotFocusEventArgs e)
|
||||
{
|
||||
SetCurrentValue(IsDropdownOpenProperty, true);
|
||||
}
|
||||
@@ -161,7 +160,7 @@ public class TimeRangePicker : TimePickerBase, IClearControl
|
||||
|
||||
if (e.Key == Key.Tab)
|
||||
{
|
||||
if (e.Source == _endTextBox) SetCurrentValue(IsDropdownOpenProperty, false);
|
||||
if (Equals(e.Source, _endTextBox)) SetCurrentValue(IsDropdownOpenProperty, false);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,5 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Controls.Presenters;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.VisualTree;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user