protected override void OnResizeStart(UIElement element, ResizableBehavior resizableBehavior) { base.OnResizeStart(element, resizableBehavior); var snapSide = ArtboardSnapEngineUtils.GetResizeSide(resizableBehavior.ResizeInfo.HandleKind); _snapEngineContext = Canvas.Artboard?.SnapEngine?.CreateContext(new ArtboardSnapEngineContextParameters(element, snapSide)); }
public override IEnumerable <ArtboardSnapSourcePrimitive> GetSnapPrimitives(ArtboardSnapEngineContextParameters parameters) { var side = parameters.Side; var hasLeft = ArtboardSnapEngineUtils.HasLeft(side); var hasTop = ArtboardSnapEngineUtils.HasTop(side); var hasRight = ArtboardSnapEngineUtils.HasRight(side); var hasBottom = ArtboardSnapEngineUtils.HasBottom(side); if (hasTop && hasLeft) { yield return(_topLeft); } if (hasTop && hasRight) { yield return(_topRight); } if (hasBottom && hasRight) { yield return(_bottomRight); } if (hasBottom && hasLeft) { yield return(_bottomLeft); } if (hasLeft) { yield return(_left); } if (hasTop) { yield return(_top); } if (hasRight) { yield return(_right); } if (hasBottom) { yield return(_bottom); } }
public override void SetBoundingBox(UIElement element, Rect rect) { if (_snapEngineContext != null) { rect = ArtboardSnapEngineUtils.CalcResizeRect(rect, _snapEngineContext.Engine.Snap(new ArtboardSnapParameters(rect, _snapEngineContext)).SnapRect, _snapEngineContext.Parameters.Side); } SetPosition(element, rect.TopLeft); if (element is FrameworkElement frameworkElement) { frameworkElement.Width = rect.Width; frameworkElement.Height = rect.Height; } Canvas.ArrangeChild(element, true); }