Browse Source

Public inherited controls now supported in Python forms designer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4574 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 16 years ago
parent
commit
d837482511
  1. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs
  2. 91
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadInheritedPublicPanelFormTestFixture.cs
  3. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

2
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs

@ -209,7 +209,7 @@ namespace ICSharpCode.PythonBinding @@ -209,7 +209,7 @@ namespace ICSharpCode.PythonBinding
public static object GetInheritedObject(string name, object component)
{
if (component != null) {
FieldInfo[] fields = component.GetType().GetFields(BindingFlags.NonPublic | BindingFlags.Instance);
FieldInfo[] fields = component.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
foreach (FieldInfo field in fields) {
if (String.Equals(name, field.Name, StringComparison.InvariantCultureIgnoreCase)) {
return field.GetValue(component);

91
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadInheritedPublicPanelFormTestFixture.cs

@ -0,0 +1,91 @@ @@ -0,0 +1,91 @@
// <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.Drawing;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using IronPython.Compiler.Ast;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
class PublicPanelBaseForm : Form
{
public Panel panel1 = new Panel();
Button button1 = new Button();
public PublicPanelBaseForm()
{
button1.Name = "button1";
panel1.Name = "panel1";
panel1.Location = new Point(5, 10);
panel1.Size = new Size(200, 100);
panel1.Controls.Add(button1);
Controls.Add(panel1);
}
}
class PublicPanelDerivedForm : PublicPanelBaseForm
{
}
[TestFixture]
public class LoadInheritedPublicPanelFormTestFixture : LoadFormTestFixtureBase
{
public override string PythonCode {
get {
base.ComponentCreator.AddType("PythonBinding.Tests.Designer.PublicPanelDerivedForm", typeof(PublicPanelDerivedForm));
return "class MainForm(PythonBinding.Tests.Designer.PublicPanelDerivedForm):\r\n" +
" def InitializeComponent(self):\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # panel1\r\n" +
" # \r\n" +
" self.panel1.Location = System.Drawing.Point(10, 15)\r\n" +
" self.panel1.Size = System.Drawing.Size(108, 120)\r\n" +
" # \r\n" +
" # form1\r\n" +
" # \r\n" +
" self.Location = System.Drawing.Point(10, 20)\r\n" +
" self.Name = \"form1\"\r\n" +
" self.Controls.Add(self._textBox1)\r\n" +
" self.ResumeLayout(False)\r\n";
}
}
PublicPanelDerivedForm DerivedForm {
get { return Form as PublicPanelDerivedForm; }
}
[Test]
public void PanelLocation()
{
Assert.AreEqual(new Point(10, 15), DerivedForm.panel1.Location);
}
[Test]
public void PanelSize()
{
Assert.AreEqual(new Size(108, 120), DerivedForm.panel1.Size);
}
[Test]
public void GetPublicPanelObject()
{
Assert.AreEqual(DerivedForm.panel1, PythonControlFieldExpression.GetInheritedObject("panel1", DerivedForm));
}
}
}

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

@ -237,6 +237,7 @@ @@ -237,6 +237,7 @@
<Compile Include="Designer\LoadFormWithBooleanPropertiesSetTestFixture.cs" />
<Compile Include="Designer\LoadFormWithSysPathAppendStatementTestFixture.cs" />
<Compile Include="Designer\LoadInheritedProtectedPanelFormTestFixture.cs" />
<Compile Include="Designer\LoadInheritedPublicPanelFormTestFixture.cs" />
<Compile Include="Designer\LoadListViewFormTestFixture.cs" />
<Compile Include="Designer\LoadLocalImageResourceTestFixture.cs" />
<Compile Include="Designer\LoadMenuStripFormTestFixture.cs" />

Loading…
Cancel
Save