Skip to content

Commit

Permalink
Cleanup: Use named arguments in PresentationCore.
Browse files Browse the repository at this point in the history
Manual changes.

Contributes to #10018
  • Loading branch information
ThomasGoulet73 committed Jan 21, 2025
1 parent 8208631 commit e206b7f
Show file tree
Hide file tree
Showing 36 changed files with 141 additions and 140 deletions.
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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -670,7 +670,7 @@ int UnsafeNativeMethods.IOleDropSource.OleGiveFeedback(int effect)
GiveFeedbackEventArgs args;

// Create GiveFeedback event arguments.
args = new GiveFeedbackEventArgs((DragDropEffects)effect, /*UseDefaultCursors*/ false);
args = new GiveFeedbackEventArgs((DragDropEffects)effect, useDefaultCursors: false);

// Raise the give feedback event for both Tunnel(Preview) and Bubble.
RaiseGiveFeedbackEvent(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ protected override sealed void ClearItems()

base.ClearItems();

RaiseStrokesChanged(null /*added*/, removed, -1);
RaiseStrokesChanged(addedStrokes: null, removed, -1);
}
}

Expand All @@ -296,7 +296,7 @@ protected override sealed void RemoveItem(int index)

StrokeCollection removed = new StrokeCollection();
( (List<Stroke>)removed.Items ).Add(removedStroke);
RaiseStrokesChanged(null /*added*/, removed, index);
RaiseStrokesChanged(addedStrokes: null, removed, index);
}

/// <summary>
Expand All @@ -314,7 +314,7 @@ protected override sealed void InsertItem(int index, Stroke stroke)

StrokeCollection addedStrokes = new StrokeCollection();
( (List<Stroke>)addedStrokes.Items ).Add(stroke);
RaiseStrokesChanged(addedStrokes, null /*removed*/, index);
RaiseStrokesChanged(addedStrokes, removedStrokes: null, index);
}

/// <summary>
Expand Down Expand Up @@ -398,7 +398,7 @@ public void Remove(StrokeCollection strokes)
( (List<Stroke>)this.Items ).RemoveAt(indexes[x]);
}

RaiseStrokesChanged(null /*added*/, strokes, indexes[0]);
RaiseStrokesChanged(addedStrokes: null, strokes, indexes[0]);
}

/// <summary>
Expand Down Expand Up @@ -434,7 +434,7 @@ public void Add(StrokeCollection strokes)
//and call our protected List<Stroke> directly
( (List<Stroke>)this.Items ).AddRange(strokes);

RaiseStrokesChanged(strokes, null /*removed*/, index);
RaiseStrokesChanged(strokes, removedStrokes: null, index);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ public void Draw(DrawingContext context)
foreach (Stroke stroke in strokes)
{
stroke.DrawInternal(context, StrokeRenderer.GetHighlighterAttributes(stroke, stroke.DrawingAttributes),
false /*Don't draw selected stroke as hollow*/);
drawAsHollow: false);
}
}
finally
Expand All @@ -397,7 +397,7 @@ public void Draw(DrawingContext context)

foreach(Stroke stroke in solidStrokes)
{
stroke.DrawInternal(context, stroke.DrawingAttributes, false/*Don't draw selected stroke as hollow*/);
stroke.DrawInternal(context, stroke.DrawingAttributes, drawAsHollow: false);
}
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ private ProcessKeyResult ProcessKey(List<IInputElement> targets, string key, boo

if (invokeUIElement != null)
{
AccessKeyEventArgs args = new AccessKeyEventArgs(key, !oneUIElement || existsElsewhere /* == isMultiple */,userInitiated);
AccessKeyEventArgs args = new AccessKeyEventArgs(key, isMultiple: !oneUIElement || existsElsewhere, userInitiated);
try
{
invokeUIElement.InvokeAccessKey(args);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ private void LegacyLoadFromStream(Stream cursorStream)
// If the buffer is filled up, then write those bytes out and read more bytes up to BUFFERSIZE
for (dataSize = cursorData.Length;
dataSize >= BUFFERSIZE;
dataSize = reader.Read(cursorData, 0 /*index in array*/, BUFFERSIZE /*bytes to read*/))
dataSize = reader.Read(cursorData, index: 0, count: BUFFERSIZE))
{
fileStream.Write(cursorData, 0 /*index in array*/, BUFFERSIZE /*bytes to write*/);
fileStream.Write(cursorData, offset: 0, count: BUFFERSIZE);
}

// Write any remaining bytes
fileStream.Write(cursorData, 0 /*index in array*/, dataSize /*bytes to write*/);
fileStream.Write(cursorData, offset: 0, count: dataSize);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ internal static Point TranslatePoint(Point pt, DependencyObject from, Dependency

bool isUpSimple = false;
isUpSimple = vFrom.TrySimpleTransformToAncestor(rootFrom,
false, /* do not apply inverse */
inverse: false,
out gUp,
out mUp);
if (isUpSimple)
Expand Down Expand Up @@ -306,7 +306,7 @@ internal static Point TranslatePoint(Point pt, DependencyObject from, Dependency
}

bool isDownSimple = vToAsVisual.TrySimpleTransformToAncestor(rootTo,
true, /* apply inverse */
inverse: true,
out gDown,
out mDown);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ ReadOnlyCollection<StylusPointPropertyInfo> properties
// use SetPropertyValue, it validates buttons, but does not copy the
// int[] on writes (since we pass the bool flag)
//
SetPropertyValue(properties[i], additionalValues[j], false/*copy on write*/);
SetPropertyValue(properties[i], additionalValues[j], copyBeforeWrite: false);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ ReadOnlyCollection<StylusPointPropertyInfo> properties
for (int x = StylusPointDescription.RequiredCountOfProperties/*3*/; x < properties.Count; x++)
{
int value = stylusPoint.GetPropertyValue(properties[x]);
newStylusPoint.SetPropertyValue(properties[x], value, false/*copy on write*/);
newStylusPoint.SetPropertyValue(properties[x], value, copyBeforeWrite: false);
}
//bypass validation
((List<StylusPoint>)newCollection.Items).Add(newStylusPoint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ internal object Value
if (compartment == null)
return;

compartment.SetValue(0 /* clientid */, ref value);
compartment.SetValue(tid: 0, ref value);
Marshal.ReleaseComObject(compartment);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public TextServicesContextShutDownListener(TextServicesContext target, ShutDownE
internal override void OnShutDown(object target, object sender, EventArgs e)
{
TextServicesContext textServicesContext = (TextServicesContext)target;
textServicesContext.Uninitialize(!(sender is Dispatcher) /*appDomainShutdown*/);
textServicesContext.Uninitialize(appDomainShutdown: !(sender is Dispatcher));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ internal override DUCE.ResourceHandle AddRefOnChannelCore(DUCE.Channel channel)
{
AddRefOnChannelAnimations(channel);

UpdateResource(channel, true /* skip "on channel" check - we already know that we're on channel */ );
UpdateResource(channel, skipOnChannelCheck: true /* We already know that we're on channel */ );

// If we are being put onto the asynchronous compositor channel in
// a dirty state, we need to subscribe to the commit batch event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,9 @@ private static object CoerceRelativeTransform(DependencyObject d, object value)

private static void StaticInitialize(Type typeofThis)
{
OpacityProperty.OverrideMetadata(typeofThis, new IndependentlyAnimatedPropertyMetadata(1.0, /* PropertyChangedHandle */ null, CoerceOpacity));
TransformProperty.OverrideMetadata(typeofThis, new UIPropertyMetadata(null, /* PropertyChangedHandle */ null, CoerceTransform));
RelativeTransformProperty.OverrideMetadata(typeofThis, new UIPropertyMetadata(null, /* PropertyChangedHandle */ null, CoerceRelativeTransform));
OpacityProperty.OverrideMetadata(typeofThis, new IndependentlyAnimatedPropertyMetadata(1.0, propertyChangedCallback: null, CoerceOpacity));
TransformProperty.OverrideMetadata(typeofThis, new UIPropertyMetadata(null, propertyChangedCallback: null, CoerceTransform));
RelativeTransformProperty.OverrideMetadata(typeofThis, new UIPropertyMetadata(null, propertyChangedCallback: null, CoerceRelativeTransform));
}

private ContainerVisual _dummyVisual;
Expand Down
Loading

0 comments on commit e206b7f

Please sign in to comment.