Browse Source

Added support for extender providers (e.g. ToolTips) in the python forms designer.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4116 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 17 years ago
parent
commit
ef849ad84d
  1. 32
      src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponent.cs
  2. 2
      src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateToolTipFormTestFixture.cs

32
src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonDesignerComponent.cs

@ -482,7 +482,10 @@ namespace ICSharpCode.PythonBinding @@ -482,7 +482,10 @@ namespace ICSharpCode.PythonBinding
return;
}
if (propertyDescriptor.SerializationVisibility == DesignerSerializationVisibility.Visible) {
ExtenderProvidedPropertyAttribute extender = GetExtenderAttribute(propertyDescriptor);
if (extender != null) {
AppendExtenderProperty(codeBuilder, propertyOwnerName, extender, propertyDescriptor, propertyValue);
} else if (propertyDescriptor.SerializationVisibility == DesignerSerializationVisibility.Visible) {
string propertyName = propertyOwnerName + "." + propertyDescriptor.Name;
Control control = propertyValue as Control;
if (control != null) {
@ -495,6 +498,22 @@ namespace ICSharpCode.PythonBinding @@ -495,6 +498,22 @@ namespace ICSharpCode.PythonBinding
AppendMethodCallWithArrayParameter(codeBuilder, propertyOwnerName, obj, propertyDescriptor);
}
}
/// <summary>
/// Appends an extender provider property.
/// </summary>
public void AppendExtenderProperty(PythonCodeBuilder codeBuilder, string propertyOwnerName, ExtenderProvidedPropertyAttribute extender, PropertyDescriptor propertyDescriptor, object propertyValue)
{
IComponent component = extender.Provider as IComponent;
codeBuilder.AppendIndented("self._" + component.Site.Name);
codeBuilder.Append(".Set" + propertyDescriptor.Name);
codeBuilder.Append("(");
codeBuilder.Append(propertyOwnerName);
codeBuilder.Append(", ");
codeBuilder.Append(PythonPropertyValueAssignment.ToString(propertyValue));
codeBuilder.Append(")");
codeBuilder.AppendLine();
}
/// <summary>
/// Appends the properties of the object to the code builder.
@ -694,5 +713,16 @@ namespace ICSharpCode.PythonBinding @@ -694,5 +713,16 @@ namespace ICSharpCode.PythonBinding
}
return "self._" + control.Name;
}
static ExtenderProvidedPropertyAttribute GetExtenderAttribute(PropertyDescriptor property)
{
foreach (Attribute attribute in property.Attributes) {
ExtenderProvidedPropertyAttribute extenderAttribute = attribute as ExtenderProvidedPropertyAttribute;
if (extenderAttribute != null) {
return extenderAttribute;
}
}
return null;
}
}
}

2
src/AddIns/BackendBindings/Python/PythonBinding/Test/Designer/GenerateToolTipFormTestFixture.cs

@ -35,6 +35,7 @@ namespace PythonBinding.Tests.Designer @@ -35,6 +35,7 @@ namespace PythonBinding.Tests.Designer
descriptor.SetValue(form, "MainForm");
ToolTip toolTip = (ToolTip)host.CreateComponent(typeof(ToolTip), "toolTip1");
toolTip.SetToolTip(form, "test");
string indentString = " ";
PythonControl pythonForm = new PythonControl(indentString);
@ -54,6 +55,7 @@ namespace PythonBinding.Tests.Designer @@ -54,6 +55,7 @@ namespace PythonBinding.Tests.Designer
" # \r\n" +
" self.ClientSize = System.Drawing.Size(284, 264)\r\n" +
" self.Name = \"MainForm\"\r\n" +
" self._toolTip1.SetToolTip(self, \"test\")\r\n" +
" self.ResumeLayout(False)\r\n" +
" self.PerformLayout()\r\n";

Loading…
Cancel
Save