ICSharpCode.WpfDesign.Designer.Services.CreateComponentTool.AddItemWithCustomSize C# (CSharp) Method

AddItemWithCustomSize() static private method

static private AddItemWithCustomSize ( DesignItem container, DesignItem createdItem, Point position, Size size ) : bool
container DesignItem
createdItem DesignItem
position Point
size System.Windows.Size
return bool
        internal static bool AddItemWithCustomSize(DesignItem container, DesignItem createdItem, Point position, Size size)
        {
            PlacementOperation operation = PlacementOperation.TryStartInsertNewComponents(
                container,
                new DesignItem[] { createdItem },
                new Rect[] { new Rect(position, size).Round() },
                PlacementType.AddItem
            );
            if (operation != null) {
                container.Services.Selection.SetSelectedComponents(new DesignItem[] { createdItem });
                operation.Commit();
                return true;
            } else {
                return false;
            }
        }