Пример #1
0
        PointApplyResult _applyCurrentPoint(Point p, ShapeUtils.RectSide side)
        {
            var res = PointApplyResult.None;

            double dx = p.X - CurrentPoint.X;
            double dy = p.Y - CurrentPoint.Y;

            if (activeMarker == null)
            {
                HandleMove(dx, dy);
                if (dx != 0.0 || dy != 0.0)
                {
                    res = PointApplyResult.Move;
                }
            }
            else
            {
                HandleResize(dx, dy, side);
                if (dx != 0.0 || dy != 0.0)
                {
                    res = PointApplyResult.Resize;
                }
            }
            SetBounds();
            CurrentPoint.X = p.X;
            CurrentPoint.Y = p.Y;

            return(res);
        }
Пример #2
0
        private void HandleResize(double deltaX, double deltaY, ShapeUtils.RectSide side)
        {
            var bounds = _bounds;

            try
            {
                switch (side)
                {
                case ShapeUtils.RectSide.TopLeft:
                    bounds.X      += deltaX;
                    bounds.Y      += deltaY;
                    bounds.Width  -= deltaX;
                    bounds.Height -= deltaY;
                    break;

                case ShapeUtils.RectSide.TopRight:
                    bounds.Width += deltaX;

                    bounds.Y      += deltaY;
                    bounds.Height -= deltaY;
                    break;

                case ShapeUtils.RectSide.BottomLeft:
                    bounds.X     += deltaX;
                    bounds.Width -= deltaX;

                    bounds.Height += deltaY;
                    break;

                case ShapeUtils.RectSide.BottomRight:
                    bounds.Width  += deltaX;
                    bounds.Height += deltaY;
                    break;

                case ShapeUtils.RectSide.TwoSided:
                    double cx = (bounds.Left + bounds.Right) / 2;
                    double cy = (bounds.Top + bounds.Bottom) / 2;
                    bounds.Width  += deltaX / 2;
                    bounds.Height += deltaY / 2;
                    bounds.X       = cx - bounds.Width / 2;
                    bounds.Y       = cy - bounds.Height / 2;
                    break;
                }
            }
            catch (Exception)
            {
            }

            if (bounds.Width > MIN_SIZE && bounds.Height > MIN_SIZE)
            {
                _bounds = bounds;
            }
        }
Пример #3
0
        private void HandleResize(double deltaX, double deltaY, ShapeUtils.RectSide side)
        {
            Rect bounds       = GetShapeBounds();
            Rect boundsBefore = bounds;

            try
            {
                switch (side)
                {
                case ShapeUtils.RectSide.TopLeft:
                    bounds.X      += deltaX;
                    bounds.Y      += deltaY;
                    bounds.Width  -= deltaX;
                    bounds.Height -= deltaY;
                    break;

                case ShapeUtils.RectSide.TopRight:
                    bounds.Width += deltaX;

                    bounds.Y      += deltaY;
                    bounds.Height -= deltaY;
                    break;

                case ShapeUtils.RectSide.BottomLeft:
                    bounds.X     += deltaX;
                    bounds.Width -= deltaX;

                    bounds.Height += deltaY;
                    break;

                case ShapeUtils.RectSide.BottomRight:
                    bounds.Width  += deltaX;
                    bounds.Height += deltaY;
                    break;

                case ShapeUtils.RectSide.TwoSided:
                    break;
                }
            }
            catch (Exception)
            {
            }

            if (bounds.Width > MIN_SIZE && bounds.Height > MIN_SIZE)
            {
                var manipOrg = _textEnterUC.RenderTransform.Transform(
                    new Point(0, 0)
                    );

                double xScale     = bounds.Width / boundsBefore.Width;
                double yScale     = bounds.Height / boundsBefore.Height;
                double scaleCoeff = Math.Max(xScale, yScale);
                var    scale      = new Vector(yScale,
                                               yScale);

                var translate = new Vector(bounds.X - boundsBefore.X,
                                           bounds.Y - boundsBefore.Y);

                ShapeUtils.ApplyTransform(_textEnterUC,
                                          new Vector(manipOrg.X, manipOrg.Y),
                                          translate,
                                          0,
                                          scale);

                SetBounds();
            }
        }