public virtual void SetPosition(PlacementInformation info) { if (info.Operation.Type != PlacementType.Move) { ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height); } }
public virtual void SetPosition(PlacementInformation info) { if (info.Operation.Type != PlacementType.Move && info.Operation.Type != PlacementType.MovePoint && info.Operation.Type != PlacementType.MoveAndIgnoreOtherContainers) { ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height); } //if (info.Operation.Type == PlacementType.MovePoint) // ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height); }
void drag_Changed(DragListener drag) { double dx = 0; double dy = 0; var alignment = (drag.Target as ResizeThumb).Alignment; if (alignment.Horizontal == HorizontalAlignment.Left) { dx = -drag.Delta.X; } if (alignment.Horizontal == HorizontalAlignment.Right) { dx = drag.Delta.X; } if (alignment.Vertical == VerticalAlignment.Top) { dy = -drag.Delta.Y; } if (alignment.Vertical == VerticalAlignment.Bottom) { dy = drag.Delta.Y; } var newWidth = Math.Max(0, oldSize.Width + dx); var newHeight = Math.Max(0, oldSize.Height + dy); ModelTools.Resize(ExtendedItem, newWidth, newHeight); if (operation != null) { var info = operation.PlacedItems[0]; var result = info.OriginalBounds; if (alignment.Horizontal == HorizontalAlignment.Left) { result.X = Math.Min(result.Right, result.X - dx); } if (alignment.Vertical == VerticalAlignment.Top) { result.Y = Math.Min(result.Bottom, result.Y - dy); } result.Width = newWidth; result.Height = newHeight; info.Bounds = result.Round(); info.ResizeThumbAlignment = alignment; operation.CurrentContainerBehavior.BeforeSetPosition(operation); operation.CurrentContainerBehavior.SetPosition(info); } }
public virtual void SetPosition(PlacementInformation info) { ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height); }
void drag_Changed(DragListener drag) { double dx = 0; double dy = 0; var alignment = (drag.Target as DesignerThumb).Alignment; var delta = drag.Delta; if (alignment.Horizontal == HorizontalAlignment.Left) { dx = -delta.X; } if (alignment.Horizontal == HorizontalAlignment.Right) { dx = delta.X; } if (alignment.Vertical == VerticalAlignment.Top) { dy = -delta.Y; } if (alignment.Vertical == VerticalAlignment.Bottom) { dy = delta.Y; } if ((Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.RightCtrl)) && alignment.Horizontal != HorizontalAlignment.Center && alignment.Vertical != VerticalAlignment.Center) { if (dx > dy) { dx = dy; } else { dy = dx; } } var newWidth = Math.Max(0, oldSize.Width + dx); var newHeight = Math.Max(0, oldSize.Height + dy); if (operation.CurrentContainerBehavior is GridPlacementSupport) { var hor = (HorizontalAlignment)this.ExtendedItem.Properties[FrameworkElement.HorizontalAlignmentProperty].ValueOnInstance; var ver = (VerticalAlignment)this.ExtendedItem.Properties[FrameworkElement.VerticalAlignmentProperty].ValueOnInstance; if (hor == HorizontalAlignment.Stretch) { this.ExtendedItem.Properties[FrameworkElement.WidthProperty].Reset(); } else { this.ExtendedItem.Properties.GetProperty(FrameworkElement.WidthProperty).SetValue(newWidth); } if (ver == VerticalAlignment.Stretch) { this.ExtendedItem.Properties[FrameworkElement.HeightProperty].Reset(); } else { this.ExtendedItem.Properties.GetProperty(FrameworkElement.HeightProperty).SetValue(newHeight); } } else { ModelTools.Resize(ExtendedItem, newWidth, newHeight); } if (operation != null) { var info = operation.PlacedItems[0]; var result = info.OriginalBounds; if (alignment.Horizontal == HorizontalAlignment.Left) { result.X = Math.Min(result.Right, result.X - dx); } if (alignment.Vertical == VerticalAlignment.Top) { result.Y = Math.Min(result.Bottom, result.Y - dy); } result.Width = newWidth; result.Height = newHeight; info.Bounds = result.Round(); info.ResizeThumbAlignment = alignment; operation.CurrentContainerBehavior.BeforeSetPosition(operation); operation.CurrentContainerBehavior.SetPosition(info); } }