コード例 #1
0
            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));
            }
コード例 #2
0
ファイル: ArtboardSnapRectSource.cs プロジェクト: Egaros/lib
        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);
            }
        }
コード例 #3
0
            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);
            }