Browse Source

Merge pull request #619 from jogibear9988/master

Allow WrapItemsNewContainer to be used from Outside
pull/622/head
Siegfried Pammer 12 years ago
parent
commit
485b758ead
  1. 33
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs

33
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs

@ -236,7 +236,7 @@ namespace ICSharpCode.WpfDesign.Designer
return itemPos; return itemPos;
} }
public static void WrapItemsNewContainer(IEnumerable<DesignItem> items, Type containerType) public static Tuple<DesignItem, Rect> WrapItemsNewContainer(IEnumerable<DesignItem> items, Type containerType, bool doInsert = true)
{ {
var collection = items; var collection = items;
@ -245,12 +245,12 @@ namespace ICSharpCode.WpfDesign.Designer
var container = collection.First().Parent; var container = collection.First().Parent;
if (collection.Any(x => x.Parent != container)) if (collection.Any(x => x.Parent != container))
return; return null;
//Change Code to use the Placment Operation! //Change Code to use the Placment Operation!
var placement = container.Extensions.OfType<IPlacementBehavior>().FirstOrDefault(); var placement = container.Extensions.OfType<IPlacementBehavior>().FirstOrDefault();
if (placement == null) if (placement == null)
return; return null;
var operation = PlacementOperation.Start(items.ToList(), PlacementType.Move); var operation = PlacementOperation.Start(items.ToList(), PlacementType.Move);
@ -325,19 +325,24 @@ namespace ICSharpCode.WpfDesign.Designer
newPanel.ContentProperty.SetValue(item.DesignItem); newPanel.ContentProperty.SetValue(item.DesignItem);
} }
} }
PlacementOperation operation2 = PlacementOperation.TryStartInsertNewComponents( if (doInsert)
container, {
new[] { newPanel }, PlacementOperation operation2 = PlacementOperation.TryStartInsertNewComponents(
new[] { new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round() }, container,
PlacementType.AddItem new[] {newPanel},
); new[] {new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round()},
PlacementType.AddItem
operation2.Commit(); );
operation2.Commit();
_context.Services.Selection.SetSelectedComponents(new[] {newPanel});
}
operation.Commit(); operation.Commit();
_context.Services.Selection.SetSelectedComponents(new []{ newPanel }); return new Tuple<DesignItem, Rect>(newPanel, new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round());
} }
public static void ArrangeItems(IEnumerable<DesignItem> items, ArrangeDirection arrangeDirection) public static void ArrangeItems(IEnumerable<DesignItem> items, ArrangeDirection arrangeDirection)

Loading…
Cancel
Save