Skip to content

Commit

Permalink
Port TabPageCollectionEditor
Browse files Browse the repository at this point in the history
Closes #1281
  • Loading branch information
zsd4yr authored and RussKie committed Nov 5, 2019
1 parent 625922e commit e0d025c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/System.Design/src/System.Design.Forwards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ImageIndexEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.StringArrayEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.StringCollectionEditor))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.TabPageCollectionEditor))]
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.ComponentModel.Design;
using System.Diagnostics;

namespace System.Windows.Forms.Design
{
/// <summary>
/// Main class for collection editor for <see cref="TabControl.TabPageCollection"/>.
/// Allows a single level of <see cref="ToolStripItem"/> children to be designed.
/// </summary>
internal class TabPageCollectionEditor : CollectionEditor
{
public TabPageCollectionEditor() : base(typeof(TabControl.TabPageCollection))
{
}

/// <summary>
/// Sets the specified collection to have the specified array of items.
/// </summary>
protected override object SetItems(object editValue, object[] value)
{
var tabControl = Context.Instance as TabControl;
tabControl?.SuspendLayout();

object retValue = base.SetItems(editValue, value);

tabControl?.ResumeLayout();
return retValue;
}

protected override object CreateInstance(Type itemType)
{
object instance = base.CreateInstance(itemType);

TabPage tabPage = instance as TabPage;
Debug.Assert(tabPage != null);
tabPage.UseVisualStyleBackColor = true;

return tabPage;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Licensed to the .NET Foundation under one or more agreements.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

Expand Down Expand Up @@ -96,7 +96,7 @@ public void EnsureUITypeEditorForType(Type type, Type expectedEditorType)
//[InlineData(typeof(MaskedTextBox), "Text", typeof(MaskedTextBoxTextEditor))]
[InlineData(typeof(NotifyIcon), "BalloonTipText", typeof(MultilineStringEditor))]
[InlineData(typeof(NotifyIcon), "Text", typeof(MultilineStringEditor))]
//[InlineData(typeof(TabControl), "TabPages", typeof(TabPageCollectionEditor))]
[InlineData(typeof(TabControl), "TabPages", typeof(TabPageCollectionEditor))]
[InlineData(typeof(TabPage), "ImageIndex", typeof(ImageIndexEditor))]
[InlineData(typeof(TabPage), "ImageKey", typeof(ImageIndexEditor))]
//[InlineData(typeof(TextBox), "AutoCompleteCustomSource", typeof(ListControlStringCollectionEditor))]
Expand Down

0 comments on commit e0d025c

Please sign in to comment.