Browse Source

Child controls on a TableLayoutPanel are now supported in the Python forms designer.

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

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

@ -347,8 +347,16 @@ namespace ICSharpCode.PythonBinding @@ -347,8 +347,16 @@ namespace ICSharpCode.PythonBinding
for (int i = startIndex; i <= endIndex; ++i) {
Type type = obj.GetType();
string name = memberNames[i];
BindingFlags propertyBindingFlags = BindingFlags.Public | BindingFlags.GetField | BindingFlags.Static | BindingFlags.Instance;
// Try class members excluding inherited members first.
BindingFlags propertyBindingFlags = BindingFlags.Public | BindingFlags.GetField | BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly;
PropertyInfo property = type.GetProperty(name, propertyBindingFlags);
if (property == null) {
// Try inherited members.
propertyBindingFlags = propertyBindingFlags & ~BindingFlags.DeclaredOnly;
property = type.GetProperty(name, propertyBindingFlags);
}
if (property != null) {
obj = property.GetValue(obj, null);
} else {

88
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadTableLayoutPanelTestFixture.cs

@ -0,0 +1,88 @@ @@ -0,0 +1,88 @@
// <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.Drawing;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
[TestFixture]
public class LoadTableLayoutPanelTestFixture : LoadFormTestFixtureBase
{
public override string PythonCode {
get {
return "class MainForm(System.Windows.Forms.Form):\r\n" +
" def InitializeComponent(self):\r\n" +
" self._button1 = System.Windows.Forms.Button()\r\n" +
" self._checkBox1 = System.Windows.Forms.CheckBox()\r\n" +
" self._tableLayoutPanel1 = System.Windows.Forms.TableLayoutPanel()\r\n" +
" self._tableLayoutPanel1.SuspendLayout()\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # button1\r\n" +
" # \r\n" +
" self._button1.Location = System.Drawing.Point(3, 3)\r\n" +
" self._button1.Name = \"button1\"\r\n" +
" self._button1.Size = System.Drawing.Size(75, 23)\r\n" +
" self._button1.TabIndex = 0\r\n" +
" self._button1.Text = \"button1\"\r\n" +
" self._button1.UseVisualStyleBackColor = True\r\n" +
" # \r\n" +
" # checkBox1\r\n" +
" # \r\n" +
" self._checkBox1.Location = System.Drawing.Point(103, 3)\r\n" +
" self._checkBox1.Name = \"checkBox1\"\r\n" +
" self._checkBox1.Size = System.Drawing.Size(94, 24)\r\n" +
" self._checkBox1.TabIndex = 1\r\n" +
" self._checkBox1.Text = \"checkBox1\"\r\n" +
" self._checkBox1.UseVisualStyleBackColor = True\r\n" +
" # \r\n" +
" # tableLayoutPanel1\r\n" +
" # \r\n" +
" self._tableLayoutPanel1.ColumnCount = 2\r\n" +
" self._tableLayoutPanel1.Controls.Add(self._button1)\r\n" +
" self._tableLayoutPanel1.Controls.Add(self._checkBox1)\r\n" +
" self._tableLayoutPanel1.Location = System.Drawing.Point(89, 36)\r\n" +
" self._tableLayoutPanel1.Name = \"tableLayoutPanel1\"\r\n" +
" self._tableLayoutPanel1.RowCount = 2\r\n" +
" self._tableLayoutPanel1.Size = System.Drawing.Size(200, 100)\r\n" +
" self._tableLayoutPanel1.TabIndex = 0\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Controls.Add(self._tableLayoutPanel1)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";
}
}
TableLayoutPanel TableLayoutPanel {
get { return Form.Controls[0] as TableLayoutPanel; }
}
[Test]
public void ButtonAddedToTableLayout()
{
Assert.IsInstanceOf(typeof(Button), TableLayoutPanel.Controls[0]);
}
[Test]
public void CheckBoxAddedToTableLayout()
{
Assert.IsInstanceOf(typeof(CheckBox), TableLayoutPanel.Controls[1]);
}
}
}

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

@ -254,6 +254,7 @@ @@ -254,6 +254,7 @@
<Compile Include="Designer\LoadSimpleFormTestFixture.cs" />
<Compile Include="Designer\LoadSimpleUserControlTestFixture.cs" />
<Compile Include="Designer\LoadSplitContainerTestFixture.cs" />
<Compile Include="Designer\LoadTableLayoutPanelTestFixture.cs" />
<Compile Include="Designer\LoadTextBoxOnPanelTestFixture.cs" />
<Compile Include="Designer\LoadTextBoxTestFixture.cs" />
<Compile Include="Designer\LoadTimerTestFixture.cs" />

Loading…
Cancel
Save