Skip to content

Commit

Permalink
Port PropertyGridDesigner NotifyIconDesigner to runtime #4908
Browse files Browse the repository at this point in the history
  • Loading branch information
Epica3055 committed Aug 4, 2023
1 parent 977ad72 commit eae980e
Show file tree
Hide file tree
Showing 19 changed files with 161 additions and 16 deletions.
2 changes: 2 additions & 0 deletions src/System.Design/src/System.Design.Forwards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListViewDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.MaskedTextBoxDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.MonthCalendarDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.NotifyIconDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PanelDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PropertyGridDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PictureBoxDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PrintDialogDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.RadioButtonDesigner))]
Expand Down
5 changes: 4 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/SR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1446,4 +1446,7 @@ Press Ctrl+Enter to accept Text.</value>
<data name="ImageListActionList_ImageSizeDisplayName" xml:space="preserve">
<value>Image Size</value>
</data>
</root>
<data name="ChooseIconDisplayName" xml:space="preserve">
<value>Choose Icon...</value>
</data>
</root>
7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/System.Windows.Forms.Design/src/Resources/xlf/SR.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;
using System.ComponentModel.Design;

namespace System.Windows.Forms.Design
{
internal class NotifyIconDesigner : ComponentDesigner
{
private DesignerActionListCollection? _actionLists;

public override void InitializeNewComponent(IDictionary defaultValues)
{
base.InitializeNewComponent(defaultValues);
NotifyIcon icon = (NotifyIcon)Component;
icon.Visible = true;
}

public override DesignerActionListCollection ActionLists
{
get
{
if (_actionLists is null)
{
_actionLists = new DesignerActionListCollection();
_actionLists.Add(new NotifyIconActionList(this));
}

return _actionLists;
}
}
}

internal class NotifyIconActionList : DesignerActionList
{
private NotifyIconDesigner _designer;
public NotifyIconActionList(NotifyIconDesigner designer) : base(designer.Component)
{
_designer = designer;
}

public void ChooseIcon()
{
EditorServiceContext.EditValue(_designer, Component, "Icon");
}

public override DesignerActionItemCollection GetSortedActionItems()
{
DesignerActionItemCollection items = new DesignerActionItemCollection();
items.Add(new DesignerActionMethodItem(this, "ChooseIcon", SR.ChooseIconDisplayName, true));
return items;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System.Collections;

namespace System.Windows.Forms.Design;

internal class PropertyGridDesigner : ControlDesigner
{
protected override void PreFilterProperties(IDictionary properties)
{
// Remove the ScrollableControl properties...
properties.Remove(nameof(PropertyGrid.AutoScroll));
properties.Remove(nameof(PropertyGrid.AutoScrollMargin));
properties.Remove(nameof(PropertyGrid.AutoScrollMinSize));
properties.Remove(nameof(PropertyGrid.DockPadding));

base.PreFilterProperties(properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,8 @@ private void CreateDesignSurface(int n)

surface.CreateControl<TabControl>(new Size(400, 100), new Point(12, 21));
surface.CreateControl<TableLayoutPanel>(new Size(290, 160), new Point(20, 150));
surface.CreateControl<PropertyGrid>(new Size(200, 150), new Point(430, 23));
surface.CreateComponent<NotifyIcon>();
}

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@ public class DesignerAttributeTests
"System.Windows.Forms.Design.DataGridViewDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Windows.Forms.Design.FlowLayoutPanelDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Windows.Forms.Design.FolderBrowserDialogDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Windows.Forms.Design.NotifyIconDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Windows.Forms.Design.PropertyGridDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Windows.Forms.Design.SaveFileDialogDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Windows.Forms.Design.StatusBarDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Windows.Forms.Design.ToolStripContainerDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
Expand Down

0 comments on commit eae980e

Please sign in to comment.