public override void InitializeResize(System.Collections.Generic.IEnumerable<IDiagramItem> newSelectedItems, double adornerAngle, Rect adornerBounds, ResizeDirection resizingDirection, Point startPoint) { this.mainContainer = newSelectedItems.FirstOrDefault() as MainContainerShapeBase; if (this.mainContainer != null) this.mainContainer.UpdateMinBounds(); base.InitializeResize(newSelectedItems, adornerAngle, adornerBounds, resizingDirection, startPoint); if (this.mainContainer != null) { var firstChild = this.mainContainer.OrderedChildren.FirstOrDefault(); var lastChild = this.mainContainer.OrderedChildren.LastOrDefault(); if (firstChild != null && lastChild != null) { this.restrictResize = true; this.startBounds = this.mainContainer.ContentBounds; if (this.mainContainer.ChildrenPositioning == System.Windows.Controls.Orientation.Vertical) { this.isFirstChildResize = resizingDirection == ResizeDirection.NorthEastSouthWest || resizingDirection == ResizeDirection.NorthWestSouthEast; this.min = firstChild.MinBoundsWithChildren != Rect.Empty ? firstChild.MinBoundsWithChildren.Top : firstChild.Bounds.Bottom - CustomResizingService.MinShapeHeight; this.max = lastChild.MinBoundsWithChildren != Rect.Empty ? lastChild.MinBoundsWithChildren.Bottom : lastChild.Bounds.Top + CustomResizingService.MinShapeHeight; } else { this.isFirstChildResize = resizingDirection == ResizeDirection.SouthWestNorthEast || resizingDirection == ResizeDirection.NorthWestSouthEast; this.min = firstChild.MinBoundsWithChildren != Rect.Empty ? firstChild.MinBoundsWithChildren.Left : firstChild.Bounds.Right - CustomResizingService.MinShapeWidth; this.max = lastChild.MinBoundsWithChildren != Rect.Empty ? lastChild.MinBoundsWithChildren.Right : lastChild.Bounds.Left + CustomResizingService.MinShapeWidth; } this.CreateResizeCommand(); } else { this.restrictResize = false; } } //this.isFirstResize = true; }
private void RemoveContainer(MainContainerShapeBase container, RadDiagramShapeBase itemToRemove) { if (container == null || itemToRemove == null) return; CompositeCommand command = new CompositeCommand("Remove horizontal container"); if (container.IsCollapsed) { command.AddCommand(new UndoableDelegateCommand("Update container", new Action<object>((o) => { container.IsCollapsed = false; }), new Action<object>((o) => { container.IsCollapsed = true; }))); } command.AddCommand(this.CreateRemoveShapeCommand(itemToRemove)); if (container.IsCollapsed) { command.AddCommand(new UndoableDelegateCommand("Update container", new Action<object>((o) => { }), new Action<object>((o) => { }))); } this.Diagram.UndoRedoService.ExecuteCommand(command); }
private void UpdateHandlers(MainContainerShapeBase mainContainer) { if (mainContainer != null) { var offset = this.ServiceLocator.GetService<IAdornerService>().InflatedAdornerBounds.TopLeft(); if (this.manipulationAdorner != null && !offset.X.IsNanOrInfinity() && !offset.Y.IsNanOrInfinity()) { this.manipulationAdorner.UpdateAdditionalHandlers(mainContainer.OrderedChildren, offset, !mainContainer.IsCollapsed, mainContainer.ChildrenPositioning); } } }
private void AddContainer(MainContainerShapeBase container, IShape itemToAdd) { if (container == null || itemToAdd == null) return; CompositeCommand command = new CompositeCommand("Add new container"); if (container.IsCollapsed) { command.AddCommand(new UndoableDelegateCommand("Update container", new Action<object>((o) => { container.IsCollapsed = false; }), new Action<object>((o) => { container.IsCollapsed = true; }))); } command.AddCommand(new UndoableDelegateCommand("Add Container", new Action<object>((o) => { container.Items.Add(itemToAdd); container.IsCollapsed = false; }), new Action<object>((o) => { this.Diagram.RemoveShape(itemToAdd); container.IsCollapsed = false; }))); this.Diagram.UndoRedoService.ExecuteCommand(command); }