From 50c66e0f1711bbb6e1a1656e2f43557af91cea24 Mon Sep 17 00:00:00 2001 From: tbulle Date: Thu, 9 Jan 2014 11:09:19 +0100 Subject: [PATCH 01/23] Changes to make it easier to use and customize the propertygrid from external project --- .../Project/PropertyGrid/PropertyGrid.cs | 6 ++++++ .../Project/PropertyGrid/PropertyGridView.cs | 9 ++++++--- .../Project/Services/CreateComponentTool.cs | 13 ++++++++++++- 3 files changed, 24 insertions(+), 4 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 5884022a92..a5203c289a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs @@ -40,9 +40,13 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid Dictionary nodeFromDescriptor = new Dictionary(); + public Dictionary NodeFromDescriptor { get { return nodeFromDescriptor; } } + public CategoriesCollection Categories { get; private set; } public PropertyNodeCollection Events { get; private set; } + public EventHandler AggregatePropertiesUpdated; + private PropertyGridGroupMode _groupMode; public PropertyGridGroupMode GroupMode @@ -205,6 +209,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 f4f8ef44b0..bf4affab54 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGridView.cs @@ -27,13 +27,16 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid DefaultStyleKeyProperty.OverrideMetadata(typeof(PropertyGridView), new FrameworkPropertyMetadata(typeof(PropertyGridView))); } + public PropertyGridView() : this(null) + { + } - public PropertyGridView() + public PropertyGridView(PropertyGrid pg) { - PropertyGrid = new PropertyGrid(); + PropertyGrid = pg??new PropertyGrid(); DataContext = PropertyGrid; } - + private Thumb thumb; public override void OnApplyTemplate() { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs index 7f130e3945..3d3cc1382f 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs @@ -142,9 +142,20 @@ namespace ICSharpCode.WpfDesign.Designer.Services return item; } + public static bool AddItemWithDefaultSize(DesignItem container, Type createdItem, Size size) + { + CreateComponentTool cct = new CreateComponentTool(createdItem); + return AddItemWithCustomSize(container, cct.CreateItem(container.Context), new Point(0, 0), size); + } + internal static bool AddItemWithDefaultSize(DesignItem container, DesignItem createdItem, Point position) { - var size = ModelTools.GetDefaultSize(createdItem); + return AddItemWithCustomSize(container, createdItem, position, ModelTools.GetDefaultSize(createdItem)); + } + + internal static bool AddItemWithCustomSize(DesignItem container, DesignItem createdItem, Point position, Size size) + { + PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents( container, new DesignItem[] { createdItem }, From c22443ba71577f5aa882e17cc25305ee3a02f63b Mon Sep 17 00:00:00 2001 From: tbulle Date: Thu, 23 Jan 2014 10:58:53 +0100 Subject: [PATCH 02/23] Setter methods for implementing a custom HitTestFilterCallback --- .../WpfDesign.Designer/Project/DesignPanel.cs | 17 +++++++++++------ .../Project/PropertyGrid/PropertyGrid.cs | 2 +- .../Project/Services/CreateComponentTool.cs | 6 ++++++ .../Project/Services/ToolService.cs | 7 ++++++- .../WpfDesign/WpfDesign/Project/Tools.cs | 9 +++++++++ 5 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs index b7af3ec784..dfe6ff2763 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs @@ -86,12 +86,15 @@ namespace ICSharpCode.WpfDesign.Designer return; } // First try hit-testing on the adorner layer. - + bool continueHitTest = true; - + + HitTestFilterCallback filterBehavior = CustomHitTestFilterBehavior ?? FilterHitTestInvisibleElements; + CustomHitTestFilterBehavior = null; if (testAdorners) { + RunHitTest( - _adornerLayer, mousePosition, FilterHitTestInvisibleElements, + _adornerLayer, mousePosition, filterBehavior, delegate(HitTestResult result) { if (result != null && result.VisualHit != null && result.VisualHit is Visual) { DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit); @@ -110,14 +113,14 @@ namespace ICSharpCode.WpfDesign.Designer } }); } - + if (continueHitTest && testDesignSurface) { RunHitTest( - this.Child, mousePosition, FilterHitTestInvisibleElements, + this.Child, mousePosition, filterBehavior, delegate(HitTestResult result) { if (result != null && result.VisualHit != null && result.VisualHit is Visual) { DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit); - + ViewService viewService = _context.Services.View; DependencyObject obj = result.VisualHit; while (obj != null) { @@ -165,6 +168,8 @@ namespace ICSharpCode.WpfDesign.Designer #region Properties + //Set custom HitTestFilterCallbak + public HitTestFilterCallback CustomHitTestFilterBehavior { get; set; } /// /// Gets/Sets the design context. /// 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 a5203c289a..b4a6d06841 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs @@ -45,7 +45,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid public CategoriesCollection Categories { get; private set; } public PropertyNodeCollection Events { get; private set; } - public EventHandler AggregatePropertiesUpdated; + public EventHandler AggregatePropertiesUpdated { get; set; } private PropertyGridGroupMode _groupMode; diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs index 3d3cc1382f..5716300d9e 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs @@ -142,6 +142,12 @@ namespace ICSharpCode.WpfDesign.Designer.Services return item; } + public static bool AddItemWithCustomSizePosition(DesignItem container, Type createdItem, Size size, Point position) + { + CreateComponentTool cct = new CreateComponentTool(createdItem); + return AddItemWithCustomSize(container, cct.CreateItem(container.Context), position, size); + } + public static bool AddItemWithDefaultSize(DesignItem container, Type createdItem, Size size) { CreateComponentTool cct = new CreateComponentTool(createdItem); diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs index 2c262998ca..66ae19fcc5 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ToolService.cs @@ -3,7 +3,7 @@ using System; using System.Windows.Input; - +using System.Windows.Media; namespace ICSharpCode.WpfDesign.Designer.Services { // See IToolService for description. @@ -22,6 +22,11 @@ namespace ICSharpCode.WpfDesign.Designer.Services }); } + public HitTestFilterCallback DesignPanelHitTestFilterCallback + { + set{ _designPanel.CustomHitTestFilterBehavior = value; } + } + public void Dispose() { if (_designPanel != null) { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs index 4525e7c246..b23c75603d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Tools.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using System.Windows.Media; using ICSharpCode.WpfDesign.Adorners; @@ -38,6 +39,10 @@ namespace ICSharpCode.WpfDesign /// public interface IToolService { + /// + /// Set custom HitTestFilterCallback for DesignPanel + /// + HitTestFilterCallback DesignPanelHitTestFilterCallback{ set; } /// /// Gets the 'pointer' tool. /// The pointer tool is the default tool for selecting and moving elements. @@ -62,6 +67,10 @@ namespace ICSharpCode.WpfDesign public interface IDesignPanel : IInputElement { /// + /// Set a custom filter callback so that any element can be filtered out + /// + HitTestFilterCallback CustomHitTestFilterBehavior { get; set; } + /// /// Gets the design context used by the DesignPanel. /// DesignContext Context { get; } From b67af16c453ac9808337cd316276ee22753bcc6f Mon Sep 17 00:00:00 2001 From: tbulle Date: Tue, 28 Jan 2014 10:45:19 +0100 Subject: [PATCH 03/23] Implemented inteface for OutlineNode so that a custom outlinenode can be implemented --- .../Project/FormsDesigner.csproj | 1 + .../Project/OutlineView/Outline.xaml.cs | 7 +- .../Project/OutlineView/OutlineNode.cs | 344 +++++------------- .../Project/OutlineView/OutlineNodeBase.cs | 239 ++++++++++++ .../Editors/CollectionEditor.xaml.cs | 2 +- .../Project/PropertyGrid/PropertyGrid.cs | 4 +- .../Project/Services/CreateComponentTool.cs | 2 +- .../Project/WpfDesign.Designer.csproj | 1 + 8 files changed, 347 insertions(+), 253 deletions(-) create mode 100644 src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj b/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj index 088d5066b6..80ced74cdb 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/FormsDesigner.csproj @@ -54,6 +54,7 @@ + diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs index 25043cbff7..754849fd7a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs @@ -25,10 +25,11 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView } public static readonly DependencyProperty RootProperty = - DependencyProperty.Register("Root", typeof(OutlineNode), typeof(Outline)); + DependencyProperty.Register("Root", typeof(IOutlineNode), typeof(Outline)); - public OutlineNode Root { - get { return (OutlineNode)GetValue(RootProperty); } + public IOutlineNode Root + { + get { return (IOutlineNode)GetValue(RootProperty); } set { SetValue(RootProperty, value); } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs index f3e03c08ba..5508d1a1ed 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs @@ -19,249 +19,101 @@ using ICSharpCode.WpfDesign.XamlDom; namespace ICSharpCode.WpfDesign.Designer.OutlineView { - public class OutlineNode : INotifyPropertyChanged - { - //Used to check if element can enter other containers - public static PlacementType DummyPlacementType; - - static OutlineNode() - { - DummyPlacementType = PlacementType.Register("DummyPlacement"); - } - public static OutlineNode Create(DesignItem designItem) - { - OutlineNode node; - if (!outlineNodes.TryGetValue(designItem, out node)) { - node = new OutlineNode(designItem); - outlineNodes[designItem] = node; - } - return node; - } - - //TODO: Reset with DesignContext - static Dictionary outlineNodes = new Dictionary(); - - OutlineNode(DesignItem designItem) - { - DesignItem = designItem; - UpdateChildren(); - - var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance; - if (hidden != null && (bool) hidden == true) { - this._isDesignTimeVisible = false; - ((FrameworkElement) this.DesignItem.Component).Visibility = Visibility.Hidden; - } - - var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance; - if (locked != null && (bool) locked == true) { - this._isDesignTimeLocked = true; - } - - //TODO - DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged); - DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged); - SelectionService.SelectionChanged += new EventHandler(Selection_SelectionChanged); - } - - public DesignItem DesignItem { get; private set; } - - public ISelectionService SelectionService { - get { return DesignItem.Services.Selection; } - } - - bool isExpanded = true; - - public bool IsExpanded { - get { - return isExpanded; - } - set { - isExpanded = value; - RaisePropertyChanged("IsExpanded"); - } - } - - bool isSelected; - - public bool IsSelected { - get { - return isSelected; - } - set { - if (isSelected != value) { - isSelected = value; - SelectionService.SetSelectedComponents(new[] { DesignItem }, - value ? SelectionTypes.Add : SelectionTypes.Remove); - RaisePropertyChanged("IsSelected"); - } - } - } - - bool _isDesignTimeVisible = true; - - public bool IsDesignTimeVisible - { - get { - return _isDesignTimeVisible; - } - set { - _isDesignTimeVisible = value; - var ctl = DesignItem.Component as UIElement; - ctl.Visibility = _isDesignTimeVisible ? Visibility.Visible : Visibility.Hidden; - - RaisePropertyChanged("IsDesignTimeVisible"); - - if (!value) - DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).SetValue(true); - else - DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).Reset(); - } - } - - bool _isDesignTimeLocked = false; - - public bool IsDesignTimeLocked - { - get { - return _isDesignTimeLocked; - } - set { - _isDesignTimeLocked = value; - ((XamlDesignItem)DesignItem).IsDesignTimeLocked = _isDesignTimeLocked; - - RaisePropertyChanged("IsDesignTimeLocked"); - -// if (value) -// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).SetValue(true); -// else -// DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset(); - } - } - - ObservableCollection children = new ObservableCollection(); - - public ObservableCollection Children { - get { return children; } - } - - public string Name { - get { - if (string.IsNullOrEmpty(DesignItem.Name)) { - return DesignItem.ComponentType.Name; - } - return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")"; - } - } - - void Selection_SelectionChanged(object sender, DesignItemCollectionEventArgs e) - { - IsSelected = DesignItem.Services.Selection.IsComponentSelected(DesignItem); - } - - void DesignItem_NameChanged(object sender, EventArgs e) - { - RaisePropertyChanged("Name"); - } - - void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e) - { - if (e.PropertyName == DesignItem.ContentPropertyName) { - UpdateChildren(); - } - } - - void UpdateChildren() - { - Children.Clear(); - - if (DesignItem.ContentPropertyName != null) { - var content = DesignItem.ContentProperty; - if (content.IsCollection) { - UpdateChildrenCore(content.CollectionElements); - } - else { - if (content.Value != null) { - UpdateChildrenCore(new[] { content.Value }); - } - } - } - } - - void UpdateChildrenCore(IEnumerable items) - { - foreach (var item in items) { - if (ModelTools.CanSelectComponent(item)) { - var node = OutlineNode.Create(item); - Children.Add(node); - } - else - { - var content = item.ContentProperty; - if (content != null) - { - if (content.IsCollection) { - UpdateChildrenCore(content.CollectionElements); - } - else { - if (content.Value != null) { - UpdateChildrenCore(new[] { content.Value }); - } - } - } - } - } - } - - public bool CanInsert(IEnumerable nodes, OutlineNode after, bool copy) - { - var placementBehavior = DesignItem.GetBehavior(); - if (placementBehavior == null) - return false; - var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); - if (operation != null) { - bool canEnter = placementBehavior.CanEnterContainer(operation, true); - operation.Abort(); - return canEnter; - } - return false; - } - - public void Insert(IEnumerable nodes, OutlineNode after, bool copy) - { - using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) { - if (copy) { - nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList(); - } else { - foreach (var node in nodes) { - node.DesignItem.Remove(); - } - } - - var index = after == null ? 0 : Children.IndexOf(after) + 1; - - var content = DesignItem.ContentProperty; - if (content.IsCollection) { - foreach (var node in nodes) { - content.CollectionElements.Insert(index++, node.DesignItem); - } - } else { - content.SetValue(nodes.First().DesignItem); - } - moveTransaction.Commit(); - } - } - - #region INotifyPropertyChanged Members - - public event PropertyChangedEventHandler PropertyChanged; - - void RaisePropertyChanged(string name) - { - if (PropertyChanged != null) { - PropertyChanged(this, new PropertyChangedEventArgs(name)); - } - } - - #endregion - } -} + public interface IOutlineNode + { + ISelectionService SelectionService { get; } + bool IsExpanded { get; set; } + DesignItem DesignItem { get; set; } + bool IsSelected { get; set; } + bool IsDesignTimeVisible { get; set; } + bool IsDesignTimeLocked { get; } + string Name { get; } + bool CanInsert(IEnumerable nodes, IOutlineNode after, bool copy); + void Insert(IEnumerable nodes, IOutlineNode after, bool copy); + } + + + public class OutlineNode: OutlineNodeBase + { + //TODO: Reset with DesignContext + static Dictionary outlineNodes = new Dictionary(); + + protected OutlineNode(DesignItem designitem): base(designitem) + { + UpdateChildren(); + SelectionService.SelectionChanged += new EventHandler(Selection_SelectionChanged); + } + + static OutlineNode() + { + DummyPlacementType = PlacementType.Register("DummyPlacement"); + } + + public static IOutlineNode Create(DesignItem designItem) + { + IOutlineNode node; + if (!outlineNodes.TryGetValue(designItem, out node)) + { + node = new OutlineNode(designItem); + outlineNodes[designItem] = node; + } + return node; + } + + void Selection_SelectionChanged(object sender, DesignItemCollectionEventArgs e) + { + IsSelected = DesignItem.Services.Selection.IsComponentSelected(DesignItem); + } + + protected override void UpdateChildren() + { + Children.Clear(); + + if (DesignItem.ContentPropertyName != null) + { + var content = DesignItem.ContentProperty; + if (content.IsCollection) + { + UpdateChildrenCore(content.CollectionElements); + } + else + { + if (content.Value != null) + { + UpdateChildrenCore(new[] { content.Value }); + } + } + } + } + + void UpdateChildrenCore(IEnumerable items) + { + foreach (var item in items) + { + if (ModelTools.CanSelectComponent(item)) + { + var node = OutlineNode.Create(item); + Children.Add(node); + } + else + { + var content = item.ContentProperty; + if (content != null) + { + if (content.IsCollection) + { + UpdateChildrenCore(content.CollectionElements); + } + else + { + if (content.Value != null) + { + UpdateChildrenCore(new[] { content.Value }); + } + } + } + } + } + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs new file mode 100644 index 0000000000..2e807f6967 --- /dev/null +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs @@ -0,0 +1,239 @@ +/* + * Created by SharpDevelop. + * User: trubra + * Date: 2014-01-28 + * Time: 10:09 + * + * To change this template use Tools | Options | Coding | Edit Standard Headers. + */ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Windows; +using System.Linq; +using ICSharpCode.WpfDesign.Designer.Xaml; +using ICSharpCode.WpfDesign.XamlDom; + +namespace ICSharpCode.WpfDesign.Designer.OutlineView +{ + /// + /// Description of OutlineNodeBase. + /// + public abstract class OutlineNodeBase : INotifyPropertyChanged, IOutlineNode + { + + protected abstract void UpdateChildren(); + //Used to check if element can enter other containers + protected static PlacementType DummyPlacementType; + + protected OutlineNodeBase(DesignItem designItem) + { + DesignItem = designItem; + + + var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance; + if (hidden != null && (bool)hidden) + { + _isDesignTimeVisible = false; + ((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden; + } + + var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance; + if (locked != null && (bool)locked) + { + _isDesignTimeLocked = true; + } + + //TODO + + DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged); + DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged); + } + + public DesignItem DesignItem { get; set; } + + public ISelectionService SelectionService + { + get { return DesignItem.Services.Selection; } + } + + bool isExpanded = true; + + public bool IsExpanded + { + get + { + return isExpanded; + } + set + { + isExpanded = value; + RaisePropertyChanged("IsExpanded"); + } + } + + bool isSelected; + + public bool IsSelected + { + get + { + return isSelected; + } + set + { + if (isSelected != value) + { + isSelected = value; + SelectionService.SetSelectedComponents(new[] { DesignItem }, + value ? SelectionTypes.Add : SelectionTypes.Remove); + RaisePropertyChanged("IsSelected"); + } + } + } + + bool _isDesignTimeVisible = true; + + public bool IsDesignTimeVisible + { + get + { + return _isDesignTimeVisible; + } + set + { + _isDesignTimeVisible = value; + var ctl = DesignItem.Component as UIElement; + if(ctl!=null) + ctl.Visibility = _isDesignTimeVisible ? Visibility.Visible : Visibility.Hidden; + + RaisePropertyChanged("IsDesignTimeVisible"); + + if (!value) + DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).SetValue(true); + else + DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).Reset(); + } + } + + bool _isDesignTimeLocked = false; + + public bool IsDesignTimeLocked + { + get + { + return _isDesignTimeLocked; + } + set + { + _isDesignTimeLocked = value; + ((XamlDesignItem)DesignItem).IsDesignTimeLocked = _isDesignTimeLocked; + + RaisePropertyChanged("IsDesignTimeLocked"); + + // if (value) + // DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).SetValue(true); + // else + // DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset(); + } + } + + ObservableCollection children = new ObservableCollection(); + + public ObservableCollection Children + { + get { return children; } + } + + public string Name + { + get + { + if (string.IsNullOrEmpty(DesignItem.Name)) + { + return DesignItem.ComponentType.Name; + } + return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")"; + } + } + + void DesignItem_NameChanged(object sender, EventArgs e) + { + RaisePropertyChanged("Name"); + } + + void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == DesignItem.ContentPropertyName) + { + UpdateChildren(); + } + } + + + + public bool CanInsert(IEnumerable nodes, IOutlineNode after, bool copy) + { + var placementBehavior = DesignItem.GetBehavior(); + if (placementBehavior == null) + return false; + var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); + if (operation != null) + { + bool canEnter = placementBehavior.CanEnterContainer(operation, true); + operation.Abort(); + return canEnter; + } + return false; + } + + public virtual void Insert(IEnumerable nodes, IOutlineNode after, bool copy) + { + using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) + { + if (copy) + { + nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList(); + } + else + { + foreach (var node in nodes) + { + node.DesignItem.Remove(); + } + } + + var index = after == null ? 0 : Children.IndexOf(after) + 1; + + var content = DesignItem.ContentProperty; + if (content.IsCollection) + { + foreach (var node in nodes) + { + content.CollectionElements.Insert(index++, node.DesignItem); + } + } + else + { + content.SetValue(nodes.First().DesignItem); + } + moveTransaction.Commit(); + } + } + + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + + public void RaisePropertyChanged(string name) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(name)); + } + } + + #endregion + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs index 57e1b3ccb7..0313d7dc0b 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs @@ -49,7 +49,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors if(control!=null){ TypeMappings.TryGetValue(control.GetType(), out _type); if (_type != null) { - OutlineNode node = OutlineNode.Create(item); + IOutlineNode node = OutlineNode.Create(item); Outline.Root = node; PropertyGridView.PropertyGrid.SelectedItems = item.Services.Selection.SelectedItems; } 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 b4a6d06841..bb7003011d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs @@ -45,13 +45,13 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid public CategoriesCollection Categories { get; private set; } public PropertyNodeCollection Events { get; private set; } - public EventHandler AggregatePropertiesUpdated { get; set; } + public event EventHandler AggregatePropertiesUpdated; private PropertyGridGroupMode _groupMode; public PropertyGridGroupMode GroupMode { - get { return _groupMode; } + get { return _groupMode; } set { if (_groupMode != value) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs index 5716300d9e..0ac05437a8 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/CreateComponentTool.cs @@ -146,7 +146,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services { CreateComponentTool cct = new CreateComponentTool(createdItem); return AddItemWithCustomSize(container, cct.CreateItem(container.Context), position, size); - } + } public static bool AddItemWithDefaultSize(DesignItem container, Type createdItem, Size size) { 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 a335f5f1f6..53a407d42d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj @@ -87,6 +87,7 @@ + FlatCollectionEditor.xaml Code From a3c162e9c0c6e7dc31bd6532cc082188897be7d6 Mon Sep 17 00:00:00 2001 From: tbulle Date: Tue, 28 Jan 2014 11:57:56 +0100 Subject: [PATCH 04/23] Format changes --- .../Project/OutlineView/Outline.xaml.cs | 8 +- .../Project/OutlineView/OutlineNode.cs | 163 ++++--- .../Project/OutlineView/OutlineNodeBase.cs | 418 +++++++++--------- .../Project/PropertyGrid/PropertyGrid.cs | 6 +- 4 files changed, 283 insertions(+), 312 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs index 754849fd7a..7e2cec2296 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs @@ -25,11 +25,11 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView } public static readonly DependencyProperty RootProperty = - DependencyProperty.Register("Root", typeof(IOutlineNode), typeof(Outline)); + DependencyProperty.Register("Root", typeof(IOutlineNode), typeof(Outline)); - public IOutlineNode Root - { - get { return (IOutlineNode)GetValue(RootProperty); } + public IOutlineNode Root + { + get { return (IOutlineNode)GetValue(RootProperty); } set { SetValue(RootProperty, value); } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs index 5508d1a1ed..5116f1f425 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs @@ -20,100 +20,85 @@ using ICSharpCode.WpfDesign.XamlDom; namespace ICSharpCode.WpfDesign.Designer.OutlineView { public interface IOutlineNode - { - ISelectionService SelectionService { get; } - bool IsExpanded { get; set; } - DesignItem DesignItem { get; set; } - bool IsSelected { get; set; } - bool IsDesignTimeVisible { get; set; } - bool IsDesignTimeLocked { get; } - string Name { get; } - bool CanInsert(IEnumerable nodes, IOutlineNode after, bool copy); - void Insert(IEnumerable nodes, IOutlineNode after, bool copy); - } - + { + ISelectionService SelectionService { get; } + bool IsExpanded { get; set; } + DesignItem DesignItem { get; set; } + bool IsSelected { get; set; } + bool IsDesignTimeVisible { get; set; } + bool IsDesignTimeLocked { get; } + string Name { get; } + bool CanInsert(IEnumerable nodes, IOutlineNode after, bool copy); + void Insert(IEnumerable nodes, IOutlineNode after, bool copy); + } + - public class OutlineNode: OutlineNodeBase - { - //TODO: Reset with DesignContext - static Dictionary outlineNodes = new Dictionary(); + public class OutlineNode: OutlineNodeBase + { + //TODO: Reset with DesignContext + static Dictionary outlineNodes = new Dictionary(); - protected OutlineNode(DesignItem designitem): base(designitem) - { - UpdateChildren(); - SelectionService.SelectionChanged += new EventHandler(Selection_SelectionChanged); - } + protected OutlineNode(DesignItem designitem): base(designitem) + { + UpdateChildren(); + SelectionService.SelectionChanged += new EventHandler(Selection_SelectionChanged); + } - static OutlineNode() - { - DummyPlacementType = PlacementType.Register("DummyPlacement"); - } + static OutlineNode() + { + DummyPlacementType = PlacementType.Register("DummyPlacement"); + } - public static IOutlineNode Create(DesignItem designItem) - { - IOutlineNode node; - if (!outlineNodes.TryGetValue(designItem, out node)) - { - node = new OutlineNode(designItem); - outlineNodes[designItem] = node; - } - return node; - } + public static IOutlineNode Create(DesignItem designItem) + { + IOutlineNode node; + if (!outlineNodes.TryGetValue(designItem, out node)) { + node = new OutlineNode(designItem); + outlineNodes[designItem] = node; + } + return node; + } - void Selection_SelectionChanged(object sender, DesignItemCollectionEventArgs e) - { - IsSelected = DesignItem.Services.Selection.IsComponentSelected(DesignItem); - } + void Selection_SelectionChanged(object sender, DesignItemCollectionEventArgs e) + { + IsSelected = DesignItem.Services.Selection.IsComponentSelected(DesignItem); + } - protected override void UpdateChildren() - { - Children.Clear(); + protected override void UpdateChildren() + { + Children.Clear(); - if (DesignItem.ContentPropertyName != null) - { - var content = DesignItem.ContentProperty; - if (content.IsCollection) - { - UpdateChildrenCore(content.CollectionElements); - } - else - { - if (content.Value != null) - { - UpdateChildrenCore(new[] { content.Value }); - } - } - } - } + if (DesignItem.ContentPropertyName != null) { + var content = DesignItem.ContentProperty; + if (content.IsCollection) { + UpdateChildrenCore(content.CollectionElements); + } else { + if (content.Value != null) { + UpdateChildrenCore(new[] { content.Value }); + } + } + } + } - void UpdateChildrenCore(IEnumerable items) - { - foreach (var item in items) - { - if (ModelTools.CanSelectComponent(item)) - { - var node = OutlineNode.Create(item); - Children.Add(node); - } - else - { - var content = item.ContentProperty; - if (content != null) - { - if (content.IsCollection) - { - UpdateChildrenCore(content.CollectionElements); - } - else - { - if (content.Value != null) - { - UpdateChildrenCore(new[] { content.Value }); - } - } - } - } - } - } - } -} + void UpdateChildrenCore(IEnumerable items) + { + foreach (var item in items) { + if (ModelTools.CanSelectComponent(item)) { + var node = OutlineNode.Create(item); + Children.Add(node); + } else { + var content = item.ContentProperty; + if (content != null) { + if (content.IsCollection) { + UpdateChildrenCore(content.CollectionElements); + } else { + if (content.Value != null) { + UpdateChildrenCore(new[] { content.Value }); + } + } + } + } + } + } + } +} diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs index 2e807f6967..648b4097ec 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNodeBase.cs @@ -12,7 +12,7 @@ using System.Collections.ObjectModel; using System.ComponentModel; using System.Windows; using System.Linq; -using ICSharpCode.WpfDesign.Designer.Xaml; +using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.XamlDom; namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -21,219 +21,205 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView /// Description of OutlineNodeBase. /// public abstract class OutlineNodeBase : INotifyPropertyChanged, IOutlineNode - { - - protected abstract void UpdateChildren(); - //Used to check if element can enter other containers - protected static PlacementType DummyPlacementType; - - protected OutlineNodeBase(DesignItem designItem) - { - DesignItem = designItem; - - - var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance; - if (hidden != null && (bool)hidden) - { - _isDesignTimeVisible = false; - ((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden; - } - - var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance; - if (locked != null && (bool)locked) - { - _isDesignTimeLocked = true; - } - - //TODO - - DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged); - DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged); - } - - public DesignItem DesignItem { get; set; } - - public ISelectionService SelectionService - { - get { return DesignItem.Services.Selection; } - } - - bool isExpanded = true; - - public bool IsExpanded - { - get - { - return isExpanded; - } - set - { - isExpanded = value; - RaisePropertyChanged("IsExpanded"); - } - } - - bool isSelected; - - public bool IsSelected - { - get - { - return isSelected; - } - set - { - if (isSelected != value) - { - isSelected = value; - SelectionService.SetSelectedComponents(new[] { DesignItem }, - value ? SelectionTypes.Add : SelectionTypes.Remove); - RaisePropertyChanged("IsSelected"); - } - } - } - - bool _isDesignTimeVisible = true; - - public bool IsDesignTimeVisible - { - get - { - return _isDesignTimeVisible; - } - set - { - _isDesignTimeVisible = value; - var ctl = DesignItem.Component as UIElement; - if(ctl!=null) - ctl.Visibility = _isDesignTimeVisible ? Visibility.Visible : Visibility.Hidden; - - RaisePropertyChanged("IsDesignTimeVisible"); - - if (!value) - DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).SetValue(true); - else - DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).Reset(); - } - } - - bool _isDesignTimeLocked = false; - - public bool IsDesignTimeLocked - { - get - { - return _isDesignTimeLocked; - } - set - { - _isDesignTimeLocked = value; - ((XamlDesignItem)DesignItem).IsDesignTimeLocked = _isDesignTimeLocked; - - RaisePropertyChanged("IsDesignTimeLocked"); - - // if (value) - // DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).SetValue(true); - // else - // DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset(); - } - } - - ObservableCollection children = new ObservableCollection(); - - public ObservableCollection Children - { - get { return children; } - } - - public string Name - { - get - { - if (string.IsNullOrEmpty(DesignItem.Name)) - { - return DesignItem.ComponentType.Name; - } - return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")"; - } - } - - void DesignItem_NameChanged(object sender, EventArgs e) - { - RaisePropertyChanged("Name"); - } - - void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e) - { - if (e.PropertyName == DesignItem.ContentPropertyName) - { - UpdateChildren(); - } - } - - - - public bool CanInsert(IEnumerable nodes, IOutlineNode after, bool copy) - { - var placementBehavior = DesignItem.GetBehavior(); - if (placementBehavior == null) - return false; - var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); - if (operation != null) - { - bool canEnter = placementBehavior.CanEnterContainer(operation, true); - operation.Abort(); - return canEnter; - } - return false; - } - - public virtual void Insert(IEnumerable nodes, IOutlineNode after, bool copy) - { - using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) - { - if (copy) - { - nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList(); - } - else - { - foreach (var node in nodes) - { - node.DesignItem.Remove(); - } - } - - var index = after == null ? 0 : Children.IndexOf(after) + 1; - - var content = DesignItem.ContentProperty; - if (content.IsCollection) - { - foreach (var node in nodes) - { - content.CollectionElements.Insert(index++, node.DesignItem); - } - } - else - { - content.SetValue(nodes.First().DesignItem); - } - moveTransaction.Commit(); - } - } - - #region INotifyPropertyChanged Members - - public event PropertyChangedEventHandler PropertyChanged; - - public void RaisePropertyChanged(string name) - { - if (PropertyChanged != null) - { - PropertyChanged(this, new PropertyChangedEventArgs(name)); - } - } - - #endregion - } + { + + protected abstract void UpdateChildren(); + //Used to check if element can enter other containers + protected static PlacementType DummyPlacementType; + + protected OutlineNodeBase(DesignItem designItem) + { + DesignItem = designItem; + + + var hidden = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).ValueOnInstance; + if (hidden != null && (bool)hidden) { + _isDesignTimeVisible = false; + ((FrameworkElement)DesignItem.Component).Visibility = Visibility.Hidden; + } + + var locked = designItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).ValueOnInstance; + if (locked != null && (bool)locked) { + _isDesignTimeLocked = true; + } + + //TODO + + DesignItem.NameChanged += new EventHandler(DesignItem_NameChanged); + DesignItem.PropertyChanged += new PropertyChangedEventHandler(DesignItem_PropertyChanged); + } + + public DesignItem DesignItem { get; set; } + + public ISelectionService SelectionService + { + get { return DesignItem.Services.Selection; } + } + + bool isExpanded = true; + + public bool IsExpanded + { + get + { + return isExpanded; + } + set + { + isExpanded = value; + RaisePropertyChanged("IsExpanded"); + } + } + + bool isSelected; + + public bool IsSelected + { + get + { + return isSelected; + } + set + { + if (isSelected != value) { + isSelected = value; + SelectionService.SetSelectedComponents(new[] { DesignItem }, + value ? SelectionTypes.Add : SelectionTypes.Remove); + RaisePropertyChanged("IsSelected"); + } + } + } + + bool _isDesignTimeVisible = true; + + public bool IsDesignTimeVisible + { + get + { + return _isDesignTimeVisible; + } + set + { + _isDesignTimeVisible = value; + var ctl = DesignItem.Component as UIElement; + if(ctl!=null) + ctl.Visibility = _isDesignTimeVisible ? Visibility.Visible : Visibility.Hidden; + + RaisePropertyChanged("IsDesignTimeVisible"); + + if (!value) + DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).SetValue(true); + else + DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsHiddenProperty).Reset(); + } + } + + bool _isDesignTimeLocked = false; + + public bool IsDesignTimeLocked + { + get + { + return _isDesignTimeLocked; + } + set + { + _isDesignTimeLocked = value; + ((XamlDesignItem)DesignItem).IsDesignTimeLocked = _isDesignTimeLocked; + + RaisePropertyChanged("IsDesignTimeLocked"); + + // if (value) + // DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).SetValue(true); + // else + // DesignItem.Properties.GetAttachedProperty(DesignTimeProperties.IsLockedProperty).Reset(); + } + } + + ObservableCollection children = new ObservableCollection(); + + public ObservableCollection Children + { + get { return children; } + } + + public string Name + { + get + { + if (string.IsNullOrEmpty(DesignItem.Name)) { + return DesignItem.ComponentType.Name; + } + return DesignItem.ComponentType.Name + " (" + DesignItem.Name + ")"; + } + } + + void DesignItem_NameChanged(object sender, EventArgs e) + { + RaisePropertyChanged("Name"); + } + + void DesignItem_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == DesignItem.ContentPropertyName) { + UpdateChildren(); + } + } + + + + public bool CanInsert(IEnumerable nodes, IOutlineNode after, bool copy) + { + var placementBehavior = DesignItem.GetBehavior(); + if (placementBehavior == null) + return false; + var operation = PlacementOperation.Start(nodes.Select(node => node.DesignItem).ToArray(), DummyPlacementType); + if (operation != null) { + bool canEnter = placementBehavior.CanEnterContainer(operation, true); + operation.Abort(); + return canEnter; + } + return false; + } + + public virtual void Insert(IEnumerable nodes, IOutlineNode after, bool copy) + { + using (var moveTransaction = DesignItem.Context.OpenGroup("Item moved in outline view", nodes.Select(n => n.DesignItem).ToList())) + { + if (copy) { + nodes = nodes.Select(n => OutlineNode.Create(n.DesignItem.Clone())).ToList(); + } else { + foreach (var node in nodes) { + node.DesignItem.Remove(); + } + } + + var index = after == null ? 0 : Children.IndexOf(after) + 1; + + var content = DesignItem.ContentProperty; + if (content.IsCollection) { + foreach (var node in nodes) { + content.CollectionElements.Insert(index++, node.DesignItem); + } + } else { + content.SetValue(nodes.First().DesignItem); + } + moveTransaction.Commit(); + } + } + + #region INotifyPropertyChanged Members + + public event PropertyChangedEventHandler PropertyChanged; + + public void RaisePropertyChanged(string name) + { + if (PropertyChanged != null) + { + PropertyChanged(this, new PropertyChangedEventArgs(name)); + } + } + + #endregion + } } 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 bb7003011d..40a2cb834a 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyGrid.cs @@ -51,7 +51,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid public PropertyGridGroupMode GroupMode { - get { return _groupMode; } + get { return _groupMode; } set { if (_groupMode != value) @@ -202,7 +202,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid if (selectedItems == null || selectedItems.Count == 0) return; if (selectedItems.Count == 1) SingleItem = selectedItems[0]; - + foreach (var md in GetDescriptors()) { if (PassesFilter(md.Name)) AddNode(md); @@ -210,7 +210,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid } finally { reloadActive = false; if (AggregatePropertiesUpdated != null) - AggregatePropertiesUpdated(this, EventArgs.Empty); + AggregatePropertiesUpdated(this, EventArgs.Empty); } } From 78e4702ca306efa3cf42a5de8c6a3537c8374316 Mon Sep 17 00:00:00 2001 From: tbulle Date: Thu, 30 Jan 2014 12:28:29 +0100 Subject: [PATCH 05/23] changes to make tests work --- .../Project/OutlineView/OutlineNode.cs | 1 + .../Tests/Designer/OutlineView/HierarchyTests.cs | 2 +- .../Tests/Designer/OutlineView/InsertTests.cs | 16 ++++++++-------- .../Tests/Designer/OutlineView/SelectionTests.cs | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs index 5116f1f425..874b126f31 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineNode.cs @@ -30,6 +30,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView string Name { get; } bool CanInsert(IEnumerable nodes, IOutlineNode after, bool copy); void Insert(IEnumerable nodes, IOutlineNode after, bool copy); + ObservableCollection Children{ get; } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/HierarchyTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/HierarchyTests.cs index 4d7080f558..416bb610fd 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/HierarchyTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/HierarchyTests.cs @@ -11,7 +11,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView public class HierarchyTests : ModelTestHelper { private DesignItem _grid; - private OutlineNode _outline; + private IOutlineNode _outline; [TestFixtureSetUp] public void Intialize() diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs index bdcb418e3e..eabc1bdff6 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/InsertTests.cs @@ -11,15 +11,15 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView public class CollectionElementsInsertTests : ModelTestHelper { private DesignItem _grid; - private OutlineNode _outline; + private IOutlineNode _outline; private DesignItem _gridButton; private DesignItem _stackPanel; private DesignItem _stackPanelButton; - private OutlineNode _gridButtonNode; - private OutlineNode _stackPanelNode; - private OutlineNode _stackPanelButtonNode; + private IOutlineNode _gridButtonNode; + private IOutlineNode _stackPanelNode; + private IOutlineNode _stackPanelButtonNode; [SetUp] public void Intialize() @@ -147,15 +147,15 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView public class ContentControlInsertTests : ModelTestHelper { private DesignItem _grid; - private OutlineNode _outline; + private IOutlineNode _outline; private DesignItem _gridButton; private DesignItem _stackPanel; private DesignItem _stackPanelImage; - private OutlineNode _gridButtonNode; - private OutlineNode _stackPanelNode; - private OutlineNode _stackPanelImageNode; + private IOutlineNode _gridButtonNode; + private IOutlineNode _stackPanelNode; + private IOutlineNode _stackPanelImageNode; [SetUp] public void Intialize() diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/SelectionTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/SelectionTests.cs index b5a5820b7a..cefd803a62 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/SelectionTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/OutlineView/SelectionTests.cs @@ -11,7 +11,7 @@ namespace ICSharpCode.WpfDesign.Tests.Designer.OutlineView public class SelectionTests : ModelTestHelper { private DesignItem _grid; - private OutlineNode _outline; + private IOutlineNode _outline; [SetUp] public void Intialize() From f4f0f39cb7132504e96bff64a68d6641c649e1c4 Mon Sep 17 00:00:00 2001 From: tbulle Date: Fri, 31 Jan 2014 00:20:33 +0100 Subject: [PATCH 06/23] Changes to OutlineTreeView to Work With IOutlineNode --- .../Project/OutlineView/OutlineTreeView.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs index f739db7366..0225f58a47 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineTreeView.cs @@ -13,30 +13,30 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView protected override bool CanInsert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy) { UpdateCustomNodes(items); - return (target.DataContext as OutlineNode).CanInsert(_customOutlineNodes, - after == null ? null : after.DataContext as OutlineNode, copy); + return (target.DataContext as IOutlineNode).CanInsert(_customOutlineNodes, + after == null ? null : after.DataContext as IOutlineNode, copy); } protected override void Insert(DragTreeViewItem target, DragTreeViewItem[] items, DragTreeViewItem after, bool copy) { UpdateCustomNodes(items); - (target.DataContext as OutlineNode).Insert(_customOutlineNodes, - after == null ? null : after.DataContext as OutlineNode, copy); + (target.DataContext as IOutlineNode).Insert(_customOutlineNodes, + after == null ? null : after.DataContext as IOutlineNode, copy); } // Need to do this through a seperate List since previously LINQ queries apparently disconnected DataContext;bug in .NET 4.0 - private List _customOutlineNodes; + private List _customOutlineNodes; void UpdateCustomNodes(IEnumerable items) { - _customOutlineNodes = new List(); + _customOutlineNodes = new List(); foreach (var item in items) - _customOutlineNodes.Add(item.DataContext as OutlineNode); + _customOutlineNodes.Add(item.DataContext as IOutlineNode); } public override bool ShouldItemBeVisible(DragTreeViewItem dragTreeViewitem) { - var node = dragTreeViewitem.DataContext as OutlineNode; + var node = dragTreeViewitem.DataContext as IOutlineNode; return string.IsNullOrEmpty(Filter) || node.Name.ToLower().Contains(Filter.ToLower()); } @@ -45,7 +45,7 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView { base.SelectOnly(item); - var node = item.DataContext as OutlineNode; + var node = item.DataContext as IOutlineNode; var surface = node.DesignItem.View.TryFindParent(); if (surface != null) From 8b8cdfbc406c138c1082e16fc1a42ef3b6643b5a Mon Sep 17 00:00:00 2001 From: tbulle Date: Thu, 8 May 2014 14:35:55 +0200 Subject: [PATCH 07/23] 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), From 6d1d189713ab97f0ffd6bb4d7fecc27bd1c71e76 Mon Sep 17 00:00:00 2001 From: gumme Date: Mon, 7 Jul 2014 20:45:26 +0200 Subject: [PATCH 08/23] BindingWrapper now supports MultiBinding and PriorityBinding. --- .../Tests/XamlDom/MarkupExtensionTests.cs | 91 +++++++++++++++++++ .../WpfDesign.XamlDom/Project/XamlObject.cs | 34 ++++++- 2 files changed, 121 insertions(+), 4 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs index cfe333f062..9a74644b5f 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs @@ -17,6 +17,9 @@ // DEALINGS IN THE SOFTWARE. using System; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; using NUnit.Framework; using System.Windows.Markup; using ICSharpCode.WpfDesign.XamlDom; @@ -118,6 +121,79 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom { TestMarkupExtension("Content=\"{t:String '" + PathWithCommasAndSpaces + "'}\""); } + + [Test] + public void TestMultiBinding() + { + string xaml = @" + + + + + + + + + +"; + + TestLoading(xaml); + + TestWindowMultiBinding((Window)XamlReader.Parse(xaml)); + + var doc = XamlParser.Parse(new StringReader(xaml)); + + TestWindowMultiBinding((Window)doc.RootInstance); + } + + + void TestWindowMultiBinding(Window w) + { + var textBox = (TextBox)w.Content; + + var expr = BindingOperations.GetMultiBindingExpression(textBox, TextBox.TextProperty); + Assert.IsNotNull(expr); + + var converter = expr.ParentMultiBinding.Converter as MyMultiConverter; + Assert.IsNotNull(converter); + + Assert.AreEqual(expr.ParentMultiBinding.Bindings.Count, 1); + } + + [Test] + public void TestPriorityBinding() + { + string xaml = @" + + + + + + + +"; + + TestLoading(xaml); + + TestWindowPriorityBinding((Window)XamlReader.Parse(xaml)); + + var doc = XamlParser.Parse(new StringReader(xaml)); + + TestWindowPriorityBinding((Window)doc.RootInstance); + } + + + void TestWindowPriorityBinding(Window w) + { + var textBox = (TextBox)w.Content; + + var expr = BindingOperations.GetPriorityBindingExpression(textBox, TextBox.TextProperty); + Assert.IsNotNull(expr); + + Assert.AreEqual(expr.ParentPriorityBinding.Bindings.Count, 2); + } // [Test] // public void Test10() @@ -177,4 +253,19 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom return null; } } + + public class MyMultiConverter : IMultiValueConverter + { + #region IMultiValueConverter implementation + public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + return System.Windows.DependencyProperty.UnsetValue; + } + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotImplementedException(); + } + #endregion + + } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs index e8275a34e4..0429d5192c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs @@ -18,6 +18,7 @@ using System; using System.Collections.Generic; +using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Linq; @@ -548,11 +549,35 @@ namespace ICSharpCode.WpfDesign.XamlDom { public override object ProvideValue() { - var target = XamlObject.Instance as Binding; + var target = XamlObject.Instance as BindingBase; + Debug.Assert(target != null); //TODO: XamlObject.Clone() - var b = new Binding(); + var b = CopyBinding(target); + return b.ProvideValue(XamlObject.ServiceProvider); + } + + BindingBase CopyBinding(BindingBase target) + { + BindingBase b; + if (target != null) { + b = (BindingBase)Activator.CreateInstance(target.GetType()); + } else { + b = new Binding(); + } + foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(target)) { - if (pd.IsReadOnly) continue; + if (pd.IsReadOnly) { + if (pd.Name.Equals("Bindings", StringComparison.Ordinal)) { + var bindings = (Collection)pd.GetValue(target); + var newBindings = (Collection)pd.GetValue(b); + + foreach (var binding in bindings) { + newBindings.Add(CopyBinding(binding)); + } + } + + continue; + } try { var val1 = pd.GetValue(b); var val2 = pd.GetValue(target); @@ -560,7 +585,8 @@ namespace ICSharpCode.WpfDesign.XamlDom pd.SetValue(b, val2); } catch {} } - return b.ProvideValue(XamlObject.ServiceProvider); + + return b; } } From cfe4b3a77eebea28ecc2588d019ff841673b06d4 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Tue, 15 Jul 2014 13:21:56 +0200 Subject: [PATCH 09/23] Bugfix -> Number Editor smallest possible Value was zero! (cherry picked from commit 22a021957b4b717bf55e816061b1971c74306e65) --- .../Project/PropertyGrid/Editors/NumberEditor.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs index 555e95a33e..4f8c7bbcf6 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs @@ -94,7 +94,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors var range = Metadata.GetValueRange(PropertyNode.FirstProperty); if (range == null) { - range = new NumberRange() { Min = 0, Max = double.MaxValue }; + range = new NumberRange() { Min = double.MinValue, Max = double.MaxValue }; } if (range.Min == double.MinValue) { From 514266dfecb667a3ddd5c259ea0eef9f2b92d109 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Thu, 17 Jul 2014 22:35:12 +0200 Subject: [PATCH 10/23] fix #434: Code action in BaseMethodParameterNameMismatchIssue doesn't rename symbols --- .../Project/Src/Refactoring/EditorScript.cs | 10 ++++ .../Editor/Commands/FindReferencesCommand.cs | 50 +++++++++++-------- 2 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/EditorScript.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/EditorScript.cs index c33d1b6b7c..cb33ec2b33 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/EditorScript.cs +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/Refactoring/EditorScript.cs @@ -24,6 +24,7 @@ using System.Windows.Threading; using ICSharpCode.AvalonEdit.Editing; using ICSharpCode.AvalonEdit.Snippets; using ICSharpCode.AvalonEdit.Document; +using ICSharpCode.Core; using ICSharpCode.NRefactory; using ICSharpCode.NRefactory.CSharp; using ICSharpCode.NRefactory.CSharp.Refactoring; @@ -32,6 +33,10 @@ using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop.Dom; using ICSharpCode.SharpDevelop.Editor; +using ICSharpCode.SharpDevelop.Editor.Commands; +using ICSharpCode.SharpDevelop.Editor.Dialogs; +using ICSharpCode.SharpDevelop.Gui; +using ICSharpCode.SharpDevelop.Refactoring; using ICSharpCode.SharpDevelop.Workbench; namespace CSharpBinding.Refactoring @@ -102,6 +107,11 @@ namespace CSharpBinding.Refactoring return tcs.Task; } + public override void Rename(ISymbol symbol, string name = null) + { + RenameSymbolCommand.RunRename(symbol, name); + } + public override Task