diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
index c131423995..fd4e4522a1 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonPropertyValueAssignment.cs
@@ -80,10 +80,15 @@ namespace ICSharpCode.PythonBinding
///
/// Returns the string enclosed by double quotes.
/// Escapes any double quotes or backslashes in the string itself.
+ /// If the string is multline triple quotes used.
///
static string GetQuotedString(string text)
{
- return "\"" + text.Replace(@"\", @"\\").Replace("\"", "\\\"") + "\"";
+ string quotes = "\"";
+ if (text.Contains("\n")) {
+ quotes = "\"\"\"";
+ }
+ return quotes + text.Replace(@"\", @"\\").Replace("\"", "\\\"") + quotes;
}
///
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateRichTextBoxTestFixture.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateRichTextBoxTestFixture.cs
new file mode 100644
index 0000000000..84471931fc
--- /dev/null
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateRichTextBoxTestFixture.cs
@@ -0,0 +1,84 @@
+//
+//
+//
+//
+// $Revision$
+//
+
+using System;
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Drawing;
+using System.Windows.Forms;
+using ICSharpCode.PythonBinding;
+using NUnit.Framework;
+using PythonBinding.Tests.Utils;
+
+namespace PythonBinding.Tests.Designer
+{
+ ///
+ /// Tests that multiline text is correctly generated for the RichTextBox.
+ ///
+ [TestFixture]
+ public class GenerateRichTextBoxTestFixture
+ {
+ string generatedPythonCode;
+
+ [TestFixtureSetUp]
+ public void SetUpFixture()
+ {
+ using (DesignSurface designSurface = new DesignSurface(typeof(Form))) {
+ IDesignerHost host = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
+ Form form = (Form)host.RootComponent;
+ form.ClientSize = new Size(284, 264);
+
+ PropertyDescriptorCollection descriptors = TypeDescriptor.GetProperties(form);
+ PropertyDescriptor namePropertyDescriptor = descriptors.Find("Name", false);
+ namePropertyDescriptor.SetValue(form, "MainForm");
+
+ RichTextBox textBox = (RichTextBox)host.CreateComponent(typeof(RichTextBox), "richTextBox1");
+ textBox.Size = new Size(110, 20);
+ textBox.TabIndex = 1;
+ textBox.Location = new Point(10, 10);
+ textBox.Text = "abc\r\n" +
+ "def\r\n" +
+ "ghi\r\n";
+
+ form.Controls.Add(textBox);
+
+ string indentString = " ";
+ PythonControl pythonForm = new PythonControl(indentString);
+ generatedPythonCode = pythonForm.GenerateInitializeComponentMethod(form);
+ }
+ }
+
+ [Test]
+ public void GeneratedCode()
+ {
+ string expectedCode = "def InitializeComponent(self):\r\n" +
+ " self._richTextBox1 = System.Windows.Forms.RichTextBox()\r\n" +
+ " self.SuspendLayout()\r\n" +
+ " # \r\n" +
+ " # richTextBox1\r\n" +
+ " # \r\n" +
+ " self._richTextBox1.Location = System.Drawing.Point(10, 10)\r\n" +
+ " self._richTextBox1.Name = \"richTextBox1\"\r\n" +
+ " self._richTextBox1.Size = System.Drawing.Size(110, 20)\r\n" +
+ " self._richTextBox1.TabIndex = 1\r\n" +
+ " self._richTextBox1.Text = \"\"\"abc\n" +
+ "def\n" +
+ "ghi\n" +
+ "\"\"\"\r\n" +
+ " # \r\n" +
+ " # MainForm\r\n" +
+ " # \r\n" +
+ " self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
+ " self.Controls.Add(self._richTextBox1)\r\n" +
+ " self.Name = \"MainForm\"\r\n" +
+ " self.ResumeLayout(False)\r\n" +
+ " self.PerformLayout()\r\n";
+
+ Assert.AreEqual(expectedCode, generatedPythonCode);
+ }
+ }
+}
diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
index 178ecfa3e9..fe0314fe14 100644
--- a/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
+++ b/src/AddIns/BackendBindings/Python/PythonBinding/Test/PythonBinding.Tests.csproj
@@ -213,6 +213,7 @@
+