From d0edca27f7ba95503b2d5d501842feb2a53e78c5 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Sun, 11 Mar 2007 13:42:28 +0000 Subject: [PATCH] Allow editing the "Content" and "Header" properties. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2444 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Controls/GridAdorner.cs | 21 ++- .../Controls/PropertyEditor/PropertyEditor.cs | 6 +- .../PropertyEditor/PropertyEditor.xaml | 2 +- .../Controls/TypeEditors/ContentEditor.cs | 139 ++++++++++++++++++ .../Extensions/GridPlacementSupport.cs | 11 +- .../Project/WpfDesign.Designer.csproj | 1 + .../Project/Xaml/XamlDesignItem.cs | 8 + .../Project/XamlPropertyValue.cs | 14 +- .../WpfDesign/WpfDesign/Project/DesignItem.cs | 5 + .../Project/Extensions/ExtensionManager.cs | 4 +- .../Extensions/SelectionExtensionServer.cs | 40 ++--- .../WpfDesign/Project/PlacementOperation.cs | 3 +- .../PropertyEditor/DesignItemDataSource.cs | 12 ++ .../Project/PropertyEditor/FallbackEditor.cs | 30 ++-- .../IPropertyEditorDataSource.cs | 5 + .../MultipleSelectionDataSource.cs | 7 + .../ProxyPropertyEditorDataProperty.cs | 109 ++++++++++++++ .../Project/PropertyEditor/TextBoxEditor.cs | 5 +- .../WpfDesign/Project/WpfDesign.csproj | 1 + 19 files changed, 377 insertions(+), 46 deletions(-) create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/ContentEditor.cs create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/ProxyPropertyEditorDataProperty.cs diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs index d5d563adec..8907246bb9 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs +++ b/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[i].Properties[RowDefinition.HeightProperty].SetValue(newLength1); newRowDefinition.Properties[RowDefinition.HeightProperty].SetValue(newLength2); + + FixIndicesAfterSplit(i, Grid.RowProperty, Grid.RowSpanProperty); changeGroup.Commit(); gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { newRowDefinition }, SelectionTypes.Auto); break; @@ -141,10 +143,11 @@ namespace ICSharpCode.WpfDesign.Designer.Controls GridLength oldLength = (GridLength)column.GetValue(ColumnDefinition.WidthProperty); GridLength newLength1, 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()); - newColumnDefinition.Properties[ColumnDefinition.WidthProperty].SetValue(newLength2); 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(); gridItem.Services.Selection.SetSelectedComponents(new DesignItem[] { newColumnDefinition }, SelectionTypes.Auto); 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, out GridLength newLength1, out GridLength newLength2) { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs index 8a0aea7933..7c52590af3 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.cs +++ b/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 TextBox nameTextBox; Label typeLabel; - Image componentImage; + Rectangle componentImage; TextBox searchTextBox; StackPanel contentStackPanel; #endif @@ -73,7 +73,9 @@ namespace ICSharpCode.WpfDesign.Designer 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) { EditedObjectChanged(this, EventArgs.Empty); } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.xaml b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.xaml index 652b1b7087..665ecd0e57 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.xaml +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PropertyEditor/PropertyEditor.xaml @@ -13,7 +13,7 @@ - + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/ContentEditor.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/ContentEditor.cs new file mode 100644 index 0000000000..36c95398ba --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/ContentEditor.cs @@ -0,0 +1,139 @@ +// +// +// +// +// $Revision$ +// + +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 +{ + /// + /// Description of ContentEditor. + /// + [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); + } + } + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs index 927f37ceeb..1f73592e82 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/GridPlacementSupport.cs @@ -103,12 +103,15 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions default: 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) { - 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; else return grid.ActualWidth; @@ -116,7 +119,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions 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; else return grid.ActualHeight; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj index 60bf8a752b..31151ec12c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj @@ -71,6 +71,7 @@ + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs index d0cbf0f51c..97ff77a477 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs @@ -100,6 +100,14 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml } } + /// + /// Occurs when the parent of this design item changes. + /// + public override event EventHandler ParentChanged { + add { _xamlObject.ParentPropertyChanged += value; } + remove { _xamlObject.ParentPropertyChanged += value; } + } + public override UIElement View { get { if (_view != null) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyValue.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyValue.cs index 5d44b6da1a..1eda445aab 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyValue.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlPropertyValue.cs @@ -33,13 +33,23 @@ namespace ICSharpCode.WpfDesign.XamlDom public XamlProperty ParentProperty { get { return _parentProperty; } internal set { - _parentProperty = value; - OnParentPropertyChanged(); + if (_parentProperty != value) { + _parentProperty = value; + OnParentPropertyChanged(); + } } } + /// + /// Occurs when the value of the ParentProperty property changes. + /// + public event EventHandler ParentPropertyChanged; + internal virtual void OnParentPropertyChanged() { + if (ParentPropertyChanged != null) { + ParentPropertyChanged(this, EventArgs.Empty); + } } internal abstract void RemoveNodeFromParent(); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs index ffc3525807..3069f96f0d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs @@ -48,6 +48,11 @@ namespace ICSharpCode.WpfDesign /// public abstract DesignItem Parent { get; } + /// + /// Occurs when the parent of this design item changes. + /// + public abstract event EventHandler ParentChanged; + /// /// Gets the property where this DesignItem is used as a value. /// diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs index 82ba2f6133..688a5b259f 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs @@ -41,7 +41,9 @@ namespace ICSharpCode.WpfDesign.Extensions void ReapplyExtensions(IEnumerable items, ExtensionServer server) { foreach (DesignItem item in items) { - item.ReapplyExtensionServer(this, server); + if (item != null) { + item.ReapplyExtensionServer(this, server); + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs index 0a1b9b0d64..ec1b97fe7a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs @@ -96,8 +96,6 @@ namespace ICSharpCode.WpfDesign.Extensions /// public class PrimarySelectionParentExtensionServer : DefaultExtensionServer { - DesignItem oldPrimarySelectionParent; - /// /// Is called after the extension server is initialized and the Context property has been set. /// @@ -107,30 +105,32 @@ namespace ICSharpCode.WpfDesign.Extensions this.Services.Selection.PrimarySelectionChanged += OnPrimarySelectionChanged; } - DesignItem PrimarySelectionParent { - get { - DesignItem newPrimarySelection = this.Services.Selection.PrimarySelection; + DesignItem primarySelection; + DesignItem primarySelectionParent; + + void OnPrimarySelectionChanged(object sender, EventArgs e) + { + DesignItem newPrimarySelection = this.Services.Selection.PrimarySelection; + if (primarySelection != newPrimarySelection) { + if (primarySelection != null) { + primarySelection.ParentChanged -= OnParentChanged; + } if (newPrimarySelection != null) { - return newPrimarySelection.Parent; - } else { - return null; + newPrimarySelection.ParentChanged += OnParentChanged; } + 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 (oldPrimarySelectionParent == null) { - ReapplyExtensions(new DesignItem[] { newPrimarySelectionParent }); - } else if (newPrimarySelectionParent == null) { - ReapplyExtensions(new DesignItem[] { oldPrimarySelectionParent }); - } else { - ReapplyExtensions(new DesignItem[] { oldPrimarySelectionParent, newPrimarySelectionParent }); - } - oldPrimarySelectionParent = newPrimarySelectionParent; + if (primarySelectionParent != newPrimarySelectionParent) { + DesignItem oldPrimarySelectionParent = primarySelectionParent; + primarySelectionParent = newPrimarySelectionParent; + ReapplyExtensions(new DesignItem[] { oldPrimarySelectionParent, newPrimarySelectionParent }); } } @@ -139,7 +139,7 @@ namespace ICSharpCode.WpfDesign.Extensions /// public override bool ShouldApplyExtensions(DesignItem extendedItem) { - return PrimarySelectionParent == extendedItem; + return primarySelectionParent == extendedItem; } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs index 8a24b75513..9825b23abb 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementOperation.cs @@ -159,7 +159,8 @@ namespace ICSharpCode.WpfDesign info.OriginalBounds = op.currentContainerBehavior.GetPosition(op, info.Item); info.Bounds = info.OriginalBounds; } - } catch { + } catch (Exception ex) { + Debug.WriteLine(ex.ToString()); op.changeGroup.Abort(); throw; } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs index 5dd0559c2a..da236d287b 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/DesignItemDataSource.cs @@ -150,5 +150,17 @@ namespace ICSharpCode.WpfDesign.PropertyEditor public ServiceContainer Services { get { return item.Services; } } + + /// See + public Brush CreateThumbnailBrush() + { + if (item.View != null) { + VisualBrush b = new VisualBrush(item.View); + b.AutoLayoutContent = false; + return b; + } else { + return null; + } + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/FallbackEditor.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/FallbackEditor.cs index 463c807492..cf01cdd3f7 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/FallbackEditor.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/FallbackEditor.cs @@ -44,20 +44,24 @@ namespace ICSharpCode.WpfDesign.PropertyEditor } else { this.FontWeight = FontWeights.Regular; } - object val = property.Value; - if (val == null) { - this.Text = "null"; - this.FontStyle = FontStyles.Italic; + if (property.IsAmbiguous) { + this.Text = ""; } else { - this.FontStyle = FontStyles.Normal; - try { - this.Text = val.ToString(); - } catch (Exception ex) { - this.FontWeight = FontWeights.Regular; - Inlines.Clear(); - Inlines.Add(new Italic(new Run(ex.GetType().Name))); - Inlines.Add(" "); - Inlines.Add(ex.Message); + object val = property.Value; + if (val == null) { + this.Text = "null"; + this.FontStyle = FontStyles.Italic; + } else { + this.FontStyle = FontStyles.Normal; + try { + this.Text = val.ToString(); + } catch (Exception ex) { + this.FontWeight = FontWeights.Regular; + Inlines.Clear(); + Inlines.Add(new Italic(new Run(ex.GetType().Name))); + Inlines.Add(" "); + Inlines.Add(ex.Message); + } } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/IPropertyEditorDataSource.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/IPropertyEditorDataSource.cs index 40af4c113c..5007df97cf 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/IPropertyEditorDataSource.cs +++ b/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. /// ServiceContainer Services { get; } + + /// + /// Gets a brush used as a preview for the data source. + /// + Brush CreateThumbnailBrush(); } /// diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataSource.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataSource.cs index 323ac3994d..3631153fb5 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataSource.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/MultipleSelectionDataSource.cs @@ -7,6 +7,7 @@ using System; using System.Collections.Generic; +using System.Windows.Media; namespace ICSharpCode.WpfDesign.PropertyEditor { @@ -127,5 +128,11 @@ namespace ICSharpCode.WpfDesign.PropertyEditor public ServiceContainer Services { get { return services; } } + + /// See + public Brush CreateThumbnailBrush() + { + return null; + } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/ProxyPropertyEditorDataProperty.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/ProxyPropertyEditorDataProperty.cs new file mode 100644 index 0000000000..9a098dbcf3 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/ProxyPropertyEditorDataProperty.cs @@ -0,0 +1,109 @@ +// +// +// +// +// $Revision$ +// + +using System; + +namespace ICSharpCode.WpfDesign.PropertyEditor +{ + /// + /// Implements IPropertyEditorDataProperty by forwarding all calls to another IPropertyEditorDataProperty. + /// + public abstract class ProxyPropertyEditorDataProperty : IPropertyEditorDataProperty + { + readonly IPropertyEditorDataProperty data; + + /// + protected ProxyPropertyEditorDataProperty(IPropertyEditorDataProperty data) + { + if (data == null) + throw new ArgumentNullException("data"); + this.data = data; + } + + /// See + public virtual event EventHandler IsSetChanged { + add { data.IsSetChanged += value; } + remove { data.IsSetChanged -= value; } + } + + /// See + public virtual event EventHandler ValueChanged { + add { data.ValueChanged += value; } + remove { data.ValueChanged -= value; } + } + + /// See + public virtual IPropertyEditorDataSource OwnerDataSource { + get { return data.OwnerDataSource; } + } + + /// See + public virtual string Category { + get { return data.Category; } + } + + /// See + public virtual string Name { + get { return data.Name; } + } + + /// See + public virtual Type ReturnType { + get { return data.ReturnType; } + } + + /// See + public virtual Type DeclaringType { + get { return data.DeclaringType; } + } + + /// See + public virtual System.ComponentModel.TypeConverter TypeConverter { + get { return data.TypeConverter; } + } + + /// See + public virtual bool IsSet { + get { return data.IsSet; } + set { data.IsSet = value; } + } + + /// See + public virtual bool IsAmbiguous { + get { return data.IsAmbiguous; } + } + + /// See + public virtual object Value { + get { return data.Value; } + set { data.Value = value; } + } + + /// See + public virtual bool CanUseCustomExpression { + get { return data.CanUseCustomExpression; } + } + + /// See + public virtual object GetDescription() + { + return data.GetDescription(); + } + + /// See + public virtual void SetCustomExpression(string expression) + { + data.SetCustomExpression(expression); + } + + /// See + public virtual System.Windows.UIElement CreateEditor() + { + return data.CreateEditor(); + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/TextBoxEditor.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/TextBoxEditor.cs index dfbef0c25b..3c2ce068c4 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/TextBoxEditor.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyEditor/TextBoxEditor.cs @@ -22,7 +22,7 @@ namespace ICSharpCode.WpfDesign.PropertyEditor /// /// Type editor used to edit properties using a text box and the type's default type converter. /// - sealed class TextBoxEditor : TextBox + public sealed class TextBoxEditor : TextBox { readonly IPropertyEditorDataProperty property; bool isDirty; @@ -33,6 +33,9 @@ namespace ICSharpCode.WpfDesign.PropertyEditor /// public TextBoxEditor(IPropertyEditorDataProperty property) { + if (property == null) + throw new ArgumentNullException("property"); + this.property = property; UpdateFromSource(); PropertyEditorBindingHelper.AddValueChangedEventHandler( diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj index ccbc2d5529..bbf8e8e81d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj @@ -90,6 +90,7 @@ +