Browse Source

Python forms designer now supports the Form's Location property.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3852 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
0b9ce6e1ab
  1. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
  2. 4
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs
  3. 30
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlPointProperty.cs
  4. 3
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs
  5. 3
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
  6. 54
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormLocationTestFixture.cs
  7. 14
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs
  8. 1
      src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj

1
src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj

@ -94,6 +94,7 @@ @@ -94,6 +94,7 @@
<Compile Include="Src\PythonControlDefaultPropertyValues.cs" />
<Compile Include="Src\PythonControlFieldExpression.cs" />
<Compile Include="Src\PythonControlImeModeProperty.cs" />
<Compile Include="Src\PythonControlPointProperty.cs" />
<Compile Include="Src\PythonControlProperty.cs" />
<Compile Include="Src\PythonControlRightToLeftProperty.cs" />
<Compile Include="Src\PythonControlSizeProperty.cs" />

4
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs

@ -35,6 +35,7 @@ namespace ICSharpCode.PythonBinding @@ -35,6 +35,7 @@ namespace ICSharpCode.PythonBinding
defaultPropertyValues.Add("MinimumSize", new PythonControlSizeProperty(0, 0));
defaultPropertyValues.Add("AutoScrollMinSize", new PythonControlSizeProperty(0, 0));
defaultPropertyValues.Add("AutoScrollMargin", new PythonControlSizeProperty(0, 0));
defaultPropertyValues.Add("Location", new PythonControlPointProperty(0, 0));
}
/// <summary>
@ -99,9 +100,6 @@ namespace ICSharpCode.PythonBinding @@ -99,9 +100,6 @@ namespace ICSharpCode.PythonBinding
return true;
} else if (propertyInfo.Name == "Icon") {
return true;
} else if (propertyInfo.Name == "Location") {
// 0, 0
return true;
} else if (propertyInfo.Name == "TransparencyKey") {
return true;
} else if (propertyInfo.Name == "Font") {

30
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlPointProperty.cs

@ -0,0 +1,30 @@ @@ -0,0 +1,30 @@
// <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.Drawing;
namespace ICSharpCode.PythonBinding
{
public class PythonControlPointProperty : PythonControlProperty
{
Point defaultPoint;
public PythonControlPointProperty(int x, int y)
{
defaultPoint = new Point(x, y);
}
public override bool IsDefaultValue(object propertyValue)
{
if (propertyValue is Point) {
return (Point)propertyValue == defaultPoint;
}
return false;
}
}
}

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

@ -143,9 +143,6 @@ namespace ICSharpCode.PythonBinding @@ -143,9 +143,6 @@ namespace ICSharpCode.PythonBinding
/// </summary>
void AppendProperty(object obj, PropertyDescriptor propertyDescriptor)
{
if (propertyDescriptor.Name == "Cursor") {
Console.WriteLine("ImeMode");
}
object propertyValue = propertyDescriptor.GetValue(obj);
if (propertyValue == null) {
return;

3
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs

@ -42,6 +42,9 @@ namespace ICSharpCode.PythonBinding @@ -42,6 +42,9 @@ namespace ICSharpCode.PythonBinding
return propertyType.FullName + "." + propertyValue.ToString();
} else if (propertyType == typeof(Cursor)) {
return GetCursorToString(propertyValue as Cursor);
} else if (propertyType == typeof(Point)) {
Point point = (Point)propertyValue;
return point.GetType().FullName + "(" + point.X + ", " + point.Y + ")";
}
return propertyValue.ToString();
}

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

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
// <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.Drawing;
using System.Windows.Forms;
using ICSharpCode.PythonBinding;
using NUnit.Framework;
using PythonBinding.Tests.Utils;
namespace PythonBinding.Tests.Designer
{
[TestFixture]
public class GenerateFormLocationTestFixture
{
string generatedPythonCode;
[TestFixtureSetUp]
public void SetUpFixture()
{
using (Form form = new Form()) {
form.Name = "MainForm";
form.ClientSize = new Size(284, 264);
form.Location = new Point(10, 20);
string indentString = " ";
PythonForm pythonForm = new PythonForm(indentString);
generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form);
}
}
[Test]
public void GeneratedCode()
{
string expectedCode = "def InitializeComponent(self):\r\n" +
" self.SuspendLayout()\r\n" +
" # \r\n" +
" # MainForm\r\n" +
" # \r\n" +
" 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";
Assert.AreEqual(expectedCode, generatedPythonCode);
}
}
}

14
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs

@ -183,5 +183,19 @@ namespace PythonBinding.Tests.Designer @@ -183,5 +183,19 @@ namespace PythonBinding.Tests.Designer
form.AutoScrollMargin = new Size(100, 100);
Assert.IsFalse(defaultPropertyValues.IsDefaultValue("AutoScrollMargin", form));
}
[Test]
public void LocationDefaultIsEmpty()
{
form.Location = new Point(0, 0);
Assert.IsTrue(defaultPropertyValues.IsDefaultValue("Location", form));
}
[Test]
public void NonDefaultLocation()
{
form.Location = new Point(10, 20);
Assert.IsFalse(defaultPropertyValues.IsDefaultValue("Location", form));
}
}
}

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

@ -153,6 +153,7 @@ @@ -153,6 +153,7 @@
<Compile Include="Designer\GenerateAutoScrollFormTestFixture.cs" />
<Compile Include="Designer\GenerateCursorFormTestFixture.cs" />
<Compile Include="Designer\GenerateDoubleBufferedFormTestFixture.cs" />
<Compile Include="Designer\GenerateFormLocationTestFixture.cs" />
<Compile Include="Designer\GenerateImeModeFormTestFixture.cs" />
<Compile Include="Designer\GenerateMinSizeFormTestFixture.cs" />
<Compile Include="Designer\GenerateRightToLeftFormTestFixture.cs" />

Loading…
Cancel
Save