Skip to content

Commit

Permalink
Port MonthCalendarDesigner to runtime (#9536)
Browse files Browse the repository at this point in the history
* Port MonthCalendarDesigner to runtime

* Delete unnecessary namespace

* Delete redundant assertions and redundant judgment conditions

* Update MonthCalendarDesigner.cs to use file-scoped namespaces
  • Loading branch information
LeafShi1 committed Jul 26, 2023
1 parent 0800132 commit 5b659e9
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 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 @@ -42,6 +42,7 @@
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.ListBoxDesigner))]
[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.PanelDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.PictureBoxDesigner))]
[assembly: TypeForwardedTo(typeof(System.Windows.Forms.Design.RadioButtonDesigner))]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
namespace System.Windows.Forms.Design;

internal class MonthCalendarDesigner : ControlDesigner
{
public MonthCalendarDesigner()
{
AutoResizeHandles = true;
}

/// <summary>
/// Retrieves a set of rules concerning the movement capabilities of a component.
/// This should be one or more flags from the SelectionRules class. If no designer
/// provides rules for a component, the component will not get any UI services.
/// </summary>
public override SelectionRules SelectionRules
{
get
{
SelectionRules rules = base.SelectionRules;

if (Control.Parent is null || !Control.Parent.IsMirrored)
{
rules &= ~(SelectionRules.TopSizeable | SelectionRules.LeftSizeable);
}
else
{
rules &= ~(SelectionRules.TopSizeable | SelectionRules.RightSizeable);
}

return rules;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -203,20 +203,22 @@ private void CreateDesignSurface(int n)
break;
case 4:
{
rootComponent = surface.CreateRootComponent<Form>(new Size(320, 200));
rootComponent = surface.CreateRootComponent<Form>(new Size(800, 600));
rootComponent.BackColor = Color.Orange;
rootComponent.Text = "Root Component hosted by the DesignSurface N.4"; //- step.1
//- step.3
//- create some Controls at DesignTime
Button b1 = surface.CreateControl<Button>(new Size(200, 40), new Point(10, 10));
Button b2 = surface.CreateControl<Button>(new Size(200, 40), new Point(100, 100));
Button b2 = surface.CreateControl<Button>(new Size(200, 40), new Point(10, 60));
b1.Text = "I'm the first Button";
b2.Text = "I'm the second Button";
b1.BackColor = Color.Gold;
b2.BackColor = Color.LightGreen;

Timer tm11 = surface.CreateComponent<Timer>();
FontDialog fd1 = surface.CreateComponent<FontDialog>();

surface.CreateControl<MonthCalendar>(new Size(230, 170), new Point(10,110));
}

break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class DesignerAttributeTests
"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.ImageListDesigner, System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
"System.Windows.Forms.Design.MonthCalendarDesigner, 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.PrintDialogDesigner, 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",
Expand Down

0 comments on commit 5b659e9

Please sign in to comment.