diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs
index 4379bb92c2..abe29458f3 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonCodeDomSerializer.cs
@@ -32,27 +32,7 @@ namespace ICSharpCode.PythonBinding
{
this.indentString = indentString;
}
-
-// public string GenerateInitializeComponentMethod(IDesignerHost host, IDesignerSerializationManager serializationManager)
-// {
-// return GenerateInitializeComponentMethod(host, serializationManager, String.Empty);
-// }
-//
-// public string GenerateInitializeComponentMethod(IDesignerHost host, IDesignerSerializationManager serializationManager, string rootNamespace)
-// {
-// CodeMemberMethod method = FindInitializeComponentMethod(host, serializationManager);
-//
-// codeBuilder = new PythonCodeBuilder();
-// codeBuilder.IndentString = indentString;
-// codeBuilder.AppendIndentedLine("def " + method.Name + "(self):");
-// codeBuilder.IncreaseIndent();
-//
-// GetResourceRootName(rootNamespace, host.RootComponent);
-// AppendStatements(method.Statements);
-//
-// return codeBuilder.ToString();
-// }
-
+
public string GenerateInitializeComponentMethodBody(IDesignerHost host, IDesignerSerializationManager serializationManager)
{
return GenerateInitializeComponentMethodBody(host, serializationManager, String.Empty);
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs
index 5d50564bd5..5781003a95 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs
@@ -304,8 +304,13 @@ namespace ICSharpCode.PythonBinding
public static object ConvertPropertyValue(PropertyDescriptor propertyDescriptor, object propertyValue)
{
if (propertyValue != null) {
- if (!propertyDescriptor.PropertyType.IsAssignableFrom(propertyValue.GetType())) {
- return propertyDescriptor.Converter.ConvertFrom(propertyValue);
+ Type propertyValueType = propertyValue.GetType();
+ if (!propertyDescriptor.PropertyType.IsAssignableFrom(propertyValueType)) {
+ if (propertyDescriptor.Converter.CanConvertFrom(propertyValueType)) {
+ return propertyDescriptor.Converter.ConvertFrom(propertyValue);
+ }
+ TypeConverter converter = TypeDescriptor.GetConverter(propertyValue);
+ return converter.ConvertTo(propertyValue, propertyDescriptor.PropertyType);
}
}
return propertyValue;
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadUserControlWithDoublePropertyTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadUserControlWithDoublePropertyTestFixture.cs
new file mode 100644
index 0000000000..b0685e5875
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/LoadUserControlWithDoublePropertyTestFixture.cs
@@ -0,0 +1,69 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+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 LoadUserControlWithDoublePropertyTestFixture
+ {
+ MockComponentCreator componentCreator = new MockComponentCreator();
+ DoublePropertyUserControl userControl;
+ Form form;
+
+ public string PythonCode {
+ get {
+ Type type = typeof(DoublePropertyUserControl);
+ componentCreator.AddType(type.FullName, type);
+ return "class MainForm(System.Windows.Forms.Form):\r\n" +
+ " def InitializeComponent(self):\r\n" +
+ " self._userControl = PythonBinding.Tests.Utils.DoublePropertyUserControl()\r\n" +
+ " self.SuspendLayout()\r\n" +
+ " # \r\n" +
+ " # userControl1\r\n" +
+ " # \r\n" +
+ " self._userControl.DoubleValue = 0\r\n" +
+ " # \r\n" +
+ " # MainForm\r\n" +
+ " # \r\n" +
+ " self.ClientSize = System.Drawing.Size(300, 400)\r\n" +
+ " self.Controls.Add(self._userControl)\r\n" +
+ " self.Name = \"MainForm\"\r\n" +
+ " self.ResumeLayout(False)\r\n";
+ }
+ }
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ PythonComponentWalker walker = new PythonComponentWalker(componentCreator);
+ form = walker.CreateComponent(PythonCode) as Form;
+ userControl = form.Controls[0] as DoublePropertyUserControl;
+ }
+
+ [TestFixtureTearDown]
+ public void TearDownFixture()
+ {
+ form.Dispose();
+ }
+
+ [Test]
+ public void UserControlDoubleProperty()
+ {
+ Assert.AreEqual(0, userControl.DoubleValue);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
index 45259294a7..3ce99b1f36 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
@@ -260,6 +260,7 @@
+
@@ -338,6 +339,7 @@
+
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DoublePropertyUserControl.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DoublePropertyUserControl.cs
new file mode 100644
index 0000000000..47aae4d9b7
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Utils/DoublePropertyUserControl.cs
@@ -0,0 +1,26 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.Windows.Forms;
+
+namespace PythonBinding.Tests.Utils
+{
+ public class DoublePropertyUserControl : UserControl
+ {
+ double doubleValue = -1.1;
+
+ public DoublePropertyUserControl()
+ {
+ }
+
+ public double DoubleValue {
+ get { return doubleValue; }
+ set { doubleValue = value; }
+ }
+ }
+}