Browse Source

Support editing enum property in PropertyEditor.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2256 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
55e7fa42b9
  1. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/EditorManager.cs
  2. 9
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/StandardValuesComboBoxEditor.cs
  3. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/TextBoxEditor.cs
  4. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/EditorManager.cs

@ -63,7 +63,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor @@ -63,7 +63,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
{
Type returnType = property.ReturnType;
if (returnType.IsEnum) {
return typeof(EnumEditor);
return typeof(StandardValuesComboBoxEditor);
} else if (returnType == typeof(bool)) {
return typeof(BooleanEditor);
} else {

9
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/EnumEditor.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/StandardValuesComboBoxEditor.cs

@ -18,14 +18,17 @@ namespace ICSharpCode.WpfDesign.PropertyEditor @@ -18,14 +18,17 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
/// <summary>
/// Type editor used to edit enum properties.
/// </summary>
sealed class EnumEditor : ComboBox
sealed class StandardValuesComboBoxEditor : ComboBox
{
/// <summary>
/// Creates a new EnumEditor instance.
/// </summary>
public EnumEditor(IPropertyEditorDataProperty property)
public StandardValuesComboBoxEditor(IPropertyEditorDataProperty property)
{
foreach (object o in property.TypeConverter.GetStandardValues()) {
this.Items.Add(o);
}
SetBinding(ComboBox.SelectedItemProperty, PropertyEditorBindingHelper.CreateBinding(this, property));
}
}
}

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/TextBoxEditor.cs

@ -13,6 +13,7 @@ using System.Windows.Data; @@ -13,6 +13,7 @@ using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.PropertyEditor
{
@ -21,6 +22,8 @@ namespace ICSharpCode.WpfDesign.PropertyEditor @@ -21,6 +22,8 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
/// </summary>
sealed class TextBoxEditor : TextBox
{
BindingExpressionBase bindingResult;
/// <summary>
/// Creates a new TextBoxEditor instance.
/// </summary>
@ -28,7 +31,20 @@ namespace ICSharpCode.WpfDesign.PropertyEditor @@ -28,7 +31,20 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
{
Binding b = PropertyEditorBindingHelper.CreateBinding(this, property);
b.Converter = new ToStringConverter(property.TypeConverter);
SetBinding(TextProperty, b);
bindingResult = SetBinding(TextProperty, b);
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (!e.Handled && e.Key == Key.Enter) {
string oldText = this.Text;
bindingResult.UpdateSource();
if (this.Text != oldText) {
this.SelectAll();
}
e.Handled = true;
}
}
sealed class ToStringConverter : IValueConverter

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

@ -80,7 +80,7 @@ @@ -80,7 +80,7 @@
<Compile Include="HashSet.cs" />
<Compile Include="Linq.cs" />
<Compile Include="PropertyEditor\BooleanEditor.cs" />
<Compile Include="PropertyEditor\EnumEditor.cs" />
<Compile Include="PropertyEditor\StandardValuesComboBoxEditor.cs" />
<Compile Include="PropertyEditor\DesignItemDataProperty.cs" />
<Compile Include="PropertyEditor\DesignItemDataSource.cs" />
<Compile Include="PropertyEditor\EditorManager.cs" />

Loading…
Cancel
Save