Skip to content

Commit a9c59ae

Browse files
Merge branch 'master' into wrapPanel.verticalAlignment
2 parents 20d95c1 + e3171b2 commit a9c59ae

File tree

4 files changed

+66
-10
lines changed

4 files changed

+66
-10
lines changed

Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGauge.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,11 @@ protected override void OnValueChanged(double oldValue, double newValue)
469469
{
470470
OnValueChanged(this);
471471
base.OnValueChanged(oldValue, newValue);
472+
if (AutomationPeer.ListenerExists(AutomationEvents.LiveRegionChanged))
473+
{
474+
var peer = FrameworkElementAutomationPeer.FromElement(this) as RadialGaugeAutomationPeer;
475+
peer?.RaiseValueChangedEvent(oldValue, newValue);
476+
}
472477
}
473478

474479
private static void OnValueChanged(DependencyObject d)

Microsoft.Toolkit.Uwp.UI.Controls/RadialGauge/RadialGaugeAutomationPeer.cs

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// See the LICENSE file in the project root for more information.
44

55
using System.Collections.Generic;
6+
using Windows.Foundation;
7+
using Windows.UI.Xaml.Automation;
68
using Windows.UI.Xaml.Automation.Peers;
79
using Windows.UI.Xaml.Automation.Provider;
810

@@ -12,7 +14,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
1214
/// Exposes <see cref="RadialGauge"/> to Microsoft UI Automation.
1315
/// </summary>
1416
public class RadialGaugeAutomationPeer :
15-
FrameworkElementAutomationPeer,
17+
RangeBaseAutomationPeer,
1618
IRangeValueProvider
1719
{
1820
/// <summary>
@@ -25,25 +27,25 @@ public RadialGaugeAutomationPeer(RadialGauge owner)
2527
}
2628

2729
/// <inheritdoc/>
28-
public bool IsReadOnly => !((RadialGauge)Owner).IsInteractive;
30+
public new bool IsReadOnly => !((RadialGauge)Owner).IsInteractive;
2931

3032
/// <inheritdoc/>
31-
public double LargeChange => ((RadialGauge)Owner).StepSize;
33+
public new double LargeChange => ((RadialGauge)Owner).StepSize;
3234

3335
/// <inheritdoc/>
34-
public double Maximum => ((RadialGauge)Owner).Maximum;
36+
public new double Maximum => ((RadialGauge)Owner).Maximum;
3537

3638
/// <inheritdoc/>
37-
public double Minimum => ((RadialGauge)Owner).Minimum;
39+
public new double Minimum => ((RadialGauge)Owner).Minimum;
3840

3941
/// <inheritdoc/>
40-
public double SmallChange => ((RadialGauge)Owner).StepSize;
42+
public new double SmallChange => ((RadialGauge)Owner).StepSize;
4143

4244
/// <inheritdoc/>
43-
public double Value => ((RadialGauge)Owner).Value;
45+
public new double Value => ((RadialGauge)Owner).Value;
4446

4547
/// <inheritdoc/>
46-
public void SetValue(double value)
48+
public new void SetValue(double value)
4749
{
4850
((RadialGauge)Owner).Value = value;
4951
}
@@ -58,7 +60,7 @@ protected override IList<AutomationPeer> GetChildrenCore()
5860
protected override string GetNameCore()
5961
{
6062
var gauge = (RadialGauge)Owner;
61-
return "radial gauge. " + (string.IsNullOrWhiteSpace(gauge.Unit) ? "no unit specified. " : "unit " + gauge.Unit + ". ");
63+
return "radial gauge. " + (string.IsNullOrWhiteSpace(gauge.Unit) ? "no unit specified, " : "unit " + gauge.Unit + ", ") + Value;
6264
}
6365

6466
/// <inheritdoc/>
@@ -78,5 +80,15 @@ protected override AutomationControlType GetAutomationControlTypeCore()
7880
{
7981
return AutomationControlType.Custom;
8082
}
83+
84+
/// <summary>
85+
/// Raises the property changed event for this AutomationPeer for the provided identifier.
86+
/// </summary>
87+
/// <param name="oldValue">Old value</param>
88+
/// <param name="newValue">New value</param>
89+
public void RaiseValueChangedEvent(double oldValue, double newValue)
90+
{
91+
RaisePropertyChangedEvent(RangeValuePatternIdentifiers.ValueProperty, PropertyValue.CreateDouble(oldValue), PropertyValue.CreateDouble(newValue));
92+
}
8193
}
8294
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using Microsoft.Toolkit.Uwp.UI.Controls;
6+
using Microsoft.VisualStudio.TestTools.UnitTesting;
7+
using Microsoft.VisualStudio.TestTools.UnitTesting.AppContainer;
8+
using Windows.UI.Xaml.Automation.Peers;
9+
10+
namespace UnitTests.UWP.UI.Controls
11+
{
12+
[TestClass]
13+
public class Test_RadialGauge
14+
{
15+
/// <summary>
16+
/// Verifies that the UIA name is valid and makes sense
17+
/// </summary>
18+
[TestCategory("Test_TextToolbar_Localization")]
19+
[UITestMethod]
20+
public void VerifyUIAName()
21+
{
22+
var gauge = new RadialGauge()
23+
{
24+
Minimum = 0,
25+
Maximum = 100,
26+
Value = 20
27+
};
28+
29+
var gaugePeer = FrameworkElementAutomationPeer.CreatePeerForElement(gauge);
30+
31+
Assert.IsTrue(gaugePeer.GetName().Contains(gauge.Value.ToString()), "Verify that the UIA name contains the value of the RadialGauge.");
32+
Assert.IsTrue(gaugePeer.GetName().Contains("no unit"), "The UIA name should indicate that unit was not specified.");
33+
34+
gauge.Unit = "KM/H";
35+
Assert.IsTrue(gaugePeer.GetName().Contains(gauge.Unit), "The UIA name should report the unit of the RadialGauge.");
36+
}
37+
}
38+
}

UnitTests/UnitTests.UWP/UnitTests.UWP.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@
179179
<Compile Include="PrivateType.cs" />
180180
<Compile Include="Properties\AssemblyInfo.cs" />
181181
<Compile Include="Helpers\Test_WeakEventListener.cs" />
182+
<Compile Include="UI\Controls\Test_RadialGauge.cs" />
182183
<Compile Include="UI\Controls\Test_TextToolbar_Localization.cs" />
183184
<Compile Include="UI\Controls\Test_InfiniteCanvas_Regression.cs" />
184185
<Compile Include="UI\Controls\Test_TokenizingTextBox_General.cs" />
@@ -498,4 +499,4 @@
498499
<Target Name="AfterBuild">
499500
</Target>
500501
-->
501-
</Project>
502+
</Project>

0 commit comments

Comments
 (0)