Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup WinFormsUtils, ButtonBase, Toolstrip, ToolstripItem + Tests #773

Merged
merged 1 commit into from Apr 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 14 additions & 14 deletions src/System.Windows.Forms/src/System/Windows/Forms/ButtonBase.cs
Expand Up @@ -666,22 +666,22 @@ internal override bool IsMnemonicsListenerAxSourced
}
}

/// <include file='doc\ButtonBase.uex' path='docs/doc[@for="ButtonBase.TextImageRelation"]/*' />
[
DefaultValue(TextImageRelation.Overlay),
Localizable(true),
SRDescription(nameof(SR.ButtonTextImageRelationDescr)),
SRCategory(nameof(SR.CatAppearance))
]
public TextImageRelation TextImageRelation {
get {
return textImageRelation;
}
set {
if (!WindowsFormsUtils.EnumValidator.IsValidTextImageRelation(value)) {
[DefaultValue(TextImageRelation.Overlay)]
[Localizable(true)]
[SRDescription(nameof(SR.ButtonTextImageRelationDescr))]
[SRCategory(nameof(SR.CatAppearance))]
public TextImageRelation TextImageRelation
{
get => textImageRelation;
set
{
if (!ClientUtils.IsEnumValid(value, (int)value, (int)TextImageRelation.Overlay, (int)TextImageRelation.TextBeforeImage,1))
{
throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(TextImageRelation));
}
if(value != TextImageRelation) {

if(value != TextImageRelation)
{
textImageRelation = value;
LayoutTransaction.DoLayoutIf(AutoSize, ParentInternal, this, PropertyNames.TextImageRelation);
Invalidate();
Expand Down
40 changes: 16 additions & 24 deletions src/System.Windows.Forms/src/System/Windows/Forms/ToolStrip.cs
Expand Up @@ -2180,37 +2180,32 @@ internal override bool IsMnemonicsListenerAxSourced
return GetNextItem(start, direction);
}

/// <include file='doc\ToolStrip.uex' path='docs/doc[@for="ToolStrip.GetNextItem"]/*' />
/// <devdoc>
/// <summary>
/// Gets the next item from the given start item in the direction specified.
/// - This function wraps if at the end
/// - This function will only surf the items in the current container
/// - Overriding this function will change the tab ordering and accessible child ordering.
/// </devdoc>
/// </summary>
public virtual ToolStripItem GetNextItem(ToolStripItem start, ArrowDirection direction)
{
if (!WindowsFormsUtils.EnumValidator.IsValidArrowDirection(direction)) {
throw new InvalidEnumArgumentException(nameof(direction), (int)direction, typeof(ArrowDirection));
}

switch (direction) {
switch (direction)
{
case ArrowDirection.Right:
return GetNextItemHorizontal(start, /*forward = */true);
return GetNextItemHorizontal(start, forward: true);
case ArrowDirection.Left:
return GetNextItemHorizontal(start, /*forward = */false);
return GetNextItemHorizontal(start, forward: false);
case ArrowDirection.Down:
return GetNextItemVertical(start, /*forward = */true);
return GetNextItemVertical(start, down: true);
case ArrowDirection.Up:
return GetNextItemVertical(start, /*forward = */false);
return GetNextItemVertical(start, down: false);
default:
throw new InvalidEnumArgumentException(nameof(direction), (int)direction, typeof(ArrowDirection));
}

return null;
}


// <devdoc>
// Helper function for GetNextItem - do not directly call this.
// </devdoc>
/// <remarks>
/// Helper function for GetNextItem - do not directly call this.
/// </remarks>
private ToolStripItem GetNextItemHorizontal(ToolStripItem start, bool forward) {

if (DisplayedItems.Count <= 0)
Expand Down Expand Up @@ -2261,12 +2256,9 @@ public virtual ToolStripItem GetNextItem(ToolStripItem start, ArrowDirection dir
return null;
}




// <devdoc>
// Helper function for GetNextItem - do not directly call this.
// </devdoc>
/// <remarks>
/// Helper function for GetNextItem - do not directly call this.
/// </remarks>
[SuppressMessage("Microsoft.Portability", "CA1902:AvoidTestingForFloatingPointEquality")]
private ToolStripItem GetNextItemVertical(ToolStripItem selectedItem, bool down) {

Expand Down
26 changes: 14 additions & 12 deletions src/System.Windows.Forms/src/System/Windows/Forms/ToolStripItem.cs
Expand Up @@ -2278,20 +2278,22 @@ internal virtual bool IsMnemonicsListenerAxSourced
}
}

/// <include file='doc\ToolStripItem.uex' path='docs/doc[@for="ToolStripItem.TextImageRelation"]/*' />
[DefaultValue(TextImageRelation.ImageBeforeText),
Localizable(true),
SRDescription(nameof(SR.ToolStripItemTextImageRelationDescr)),
SRCategory(nameof(SR.CatAppearance))]
public TextImageRelation TextImageRelation {
get {
return textImageRelation;
}
set {
if (!WindowsFormsUtils.EnumValidator.IsValidTextImageRelation(value)) {
[DefaultValue(TextImageRelation.ImageBeforeText)]
[Localizable(true)]
[SRDescription(nameof(SR.ToolStripItemTextImageRelationDescr))]
[SRCategory(nameof(SR.CatAppearance))]
public TextImageRelation TextImageRelation
{
get => textImageRelation;
set
{
if (!ClientUtils.IsEnumValid(value, (int)value, (int)TextImageRelation.Overlay, (int)TextImageRelation.TextBeforeImage, 1))
{
throw new InvalidEnumArgumentException(nameof(value), (int)value, typeof(TextImageRelation));
}
if(value != TextImageRelation) {

if(value != TextImageRelation)
{
textImageRelation = value;
InvalidateItemLayout(PropertyNames.TextImageRelation);
}
Expand Down