Ejemplo n.º 1
0
        /// <summary>
        /// Sets all provided transformation values and updates the transformation matrix. You can leave out
        /// multiple parameters by setting them to null.
        /// </summary>
        /// <param name="x">Translation in x direction.</param>
        /// <param name="y">Translation in y direction.</param>
        /// <param name="rotation">Roation in degrees counterclockwise.</param>
        /// <param name="shearX">Shear in x-direction.</param>
        /// <param name="scaleX">X scale value.</param>
        /// <param name="scaleY">Y scale value.</param>
        /// <param name="eventFiring">Designates whether or not the change event should be fired if the value has changed.</param>
        public void SetTranslationRotationShearxScale(double?x, double?y, double?rotation, double?shearX, double?scaleX, double?scaleY, Main.EventFiring eventFiring)
        {
            if (null != x)
            {
                _x = (double)x;
            }
            if (null != y)
            {
                _y = (double)y;
            }
            if (null != rotation)
            {
                _rotationDeg = (double)rotation;
            }
            if (null != shearX)
            {
                _shearX = (double)shearX;
            }
            if (null != scaleX)
            {
                _scaleX = (double)scaleX;
            }
            if (null != scaleY)
            {
                _scaleY = (double)scaleY;
            }

            _transformation.SetTranslationRotationShearxScale(_x, _y, _rotationDeg, _shearX, _scaleX, _scaleY);

            if (eventFiring == Main.EventFiring.Enabled)
            {
                EhSelfChanged(EventArgs.Empty);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the absolute enclosing rectangle, taking into account ScaleX, ScaleY, Rotation and Shear (SSRS).
        /// </summary>
        /// <returns>The enclosing rectangle in absolute values.</returns>
        public RectangleD2D GetAbsoluteEnclosingRectangle()
        {
            var m = new MatrixD2D();

            m.SetTranslationRotationShearxScale(AbsolutePivotPositionX, AbsolutePivotPositionY, -Rotation, ShearX, ScaleX, ScaleY);
            m.TranslatePrepend(AbsoluteVectorPivotToLeftUpper.X, AbsoluteVectorPivotToLeftUpper.Y);

            var s  = AbsoluteSize;
            var p1 = m.TransformPoint(new PointD2D(0, 0));
            var p2 = m.TransformPoint(new PointD2D(s.X, 0));
            var p3 = m.TransformPoint(new PointD2D(0, s.Y));
            var p4 = m.TransformPoint(new PointD2D(s.X, s.Y));

            var r = new RectangleD2D(p1, PointD2D.Empty);

            r.ExpandToInclude(p2);
            r.ExpandToInclude(p3);
            r.ExpandToInclude(p4);
            return(r);
        }