コード例 #1
0
        // ------------------------------
        // private
        // ------------------------------
        private Matrix CreateMatrix()
        {
            var bounds = _Bounds;
            var center = RectUtil.GetCenterF(bounds);

            var ret = default(Matrix);

            if (_isFlippedHorizontal && _isFlippedVertical)
            {
                ret = new Matrix(
                    -1, 0, 0, -1, bounds.Left * 2 + bounds.Width - 1, bounds.Top * 2 + bounds.Height - 1
                    );
                if (_angle != 0)
                {
                    ret.RotateAt(_angle, center);
                }
            }
            else if (_isFlippedHorizontal)
            {
                ret = new Matrix(-1, 0, 0, 1, bounds.Left * 2 + bounds.Width - 1, 0);
                if (_angle != 0)
                {
                    ret.RotateAt(_angle, center);
                }
            }
            else if (_isFlippedVertical)
            {
                ret = new Matrix(1, 0, 0, -1, 0, bounds.Top * 2 + bounds.Height - 1);
                if (_angle != 0)
                {
                    ret.RotateAt(_angle, center);
                }
            }
            else if (_angle != 0)
            {
                ret = new Matrix();
                ret.RotateAt(_angle, center);
            }
            return(ret);
        }
コード例 #2
0
        private Rectangle GetBoundsForPathCreation()
        {
            var bounds = _Bounds;

            var ret = Rectangle.Empty;

            if (_angle == 0)
            {
                ret = new Rectangle(bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1);
            }
            else if (_angle == 90)
            {
                var center = RectUtil.GetCenterF(bounds);
                ret = new Rectangle(
                    (int)Math.Round(center.X - (float)bounds.Height / 2),
                    (int)Math.Round(center.Y - (float)bounds.Width / 2) + 1,
                    bounds.Height - 1,
                    bounds.Width - 1
                    );
            }
            else if (_angle == 180)
            {
                ret = new Rectangle(bounds.Left + 1, bounds.Top + 1, bounds.Width - 1, bounds.Height - 1);
            }
            else if (_angle == 270)
            {
                var center = RectUtil.GetCenterF(bounds);
                ret = new Rectangle(
                    (int)Math.Round(center.X - (float)bounds.Height / 2) + 1,
                    (int)Math.Round(center.Y - (float)bounds.Width / 2),
                    bounds.Height - 1,
                    bounds.Width - 1
                    );
            }

            return(ret);
        }
コード例 #3
0
        // === AbstractPathBoundingNode ==========
        public void Rotate(float rot)
        {
            Contract.Requires(rot == 90 || rot == 180 || rot == 270);

            if (_isFlippedHorizontal ^ _isFlippedVertical)
            {
                if (rot == 90)
                {
                    rot = 270;
                }
                else if (rot == 270)
                {
                    rot = 90;
                }
            }

            _angle = (_angle + rot) % 360;

            if (rot == 90 || rot == 270)
            {
                var bounds = _Bounds;
                var center = RectUtil.GetCenterF(bounds);
                _Bounds = new Rectangle(
                    (int)Math.Round(center.X - (float)bounds.Height / 2),
                    (int)Math.Round(center.Y - (float)bounds.Width / 2),
                    bounds.Height,
                    bounds.Width
                    );
            }
            else if (rot == 180)
            {
                _ResourceCache.DisposeResource(PathResourceKey);
                _ResourceCache.DisposeResource(DrawPathResourceKey);
                _ResourceCache.DisposeResource(OutlinePathResourceKey);
                InvalidatePaint();
            }
        }