diff --git a/src/AddIns/BackendBindings/Python/PythonBinding.sln b/src/AddIns/BackendBindings/Python/PythonBinding.sln index 165ac88b05..bfe33e2da5 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding.sln +++ b/src/AddIns/BackendBindings/Python/PythonBinding.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 -# SharpDevelop 3.0.0.3710 +# SharpDevelop 3.0.0.3800 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding", "PythonBinding\Project\PythonBinding.csproj", "{8D732610-8FC6-43BA-94C9-7126FD7FE361}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PythonBinding.Tests", "PythonBinding\Test\PythonBinding.Tests.csproj", "{23B517C9-1ECC-4419-A13F-0B7136D085CB}" diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj index 10a1a3de86..44f8b6c772 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/PythonBinding.csproj @@ -96,6 +96,7 @@ + diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs index 27fdcff1c9..77e5ffa3f7 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlDefaultPropertyValues.cs @@ -32,6 +32,9 @@ namespace ICSharpCode.PythonBinding 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)); } /// @@ -97,24 +100,10 @@ namespace ICSharpCode.PythonBinding } else if (propertyInfo.Name == "Icon") { return true; } else if (propertyInfo.Name == "Location") { - // 0, 0 - return true; - } else if (propertyInfo.Name == "Margin") { - // Padding.DefaultMargin. - return true; - } else if (propertyInfo.Name == "MinimumSize") { // 0, 0 return true; } else if (propertyInfo.Name == "TransparencyKey") { return true; - } else if (propertyInfo.Name == "AutoScrollMargin") { - return true; - } else if (propertyInfo.Name == "AutoScrollMinSize") { - return true; - } else if (propertyInfo.Name == "HorizontalScroll") { - return true; - } else if (propertyInfo.Name == "VerticalScroll") { - return true; } else if (propertyInfo.Name == "Font") { // Default is Control.DefaultFont return true; diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlSizeProperty.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlSizeProperty.cs new file mode 100644 index 0000000000..624b7eb71f --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlSizeProperty.cs @@ -0,0 +1,30 @@ +// +// +// +// +// $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/Test/Designer/GenerateMinSizeFormTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMinSizeFormTestFixture.cs new file mode 100644 index 0000000000..d05e4f0ea5 --- /dev/null +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateMinSizeFormTestFixture.cs @@ -0,0 +1,63 @@ +// +// +// +// +// $Revision$ +// + +using System; +using System.Drawing; +using System.Windows.Forms; +using ICSharpCode.PythonBinding; +using NUnit.Framework; +using PythonBinding.Tests.Utils; + +namespace PythonBinding.Tests.Designer +{ + /// + /// Tests that a form's MinimumSize, AutoScrollMinSize and AutoScrollMargin properties are generated + /// in the InitializeComponent method. + /// + [TestFixture] + public class GenerateMinSizeFormTestFixture + { + string generatedPythonCode; + + [TestFixtureSetUp] + public void SetUpFixture() + { + using (Form form = new Form()) { + form.Name = "MainForm"; + form.ClientSize = new Size(284, 264); + form.MinimumSize = new Size(100, 200); + form.AutoScrollMinSize = new Size(10, 20); + form.AutoScrollMargin = new Size(11, 22); + form.AutoScroll = false; + + 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.MinimumSize = System.Drawing.Size(100, 200)\r\n" + + " self.AutoScrollMargin = System.Drawing.Size(11, 22)\r\n" + + " self.AutoScrollMinSize = System.Drawing.Size(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 b199aa1050..4b329aa61b 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/IsDefaultPropertyValueTests.cs @@ -140,6 +140,48 @@ namespace PythonBinding.Tests.Designer { form.Visible = false; Assert.IsFalse(defaultPropertyValues.IsDefaultValue("Visible", form)); + } + + [Test] + public void MinFormSizeDefaultIsEmpty() + { + form.MinimumSize = new Size(0, 0); + Assert.IsTrue(defaultPropertyValues.IsDefaultValue("MinimumSize", form)); + } + + [Test] + public void NonDefaultMinFormSize() + { + form.MinimumSize = new Size(100, 100); + Assert.IsFalse(defaultPropertyValues.IsDefaultValue("MinimumSize", form)); + } + + [Test] + public void AutoScrollSizeDefaultIsEmpty() + { + form.AutoScrollMinSize = new Size(0, 0); + Assert.IsTrue(defaultPropertyValues.IsDefaultValue("AutoScrollMinSize", form)); + } + + [Test] + public void NonDefaultAutoScrollMinSize() + { + form.AutoScrollMinSize = new Size(100, 100); + Assert.IsFalse(defaultPropertyValues.IsDefaultValue("AutoScrollMinSize", form)); + } + + [Test] + public void AutoScrollMarginDefaultIsEmpty() + { + form.AutoScrollMargin = new Size(0, 0); + Assert.IsTrue(defaultPropertyValues.IsDefaultValue("AutoScrollMargin", form)); + } + + [Test] + public void NonDefaultAutoScrollMargin() + { + form.AutoScrollMargin = new Size(100, 100); + Assert.IsFalse(defaultPropertyValues.IsDefaultValue("AutoScrollMargin", form)); } } } diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj index 36cf8806b9..a0bbc27cca 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 @@ +