Browse Source

Merge pull request #10275 from AvaloniaUI/progressBar-automationPeer

Add ProgressBarAutomationPeer
pull/10284/head
Max Katz 4 years ago
committed by GitHub
parent
commit
0035fb6c7a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 62
      src/Avalonia.Controls/Automation/Peers/ProgressBarAutomationPeer.cs
  2. 7
      src/Avalonia.Controls/ProgressBar.cs

62
src/Avalonia.Controls/Automation/Peers/ProgressBarAutomationPeer.cs

@ -0,0 +1,62 @@
using System;
using Avalonia.Automation.Peers;
using Avalonia.Automation.Provider;
using Avalonia.Controls.Primitives;
namespace Avalonia.Controls.Automation.Peers
{
public class ProgressBarAutomationPeer : RangeBaseAutomationPeer, IRangeValueProvider
{
public ProgressBarAutomationPeer(RangeBase owner) : base(owner)
{
}
protected override string GetClassNameCore()
{
return "ProgressBar";
}
protected override AutomationControlType GetAutomationControlTypeCore()
{
return AutomationControlType.ProgressBar;
}
/// <summary>
/// Request to set the value that this UI element is representing
/// </summary>
/// <param name="val">Value to set the UI to, as an object</param>
/// <returns>true if the UI element was successfully set to the specified value</returns>
void IRangeValueProvider.SetValue(double val)
{
throw new InvalidOperationException("ProgressBar is ReadOnly, value can't be set.");
}
///<summary>Indicates that the value can only be read, not modified.
///returns True if the control is read-only</summary>
bool IRangeValueProvider.IsReadOnly
{
get
{
return true;
}
}
///<summary>Value of a Large Change</summary>
double IRangeValueProvider.LargeChange
{
get
{
return double.NaN;
}
}
///<summary>Value of a Small Change</summary>
double IRangeValueProvider.SmallChange
{
get
{
return double.NaN;
}
}
}
}

7
src/Avalonia.Controls/ProgressBar.cs

@ -1,4 +1,6 @@
using System;
using Avalonia.Automation.Peers;
using Avalonia.Controls.Automation.Peers;
using Avalonia.Controls.Metadata;
using Avalonia.Controls.Primitives;
using Avalonia.Data;
@ -228,6 +230,11 @@ namespace Avalonia.Controls
UpdateIndicator();
}
protected override AutomationPeer OnCreateAutomationPeer()
{
return new ProgressBarAutomationPeer(this);
}
private void UpdateIndicator()
{
// Gets the size of the parent indicator container

Loading…
Cancel
Save