diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
index 8beb05e895..bf51f60391 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj
@@ -87,18 +87,8 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlAutoScaleModeProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlAutoScaleModeProperty.cs
deleted file mode 100644
index adde086cff..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlAutoScaleModeProperty.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Forms;
-
-namespace ICSharpCode.PythonBinding
-{
- public class PythonControlAutoScaleModeProperty : PythonControlProperty
- {
- public PythonControlAutoScaleModeProperty()
- {
- }
-
- public override bool IsDefaultValue(object propertyValue)
- {
- if (propertyValue is AutoScaleMode) {
- return (AutoScaleMode)propertyValue == AutoScaleMode.Inherit;
- }
- return false;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlAutoValidateProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlAutoValidateProperty.cs
deleted file mode 100644
index bb9064be11..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlAutoValidateProperty.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Forms;
-
-namespace ICSharpCode.PythonBinding
-{
- ///
- /// Represents the AutoValidate property for a Form or ContainerControl.
- ///
- public class PythonControlAutoValidateProperty : PythonControlProperty
- {
- public PythonControlAutoValidateProperty()
- {
- }
-
- public override bool IsDefaultValue(object propertyValue)
- {
- if (propertyValue is AutoValidate) {
- return (AutoValidate)propertyValue == AutoValidate.EnablePreventFocusChange;
- }
- return false;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlBooleanProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlBooleanProperty.cs
deleted file mode 100644
index 80970cc8c6..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlBooleanProperty.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.PythonBinding
-{
- public class PythonControlBooleanProperty : PythonControlProperty
- {
- bool defaultValue;
-
- public PythonControlBooleanProperty(bool defaultValue)
- {
- this.defaultValue = defaultValue;
- }
-
- public override bool IsDefaultValue(object propertyValue)
- {
- return (bool)propertyValue == defaultValue;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlCursorProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlCursorProperty.cs
deleted file mode 100644
index 222071d709..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlCursorProperty.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Forms;
-
-namespace ICSharpCode.PythonBinding
-{
- public class PythonControlCursorProperty : PythonControlProperty
- {
- public PythonControlCursorProperty()
- {
- }
-
- public override bool IsDefaultValue(object propertyValue)
- {
- Cursor cursor = propertyValue as Cursor;
- if (cursor != null) {
- return cursor == Cursors.Default;
- }
- return false;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs
index 8e953edfa0..ae532140ad 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs
@@ -19,23 +19,24 @@ namespace ICSharpCode.PythonBinding
///
public class PythonControlDefaultPropertyValues
{
- Dictionary defaultPropertyValues = new Dictionary();
-
+ Dictionary defaultPropertyValues = new Dictionary();
+
public PythonControlDefaultPropertyValues()
{
- defaultPropertyValues.Add("Text", new PythonControlTextProperty());
- defaultPropertyValues.Add("AutoValidate", new PythonControlAutoValidateProperty());
- defaultPropertyValues.Add("Enabled", new PythonControlBooleanProperty(true));
- defaultPropertyValues.Add("Visible", new PythonControlBooleanProperty(true));
- defaultPropertyValues.Add("AutoScaleMode", new PythonControlAutoScaleModeProperty());
- defaultPropertyValues.Add("DoubleBuffered", new PythonControlBooleanProperty(false));
- defaultPropertyValues.Add("ImeMode", new PythonControlImeModeProperty());
- defaultPropertyValues.Add("RightToLeft", new PythonControlRightToLeftProperty());
- defaultPropertyValues.Add("Cursor", new PythonControlCursorProperty());
- 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));
+ defaultPropertyValues.Add("Text", String.Empty);
+ defaultPropertyValues.Add("AutoValidate", AutoValidate.EnablePreventFocusChange);
+ defaultPropertyValues.Add("Enabled", true);
+ defaultPropertyValues.Add("Visible", true);
+ defaultPropertyValues.Add("AutoScaleMode", AutoScaleMode.Inherit);
+ defaultPropertyValues.Add("DoubleBuffered", false);
+ defaultPropertyValues.Add("ImeMode", ImeMode.NoControl);
+ defaultPropertyValues.Add("RightToLeft", RightToLeft.No);
+ defaultPropertyValues.Add("Cursor", Cursors.Default);
+ defaultPropertyValues.Add("MinimumSize", new Size(0, 0));
+ defaultPropertyValues.Add("AutoScrollMinSize", new Size(0, 0));
+ defaultPropertyValues.Add("AutoScrollMargin", new Size(0, 0));
+ defaultPropertyValues.Add("Location", new Point(0, 0));
+ defaultPropertyValues.Add("Padding", Padding.Empty);
}
///
@@ -90,9 +91,9 @@ namespace ICSharpCode.PythonBinding
return defaultValueAttribute.Value == propertyValue;
}
- PythonControlProperty controlProperty = null;
- if (defaultPropertyValues.TryGetValue(propertyInfo.Name, out controlProperty)) {
- return controlProperty.IsDefaultValue(propertyValue);
+ object defaultPropertyValue = null;
+ if (defaultPropertyValues.TryGetValue(propertyInfo.Name, out defaultPropertyValue)) {
+ return defaultPropertyValue.Equals(propertyValue);
}
if (propertyInfo.Name == "BackColor") {
@@ -108,11 +109,7 @@ namespace ICSharpCode.PythonBinding
} else if (propertyInfo.Name == "ForeColor") {
// Default is Control.DefaultForeColor
return true;
- } else if (propertyInfo.Name == "Padding") {
- // Padding.Empty.
- return true;
}
-
return false;
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlImeModeProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlImeModeProperty.cs
deleted file mode 100644
index 226ed8ee13..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlImeModeProperty.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Forms;
-
-namespace ICSharpCode.PythonBinding
-{
- public class PythonControlImeModeProperty : PythonControlProperty
- {
- public PythonControlImeModeProperty()
- {
- }
-
- public override bool IsDefaultValue(object propertyValue)
- {
- if (propertyValue is ImeMode) {
- return (ImeMode)propertyValue == ImeMode.NoControl;
- }
- return false;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlPointProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlPointProperty.cs
deleted file mode 100644
index 9b655b7476..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlPointProperty.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-//
-//
-//
-// $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/PythonControlProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlProperty.cs
deleted file mode 100644
index bfa4dcd0f1..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlProperty.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.PythonBinding
-{
- ///
- /// Represents a property on a control or form.
- ///
- public abstract class PythonControlProperty
- {
- public PythonControlProperty()
- {
- }
-
- ///
- /// Returns true if the property value matches the default for this control's property.
- ///
- public virtual bool IsDefaultValue(object propertyValue)
- {
- return false;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlRightToLeftProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlRightToLeftProperty.cs
deleted file mode 100644
index adb95eb410..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlRightToLeftProperty.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Windows.Forms;
-
-namespace ICSharpCode.PythonBinding
-{
- public class PythonControlRightToLeftProperty : PythonControlProperty
- {
- public PythonControlRightToLeftProperty()
- {
- }
-
- public override bool IsDefaultValue(object propertyValue)
- {
- if (propertyValue is RightToLeft) {
- return (RightToLeft)propertyValue == RightToLeft.No;
- }
- return false;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlSizeProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlSizeProperty.cs
deleted file mode 100644
index 624b7eb71f..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlSizeProperty.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-using System.Drawing;
-
-namespace ICSharpCode.PythonBinding
-{
- public class PythonControlSizeProperty : PythonControlProperty
- {
- Size defaultSize;
-
- public PythonControlSizeProperty(int width, int height)
- {
- defaultSize = new Size(width, height);
- }
-
- public override bool IsDefaultValue(object propertyValue)
- {
- if (propertyValue is Size) {
- return (Size)propertyValue == defaultSize;
- }
- return false;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlTextProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlTextProperty.cs
deleted file mode 100644
index 52586b9245..0000000000
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlTextProperty.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-//
-//
-//
-//
-// $Revision$
-//
-
-using System;
-
-namespace ICSharpCode.PythonBinding
-{
- ///
- /// Represents a Control's Text Property.
- ///
- public class PythonControlTextProperty : PythonControlProperty
- {
- public PythonControlTextProperty()
- {
- }
-
- ///
- /// Returns true if the Text property's value is an empty string.
- ///
- public override bool IsDefaultValue(object propertyValue)
- {
- return (string)propertyValue == String.Empty;
- }
- }
-}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs
index d86f997e3c..6e0625dbbb 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonForm.cs
@@ -143,6 +143,10 @@ namespace ICSharpCode.PythonBinding
///
void AppendProperty(object obj, PropertyDescriptor propertyDescriptor)
{
+ if (propertyDescriptor.Name == "Text") {
+ Console.WriteLine("asfads");
+ }
+
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 4b7589538c..c38b4ec313 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
@@ -45,6 +45,9 @@ namespace ICSharpCode.PythonBinding
} else if (propertyType == typeof(Point)) {
Point point = (Point)propertyValue;
return point.GetType().FullName + "(" + point.X + ", " + point.Y + ")";
+ } else if (propertyType == typeof(Padding)) {
+ Padding padding = (Padding)propertyValue;
+ return padding.GetType().FullName + "(" + padding.Left + ", " + padding.Top + ", " + padding.Right + ", " + padding.Bottom + ")";
}
return propertyValue.ToString();
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormPaddingTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormPaddingTestFixture.cs
new file mode 100644
index 0000000000..a668fa3553
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateFormPaddingTestFixture.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 GenerateFormPaddingTestFixture
+ {
+ string generatedPythonCode;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ using (Form form = new Form()) {
+ form.Name = "MainForm";
+ form.ClientSize = new Size(284, 264);
+ form.Padding = new Padding(10, 20, 15, 18);
+
+ 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.Name = \"MainForm\"\r\n" +
+ " self.Visible = False\r\n" +
+ " self.Padding = System.Windows.Forms.Padding(10, 20, 15, 18)\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/IgnoreDesignTimePropertiesTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IgnoreDesignTimePropertiesTestFixture.cs
index 6cd4317fcd..73104bb412 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IgnoreDesignTimePropertiesTestFixture.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IgnoreDesignTimePropertiesTestFixture.cs
@@ -37,7 +37,7 @@ namespace PythonBinding.Tests.Designer
/// add design time properties and does not throw a null reference exception.
///
[Test]
- public void DesignTimePropertyIsIgnore()
+ public void DesignTimePropertyIsIgnored()
{
using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs
index e483cad94b..70c69f3da4 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs
@@ -196,6 +196,20 @@ namespace PythonBinding.Tests.Designer
{
form.Location = new Point(10, 20);
Assert.IsFalse(defaultPropertyValues.IsDefaultValue("Location", form));
- }
+ }
+
+ [Test]
+ public void PaddingPropertyDefaultIsPaddingEmpty()
+ {
+ form.Padding = Padding.Empty;
+ Assert.IsTrue(defaultPropertyValues.IsDefaultValue("Padding", form));
+ }
+
+ [Test]
+ public void NonDefaultPaddingProperty()
+ {
+ form.Padding = new Padding(10, 10, 10, 10);
+ Assert.IsFalse(defaultPropertyValues.IsDefaultValue("Padding", form));
+ }
}
}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
index 7220496a33..860b31f85c 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
@@ -154,6 +154,7 @@
+