Browse Source

Possibility to disable Snaplines in a Derived Extension via returning CanPlace = false

pull/604/head
jkuehner 12 years ago
parent
commit
cf41d83966
  1. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
  2. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
  3. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs
  4. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs

@ -50,7 +50,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
ExtendedItem.AddBehavior(typeof(IPlacementBehavior), this); ExtendedItem.AddBehavior(typeof(IPlacementBehavior), this);
} }
public virtual bool CanPlace(ICollection<DesignItem> childItems, PlacementType type, PlacementAlignment position) public virtual bool CanPlace(IEnumerable<DesignItem> childItems, PlacementType type, PlacementAlignment position)
{ {
return true; 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) public virtual void SetPosition(PlacementInformation info)
{ {
if (info.Operation.Type != PlacementType.Move) if (info.Operation.Type != PlacementType.Move)

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs

@ -225,6 +225,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
AddLines(containerRect, 0, 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 */ foreach (var item in AllDesignItems() /* ExtendedItem.ContentProperty.CollectionElements */
.Except(operation.PlacedItems.Select(f => f.Item)) .Except(operation.PlacedItems.Select(f => f.Item))
.Where(x=> x.View != null && !GetDisableSnaplines(x.View))) { .Where(x=> x.View != null && !GetDisableSnaplines(x.View))) {

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs

@ -38,12 +38,9 @@ namespace ICSharpCode.WpfDesign.Designer
_rootItem.AddBehavior(typeof(IRootPlacementBehavior),this); _rootItem.AddBehavior(typeof(IRootPlacementBehavior),this);
} }
public bool CanPlace(System.Collections.Generic.ICollection<DesignItem> childItems, PlacementType type, PlacementAlignment position) public bool CanPlace(IEnumerable<DesignItem> childItems, PlacementType type, PlacementAlignment position)
{ {
return type == PlacementType.Resize && return type == PlacementType.Resize && (position == PlacementAlignment.Right || position == PlacementAlignment.BottomRight || position == PlacementAlignment.Bottom);
(position == PlacementAlignment.Right
|| position == PlacementAlignment.BottomRight
|| position == PlacementAlignment.Bottom);
} }
public void BeginPlacement(PlacementOperation operation) public void BeginPlacement(PlacementOperation operation)

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.WpfDesign
/// <summary> /// <summary>
/// Gets if the child element can be resized. /// Gets if the child element can be resized.
/// </summary> /// </summary>
bool CanPlace(ICollection<DesignItem> childItems, PlacementType type, PlacementAlignment position); bool CanPlace(IEnumerable<DesignItem> childItems, PlacementType type, PlacementAlignment position);
/// <summary> /// <summary>
/// Starts placement mode for this container. /// Starts placement mode for this container.

Loading…
Cancel
Save