Skip to content

Commit

Permalink
[Cleanup] Use named arguments in PresentationCore (#10321)
Browse files Browse the repository at this point in the history
* Cleanup: Use named arguments in PresentationCore.

Automated changes.

Contributes to #10018

* Cleanup: Use named arguments in PresentationCore.

Manual changes.

Contributes to #10018
  • Loading branch information
ThomasGoulet73 authored Feb 27, 2025
1 parent 7481b7e commit ef4f81d
Show file tree
Hide file tree
Showing 84 changed files with 319 additions and 321 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ internal static Rect InterpolateRect(Rect from, Rect to, Double progress)

internal static Rotation3D InterpolateRotation3D(Rotation3D from, Rotation3D to, Double progress)
{
return new QuaternionRotation3D(InterpolateQuaternion(from.InternalQuaternion, to.InternalQuaternion, progress, /* useShortestPath = */ true));
return new QuaternionRotation3D(InterpolateQuaternion(from.InternalQuaternion, to.InternalQuaternion, progress, useShortestPath: true));
}

internal static Single InterpolateSingle(Single from, Single to, Double progress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal static void HandleWebRequest(WebRequest request)
{
try
{
string cookies = GetCookie(httpRequest.RequestUri, false/*throwIfNoCookie*/);
string cookies = GetCookie(httpRequest.RequestUri, throwIfNoCookie: false);
if(!string.IsNullOrEmpty(cookies))
{
if (httpRequest.CookieContainer == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal static Visual GetNextSibling( Visual el )
{
return null;
}
return FindVisibleSibling ( parent, el, true /* Next */);
return FindVisibleSibling ( parent, el, searchForwards: true);
}

// Warning: Method is O(N). See FindVisibleSibling function for more information.
Expand All @@ -92,7 +92,7 @@ internal static Visual GetPreviousSibling( Visual el )
return null;
}

return FindVisibleSibling ( parent, el, false /* Previous */);
return FindVisibleSibling ( parent, el, searchForwards: false);
}

internal static Visual GetRoot( Visual el )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public GlyphTypeface CreateGlyphTypeface()
return new GlyphTypeface(
_familyCollection.GetFontUri(CachedPhysicalFace),
CachedPhysicalFace->styleSimulations,
/* fromPublic = */ false
fromPublic: false
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public sealed class DoubleIListConverter : BaseIListConverter
{
internal sealed override object ConvertFromCore(ITypeDescriptorContext td, CultureInfo ci, string value)
{
_tokenizer = new TokenizerHelper(value, '\0' /* quote char */, DelimiterChar);
_tokenizer = new TokenizerHelper(value, quoteChar: '\0', DelimiterChar);

// Estimate the output list's capacity from length of the input string.
List<double> list = new List<double>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1));
Expand Down Expand Up @@ -138,7 +138,7 @@ public sealed class UShortIListConverter : BaseIListConverter
{
internal override object ConvertFromCore(ITypeDescriptorContext td, CultureInfo ci, string value)
{
_tokenizer = new TokenizerHelper(value, '\0' /* quote char */, DelimiterChar);
_tokenizer = new TokenizerHelper(value, quoteChar: '\0', DelimiterChar);
List<ushort> list = new List<ushort>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1));
while (_tokenizer.NextToken())
{
Expand Down Expand Up @@ -179,7 +179,7 @@ public sealed class BoolIListConverter : BaseIListConverter
{
internal override object ConvertFromCore(ITypeDescriptorContext td, CultureInfo ci, string value)
{
_tokenizer = new TokenizerHelper(value, '\0' /* quote char */, DelimiterChar);
_tokenizer = new TokenizerHelper(value, quoteChar: '\0', DelimiterChar);
List<bool> list = new List<bool>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1));
while (_tokenizer.NextToken())
{
Expand Down Expand Up @@ -220,7 +220,7 @@ public sealed class PointIListConverter : BaseIListConverter
{
internal override object ConvertFromCore(ITypeDescriptorContext td, CultureInfo ci, string value)
{
_tokenizer = new TokenizerHelper(value, '\0' /* quote char */, DelimiterChar);
_tokenizer = new TokenizerHelper(value, quoteChar: '\0', DelimiterChar);

List<Point> list = new List<Point>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1));
while (_tokenizer.NextToken())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ protected override bool Filter(Point point)
// points[i-1] should be removed
if (i > 0)
{
points.RemoveRange(0, i /*count*/); // Remove points[0] to points[i-1]
points.RemoveRange(0, count: i); // Remove points[0] to points[i-1]
IsIncrementalLassoDirty = true;
}

Expand Down Expand Up @@ -786,10 +786,12 @@ private bool GetIntersectionWithExistingLasso(Point point, ref double bIndex)
continue;
}

double s = FindIntersection(points[count-1] - points[i], /*hitBegin*/
point - points[i], /*hitEnd*/
new Vector(0, 0), /*orgBegin*/
points[i+1] - points[i] /*orgEnd*/);
double s = FindIntersection(
hitBegin: points[count-1] - points[i],
hitEnd: point - points[i],
orgBegin: new Vector(0, 0),
orgEnd: points[i+1] - points[i]);

if (s >=0 && s <= 1)
{
// Intersection found, adjust the fIndex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ internal StrokeCollection Strokes
StartListeningOnStrokeEvents(visual.Stroke);

// Attach it to the visual tree
AttachVisual(visual, true/*buildingStrokeCollection*/);
AttachVisual(visual, buildingStrokeCollection: true);
}

// Start listening on events from the stroke collection.
Expand Down Expand Up @@ -445,7 +445,7 @@ private void OnStrokesChanged(object sender, StrokeCollectionChangedEventArgs ev
StartListeningOnStrokeEvents(visual.Stroke);

// Attach it to the visual tree
AttachVisual(visual, false/*buildingStrokeCollection*/);
AttachVisual(visual, buildingStrokeCollection: false);
}

// Deal with removed strokes first
Expand Down Expand Up @@ -492,7 +492,7 @@ private void OnStrokeInvalidated(object sender, EventArgs eventArgs)
{
// The change requires reparenting the visual in the tree.
DetachVisual(visual);
AttachVisual(visual, false/*buildingStrokeCollection*/);
AttachVisual(visual, buildingStrokeCollection: false);

// Update the cached values
visual.CachedIsHighlighter = stroke.DrawingAttributes.IsHighlighter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ internal StrokeNode this[int index]
}

//we use previousIndex+1 because index can skip ahead
return new StrokeNode(_operations, previousIndex + 1, nodeData, lastNodeData, index == _stylusPoints.Count - 1 /*Is this the last node?*/);
return new StrokeNode(_operations, previousIndex + 1, nodeData, lastNodeData, isLastNode: index == _stylusPoints.Count - 1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ internal static void CalcGeometryAndBoundsWithTransform(StrokeNodeIterator itera
//insert a stroke node for the previous node
strokeNodePoints.Clear();
strokeNode.GetPreviousContourPoints(strokeNodePoints);
AddFigureToStreamGeometryContext(context, strokeNodePoints, strokeNode.IsEllipse/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, strokeNodePoints, isBezierFigure: strokeNode.IsEllipse);

previousPreviousNodeRendered = true;
}

//render the stroke node
strokeNodePoints.Clear();
strokeNode.GetContourPoints(strokeNodePoints);
AddFigureToStreamGeometryContext(context, strokeNodePoints, strokeNode.IsEllipse/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, strokeNodePoints, isBezierFigure: strokeNode.IsEllipse);
}

if (!directionChanged)
Expand Down Expand Up @@ -176,7 +176,7 @@ internal static void CalcGeometryAndBoundsWithTransform(StrokeNodeIterator itera
}

//now render away!
AddFigureToStreamGeometryContext(context, connectingQuadPoints, false/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, connectingQuadPoints, isBezierFigure: false);
}
}
}
Expand Down Expand Up @@ -490,7 +490,7 @@ internal static void CalcGeometryAndBounds(StrokeNodeIterator iterator,
{
//render a complete first stroke node or we can get artifacts
prevPrevStrokeNode.GetContourPoints(polyLinePoints);
AddFigureToStreamGeometryContext(context, polyLinePoints, prevPrevStrokeNode.IsEllipse/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, polyLinePoints, isBezierFigure: prevPrevStrokeNode.IsEllipse);
polyLinePoints.Clear();
}

Expand Down Expand Up @@ -565,7 +565,7 @@ internal static void CalcGeometryAndBounds(StrokeNodeIterator iterator,
{
//render a complete stroke node or we can get artifacts
prevStrokeNode.GetContourPoints(polyLinePoints);
AddFigureToStreamGeometryContext(context, polyLinePoints, prevStrokeNode.IsEllipse/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, polyLinePoints, isBezierFigure: prevStrokeNode.IsEllipse);
polyLinePoints.Clear();
}
}
Expand Down Expand Up @@ -672,7 +672,7 @@ internal static void CalcGeometryAndBounds(StrokeNodeIterator iterator,
// we only have a single point to render
Debug.Assert(pathFigureABSide.Count == 0);
prevPrevStrokeNode.GetContourPoints(pathFigureABSide);
AddFigureToStreamGeometryContext(context, pathFigureABSide, prevPrevStrokeNode.IsEllipse/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, pathFigureABSide, isBezierFigure: prevPrevStrokeNode.IsEllipse);
}
}
else if (prevStrokeNode.IsValid && strokeNode.IsValid)
Expand Down Expand Up @@ -700,7 +700,7 @@ internal static void CalcGeometryAndBounds(StrokeNodeIterator iterator,
{
//render a complete stroke node or we can get artifacts
strokeNode.GetContourPoints(polyLinePoints);
AddFigureToStreamGeometryContext(context, polyLinePoints, strokeNode.IsEllipse/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, polyLinePoints, isBezierFigure: strokeNode.IsEllipse);
}
}
else
Expand Down Expand Up @@ -763,7 +763,7 @@ bool showFeedback
//we're between 100% and 70% overlapped
//just render two distinct figures with a connecting quad (if needed)
strokeNodePrevious.GetContourPoints(pointBuffer1);
AddFigureToStreamGeometryContext(context, pointBuffer1, strokeNodePrevious.IsEllipse/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, pointBuffer1, isBezierFigure: strokeNodePrevious.IsEllipse);

Quad quad = strokeNodeCurrent.GetConnectingQuad();
if (!quad.IsEmpty)
Expand All @@ -772,11 +772,11 @@ bool showFeedback
pointBuffer3.Add(quad.B);
pointBuffer3.Add(quad.C);
pointBuffer3.Add(quad.D);
AddFigureToStreamGeometryContext(context, pointBuffer3, false/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, pointBuffer3, isBezierFigure: false);
}

strokeNodeCurrent.GetContourPoints(pointBuffer2);
AddFigureToStreamGeometryContext(context, pointBuffer2, strokeNodeCurrent.IsEllipse/*isBezierFigure*/);
AddFigureToStreamGeometryContext(context, pointBuffer2, isBezierFigure: strokeNodeCurrent.IsEllipse);
}
else
{
Expand Down Expand Up @@ -867,21 +867,21 @@ private static void AddFigureToStreamGeometryContext(StreamGeometryContext conte
Debug.Assert(points != null);
Debug.Assert(points.Count > 0);

context.BeginFigure(points[points.Count - 1], //start point
true, //isFilled
true); //IsClosed
context.BeginFigure(startPoint: points[points.Count - 1],
isFilled: true,
isClosed: true);

if (isBezierFigure)
{
context.PolyBezierTo(points,
true, //isStroked
true); //isSmoothJoin
isStroked: true,
isSmoothJoin: true);
}
else
{
context.PolyLineTo(points,
true, //isStroked
true); //isSmoothJoin
isStroked: true,
isSmoothJoin: true);
}
}

Expand All @@ -895,18 +895,18 @@ private static void AddPolylineFigureToStreamGeometryContext(StreamGeometryConte
Debug.Assert(abPoints != null && dcPoints != null);
Debug.Assert(abPoints.Count > 0 && dcPoints.Count > 0);

context.BeginFigure(abPoints[0], //start point
true, //isFilled
true); //IsClosed
context.BeginFigure(startPoint: abPoints[0],
isFilled: true,
isClosed: true);

context.PolyLineTo(abPoints,
true, //isStroked
true); //isSmoothJoin
isStroked: true,
isSmoothJoin: true);

context.PolyLineTo(dcPoints,
true, //isStroked
true); //isSmoothJoin
}
isStroked: true,
isSmoothJoin: true);
}

/// <summary>
/// Private helper to render a path figure to the SGC
Expand All @@ -922,9 +922,9 @@ private static void AddArcToFigureToStreamGeometryContext(StreamGeometryContext
return;
}

context.BeginFigure(abPoints[0], //start point
true, //isFilled
true); //IsClosed
context.BeginFigure(startPoint: abPoints[0],
isFilled: true,
isClosed: true);

for (int j = 0; j < 2; j++)
{
Expand All @@ -938,28 +938,28 @@ private static void AddArcToFigureToStreamGeometryContext(StreamGeometryContext
if (polyLinePoints.Count > 0)
{
//polyline first
context.PolyLineTo( polyLinePoints,
true, //isStroked
true); //isSmoothJoin
context.PolyLineTo(polyLinePoints,
isStroked: true,
isSmoothJoin: true);
polyLinePoints.Clear();
}
//we're arcing, pull out height, width and the arc to point
Debug.Assert(i + 2 < points.Count);
if (i + 2 < points.Count)
{
Point sizePoint = points[i + 1];
Size ellipseSize = new Size(sizePoint.X / 2/*width*/, sizePoint.Y / 2/*height*/);
Size ellipseSize = new Size(width: sizePoint.X / 2, height: sizePoint.Y / 2);
Point arcToPoint = points[i + 2];

bool isLargeArc = false; //>= 180

context.ArcTo( arcToPoint,
ellipseSize,
0d, //rotation
isLargeArc, //isLargeArc
SweepDirection.Clockwise,
true, //isStroked
true); //isSmoothJoin
context.ArcTo(arcToPoint,
ellipseSize,
rotationAngle: 0d,
isLargeArc: isLargeArc,
SweepDirection.Clockwise,
isStroked: true,
isSmoothJoin: true);
}
i += 3; //advance past this arcTo block
}
Expand All @@ -974,8 +974,8 @@ private static void AddArcToFigureToStreamGeometryContext(StreamGeometryContext
{
//polyline
context.PolyLineTo(polyLinePoints,
true, //isStroked
true); //isSmoothJoin
isStroked: true,
isSmoothJoin: true);
polyLinePoints.Clear();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ internal static PointHitTestResult AsNearestPointHitTestResult(HitTestResult res
/// </summary>
internal static void EnsureNonNullVisual(DependencyObject element)
{
EnsureVisual(element, /* allowNull = */ false);
EnsureVisual(element, allowNull: false);
}

/// <summary>
Expand All @@ -195,7 +195,7 @@ internal static void EnsureNonNullVisual(DependencyObject element)
/// </summary>
internal static void EnsureVisual(DependencyObject element)
{
EnsureVisual(element, /* allowNull = */ true);
EnsureVisual(element, allowNull: true);
}

/// <summary>
Expand Down
Loading

0 comments on commit ef4f81d

Please sign in to comment.