зеркало из https://github.com/AvaloniaUI/Avalonia.git
Added basic date/time picker automation peers. (#17426)
This commit is contained in:
Родитель
b78b995042
Коммит
57b4be4b73
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using Avalonia.Automation.Provider;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Avalonia.Automation.Peers;
|
||||
|
||||
public class DatePickerAutomationPeer : ControlAutomationPeer, IValueProvider
|
||||
{
|
||||
public DatePickerAutomationPeer(DatePicker owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsReadOnly => false;
|
||||
public new DatePicker Owner => (DatePicker)base.Owner;
|
||||
public string? Value => Owner.SelectedDate?.ToString();
|
||||
|
||||
public void SetValue(string? value)
|
||||
{
|
||||
if (DateTimeOffset.TryParse(value, out var result))
|
||||
Owner.SelectedDate = result;
|
||||
}
|
||||
|
||||
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Custom;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using Avalonia.Automation.Provider;
|
||||
using Avalonia.Controls;
|
||||
|
||||
namespace Avalonia.Automation.Peers;
|
||||
|
||||
public class TimePickerAutomationPeer : ControlAutomationPeer, IValueProvider
|
||||
{
|
||||
public TimePickerAutomationPeer(TimePicker owner)
|
||||
: base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public bool IsReadOnly => false;
|
||||
public new TimePicker Owner => (TimePicker)base.Owner;
|
||||
public string? Value => Owner.SelectedTime?.ToString();
|
||||
|
||||
public void SetValue(string? value)
|
||||
{
|
||||
if (TimeSpan.TryParse(value, out var result))
|
||||
Owner.SelectedTime = result;
|
||||
}
|
||||
|
||||
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Custom;
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Automation.Peers;
|
||||
using Avalonia.Controls.Metadata;
|
||||
using Avalonia.Controls.Primitives;
|
||||
using Avalonia.Controls.Shapes;
|
||||
using Avalonia.Data;
|
||||
|
@ -267,6 +268,8 @@ namespace Avalonia.Controls
|
|||
}
|
||||
}
|
||||
|
||||
protected override AutomationPeer OnCreateAutomationPeer() => new DatePickerAutomationPeer(this);
|
||||
|
||||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
||||
{
|
||||
base.OnPropertyChanged(change);
|
||||
|
|
|
@ -6,6 +6,7 @@ using Avalonia.Layout;
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using Avalonia.Controls.Utils;
|
||||
using Avalonia.Automation.Peers;
|
||||
|
||||
namespace Avalonia.Controls
|
||||
{
|
||||
|
@ -330,6 +331,8 @@ namespace Avalonia.Controls
|
|||
}
|
||||
}
|
||||
|
||||
protected override AutomationPeer OnCreateAutomationPeer() => new TimePickerAutomationPeer(this);
|
||||
|
||||
protected virtual void OnSelectedTimeChanged(TimeSpan? oldTime, TimeSpan? newTime)
|
||||
{
|
||||
SelectedTimeChanged?.Invoke(this, new TimePickerSelectedValueChangedEventArgs(oldTime, newTime));
|
||||
|
|
Загрузка…
Ссылка в новой задаче