Browse Source

Allow editing the "Content" and "Header" properties.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2444 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 19 years ago
parent
commit
d0edca27f7
  1. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs
  2. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs
  3. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.xaml
  4. 139
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/ContentEditor.cs
  5. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs
  6. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  7. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
  8. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyValue.cs
  9. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
  10. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
  11. 40
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs
  12. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs
  13. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs
  14. 30
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/FallbackEditor.cs
  15. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/IPropertyEditorDataSource.cs
  16. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataSource.cs
  17. 109
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/ProxyPropertyEditorDataProperty.cs
  18. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/TextBoxEditor.cs
  19. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

21
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs

@ -118,6 +118,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
rowCollection.CollectionElements.Insert(i + 1, newRowDefinition); rowCollection.CollectionElements.Insert(i + 1, newRowDefinition);
rowCollection.CollectionElements[i].Properties[RowDefinition.HeightProperty].SetValue(newLength1); rowCollection.CollectionElements[i].Properties[RowDefinition.HeightProperty].SetValue(newLength1);
newRowDefinition.Properties[RowDefinition.HeightProperty].SetValue(newLength2); newRowDefinition.Properties[RowDefinition.HeightProperty].SetValue(newLength2);
FixIndicesAfterSplit(i, Grid.RowProperty, Grid.RowSpanProperty);
changeGroup.Commit(); changeGroup.Commit();
gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { newRowDefinition }, SelectionTypes.Auto); gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { newRowDefinition }, SelectionTypes.Auto);
break; break;
@ -141,10 +143,11 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
GridLength oldLength = (GridLength)column.GetValue(ColumnDefinition.WidthProperty); GridLength oldLength = (GridLength)column.GetValue(ColumnDefinition.WidthProperty);
GridLength newLength1, newLength2; GridLength newLength1, newLength2;
SplitLength(oldLength, insertionPosition - column.Offset, column.ActualWidth, out newLength1, out newLength2); SplitLength(oldLength, insertionPosition - column.Offset, column.ActualWidth, out newLength1, out newLength2);
columnCollection.CollectionElements[i].Properties[ColumnDefinition.WidthProperty].SetValue(newLength1);
DesignItem newColumnDefinition = gridItem.Services.Component.RegisterComponentForDesigner(new ColumnDefinition()); DesignItem newColumnDefinition = gridItem.Services.Component.RegisterComponentForDesigner(new ColumnDefinition());
newColumnDefinition.Properties[ColumnDefinition.WidthProperty].SetValue(newLength2);
columnCollection.CollectionElements.Insert(i + 1, newColumnDefinition); columnCollection.CollectionElements.Insert(i + 1, newColumnDefinition);
columnCollection.CollectionElements[i].Properties[ColumnDefinition.WidthProperty].SetValue(newLength1);
newColumnDefinition.Properties[ColumnDefinition.WidthProperty].SetValue(newLength2);
FixIndicesAfterSplit(i, Grid.ColumnProperty, Grid.ColumnSpanProperty);
changeGroup.Commit(); changeGroup.Commit();
gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { newColumnDefinition }, SelectionTypes.Auto); gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { newColumnDefinition }, SelectionTypes.Auto);
break; break;
@ -153,6 +156,20 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
} }
} }
void FixIndicesAfterSplit(int splitIndex, DependencyProperty idxProperty, DependencyProperty spanProperty)
{
// increment ColSpan of all controls in the split column, increment Column of all controls in later columns:
foreach (DesignItem child in gridItem.Properties["Children"].CollectionElements) {
int start = (int)child.Properties.GetAttachedProperty(idxProperty).ValueOnInstance;
int span = (int)child.Properties.GetAttachedProperty(spanProperty).ValueOnInstance;
if (start <= splitIndex && splitIndex < start + span) {
child.Properties.GetAttachedProperty(spanProperty).SetValue(span + 1);
} else if (start > splitIndex) {
child.Properties.GetAttachedProperty(idxProperty).SetValue(start + 1);
}
}
}
void SplitLength(GridLength oldLength, double insertionPosition, double oldActualValue, void SplitLength(GridLength oldLength, double insertionPosition, double oldActualValue,
out GridLength newLength1, out GridLength newLength2) out GridLength newLength1, out GridLength newLength2)
{ {

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.WpfDesign.Designer
// this is not compiled, but gives us code-completion inside SharpDevelop // this is not compiled, but gives us code-completion inside SharpDevelop
TextBox nameTextBox; TextBox nameTextBox;
Label typeLabel; Label typeLabel;
Image componentImage; Rectangle componentImage;
TextBox searchTextBox; TextBox searchTextBox;
StackPanel contentStackPanel; StackPanel contentStackPanel;
#endif #endif
@ -73,7 +73,9 @@ namespace ICSharpCode.WpfDesign.Designer
void OnEditedObjectPropertyChanged(DependencyPropertyChangedEventArgs e) void OnEditedObjectPropertyChanged(DependencyPropertyChangedEventArgs e)
{ {
ShowProperties(e.NewValue as IPropertyEditorDataSource); IPropertyEditorDataSource dataSource = e.NewValue as IPropertyEditorDataSource;
componentImage.Fill = dataSource != null ? dataSource.CreateThumbnailBrush() : null;
ShowProperties(dataSource);
if (EditedObjectChanged != null) { if (EditedObjectChanged != null) {
EditedObjectChanged(this, EventArgs.Empty); EditedObjectChanged(this, EventArgs.Empty);
} }

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.xaml

@ -13,7 +13,7 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Image Grid.Column="0" Width="32" Height="32" Name="componentImage" /> <Rectangle Grid.Column="0" Width="32" Height="32" Name="componentImage"/>
<Grid Grid.Column="1" Margin="0 0 2 0"> <Grid Grid.Column="1" Margin="0 0 2 0">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" />

139
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/ContentEditor.cs

@ -0,0 +1,139 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Data;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Threading;
using ICSharpCode.WpfDesign.PropertyEditor;
namespace ICSharpCode.WpfDesign.Designer.Controls.TypeEditors
{
/// <summary>
/// Description of ContentEditor.
/// </summary>
[PropertyEditor(typeof(ContentControl), "Content")]
[PropertyEditor(typeof(HeaderedContentControl), "Header")]
[PropertyEditor(typeof(HeaderedItemsControl), "Header")]
public class ContentEditor : DockPanel
{
readonly IPropertyEditorDataProperty property;
Button createObjectButton = new Button();
readonly TextBoxEditor textBoxEditor;
readonly FallbackEditor fallbackEditor;
readonly DataPropertyWithCustomOnValueChangedEvent textBoxEditorDataProperty, fallbackEditorDataProperty;
UIElement activeEditor;
DataPropertyWithCustomOnValueChangedEvent activeEditorDataProperty;
public ContentEditor(IPropertyEditorDataProperty property)
{
this.property = property;
PropertyEditorBindingHelper.AddValueChangedEventHandler(this, property, OnValueChanged);
createObjectButton.Content = "C";
createObjectButton.ContextMenuOpening += delegate {
createObjectButton.ContextMenu = CreateContextMenu();
};
createObjectButton.Click += delegate {
createObjectButton.ContextMenu = CreateContextMenu();
createObjectButton.ContextMenu.IsOpen = true;
};
SetDock(createObjectButton, Dock.Right);
this.Children.Add(createObjectButton);
textBoxEditor = new TextBoxEditor(textBoxEditorDataProperty = new DataPropertyWithCustomOnValueChangedEvent(property));
fallbackEditor = new FallbackEditor(fallbackEditorDataProperty = new DataPropertyWithCustomOnValueChangedEvent(property));
OnValueChanged(null, null);
}
#region CreateObjectButton Context menu
ContextMenu CreateContextMenu()
{
ContextMenu contextMenu = new ContextMenu();
contextMenu.Items.Add(CreateMenuItem("Set to _null", delegate { property.Value = null; }));
contextMenu.Items.Add(CreateMenuItem("Create _string", delegate { property.Value = ""; }));
return contextMenu;
}
static MenuItem CreateMenuItem(string title, RoutedEventHandler handler)
{
MenuItem item = new MenuItem();
item.Header = title;
item.Click += handler;
return item;
}
#endregion
void SetActiveEditor(UIElement newEditor, DataPropertyWithCustomOnValueChangedEvent newDataProperty)
{
if (activeEditor != newEditor) {
if (activeEditorDataProperty != null) {
activeEditorDataProperty.preventSetValue = true;
}
this.Children.Remove(activeEditor);
this.Children.Add(newEditor);
activeEditor = newEditor;
newDataProperty.preventSetValue = false;
activeEditorDataProperty = newDataProperty;
}
}
void OnValueChanged(object sender, EventArgs e)
{
object val = property.Value;
if (val is string) {
SetActiveEditor(textBoxEditor, textBoxEditorDataProperty);
} else {
SetActiveEditor(fallbackEditor, fallbackEditorDataProperty);
}
// raise ValueChanged after the new editor's Loaded event has fired
Dispatcher.BeginInvoke(DispatcherPriority.Loaded,
(Action)activeEditorDataProperty.RaiseValueChanged);
}
sealed class DataPropertyWithCustomOnValueChangedEvent : ProxyPropertyEditorDataProperty
{
internal DataPropertyWithCustomOnValueChangedEvent(IPropertyEditorDataProperty property)
: base(property)
{
}
EventHandler valueChangedListeners;
internal bool preventSetValue;
public override object Value {
get { return base.Value; }
set {
if (!preventSetValue) {
base.Value = value;
}
}
}
public override event EventHandler ValueChanged {
add { valueChangedListeners += value; }
remove { valueChangedListeners -= value; }
}
public override System.ComponentModel.TypeConverter TypeConverter {
get { return System.ComponentModel.TypeDescriptor.GetConverter(typeof(string)); }
}
internal void RaiseValueChanged()
{
if (valueChangedListeners != null) {
valueChangedListeners(this, EventArgs.Empty);
}
}
}
}
}

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs

@ -103,12 +103,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
default: default:
throw new NotSupportedException(); throw new NotSupportedException();
} }
return new Rect(left, top, width, height); return new Rect(left, top, Math.Max(0, width), Math.Max(0, height));
} }
double GetColumnOffset(int index) double GetColumnOffset(int index)
{ {
if (index < grid.ColumnDefinitions.Count) // when the grid has no columns, we still need to return 0 for index=0 and grid.Width for index=1
if (index == 0)
return 0;
else if (index < grid.ColumnDefinitions.Count)
return grid.ColumnDefinitions[index].Offset; return grid.ColumnDefinitions[index].Offset;
else else
return grid.ActualWidth; return grid.ActualWidth;
@ -116,7 +119,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
double GetRowOffset(int index) double GetRowOffset(int index)
{ {
if (index < grid.RowDefinitions.Count) if (index == 0)
return 0;
else if (index < grid.RowDefinitions.Count)
return grid.RowDefinitions[index].Offset; return grid.RowDefinitions[index].Offset;
else else
return grid.ActualHeight; return grid.ActualHeight;

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -71,6 +71,7 @@
<Compile Include="Controls\ResizeThumb.cs" /> <Compile Include="Controls\ResizeThumb.cs" />
<Compile Include="Controls\SingleVisualChildElement.cs" /> <Compile Include="Controls\SingleVisualChildElement.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor.cs" /> <Compile Include="Controls\TypeEditors\BrushEditor.cs" />
<Compile Include="Controls\TypeEditors\ContentEditor.cs" />
<Compile Include="Controls\WindowClone.cs" /> <Compile Include="Controls\WindowClone.cs" />
<Compile Include="DesignPanel.cs" /> <Compile Include="DesignPanel.cs" />
<Compile Include="Extensions\GridAdornerProvider.cs" /> <Compile Include="Extensions\GridAdornerProvider.cs" />

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs

@ -100,6 +100,14 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
} }
} }
/// <summary>
/// Occurs when the parent of this design item changes.
/// </summary>
public override event EventHandler ParentChanged {
add { _xamlObject.ParentPropertyChanged += value; }
remove { _xamlObject.ParentPropertyChanged += value; }
}
public override UIElement View { public override UIElement View {
get { get {
if (_view != null) if (_view != null)

14
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyValue.cs

@ -33,13 +33,23 @@ namespace ICSharpCode.WpfDesign.XamlDom
public XamlProperty ParentProperty { public XamlProperty ParentProperty {
get { return _parentProperty; } get { return _parentProperty; }
internal set { internal set {
_parentProperty = value; if (_parentProperty != value) {
OnParentPropertyChanged(); _parentProperty = value;
OnParentPropertyChanged();
}
} }
} }
/// <summary>
/// Occurs when the value of the ParentProperty property changes.
/// </summary>
public event EventHandler ParentPropertyChanged;
internal virtual void OnParentPropertyChanged() internal virtual void OnParentPropertyChanged()
{ {
if (ParentPropertyChanged != null) {
ParentPropertyChanged(this, EventArgs.Empty);
}
} }
internal abstract void RemoveNodeFromParent(); internal abstract void RemoveNodeFromParent();

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs

@ -48,6 +48,11 @@ namespace ICSharpCode.WpfDesign
/// </summary> /// </summary>
public abstract DesignItem Parent { get; } public abstract DesignItem Parent { get; }
/// <summary>
/// Occurs when the parent of this design item changes.
/// </summary>
public abstract event EventHandler ParentChanged;
/// <summary> /// <summary>
/// Gets the property where this DesignItem is used as a value. /// Gets the property where this DesignItem is used as a value.
/// </summary> /// </summary>

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs

@ -41,7 +41,9 @@ namespace ICSharpCode.WpfDesign.Extensions
void ReapplyExtensions(IEnumerable<DesignItem> items, ExtensionServer server) void ReapplyExtensions(IEnumerable<DesignItem> items, ExtensionServer server)
{ {
foreach (DesignItem item in items) { foreach (DesignItem item in items) {
item.ReapplyExtensionServer(this, server); if (item != null) {
item.ReapplyExtensionServer(this, server);
}
} }
} }

40
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs

@ -96,8 +96,6 @@ namespace ICSharpCode.WpfDesign.Extensions
/// </summary> /// </summary>
public class PrimarySelectionParentExtensionServer : DefaultExtensionServer public class PrimarySelectionParentExtensionServer : DefaultExtensionServer
{ {
DesignItem oldPrimarySelectionParent;
/// <summary> /// <summary>
/// Is called after the extension server is initialized and the Context property has been set. /// Is called after the extension server is initialized and the Context property has been set.
/// </summary> /// </summary>
@ -107,30 +105,32 @@ namespace ICSharpCode.WpfDesign.Extensions
this.Services.Selection.PrimarySelectionChanged += OnPrimarySelectionChanged; this.Services.Selection.PrimarySelectionChanged += OnPrimarySelectionChanged;
} }
DesignItem PrimarySelectionParent { DesignItem primarySelection;
get { DesignItem primarySelectionParent;
DesignItem newPrimarySelection = this.Services.Selection.PrimarySelection;
void OnPrimarySelectionChanged(object sender, EventArgs e)
{
DesignItem newPrimarySelection = this.Services.Selection.PrimarySelection;
if (primarySelection != newPrimarySelection) {
if (primarySelection != null) {
primarySelection.ParentChanged -= OnParentChanged;
}
if (newPrimarySelection != null) { if (newPrimarySelection != null) {
return newPrimarySelection.Parent; newPrimarySelection.ParentChanged += OnParentChanged;
} else {
return null;
} }
primarySelection = newPrimarySelection;
OnParentChanged(sender, e);
} }
} }
void OnPrimarySelectionChanged(object sender, EventArgs e) void OnParentChanged(object sender, EventArgs e)
{ {
DesignItem newPrimarySelectionParent = PrimarySelectionParent; DesignItem newPrimarySelectionParent = primarySelection != null ? primarySelection.Parent : null;
if (oldPrimarySelectionParent != newPrimarySelectionParent) { if (primarySelectionParent != newPrimarySelectionParent) {
if (oldPrimarySelectionParent == null) { DesignItem oldPrimarySelectionParent = primarySelectionParent;
ReapplyExtensions(new DesignItem[] { newPrimarySelectionParent }); primarySelectionParent = newPrimarySelectionParent;
} else if (newPrimarySelectionParent == null) { ReapplyExtensions(new DesignItem[] { oldPrimarySelectionParent, newPrimarySelectionParent });
ReapplyExtensions(new DesignItem[] { oldPrimarySelectionParent });
} else {
ReapplyExtensions(new DesignItem[] { oldPrimarySelectionParent, newPrimarySelectionParent });
}
oldPrimarySelectionParent = newPrimarySelectionParent;
} }
} }
@ -139,7 +139,7 @@ namespace ICSharpCode.WpfDesign.Extensions
/// </summary> /// </summary>
public override bool ShouldApplyExtensions(DesignItem extendedItem) public override bool ShouldApplyExtensions(DesignItem extendedItem)
{ {
return PrimarySelectionParent == extendedItem; return primarySelectionParent == extendedItem;
} }
} }
} }

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs

@ -159,7 +159,8 @@ namespace ICSharpCode.WpfDesign
info.OriginalBounds = op.currentContainerBehavior.GetPosition(op, info.Item); info.OriginalBounds = op.currentContainerBehavior.GetPosition(op, info.Item);
info.Bounds = info.OriginalBounds; info.Bounds = info.OriginalBounds;
} }
} catch { } catch (Exception ex) {
Debug.WriteLine(ex.ToString());
op.changeGroup.Abort(); op.changeGroup.Abort();
throw; throw;
} }

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs

@ -150,5 +150,17 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
public ServiceContainer Services { public ServiceContainer Services {
get { return item.Services; } get { return item.Services; }
} }
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
public Brush CreateThumbnailBrush()
{
if (item.View != null) {
VisualBrush b = new VisualBrush(item.View);
b.AutoLayoutContent = false;
return b;
} else {
return null;
}
}
} }
} }

30
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/FallbackEditor.cs

@ -44,20 +44,24 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
} else { } else {
this.FontWeight = FontWeights.Regular; this.FontWeight = FontWeights.Regular;
} }
object val = property.Value; if (property.IsAmbiguous) {
if (val == null) { this.Text = "";
this.Text = "null";
this.FontStyle = FontStyles.Italic;
} else { } else {
this.FontStyle = FontStyles.Normal; object val = property.Value;
try { if (val == null) {
this.Text = val.ToString(); this.Text = "null";
} catch (Exception ex) { this.FontStyle = FontStyles.Italic;
this.FontWeight = FontWeights.Regular; } else {
Inlines.Clear(); this.FontStyle = FontStyles.Normal;
Inlines.Add(new Italic(new Run(ex.GetType().Name))); try {
Inlines.Add(" "); this.Text = val.ToString();
Inlines.Add(ex.Message); } catch (Exception ex) {
this.FontWeight = FontWeights.Regular;
Inlines.Clear();
Inlines.Add(new Italic(new Run(ex.GetType().Name)));
Inlines.Add(" ");
Inlines.Add(ex.Message);
}
} }
} }
} }

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/IPropertyEditorDataSource.cs

@ -52,6 +52,11 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
/// Gets the service container attached to this data source. /// Gets the service container attached to this data source.
/// </summary> /// </summary>
ServiceContainer Services { get; } ServiceContainer Services { get; }
/// <summary>
/// Gets a brush used as a preview for the data source.
/// </summary>
Brush CreateThumbnailBrush();
} }
/// <summary> /// <summary>

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataSource.cs

@ -7,6 +7,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.PropertyEditor namespace ICSharpCode.WpfDesign.PropertyEditor
{ {
@ -127,5 +128,11 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
public ServiceContainer Services { public ServiceContainer Services {
get { return services; } get { return services; }
} }
/// <summary>See <see cref="IPropertyEditorDataSource"/></summary>
public Brush CreateThumbnailBrush()
{
return null;
}
} }
} }

109
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/ProxyPropertyEditorDataProperty.cs

@ -0,0 +1,109 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
namespace ICSharpCode.WpfDesign.PropertyEditor
{
/// <summary>
/// Implements IPropertyEditorDataProperty by forwarding all calls to another IPropertyEditorDataProperty.
/// </summary>
public abstract class ProxyPropertyEditorDataProperty : IPropertyEditorDataProperty
{
readonly IPropertyEditorDataProperty data;
/// <summary></summary>
protected ProxyPropertyEditorDataProperty(IPropertyEditorDataProperty data)
{
if (data == null)
throw new ArgumentNullException("data");
this.data = data;
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual event EventHandler IsSetChanged {
add { data.IsSetChanged += value; }
remove { data.IsSetChanged -= value; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual event EventHandler ValueChanged {
add { data.ValueChanged += value; }
remove { data.ValueChanged -= value; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual IPropertyEditorDataSource OwnerDataSource {
get { return data.OwnerDataSource; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual string Category {
get { return data.Category; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual string Name {
get { return data.Name; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual Type ReturnType {
get { return data.ReturnType; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual Type DeclaringType {
get { return data.DeclaringType; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual System.ComponentModel.TypeConverter TypeConverter {
get { return data.TypeConverter; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual bool IsSet {
get { return data.IsSet; }
set { data.IsSet = value; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual bool IsAmbiguous {
get { return data.IsAmbiguous; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual object Value {
get { return data.Value; }
set { data.Value = value; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual bool CanUseCustomExpression {
get { return data.CanUseCustomExpression; }
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual object GetDescription()
{
return data.GetDescription();
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual void SetCustomExpression(string expression)
{
data.SetCustomExpression(expression);
}
/// <summary>See <see cref="IPropertyEditorDataProperty"/></summary>
public virtual System.Windows.UIElement CreateEditor()
{
return data.CreateEditor();
}
}
}

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

@ -22,7 +22,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
/// <summary> /// <summary>
/// Type editor used to edit properties using a text box and the type's default type converter. /// Type editor used to edit properties using a text box and the type's default type converter.
/// </summary> /// </summary>
sealed class TextBoxEditor : TextBox public sealed class TextBoxEditor : TextBox
{ {
readonly IPropertyEditorDataProperty property; readonly IPropertyEditorDataProperty property;
bool isDirty; bool isDirty;
@ -33,6 +33,9 @@ namespace ICSharpCode.WpfDesign.PropertyEditor
/// </summary> /// </summary>
public TextBoxEditor(IPropertyEditorDataProperty property) public TextBoxEditor(IPropertyEditorDataProperty property)
{ {
if (property == null)
throw new ArgumentNullException("property");
this.property = property; this.property = property;
UpdateFromSource(); UpdateFromSource();
PropertyEditorBindingHelper.AddValueChangedEventHandler( PropertyEditorBindingHelper.AddValueChangedEventHandler(

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

@ -90,6 +90,7 @@
<Compile Include="PlacementType.cs" /> <Compile Include="PlacementType.cs" />
<Compile Include="PropertyEditor\BooleanEditor.cs" /> <Compile Include="PropertyEditor\BooleanEditor.cs" />
<Compile Include="PropertyEditor\MultipleSelectionDataProperty.cs" /> <Compile Include="PropertyEditor\MultipleSelectionDataProperty.cs" />
<Compile Include="PropertyEditor\ProxyPropertyEditorDataProperty.cs" />
<Compile Include="PropertyEditor\StandardValuesComboBoxEditor.cs" /> <Compile Include="PropertyEditor\StandardValuesComboBoxEditor.cs" />
<Compile Include="PropertyEditor\DesignItemDataProperty.cs" /> <Compile Include="PropertyEditor\DesignItemDataProperty.cs" />
<Compile Include="PropertyEditor\DesignItemDataSource.cs" /> <Compile Include="PropertyEditor\DesignItemDataSource.cs" />

Loading…
Cancel
Save