-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic date/time picker automation peers. (#17426)
- Loading branch information
Showing
4 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
src/Avalonia.Controls/Automation/Peers/DatePickerAutomationPeer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Avalonia.Controls/Automation/Peers/TimePickerAutomationPeer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters