Skip to content

Commit

Permalink
Remove some unused parameters (#7111)
Browse files Browse the repository at this point in the history
## Proposed changes

- Remove some unused parameters.
  • Loading branch information
gpetrou authored Apr 30, 2022
1 parent 498073f commit e0e125a
Show file tree
Hide file tree
Showing 13 changed files with 40 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ protected void DrawCheckFlat(
Color checkBorder)
{
DrawCheckBackgroundFlat(e, layout.CheckBounds, checkBorder, checkBackground);
DrawCheckOnly(e, layout, checkColor, checkBackground, true);
DrawCheckOnly(e, layout, checkColor, true);
}

protected void DrawCheckBackground3DLite(
Expand Down Expand Up @@ -133,7 +133,7 @@ private static int GetScaledNumber(int n, double scale)
return (int)(n * scale);
}

protected void DrawCheckOnly(PaintEventArgs e, LayoutData layout, Color checkColor, Color checkBackground, bool disabledColors)
protected void DrawCheckOnly(PaintEventArgs e, LayoutData layout, Color checkColor, bool disabledColors)
{
if (!Control.Checked)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ internal override void PaintUp(PaintEventArgs e, CheckState state)
colors.ButtonShadow,
colors.Options.HighContrast ? colors.ButtonFace : colors.Highlight);

DrawCheckOnly(e, layout, colors.WindowText, colors.Highlight, true);
DrawCheckOnly(e, layout, colors.WindowText, true);

AdjustFocusRectangle(layout);
PaintField(e, layout, colors, colors.WindowText, true);
Expand All @@ -57,7 +57,7 @@ internal override void PaintOver(PaintEventArgs e, CheckState state)

Color checkBackgroundColor = colors.Options.HighContrast ? colors.ButtonFace : colors.Highlight;
DrawCheckBackground3DLite(e, layout.CheckBounds, checkBackgroundColor, colors, true);
DrawCheckOnly(e, layout, colors.WindowText, colors.Highlight, true);
DrawCheckOnly(e, layout, colors.WindowText, true);

AdjustFocusRectangle(layout);
PaintField(e, layout, colors, colors.WindowText, true);
Expand All @@ -81,7 +81,7 @@ internal override void PaintDown(PaintEventArgs e, CheckState state)
PaintImage(e, layout);

DrawCheckBackground3DLite(e, layout.CheckBounds, colors.Highlight, colors, true);
DrawCheckOnly(e, layout, colors.ButtonShadow, colors.Highlight, true);
DrawCheckOnly(e, layout, colors.ButtonShadow, true);

AdjustFocusRectangle(layout);
PaintField(e, layout, colors, colors.WindowText, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ internal static unsafe string GetClassName(object component)
return nameBstr.String.TrimStart('_').ToString();
}

internal static TypeConverter GetConverter(object component)
internal static TypeConverter GetConverter()
{
return TypeDescriptor.GetConverter(typeof(IComponent));
}
Expand Down Expand Up @@ -242,7 +242,7 @@ internal static bool IsNameDispId(object obj, DispatchID dispid)
/// <summary>
/// Checks all our property manages to see if any have become invalid.
/// </summary>
private void CheckClear(object component)
private void CheckClear()
{
// walk the list every so many calls
if ((++clearCount % CLEAR_INTERVAL) == 0)
Expand Down Expand Up @@ -302,7 +302,7 @@ private Com2Properties GetPropsInfo(object component)
{
// check caches if necessary
//
CheckClear(component);
CheckClear();

// Get the property info Object
//
Expand Down Expand Up @@ -363,7 +363,7 @@ internal AttributeCollection GetAttributes(object component)
/// </summary>
internal PropertyDescriptor GetDefaultProperty(object component)
{
CheckClear(component);
CheckClear();

Com2Properties propsInfo = GetPropsInfo(component);
if (propsInfo is not null)
Expand All @@ -374,17 +374,12 @@ internal PropertyDescriptor GetDefaultProperty(object component)
return null;
}

internal static EventDescriptorCollection GetEvents(object component)
internal static EventDescriptorCollection GetEvents()
{
return new EventDescriptorCollection(null);
}

internal static EventDescriptorCollection GetEvents(object component, Attribute[] attributes)
{
return new EventDescriptorCollection(null);
}

internal static EventDescriptor GetDefaultEvent(object component)
internal static EventDescriptor GetDefaultEvent()
{
return null;
}
Expand Down Expand Up @@ -523,15 +518,15 @@ string ICustomTypeDescriptor.GetComponentName()
/// </summary>
TypeConverter ICustomTypeDescriptor.GetConverter()
{
return GetConverter(_instance);
return GetConverter();
}

/// <summary>
/// ICustomTypeDescriptor implementation.
/// </summary>
EventDescriptor ICustomTypeDescriptor.GetDefaultEvent()
{
return GetDefaultEvent(_instance);
return GetDefaultEvent();
}

/// <summary>
Expand All @@ -555,15 +550,15 @@ object ICustomTypeDescriptor.GetEditor(Type editorBaseType)
/// </summary>
EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
{
return GetEvents(_instance);
return GetEvents();
}

/// <summary>
/// ICustomTypeDescriptor implementation.
/// </summary>
EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[] attributes)
{
return GetEvents(_instance, attributes);
return GetEvents();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ private AmbientProperties AmbientPropertiesService
public virtual AnchorStyles Anchor
{
get => DefaultLayout.GetAnchor(this);
set => DefaultLayout.SetAnchor(ParentInternal, this, value);
set => DefaultLayout.SetAnchor(this, value);
}

[SRCategory(nameof(SR.CatLayout))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ private static void TryCalculatePreferredSizeDockedControl(IArrangedElement elem

private static Size GetVerticalDockedSize(IArrangedElement element, Size remainingSize, bool measureOnly)
{
Size newSize = xGetDockedSize(element, remainingSize, /* constraints = */ new Size(remainingSize.Width, 1), measureOnly);
Size newSize = xGetDockedSize(element, /* constraints = */ new Size(remainingSize.Width, 1));
if (!measureOnly)
{
newSize.Width = remainingSize.Width;
Expand All @@ -488,7 +488,7 @@ private static Size GetVerticalDockedSize(IArrangedElement element, Size remaini

private static Size GetHorizontalDockedSize(IArrangedElement element, Size remainingSize, bool measureOnly)
{
Size newSize = xGetDockedSize(element, remainingSize, /* constraints = */ new Size(1, remainingSize.Height), measureOnly);
Size newSize = xGetDockedSize(element, /* constraints = */ new Size(1, remainingSize.Height));
if (!measureOnly)
{
newSize.Height = remainingSize.Height;
Expand All @@ -503,7 +503,7 @@ private static Size GetHorizontalDockedSize(IArrangedElement element, Size remai
return newSize;
}

private static Size xGetDockedSize(IArrangedElement element, Size remainingSize, Size constraints, bool measureOnly)
private static Size xGetDockedSize(IArrangedElement element, Size constraints)
{
Size desiredSize;
if (CommonProperties.GetAutoSize(element))
Expand Down Expand Up @@ -735,7 +735,7 @@ private static void UpdateAnchorInfo(IArrangedElement element)

public static AnchorStyles GetAnchor(IArrangedElement element) => CommonProperties.xGetAnchor(element);

public static void SetAnchor(IArrangedElement container, IArrangedElement element, AnchorStyles value)
public static void SetAnchor(IArrangedElement element, AnchorStyles value)
{
AnchorStyles oldValue = GetAnchor(element);
if (oldValue != value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,15 +568,15 @@ private static void AdvanceUntilFits(int maxColumns, ReservationGrid reservation
int prevRow = layoutInfo.RowStart;
do
{
GetColStartAndStop(maxColumns, reservationGrid, layoutInfo, out colStop);
GetColStartAndStop(maxColumns, layoutInfo, out colStop);
}
while (ScanRowForOverlap(maxColumns, reservationGrid, layoutInfo, colStop, layoutInfo.RowStart - prevRow));
}

/// <summary>
/// GetColStartAndStop: part of xAssignRowsAndColumns.
/// </summary>
private static void GetColStartAndStop(int maxColumns, ReservationGrid reservationGrid, LayoutInfo layoutInfo, out int colStop)
private static void GetColStartAndStop(int maxColumns, LayoutInfo layoutInfo, out int colStop)
{
// Compute the column our element ends on
colStop = layoutInfo.ColumnStart + layoutInfo.ColumnSpan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ListViewGroup() : this(string.Format(SR.ListViewGroupDefaultHeader, s_nex
/// </summary>
private ListViewGroup(SerializationInfo info, StreamingContext context) : this()
{
Deserialize(info, context);
Deserialize(info);
}

/// <summary>
Expand Down Expand Up @@ -348,7 +348,7 @@ public string TitleImageKey
[TypeConverter(typeof(StringConverter))]
public object? Tag { get; set; }

private void Deserialize(SerializationInfo info, StreamingContext context)
private void Deserialize(SerializationInfo info)
{
int count = 0;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ internal override Size GetPreferredSizeCore(Size proposedSize)
}
else
{
return GetPreferredSizeVertical(this, proposedSize) + Padding.Size;
return GetPreferredSizeVertical(this) + Padding.Size;
}
}

Expand Down
18 changes: 7 additions & 11 deletions src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ public override bool AllowDrop

if (value)
{
DropTargetManager.EnsureRegistered(this);
DropTargetManager.EnsureRegistered();
}
else
{
DropTargetManager.EnsureUnRegistered(this);
DropTargetManager.EnsureUnRegistered();
}
}
}
Expand Down Expand Up @@ -345,11 +345,11 @@ public bool AllowItemReorder
ItemReorderDropSource = dragDropHandler;
ItemReorderDropTarget = dragDropHandler;

DropTargetManager.EnsureRegistered(this);
DropTargetManager.EnsureRegistered();
}
else
{
DropTargetManager.EnsureUnRegistered(this);
DropTargetManager.EnsureUnRegistered();
}
}
}
Expand Down Expand Up @@ -2553,7 +2553,7 @@ internal static Size GetPreferredSizeHorizontal(IArrangedElement container, Size
return maxSize;
}

internal static Size GetPreferredSizeVertical(IArrangedElement container, Size proposedConstraints)
internal static Size GetPreferredSizeVertical(IArrangedElement container)
{
Size maxSize = Size.Empty;
bool requiresOverflow = false;
Expand Down Expand Up @@ -2887,10 +2887,6 @@ protected override void SetBoundsCore(int x, int y, int width, int height, Bound
}
}

internal static void PaintParentRegion(Graphics g, Region region)
{
}

internal bool ProcessCmdKeyInternal(ref Message m, Keys keyData)
{
return ProcessCmdKey(ref m, keyData);
Expand Down Expand Up @@ -3479,7 +3475,7 @@ protected override void OnHandleCreated(EventArgs e)
{
if ((AllowDrop || AllowItemReorder) && (DropTargetManager is not null))
{
DropTargetManager.EnsureRegistered(this);
DropTargetManager.EnsureRegistered();
}

// calling control's (in base) version AFTER we register our DropTarget, so it will
Expand All @@ -3492,7 +3488,7 @@ protected override void OnHandleDestroyed(EventArgs e)
if (DropTargetManager is not null)
{
// Make sure we unregister ourselves as a drop target
DropTargetManager.EnsureUnRegistered(this);
DropTargetManager.EnsureUnRegistered();
}

base.OnHandleDestroyed(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@ public ToolStripDropTargetManager(ToolStrip owner)
ArgumentNullException.ThrowIfNull(owner);
}

public void EnsureRegistered(IDropTarget dropTarget)
public void EnsureRegistered()
{
Debug.WriteLineIf(DragDropDebug.TraceVerbose, "Ensuring drop target registered");
SetAcceptDrops(true);
}

public void EnsureUnRegistered(IDropTarget dropTarget)
public void EnsureUnRegistered()
{
Debug.WriteLineIf(DragDropDebug.TraceVerbose, "Attempting to unregister droptarget");
for (int i = 0; i < owner.Items.Count; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ private void EnsureParentDropTargetRegistered()
{
if (ParentInternal is not null)
{
ParentInternal.DropTargetManager.EnsureRegistered(this);
ParentInternal.DropTargetManager.EnsureRegistered();
}
}

Expand Down Expand Up @@ -2814,7 +2814,7 @@ protected virtual void OnParentChanged(ToolStrip oldParent, ToolStrip newParent)
SetAmbientMargin();
if ((oldParent is not null) && (oldParent.DropTargetManager is not null))
{
oldParent.DropTargetManager.EnsureUnRegistered(this);
oldParent.DropTargetManager.EnsureUnRegistered();
}

if (AllowDrop && (newParent is not null))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ internal override Size GetPreferredSize(IArrangedElement container, Size propose
}
else
{
return ToolStrip.GetPreferredSizeVertical(container, proposedConstraints);
return ToolStrip.GetPreferredSizeVertical(container);
}
}

Expand Down Expand Up @@ -431,7 +431,7 @@ private bool LayoutVertical()
{
// if we're autosizing, make sure we pad out items to the preferred width, not the
// width of the display rectangle.
toolStripPreferredSize = ToolStrip.GetPreferredSizeVertical(toolStrip, Size.Empty) - toolStrip.Padding.Size;
toolStripPreferredSize = ToolStrip.GetPreferredSizeVertical(toolStrip) - toolStrip.Padding.Size;
}

CalculatePlacementsVertical();
Expand Down
4 changes: 2 additions & 2 deletions src/System.Windows.Forms/src/System/Windows/Forms/ToolTip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ internal void ShowKeyboardToolTip(string text, IKeyboardToolTip tool, int durati
SetTool(tool.GetOwnerWindow(), text, TipInfo.Type.Absolute, new Point(pointX, pointY));

// Then look for a better ToolTip location.
if (TryGetBubbleSize(tool, toolRectangle, out Size bubbleSize))
if (TryGetBubbleSize(tool, out Size bubbleSize))
{
Point optimalPoint = GetOptimalToolTipPosition(tool, toolRectangle, bubbleSize.Width, bubbleSize.Height);

Expand Down Expand Up @@ -1559,7 +1559,7 @@ internal void ShowKeyboardToolTip(string text, IKeyboardToolTip tool, int durati
}
}

private bool TryGetBubbleSize(IKeyboardToolTip tool, Rectangle toolRectangle, out Size bubbleSize)
private bool TryGetBubbleSize(IKeyboardToolTip tool, out Size bubbleSize)
{
// Get bubble size to use it for optimal position calculation. Requesting the bubble
// size will AV if there isn't a current tool window.
Expand Down

0 comments on commit e0e125a

Please sign in to comment.