Skip to content

Commit ef765d9

Browse files
authored
Merge branch 'master' into feature/parameterless-throw-helpers2
2 parents 746eeee + 06eed0d commit ef765d9

File tree

8 files changed

+235
-111
lines changed

8 files changed

+235
-111
lines changed

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/WrapPanel/WrapPanel.bind

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@
4949
HorizontalSpacing="@[HorizontalSpacing:Slider:5:0-200]@" />
5050
</ItemsPanelTemplate>
5151
</ItemsControl.ItemsPanel>
52+
<ListView.ItemContainerStyle>
53+
<Style TargetType="ListViewItem">
54+
<!-- Change those values to change the WrapPanel's children alignment -->
55+
<Setter Property="VerticalContentAlignment" Value="Center" />
56+
<Setter Property="HorizontalContentAlignment" Value="Center" />
57+
<Setter Property="Padding" Value="0" />
58+
<Setter Property="MinWidth" Value="0" />
59+
<Setter Property="MinHeight" Value="0" />
60+
</Style>
61+
</ListView.ItemContainerStyle>
5262
</ListView>
5363
</Grid>
5464
</Page>

Microsoft.Toolkit.Uwp.SampleApp/SamplePages/WrapPanel/WrapPanelPage.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ private void AddButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
6464
{
6565
Category = "Remove",
6666
Thumbnail = "ms-appx:///Assets/Photos/BigFourSummerHeat.jpg",
67-
Width = Rand.Next(120, 180),
68-
Height = Rand.Next(80, 130)
67+
Width = Rand.Next(60, 180),
68+
Height = Rand.Next(40, 140)
6969
});
7070
}
7171

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
}

Microsoft.Toolkit.Uwp.UI.Controls/WrapPanel/WrapPanel.Data.cs

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5+
using System;
6+
using System.Collections.Generic;
7+
using Microsoft.Toolkit.Diagnostics;
8+
using Windows.Foundation;
59
using Windows.UI.Xaml.Controls;
610

711
namespace Microsoft.Toolkit.Uwp.UI.Controls
@@ -14,12 +18,17 @@ public partial class WrapPanel
1418
[System.Diagnostics.DebuggerDisplay("U = {U} V = {V}")]
1519
private struct UvMeasure
1620
{
17-
internal static readonly UvMeasure Zero = default(UvMeasure);
21+
internal static UvMeasure Zero => default;
1822

1923
internal double U { get; set; }
2024

2125
internal double V { get; set; }
2226

27+
public UvMeasure(Orientation orientation, Size size)
28+
: this(orientation, size.Width, size.Height)
29+
{
30+
}
31+
2332
public UvMeasure(Orientation orientation, double width, double height)
2433
{
2534
if (orientation == Orientation.Horizontal)
@@ -33,6 +42,56 @@ public UvMeasure(Orientation orientation, double width, double height)
3342
V = width;
3443
}
3544
}
45+
46+
public UvMeasure Add(double u, double v)
47+
=> new UvMeasure { U = U + u, V = V + v };
48+
49+
public UvMeasure Add(UvMeasure measure)
50+
=> Add(measure.U, measure.V);
51+
52+
public Size ToSize(Orientation orientation)
53+
=> orientation == Orientation.Horizontal ? new Size(U, V) : new Size(V, U);
54+
}
55+
56+
private struct UvRect
57+
{
58+
public UvMeasure Position { get; set; }
59+
60+
public UvMeasure Size { get; set; }
61+
62+
public Rect ToRect(Orientation orientation) => orientation switch
63+
{
64+
Orientation.Vertical => new Rect(Position.V, Position.U, Size.V, Size.U),
65+
Orientation.Horizontal => new Rect(Position.U, Position.V, Size.U, Size.V),
66+
_ => ThrowHelper.ThrowNotSupportedException<Rect>("unsupported orientation"),
67+
};
68+
}
69+
70+
private struct Row
71+
{
72+
public Row(List<UvRect> childrenRects, UvMeasure size)
73+
{
74+
ChildrenRects = childrenRects;
75+
Size = size;
76+
}
77+
78+
public List<UvRect> ChildrenRects { get; }
79+
80+
public UvMeasure Size { get; set; }
81+
82+
public UvRect Rect => ChildrenRects.Count > 0 ?
83+
new UvRect { Position = ChildrenRects[0].Position, Size = Size } :
84+
new UvRect { Position = UvMeasure.Zero, Size = Size };
85+
86+
public void Add(UvMeasure position, UvMeasure size)
87+
{
88+
ChildrenRects.Add(new UvRect { Position = position, Size = size });
89+
Size = new UvMeasure
90+
{
91+
U = position.U + size.U,
92+
V = Math.Max(Size.V, size.V),
93+
};
94+
}
3695
}
3796
}
3897
}

0 commit comments

Comments
 (0)