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 Microsoft . Toolkit . Diagnostics ;
56using System ;
67using System . Collections . Generic ;
78using Windows . Foundation ;
@@ -17,7 +18,7 @@ public partial class WrapPanel
1718 [ System . Diagnostics . DebuggerDisplay ( "U = {U} V = {V}" ) ]
1819 private struct UvMeasure
1920 {
20- internal static readonly UvMeasure Zero = default ;
21+ internal static UvMeasure Zero => default ;
2122
2223 internal double U { get ; set ; }
2324
@@ -62,37 +63,34 @@ private struct UvRect
6263 {
6364 Orientation . Vertical => new Rect ( Position . V , Position . U , Size . V , Size . U ) ,
6465 Orientation . Horizontal => new Rect ( Position . U , Position . V , Size . U , Size . V ) ,
65- _ => throw new NotSupportedException ( ) ,
66+ _ => ThrowHelper . ThrowNotSupportedException < Rect > ( "unsupported orientation" ) ,
6667 } ;
6768 }
6869
6970 private struct Row
7071 {
71- private readonly List < UvRect > _childrenRects ;
72- private UvMeasure _rowSize ;
73-
7472 public Row ( List < UvRect > childrenRects , UvMeasure size )
7573 {
76- _childrenRects = childrenRects ;
77- _rowSize = size ;
74+ ChildrenRects = childrenRects ;
75+ Size = size ;
7876 }
7977
80- public IReadOnlyList < UvRect > ChildrenRects => _childrenRects ;
78+ public List < UvRect > ChildrenRects { get ; }
8179
82- /// <summary>
83- /// Gets the size of the row.
84- /// </summary>
85- public UvMeasure Size => _rowSize ;
80+ public UvMeasure Size { get ; set ; }
8681
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 } :
8984 new UvRect { Position = UvMeasure . Zero , Size = Size } ;
9085
9186 public void Add ( UvMeasure position , UvMeasure size )
9287 {
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+ } ;
9694 }
9795 }
9896 }
0 commit comments