Skip to content

Commit c0f9b5a

Browse files
committed
removed unneeded code
1 parent 97b9dba commit c0f9b5a

File tree

2 files changed

+4
-70
lines changed

2 files changed

+4
-70
lines changed

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

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
using System;
66
using System.Collections.Generic;
7-
using System.Runtime.InteropServices.WindowsRuntime;
87
using Windows.Foundation;
9-
using Windows.UI.Xaml;
108
using Windows.UI.Xaml.Controls;
119

1210
namespace Microsoft.Toolkit.Uwp.UI.Controls
@@ -54,64 +52,6 @@ private struct UvRect
5452

5553
public UvMeasure Size { get; set; }
5654

57-
public UvRect WithVerticalAlignment(VerticalAlignment alignment, double maxHeight)
58-
{
59-
switch (alignment)
60-
{
61-
case VerticalAlignment.Center:
62-
return new UvRect
63-
{
64-
Position = Position.Add(
65-
u: 0,
66-
v: Math.Max((maxHeight - Size.V) / 2.0, 0.0)),
67-
Size = Size,
68-
};
69-
case VerticalAlignment.Bottom:
70-
return new UvRect
71-
{
72-
Position = Position.Add(
73-
u: 0,
74-
v: Math.Max(maxHeight - Size.V, 0.0)),
75-
Size = Size,
76-
};
77-
case VerticalAlignment.Stretch:
78-
return new UvRect
79-
{
80-
Position = Position,
81-
Size = new UvMeasure { U = Size.U, V = maxHeight },
82-
};
83-
case VerticalAlignment.Top:
84-
default:
85-
return this;
86-
}
87-
}
88-
89-
public UvRect WithHorizontalAlignment(HorizontalAlignment alignment, double maxHeight)
90-
{
91-
// Since (U,V) coordinates are flipped, we can use the exact same logic as for the vertical alignment
92-
// We just convert the HorizontalAlignment values to VerticalAlignment values (more or less a no-op
93-
// since the integer values are the same).
94-
VerticalAlignment verticalAlignment;
95-
switch (alignment)
96-
{
97-
case HorizontalAlignment.Center:
98-
verticalAlignment = VerticalAlignment.Center;
99-
break;
100-
case HorizontalAlignment.Right:
101-
verticalAlignment = VerticalAlignment.Bottom;
102-
break;
103-
case HorizontalAlignment.Stretch:
104-
verticalAlignment = VerticalAlignment.Stretch;
105-
break;
106-
case HorizontalAlignment.Left:
107-
default:
108-
verticalAlignment = VerticalAlignment.Top;
109-
break;
110-
}
111-
112-
return WithVerticalAlignment(verticalAlignment, maxHeight);
113-
}
114-
11555
public Rect ToRect(Orientation orientation)
11656
{
11757
switch (orientation)

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

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,17 +262,11 @@ void Arrange(UIElement child, bool isLast = false)
262262
foreach (var rect in row.ChildrenRects)
263263
{
264264
var child = Children[childIndex++];
265-
UvRect arrangeRect;
266-
if (Orientation == Orientation.Horizontal)
265+
var arrangeRect = new UvRect
267266
{
268-
var verticalAlignment = (child as FrameworkElement)?.VerticalAlignment ?? VerticalAlignment.Top;
269-
arrangeRect = rect.WithVerticalAlignment(verticalAlignment, row.Size.V);
270-
}
271-
else
272-
{
273-
var horizontalAlignment = (child as FrameworkElement)?.HorizontalAlignment ?? HorizontalAlignment.Left;
274-
arrangeRect = rect.WithHorizontalAlignment(horizontalAlignment, row.Size.V);
275-
}
267+
Position = rect.Position,
268+
Size = new UvMeasure { U = rect.Size.U, V = row.Size.V },
269+
};
276270

277271
var finalRect = arrangeRect.ToRect(Orientation);
278272
child.Arrange(finalRect);

0 commit comments

Comments
 (0)