From cf41d839662870ecea4dc7487602f84e61f5b5e8 Mon Sep 17 00:00:00 2001 From: jkuehner Date: Tue, 2 Dec 2014 11:18:21 +0100 Subject: [PATCH] Possibility to disable Snaplines in a Derived Extension via returning CanPlace = false --- .../Project/Extensions/DefaultPlacementBehavior.cs | 7 ++++++- .../Project/Extensions/SnaplinePlacementBehavior.cs | 5 ++++- .../WpfDesign.Designer/Project/RootItemBehavior.cs | 9 +++------ .../WpfDesign/WpfDesign/Project/PlacementBehavior.cs | 2 +- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs index 3100b99a8e..26e7d9c46e 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs @@ -50,7 +50,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions ExtendedItem.AddBehavior(typeof(IPlacementBehavior), this); } - public virtual bool CanPlace(ICollection childItems, PlacementType type, PlacementAlignment position) + public virtual bool CanPlace(IEnumerable childItems, PlacementType type, PlacementAlignment position) { return true; } @@ -80,6 +80,11 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions { } + public virtual bool CanPlaceItem(PlacementInformation info) + { + return true; + } + public virtual void SetPosition(PlacementInformation info) { if (info.Operation.Type != PlacementType.Move) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs index d9e6e8552a..d2d187561e 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs @@ -224,7 +224,10 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions AddLines(containerRect, -Margin, false); AddLines(containerRect, 0, false); - + + if (!CanPlace(operation.PlacedItems.Select(x => x.Item), operation.Type, PlacementAlignment.Center)) + return; + foreach (var item in AllDesignItems() /* ExtendedItem.ContentProperty.CollectionElements */ .Except(operation.PlacedItems.Select(f => f.Item)) .Where(x=> x.View != null && !GetDisableSnaplines(x.View))) { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs index 7d96801a4f..4b436dba98 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs @@ -37,13 +37,10 @@ namespace ICSharpCode.WpfDesign.Designer this._rootItem=context.RootItem; _rootItem.AddBehavior(typeof(IRootPlacementBehavior),this); } - - public bool CanPlace(System.Collections.Generic.ICollection childItems, PlacementType type, PlacementAlignment position) + + public bool CanPlace(IEnumerable childItems, PlacementType type, PlacementAlignment position) { - return type == PlacementType.Resize && - (position == PlacementAlignment.Right - || position == PlacementAlignment.BottomRight - || position == PlacementAlignment.Bottom); + return type == PlacementType.Resize && (position == PlacementAlignment.Right || position == PlacementAlignment.BottomRight || position == PlacementAlignment.Bottom); } public void BeginPlacement(PlacementOperation operation) diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs index c4b393519f..f34341e7bb 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs @@ -31,7 +31,7 @@ namespace ICSharpCode.WpfDesign /// /// Gets if the child element can be resized. /// - bool CanPlace(ICollection childItems, PlacementType type, PlacementAlignment position); + bool CanPlace(IEnumerable childItems, PlacementType type, PlacementAlignment position); /// /// Starts placement mode for this container.