Browse Source

Code code now generated for empty menu strip in python forms designer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3946 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 16 years ago
parent
commit
072d5ec0cc
  1. 40
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs
  2. 3
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateAcceptButtonFormTestFixture.cs
  3. 17
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateAccessibleRoleFormTestFixture.cs
  4. 17
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateAutoScrollFormTestFixture.cs
  5. 17
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateCursorFormTestFixture.cs
  6. 22
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormColorTestFixture.cs
  7. 17
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormLocationTestFixture.cs
  8. 17
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormPaddingTestFixture.cs
  9. 82
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMenuStripFormTestFixture.cs
  10. 25
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMinSizeFormTestFixture.cs
  11. 21
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateNestedPanelFormTestFixture.cs
  12. 18
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratePanelFormTestFixture.cs
  13. 15
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateTextBoxFormTestFixture.cs
  14. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
  15. 12
      src/AddIns/BackendBindings/Python/PythonBinding/Test/TODO.txt

40
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs

@ -31,6 +31,10 @@ namespace ICSharpCode.PythonBinding @@ -31,6 +31,10 @@ namespace ICSharpCode.PythonBinding
IEventBindingService eventBindingService;
Attribute[] notDesignOnlyFilter = new Attribute[] { DesignOnlyAttribute.No };
/// <summary>
/// Used so the EventBindingService.GetEventProperty method can be called to get the property descriptor
/// for an event.
/// </summary>
class PythonFormEventBindingService : EventBindingService
{
public PythonFormEventBindingService()
@ -172,12 +176,16 @@ namespace ICSharpCode.PythonBinding @@ -172,12 +176,16 @@ namespace ICSharpCode.PythonBinding
}
foreach (Control childControl in control.Controls) {
AppendIndentedLine(GetPropertyName(propertyOwnerName, "Controls") + ".Add(self._" + childControl.Name + ")");
if (IsSitedControl(childControl)) {
AppendIndentedLine(GetPropertyName(propertyOwnerName, "Controls") + ".Add(self._" + childControl.Name + ")");
}
}
if (addChildControlProperties) {
foreach (Control childControl in control.Controls) {
AppendControl(childControl, true, true);
if (IsSitedControl(childControl)) {
AppendControl(childControl, true, true);
}
}
}
@ -255,8 +263,10 @@ namespace ICSharpCode.PythonBinding @@ -255,8 +263,10 @@ namespace ICSharpCode.PythonBinding
void AppendChildControlCreation(Control.ControlCollection controls)
{
foreach (Control control in controls) {
AppendControlCreation(control);
AppendChildControlCreation(control.Controls);
if (IsSitedControl(control)) {
AppendControlCreation(control);
AppendChildControlCreation(control.Controls);
}
}
}
@ -279,12 +289,12 @@ namespace ICSharpCode.PythonBinding @@ -279,12 +289,12 @@ namespace ICSharpCode.PythonBinding
void AppendChildControlLayoutMethodCalls(Control.ControlCollection controls, string[] methods)
{
foreach (Control control in controls) {
if (control.Controls.Count > 0) {
if (HasSitedChildControls(control)) {
foreach (string method in methods) {
AppendIndentedLine("self._" + control.Name + "." + method);
}
AppendChildControlLayoutMethodCalls(control.Controls, methods);
}
AppendChildControlLayoutMethodCalls(control.Controls, methods);
}
}
@ -315,5 +325,23 @@ namespace ICSharpCode.PythonBinding @@ -315,5 +325,23 @@ namespace ICSharpCode.PythonBinding
AppendIndentedLine(GetPropertyName(propertyOwnerName, eventDescriptor.Name) + " += self." + methodName);
}
}
static bool IsSitedControl(Control control)
{
return control.Site != null;
}
bool HasSitedChildControls(Control control)
{
if (control.Controls.Count > 0) {
foreach (Control childControl in control.Controls) {
if (!IsSitedControl(childControl)) {
return false;
}
}
return true;
}
return false;
}
}
}

3
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateAcceptButtonFormTestFixture.cs

@ -32,10 +32,9 @@ namespace PythonBinding.Tests.Designer @@ -32,10 +32,9 @@ namespace PythonBinding.Tests.Designer
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(200, 300);
Button button = new Button();
Button button = (Button)host.CreateComponent(typeof(Button), "button1");
button.Location = new Point(0, 0);
button.Size = new Size(10, 10);
button.Name = "button1";
button.Text = "button1";
button.UseCompatibleTextRendering = false;
form.Controls.Add(button);

17
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateAccessibleRoleFormTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer @@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
form.AccessibleRole = AccessibleRole.None;
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor accessibleRoleDescriptor = descriptors.Find("AccessibleRole", false);
accessibleRoleDescriptor.SetValue(form, AccessibleRole.None);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
string indentString = " ";
PythonForm pythonForm = new PythonForm(indentString);
@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer @@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer
" self.AccessibleRole = System.Windows.Forms.AccessibleRole.None\r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";

17
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateAutoScrollFormTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer @@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
form.AutoScroll = true;
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor autoScrollDescriptor = descriptors.Find("AutoScroll", false);
autoScrollDescriptor.SetValue(form, true);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
string indentString = " ";
PythonForm pythonForm = new PythonForm(indentString);
@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer @@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer
" self.AutoScroll = True\r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";

17
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateCursorFormTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer @@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
form.Cursor = Cursors.Help;
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor cursorDescriptor = descriptors.Find("Cursor", false);
cursorDescriptor.SetValue(form, Cursors.Help);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
string indentString = " ";
PythonForm pythonForm = new PythonForm(indentString);
@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer @@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Cursor = System.Windows.Forms.Cursors.Help\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";

22
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormColorTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -22,12 +24,21 @@ namespace PythonBinding.Tests.Designer @@ -22,12 +24,21 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
form.BackColor = SystemColors.HotTrack;
form.ForeColor = Color.Red;
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor colorDescriptor = descriptors.Find("BackColor", false);
colorDescriptor.SetValue(form, SystemColors.HotTrack);
colorDescriptor = descriptors.Find("ForeColor", false);
colorDescriptor.SetValue(form, Color.Red);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
string indentString = " ";
PythonForm pythonForm = new PythonForm(indentString);
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form);
@ -46,7 +57,6 @@ namespace PythonBinding.Tests.Designer @@ -46,7 +57,6 @@ namespace PythonBinding.Tests.Designer
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.ForeColor = System.Drawing.Color.Red\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";

17
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormLocationTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer @@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
form.Location = new Point(10, 20);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor descriptor = descriptors.Find("Location", false);
descriptor.SetValue(form, new Point(10, 20));
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
string indentString = " ";
PythonForm pythonForm = new PythonForm(indentString);
@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer @@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Location = System.Drawing.Point(10, 20)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";

17
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormPaddingTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer @@ -22,10 +24,18 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
form.Padding = new Padding(10, 20, 15, 18);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor descriptor = descriptors.Find("Padding", false);
descriptor.SetValue(form, new Padding(10, 20, 15, 18));
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
string indentString = " ";
PythonForm pythonForm = new PythonForm(indentString);
@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer @@ -44,7 +54,6 @@ namespace PythonBinding.Tests.Designer
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Padding = System.Windows.Forms.Padding(10, 20, 15, 18)\r\n" +
" self.Visible = False\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";

82
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMenuStripFormTestFixture.cs

@ -0,0 +1,82 @@ @@ -0,0 +1,82 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Matthew Ward" email="mrward@users.sourceforge.net"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.ComponentModel.Design.Serialization;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
/// <summary>
/// Adding a MenuStrip control to a form in the designer generates code for a
/// miniToolStrip - System.Windows.Forms.Design.ToolStripTemplateNode+TransparentToolStrip()
/// This is a design time control and should be ignored.
/// </summary>
[TestFixture]
public class GenerateMenuStripFormTestFixture
{
string generatedPythonCode;
[TestFixtureSetUp]
public void SetUpFixture()
{
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
IEventBindingService eventBindingService = new MockEventBindingService(host);
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(200, 300);
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
// Add menu strip.
MenuStrip menuStrip = (MenuStrip)host.CreateComponent(typeof(MenuStrip), "menuStrip1");
menuStrip.Text = "menuStrip1";
menuStrip.TabIndex = 0;
menuStrip.Location = new Point(0, 0);
form.Controls.Add(menuStrip);
PythonForm pythonForm = new PythonForm(" ");
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form);
}
}
[Test]
public void GeneratedCode()
{
string expectedCode = "def InitializeComponent(self):\r\n" +
" self._menuStrip1 = System.Windows.Forms.MenuStrip()\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # menuStrip1\r\n" +
" # \r\n" +
" self._menuStrip1.Location = System.Drawing.Point(0, 0)\r\n" +
" self._menuStrip1.Name = \"menuStrip1\"\r\n" +
" self._menuStrip1.Size = System.Drawing.Size(200, 24)\r\n" +
" self._menuStrip1.TabIndex = 0\r\n" +
" self._menuStrip1.Text = \"menuStrip1\"\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" self.ClientSize = System.Drawing.Size(200, 300)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Controls.Add(self._menuStrip1)\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";
Assert.AreEqual(expectedCode, generatedPythonCode);
}
}
}

25
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMinSizeFormTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -26,13 +28,23 @@ namespace PythonBinding.Tests.Designer @@ -26,13 +28,23 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
form.MinimumSize = new Size(100, 200);
form.AutoScrollMinSize = new Size(10, 20);
form.AutoScrollMargin = new Size(11, 22);
form.AutoScroll = false;
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor descriptor = descriptors.Find("MinimumSize", false);
descriptor.SetValue(form, new Size(100, 200));
descriptor = descriptors.Find("AutoScrollMinSize", false);
descriptor.SetValue(form, new Size(10, 20));
descriptor = descriptors.Find("AutoScrollMargin", false);
descriptor.SetValue(form, new Size(11, 22));
descriptor = descriptors.Find("AutoScroll", false);
descriptor.SetValue(form, false);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
string indentString = " ";
PythonForm pythonForm = new PythonForm(indentString);
@ -53,7 +65,6 @@ namespace PythonBinding.Tests.Designer @@ -53,7 +65,6 @@ namespace PythonBinding.Tests.Designer
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.MinimumSize = System.Drawing.Size(100, 200)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";

21
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateNestedPanelFormTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -26,24 +28,26 @@ namespace PythonBinding.Tests.Designer @@ -26,24 +28,26 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
Panel panel1 = new Panel();
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
Panel panel1 = (Panel)host.CreateComponent(typeof(Panel), "panel1");
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
panel1.TabIndex = 0;
panel1.Size = new Size(200, 220);
Panel panel2 = new Panel();
Panel panel2 = (Panel)host.CreateComponent(typeof(Panel), "panel2");
panel2.Location = new Point(10, 15);
panel2.Name = "panel2";
panel2.TabIndex = 0;
panel2.Size = new Size(100, 120);
TextBox textBox = new TextBox();
TextBox textBox = (TextBox)host.CreateComponent(typeof(TextBox), "textBox1");
textBox.Location = new Point(5, 5);
textBox.Name = "textBox1";
textBox.TabIndex = 0;
textBox.Size = new Size(110, 20);
panel2.Controls.Add(textBox);
@ -95,7 +99,6 @@ namespace PythonBinding.Tests.Designer @@ -95,7 +99,6 @@ namespace PythonBinding.Tests.Designer
" # \r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.Controls.Add(self._panel1)\r\n" +
" self._panel1.ResumeLayout(false)\r\n" +
" self._panel1.PerformLayout()\r\n" +

18
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GeneratePanelFormTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -22,18 +24,21 @@ namespace PythonBinding.Tests.Designer @@ -22,18 +24,21 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
Panel panel = new Panel();
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
Panel panel = (Panel)host.CreateComponent(typeof(Panel), "panel1");
panel.Location = new Point(10, 15);
panel.Name = "panel1";
panel.TabIndex = 0;
panel.Size = new Size(100, 120);
TextBox textBox = new TextBox();
TextBox textBox = (TextBox)host.CreateComponent(typeof(TextBox), "textBox1");
textBox.Location = new Point(5, 5);
textBox.Name = "textBox1";
textBox.TabIndex = 0;
textBox.Size = new Size(110, 20);
panel.Controls.Add(textBox);
@ -74,7 +79,6 @@ namespace PythonBinding.Tests.Designer @@ -74,7 +79,6 @@ namespace PythonBinding.Tests.Designer
" # \r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.Controls.Add(self._panel1)\r\n" +
" self._panel1.ResumeLayout(false)\r\n" +
" self._panel1.PerformLayout()\r\n" +

15
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateTextBoxFormTestFixture.cs

@ -6,6 +6,8 @@ @@ -6,6 +6,8 @@
// </file>
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
@ -22,12 +24,16 @@ namespace PythonBinding.Tests.Designer @@ -22,12 +24,16 @@ namespace PythonBinding.Tests.Designer
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
Form form = (Form)host.RootComponent;
form.ClientSize = new Size(284, 264);
TextBox textBox = new TextBox();
textBox.Name = "textBox1";
PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
namePropertyDescriptor.SetValue(form, "MainForm");
TextBox textBox = (TextBox)host.CreateComponent(typeof(TextBox), "textBox1");
textBox.Size = new Size(110, 20);
textBox.TabIndex = 1;
textBox.Location = new Point(10, 10);
@ -58,7 +64,6 @@ namespace PythonBinding.Tests.Designer @@ -58,7 +64,6 @@ namespace PythonBinding.Tests.Designer
" # \r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.Visible = False\r\n" +
" self.Controls.Add(self._textBox1)\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";

1
src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

@ -161,6 +161,7 @@ @@ -161,6 +161,7 @@
<Compile Include="Designer\GenerateFormLocationTestFixture.cs" />
<Compile Include="Designer\GenerateFormPaddingTestFixture.cs" />
<Compile Include="Designer\GenerateImeModeFormTestFixture.cs" />
<Compile Include="Designer\GenerateMenuStripFormTestFixture.cs" />
<Compile Include="Designer\GenerateMinSizeFormTestFixture.cs" />
<Compile Include="Designer\GenerateNestedPanelFormTestFixture.cs" />
<Compile Include="Designer\GeneratePanelFormTestFixture.cs" />

12
src/AddIns/BackendBindings/Python/PythonBinding/Test/TODO.txt

@ -92,4 +92,14 @@ def main(args): @@ -92,4 +92,14 @@ def main(args):
Handle invalid event name.
Check that += operator used.
Support event handlers on other controls.
* Double clicking an event handler name in the property grid when it is already defined generates a new
event handler.
* ContextMenuStrip - designer does not generate the correct code.
* MenuStrip - adds a design time only control to the generated code.
self._menuStrip1.Items.AddRange(System.Array[System.Windows.Forms.ToolStripItem]((self._fileToolStripMenuItem, )))
System.Array[System.Windows.Forms.ToolStripItem([self._fileToolStripMenuItem,self._exitToolStripMenuItem])
Loading…
Cancel
Save