diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
index 44f8b6c772..8beb05e895 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
@@ -94,6 +94,7 @@
+
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs
index 77e5ffa3f7..8e953edfa0 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs
@@ -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));
}
///
@@ -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") {
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlPointProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlPointProperty.cs
new file mode 100644
index 0000000000..9b655b7476
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlPointProperty.cs
@@ -0,0 +1,30 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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;
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs
index 314eaec585..d86f997e3c 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs
@@ -142,10 +142,7 @@ namespace ICSharpCode.PythonBinding
/// Appends a property to the InitializeComponents method.
///
void AppendProperty(object obj, PropertyDescriptor propertyDescriptor)
- {
- if (propertyDescriptor.Name == "Cursor") {
- Console.WriteLine("ImeMode");
- }
+ {
object propertyValue = propertyDescriptor.GetValue(obj);
if (propertyValue == null) {
return;
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
index 23a378d694..4b7589538c 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
@@ -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();
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormLocationTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormLocationTestFixture.cs
new file mode 100644
index 0000000000..8fdc5b3c60
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormLocationTestFixture.cs
@@ -0,0 +1,54 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs
index 4b329aa61b..e483cad94b 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs
@@ -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));
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
index a0bbc27cca..7220496a33 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
@@ -153,6 +153,7 @@
+