From 8b8cdfbc406c138c1082e16fc1a42ef3b6643b5a Mon Sep 17 00:00:00 2001 From: tbulle Date: Thu, 8 May 2014 14:35:55 +0200 Subject: [PATCH] Created Interface to be able to customize PropertyGrid --- .../Project/PropertyGrid/PropertyGrid.cs | 20 +++++++++++++++++-- .../Project/PropertyGrid/PropertyGridView.cs | 10 +++++++--- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs index 14de050360..290ba2f121 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs @@ -35,7 +35,20 @@ using System.Windows; namespace ICSharpCode.WpfDesign.Designer.PropertyGrid { - public class PropertyGrid : INotifyPropertyChanged + public interface IPropertyGrid + { + IEnumerable SelectedItems { get; set; } + Dictionary NodeFromDescriptor { get; } + DesignItem SingleItem { get; } + string Name { get; set; } + string OldName { get; } + bool IsNameCorrect { get; set; } + bool ReloadActive { get; } + event EventHandler AggregatePropertiesUpdated; + event PropertyChangedEventHandler PropertyChanged; + } + + public class PropertyGrid : INotifyPropertyChanged, IPropertyGrid { public PropertyGrid() { @@ -54,7 +67,8 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid Category attachedCategory = new Category("Attached"); Dictionary nodeFromDescriptor = new Dictionary(); - + public Dictionary NodeFromDescriptor { get { return nodeFromDescriptor; } } + public event EventHandler AggregatePropertiesUpdated; public CategoriesCollection Categories { get; private set; } public PropertyNodeCollection Events { get; private set; } @@ -220,6 +234,8 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid } } finally { reloadActive = false; + if (AggregatePropertiesUpdated != null) + AggregatePropertiesUpdated(this, EventArgs.Empty); } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs index b80aeb5582..c213b05690 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs @@ -43,9 +43,13 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid } - public PropertyGridView() + public PropertyGridView() : this(null) { - PropertyGrid = new PropertyGrid(); + } + + public PropertyGridView(IPropertyGrid pg) + { + PropertyGrid = pg??new PropertyGrid(); DataContext = PropertyGrid; } @@ -61,7 +65,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid static PropertyContextMenu propertyContextMenu = new PropertyContextMenu(); - public PropertyGrid PropertyGrid { get; private set; } + public IPropertyGrid PropertyGrid { get; private set; } public static readonly DependencyProperty FirstColumnWidthProperty = DependencyProperty.Register("FirstColumnWidth", typeof(double), typeof(PropertyGridView),