2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+ using Microsoft . Toolkit . Diagnostics ;
5
6
using System ;
6
7
using System . Collections . Generic ;
7
8
using Windows . Foundation ;
@@ -17,7 +18,7 @@ public partial class WrapPanel
17
18
[ System . Diagnostics . DebuggerDisplay ( "U = {U} V = {V}" ) ]
18
19
private struct UvMeasure
19
20
{
20
- internal static readonly UvMeasure Zero = default ;
21
+ internal static UvMeasure Zero => default ;
21
22
22
23
internal double U { get ; set ; }
23
24
@@ -62,37 +63,34 @@ private struct UvRect
62
63
{
63
64
Orientation . Vertical => new Rect ( Position . V , Position . U , Size . V , Size . U ) ,
64
65
Orientation . Horizontal => new Rect ( Position . U , Position . V , Size . U , Size . V ) ,
65
- _ => throw new NotSupportedException ( ) ,
66
+ _ => ThrowHelper . ThrowNotSupportedException < Rect > ( "unsupported orientation" ) ,
66
67
} ;
67
68
}
68
69
69
70
private struct Row
70
71
{
71
- private readonly List < UvRect > _childrenRects ;
72
- private UvMeasure _rowSize ;
73
-
74
72
public Row ( List < UvRect > childrenRects , UvMeasure size )
75
73
{
76
- _childrenRects = childrenRects ;
77
- _rowSize = size ;
74
+ ChildrenRects = childrenRects ;
75
+ Size = size ;
78
76
}
79
77
80
- public IReadOnlyList < UvRect > ChildrenRects => _childrenRects ;
78
+ public List < UvRect > ChildrenRects { get ; }
81
79
82
- /// <summary>
83
- /// Gets the size of the row.
84
- /// </summary>
85
- public UvMeasure Size => _rowSize ;
80
+ public UvMeasure Size { get ; set ; }
86
81
87
- public UvRect Rect => _childrenRects . Count > 0 ?
88
- new UvRect { Position = _childrenRects [ 0 ] . Position , Size = Size } :
82
+ public UvRect Rect => ChildrenRects . Count > 0 ?
83
+ new UvRect { Position = ChildrenRects [ 0 ] . Position , Size = Size } :
89
84
new UvRect { Position = UvMeasure . Zero , Size = Size } ;
90
85
91
86
public void Add ( UvMeasure position , UvMeasure size )
92
87
{
93
- _childrenRects . Add ( new UvRect { Position = position , Size = size } ) ;
94
- _rowSize . U = position . U + size . U ;
95
- _rowSize . V = Math . Max ( _rowSize . V , size . V ) ;
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
+ } ;
96
94
}
97
95
}
98
96
}
0 commit comments