Skip to content

Commit ad0e6fd

Browse files
committed
Minor code refactoring to use the new extensions
1 parent 23e223c commit ad0e6fd

File tree

7 files changed

+14
-15
lines changed

7 files changed

+14
-15
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.Markdown/Render/MarkdownTable.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,7 @@ protected override Size ArrangeOverride(Size finalSize)
155155
var columnIndex = Grid.GetColumn(child);
156156
var rowIndex = Grid.GetRow(child);
157157

158-
var rect = new Rect(0, 0, 0, 0)
159-
{
160-
X = _borderThickness
161-
};
158+
var rect = new Rect(_borderThickness, 0, 0, 0);
162159

163160
for (int col = 0; col < columnIndex; col++)
164161
{

Microsoft.Toolkit.Uwp.UI.Controls/Eyedropper/Eyedropper.Logic.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
using Windows.UI;
1313
using Windows.UI.Xaml;
1414
using Windows.UI.Xaml.Media.Imaging;
15+
using Microsoft.Toolkit.Uwp.Extensions;
1516

1617
namespace Microsoft.Toolkit.Uwp.UI.Controls
1718
{
@@ -98,7 +99,7 @@ private void UpdatePreview(int centerX, int centerY)
9899
for (var j = colorStartX; j < colorEndX; j++)
99100
{
100101
var color = colors[((i - colorStartY) * width) + (j - colorStartX)];
101-
drawingSession.FillRectangle(new Rect(startPoint, size), color);
102+
drawingSession.FillRectangle(startPoint.ToRect(size), color);
102103
startPoint.X += PreviewPixelsPerRawPixel;
103104
}
104105

Microsoft.Toolkit.Uwp.UI.Controls/Eyedropper/EyedropperToolButton.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
using System;
66
using System.Threading.Tasks;
7+
using Microsoft.Toolkit.Uwp.Extensions;
78
using Windows.Foundation;
89
using Windows.UI.Core;
910
using Windows.UI.Xaml;
@@ -216,8 +217,8 @@ private async Task UpdateEyedropperWorkAreaAsync()
216217
}
217218

218219
var transform = TargetElement.TransformToVisual(content);
219-
var position = transform.TransformPoint(default(Point));
220-
_eyedropper.WorkArea = new Rect(position, new Size(TargetElement.ActualWidth, TargetElement.ActualHeight));
220+
var position = transform.TransformPoint(default);
221+
_eyedropper.WorkArea = position.ToRect(TargetElement.ActualWidth, TargetElement.ActualHeight);
221222
if (ControlHelpers.IsXamlRootAvailable && XamlRoot != null)
222223
{
223224
_eyedropper.XamlRoot = XamlRoot;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
using System;
66
using System.Threading.Tasks;
7+
using Microsoft.Toolkit.Uwp.Extensions;
78
using Windows.Foundation;
8-
using Windows.Graphics.Imaging;
99
using Windows.Storage;
1010
using Windows.Storage.Streams;
1111
using Windows.UI.Xaml;
@@ -120,7 +120,7 @@ private Size MinSelectSize
120120
{
121121
get
122122
{
123-
var realMinSelectSize = _imageTransform.TransformBounds(new Rect(default(Point), MinCropSize));
123+
var realMinSelectSize = _imageTransform.TransformBounds(MinCropSize.ToRect());
124124
var minLength = Math.Min(realMinSelectSize.Width, realMinSelectSize.Height);
125125
if (minLength < MinSelectedLength)
126126
{

Microsoft.Toolkit.Uwp.UI.Controls/OrbitView/OrbitViewPanel.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System;
66
using System.Collections.Generic;
77
using System.Linq;
8+
using Microsoft.Toolkit.Uwp.Extensions;
89
using Microsoft.Toolkit.Uwp.UI.Extensions;
910
using Windows.Foundation;
1011
using Windows.UI.Xaml;
@@ -131,7 +132,7 @@ protected override Size ArrangeOverride(Size finalSize)
131132
var y_normalized = (finalSize.Height / 2) - y - (element.DesiredSize.Height / 2);
132133
var point = new Point(x_normalized, y_normalized);
133134

134-
element.Arrange(new Rect(point, element.DesiredSize));
135+
element.Arrange(point.ToRect(element.DesiredSize));
135136

136137
var elementProperties = new OrbitViewElementProperties()
137138
{

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
using System;
66
using System.Collections;
77
using System.Collections.Specialized;
8+
using Microsoft.Toolkit.Uwp.Extensions;
89
using Microsoft.Toolkit.Uwp.Helpers;
9-
using Windows.Foundation;
1010
using Windows.UI.Xaml;
1111
using Windows.UI.Xaml.Controls;
1212
using Windows.UI.Xaml.Media;
@@ -143,7 +143,7 @@ private void RotatorTile_SizeChanged(object sender, SizeChangedEventArgs e)
143143
}
144144

145145
// Set clip to control
146-
Clip = new RectangleGeometry() { Rect = new Rect(default(Point), e.NewSize) };
146+
Clip = new RectangleGeometry { Rect = e.NewSize.ToRect() };
147147
}
148148

149149
private void RotatorTile_Loaded(object sender, RoutedEventArgs e)

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
using Windows.Foundation.Metadata;
1111
using Windows.UI.Xaml;
1212
using Windows.UI.Xaml.Controls;
13-
using Windows.UI.Xaml.Data;
1413

1514
namespace Microsoft.Toolkit.Uwp.UI.Controls
1615
{
@@ -20,7 +19,7 @@ namespace Microsoft.Toolkit.Uwp.UI.Controls
2019
public partial class UniformGrid : Grid
2120
{
2221
// Guard for 15063 as Grid Spacing only works on 16299+.
23-
private static bool _hasGridSpacing = ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Grid", "ColumnSpacing");
22+
private static readonly bool _hasGridSpacing = ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Controls.Grid", "ColumnSpacing");
2423

2524
// Internal list we use to keep track of items that we don't have space to layout.
2625
private List<UIElement> _overflow = new List<UIElement>();
@@ -161,7 +160,7 @@ protected override Size ArrangeOverride(Size finalSize)
161160
// Make sure all overflown elements have no size.
162161
foreach (var child in _overflow)
163162
{
164-
child.Arrange(new Rect(0, 0, 0, 0));
163+
child.Arrange(default);
165164
}
166165

167166
_overflow = new List<UIElement>(); // Reset for next time.

0 commit comments

Comments
 (0)