Skip to content

Commit

Permalink
[create-pull-request] automated change
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 8, 2022
1 parent 0ace1bf commit a1f6db6
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Microsoft.AspNetCore.Components.WebView.Maui
#endif
{
internal class BlazorWebViewDeveloperTools
{
public bool Enabled { get; set; } = false;
}
{
public bool Enabled { get; set; } = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public static IMauiBlazorWebViewBuilder AddMauiBlazorWebView(this IServiceCollec
#endif
}

/// <summary>
/// Enables Developer tools on the underlying WebView controls.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
/// <returns>The <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddBlazorWebViewDeveloperTools(this IServiceCollection services)
{
return services.AddSingleton<BlazorWebViewDeveloperTools>(new BlazorWebViewDeveloperTools { Enabled = true });
}
/// <summary>
/// Enables Developer tools on the underlying WebView controls.
/// </summary>
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
/// <returns>The <see cref="IServiceCollection"/>.</returns>
public static IServiceCollection AddBlazorWebViewDeveloperTools(this IServiceCollection services)
{
return services.AddSingleton<BlazorWebViewDeveloperTools>(new BlazorWebViewDeveloperTools { Enabled = true });
}
}
}
4 changes: 2 additions & 2 deletions src/Controls/src/Core/Platform/iOS/DragAndDropDelegate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public DragAndDropDelegate(IPlatformViewHandler viewHandler)
_viewHandler = viewHandler;
}

#region UIDragInteractionDelegate
#region UIDragInteractionDelegate
[Export("dragInteraction:session:willEndWithOperation:")]
[Preserve(Conditional = true)]
public void SessionWillEnd(UIDragInteraction interaction, IUIDragSession session, UIDropOperation operation)
Expand All @@ -39,7 +39,7 @@ public UIDragItem[] GetItemsForBeginningSession(UIDragInteraction interaction, I
{
return HandleDragStarting((View)_viewHandler.VirtualView, _viewHandler);
}
#endregion
#endregion

[Export("dropInteraction:canHandleSession:")]
[Preserve(Conditional = true)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ await InvokeOnMainThreadAsync(() =>
// so on iOS we just return the shadow that was hard coded into the renderer
var expectedShadow = new Shadow() { Radius = 5, Opacity = 0.8f, Offset = new Point(0, 0), Brush = Brush.Black };
if(platformView.Element is IView element)
if (platformView.Element is IView element)
{
var platformShadow = element.Shadow;
await AssertionExtensions.Wait(() => platformShadow != null);
Expand All @@ -45,7 +45,7 @@ await InvokeOnMainThreadAsync(() =>
Assert.Equal(platformShadow.Opacity, expectedShadow.Opacity);
Assert.Equal(platformShadow.Offset, expectedShadow.Offset);
}
}));
}));
}
}
}
2 changes: 1 addition & 1 deletion src/Essentials/src/Platform/PlatformUtils.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal static void SetLocale(Java.Util.Locale locale)
else
#endif
#pragma warning disable CS0618 // Type or member is obsolete
config.Locale = locale;
config.Locale = locale;
#pragma warning restore CS0618 // Type or member is obsolete

#pragma warning disable CS0618 // Type or member is obsolete
Expand Down
62 changes: 31 additions & 31 deletions src/Graphics/src/Graphics.Win2D/W2DCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,42 +239,42 @@ public override void DrawString(string value, float x, float y, HorizontalAlignm
try
{
#endif
var textFormat = (CurrentState.Font ?? Graphics.Font.Default).ToCanvasTextFormat(CurrentState.FontSize);
textFormat.VerticalAlignment = CanvasVerticalAlignment.Top;
var textFormat = (CurrentState.Font ?? Graphics.Font.Default).ToCanvasTextFormat(CurrentState.FontSize);
textFormat.VerticalAlignment = CanvasVerticalAlignment.Top;

switch (horizontalAlignment)
{
case HorizontalAlignment.Left:
_rect.X = x;
_rect.Width = CanvasSize.Width;
textFormat.HorizontalAlignment = CanvasHorizontalAlignment.Left;
break;
case HorizontalAlignment.Right:
_rect.X = x - CanvasSize.Width;
_rect.Width = CanvasSize.Width;
textFormat.HorizontalAlignment = CanvasHorizontalAlignment.Right;
break;
default:
_rect.X = x - _canvasSize.Width;
_rect.Width = _canvasSize.Width * 2;
textFormat.HorizontalAlignment = CanvasHorizontalAlignment.Center;
break;
}
switch (horizontalAlignment)
{
case HorizontalAlignment.Left:
_rect.X = x;
_rect.Width = CanvasSize.Width;
textFormat.HorizontalAlignment = CanvasHorizontalAlignment.Left;
break;
case HorizontalAlignment.Right:
_rect.X = x - CanvasSize.Width;
_rect.Width = CanvasSize.Width;
textFormat.HorizontalAlignment = CanvasHorizontalAlignment.Right;
break;
default:
_rect.X = x - _canvasSize.Width;
_rect.Width = _canvasSize.Width * 2;
textFormat.HorizontalAlignment = CanvasHorizontalAlignment.Center;
break;
}

_rect.Y = y - CurrentState.FontSize;
_rect.Height = CurrentState.FontSize * 2;
_rect.Y = y - CurrentState.FontSize;
_rect.Height = CurrentState.FontSize * 2;

_point1.X = (float)_rect.X;
_point1.Y = (float)_rect.Y;
_point1.X = (float)_rect.X;
_point1.Y = (float)_rect.Y;

var textLayout = new CanvasTextLayout(
_session,
value,
textFormat,
(float)_rect.Width,
(float)_rect.Height);
var textLayout = new CanvasTextLayout(
_session,
value,
textFormat,
(float)_rect.Width,
(float)_rect.Height);

Draw(ctx => ctx.DrawTextLayout(textLayout, _point1, CurrentState.PlatformFontBrush));
Draw(ctx => ctx.DrawTextLayout(textLayout, _point1, CurrentState.PlatformFontBrush));

#if DEBUG

Expand Down
192 changes: 96 additions & 96 deletions src/Graphics/src/Graphics.Win2D/W2DExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,122 +66,122 @@ public static CanvasGeometry AsPath(this PathF path, float ox, float oy, float f
try
{
#endif
builder.SetFilledRegionDetermination(fillMode);
builder.SetFilledRegionDetermination(fillMode);

var pointIndex = 0;
var arcAngleIndex = 0;
var arcClockwiseIndex = 0;
var figureOpen = false;
var segmentIndex = -1;
var pointIndex = 0;
var arcAngleIndex = 0;
var arcClockwiseIndex = 0;
var figureOpen = false;
var segmentIndex = -1;

var lastOperation = PathOperation.Move;
var lastOperation = PathOperation.Move;

foreach (var type in path.SegmentTypes)
{
segmentIndex++;

if (type == PathOperation.Move)
{
if (lastOperation != PathOperation.Close && lastOperation != PathOperation.Move)
{
builder.EndFigure(CanvasFigureLoop.Open);
}
foreach (var type in path.SegmentTypes)
{
segmentIndex++;

var point = path[pointIndex++];
var begin = CanvasFigureFill.Default;
builder.BeginFigure(ox + point.X * fx, oy + point.Y * fy, begin);
figureOpen = true;
}
else if (type == PathOperation.Line)
if (type == PathOperation.Move)
{
if (lastOperation != PathOperation.Close && lastOperation != PathOperation.Move)
{
var point = path[pointIndex++];
builder.AddLine(ox + point.X * fx, oy + point.Y * fy);
builder.EndFigure(CanvasFigureLoop.Open);
}

else if (type == PathOperation.Quad)
{
var controlPoint = path[pointIndex++];
var endPoint = path[pointIndex++];
var point = path[pointIndex++];
var begin = CanvasFigureFill.Default;
builder.BeginFigure(ox + point.X * fx, oy + point.Y * fy, begin);
figureOpen = true;
}
else if (type == PathOperation.Line)
{
var point = path[pointIndex++];
builder.AddLine(ox + point.X * fx, oy + point.Y * fy);
}

else if (type == PathOperation.Quad)
{
var controlPoint = path[pointIndex++];
var endPoint = path[pointIndex++];

builder.AddQuadraticBezier(
new Vector2(ox + controlPoint.X * fx, oy + controlPoint.Y * fy),
new Vector2(ox + endPoint.X * fx, oy + endPoint.Y * fy));
}
else if (type == PathOperation.Cubic)
{
var controlPoint1 = path[pointIndex++];
var controlPoint2 = path[pointIndex++];
var endPoint = path[pointIndex++];
builder.AddCubicBezier(
new Vector2(ox + controlPoint1.X * fx, oy + controlPoint1.Y * fy),
new Vector2(ox + controlPoint2.X * fx, oy + controlPoint2.Y * fy),
new Vector2(ox + endPoint.X * fx, oy + endPoint.Y * fy));
}
else if (type == PathOperation.Arc)
{
var topLeft = path[pointIndex++];
var bottomRight = path[pointIndex++];
var startAngle = path.GetArcAngle(arcAngleIndex++);
var endAngle = path.GetArcAngle(arcAngleIndex++);
var clockwise = path.GetArcClockwise(arcClockwiseIndex++);

builder.AddQuadraticBezier(
new Vector2(ox + controlPoint.X * fx, oy + controlPoint.Y * fy),
new Vector2(ox + endPoint.X * fx, oy + endPoint.Y * fy));
while (startAngle < 0)
{
startAngle += 360;
}
else if (type == PathOperation.Cubic)

while (endAngle < 0)
{
var controlPoint1 = path[pointIndex++];
var controlPoint2 = path[pointIndex++];
var endPoint = path[pointIndex++];
builder.AddCubicBezier(
new Vector2(ox + controlPoint1.X * fx, oy + controlPoint1.Y * fy),
new Vector2(ox + controlPoint2.X * fx, oy + controlPoint2.Y * fy),
new Vector2(ox + endPoint.X * fx, oy + endPoint.Y * fy));
endAngle += 360;
}
else if (type == PathOperation.Arc)

var rotation = GeometryUtil.GetSweep(startAngle, endAngle, clockwise);
var absRotation = Math.Abs(rotation);

var rectX = ox + topLeft.X * fx;
var rectY = oy + topLeft.Y * fy;
var rectWidth = (ox + bottomRight.X * fx) - rectX;
var rectHeight = (oy + bottomRight.Y * fy) - rectY;

var startPoint = GeometryUtil.EllipseAngleToPoint(rectX, rectY, rectWidth, rectHeight, -startAngle);
var endPoint = GeometryUtil.EllipseAngleToPoint(rectX, rectY, rectWidth, rectHeight, -endAngle);


if (!figureOpen)
{
var topLeft = path[pointIndex++];
var bottomRight = path[pointIndex++];
var startAngle = path.GetArcAngle(arcAngleIndex++);
var endAngle = path.GetArcAngle(arcAngleIndex++);
var clockwise = path.GetArcClockwise(arcClockwiseIndex++);

while (startAngle < 0)
{
startAngle += 360;
}

while (endAngle < 0)
{
endAngle += 360;
}

var rotation = GeometryUtil.GetSweep(startAngle, endAngle, clockwise);
var absRotation = Math.Abs(rotation);

var rectX = ox + topLeft.X * fx;
var rectY = oy + topLeft.Y * fy;
var rectWidth = (ox + bottomRight.X * fx) - rectX;
var rectHeight = (oy + bottomRight.Y * fy) - rectY;

var startPoint = GeometryUtil.EllipseAngleToPoint(rectX, rectY, rectWidth, rectHeight, -startAngle);
var endPoint = GeometryUtil.EllipseAngleToPoint(rectX, rectY, rectWidth, rectHeight, -endAngle);


if (!figureOpen)
{
var begin = CanvasFigureFill.Default;
builder.BeginFigure(startPoint.X, startPoint.Y, begin);
figureOpen = true;
}
else
{
builder.AddLine(startPoint.X, startPoint.Y);
}

builder.AddArc(
new Vector2(endPoint.X, endPoint.Y),
rectWidth / 2,
rectHeight / 2,
0,
clockwise ? CanvasSweepDirection.Clockwise : CanvasSweepDirection.CounterClockwise,
absRotation >= 180 ? CanvasArcSize.Large : CanvasArcSize.Small
);
var begin = CanvasFigureFill.Default;
builder.BeginFigure(startPoint.X, startPoint.Y, begin);
figureOpen = true;
}
else if (type == PathOperation.Close)
else
{
builder.EndFigure(CanvasFigureLoop.Closed);
builder.AddLine(startPoint.X, startPoint.Y);
}

lastOperation = type;
builder.AddArc(
new Vector2(endPoint.X, endPoint.Y),
rectWidth / 2,
rectHeight / 2,
0,
clockwise ? CanvasSweepDirection.Clockwise : CanvasSweepDirection.CounterClockwise,
absRotation >= 180 ? CanvasArcSize.Large : CanvasArcSize.Small
);
}

if (segmentIndex >= 0 && lastOperation != PathOperation.Close)
else if (type == PathOperation.Close)
{
builder.EndFigure(CanvasFigureLoop.Open);
builder.EndFigure(CanvasFigureLoop.Closed);
}

var geometry = CanvasGeometry.CreatePath(builder);
return geometry;
lastOperation = type;
}

if (segmentIndex >= 0 && lastOperation != PathOperation.Close)
{
builder.EndFigure(CanvasFigureLoop.Open);
}

var geometry = CanvasGeometry.CreatePath(builder);
return geometry;
#if DEBUG
}
catch (Exception exc)
Expand Down

0 comments on commit a1f6db6

Please sign in to comment.