コード例 #1
0
        public void RationalScaleTest()
        {
            RectangleF r = new RectangleF(0, 0, 10, 20);

            ScaleHelper.RationalScale(ref r, Gripper.POSITION_BOTTOM_RIGHT, new PointF(10, 20));
            Assert.AreEqual(0, r.Left);
            Assert.AreEqual(0, r.Top);
            Assert.AreEqual(10, r.Width);
            Assert.AreEqual(20, r.Height);

            r = new RectangleF(0, 0, 10, 20);
            ScaleHelper.RationalScale(ref r, Gripper.POSITION_BOTTOM_RIGHT, new PointF(30, 60));
            Assert.AreEqual(0, r.Left);
            Assert.AreEqual(0, r.Top);
            Assert.AreEqual(30, r.Width);
            Assert.AreEqual(60, r.Height);

            r = new RectangleF(0, 0, 10, 20);
            ScaleHelper.RationalScale(ref r, Gripper.POSITION_BOTTOM_RIGHT, new PointF(30, 96768));
            Assert.AreEqual(0, r.Left);
            Assert.AreEqual(0, r.Top);
            Assert.AreEqual(30, r.Width);
            Assert.AreEqual(60, r.Height);

            r = new RectangleF(0, 0, 10, 20);
            ScaleHelper.RationalScale(ref r, Gripper.POSITION_BOTTOM_CENTER, new PointF(9999, 40));
            Assert.AreEqual(0, r.Left);
            Assert.AreEqual(0, r.Top);
            Assert.AreEqual(10, r.Width);
            Assert.AreEqual(40, r.Height);

            r = new RectangleF(0, 0, 10, 20);
            ScaleHelper.RationalScale(ref r, Gripper.POSITION_BOTTOM_LEFT, new PointF(-90, 9234));
            Assert.AreEqual(-90, r.Left);
            Assert.AreEqual(0, r.Top);
            Assert.AreEqual(100, r.Width);
            Assert.AreEqual(200, r.Height);

            r = new RectangleF(0, 0, 10, 20);
            ScaleHelper.RationalScale(ref r, Gripper.POSITION_MIDDLE_RIGHT, new PointF(48, 9999));
            Assert.AreEqual(0, r.Left);
            Assert.AreEqual(0, r.Top);
            Assert.AreEqual(48, r.Width);
            Assert.AreEqual(20, r.Height);

            r = new RectangleF(0, 0, 10, 20);
            ScaleHelper.RationalScale(ref r, Gripper.POSITION_MIDDLE_RIGHT, new PointF(8, 9999));
            Assert.AreEqual(0, r.Left);
            Assert.AreEqual(0, r.Top);
            Assert.AreEqual(8, r.Width);
            Assert.AreEqual(20, r.Height);

            r = new RectangleF(0, 20, 10, 20);
            ScaleHelper.RationalScale(ref r, Gripper.POSITION_TOP_RIGHT, new PointF(20, 829634235));
            Assert.AreEqual(0, r.Left);
            Assert.AreEqual(0, r.Top);
            Assert.AreEqual(20, r.Width);
            Assert.AreEqual(40, r.Height);

            r = new RectangleF(0, 0, 10, 20);
            ScaleHelper.RationalScale(ref r, Gripper.POSITION_TOP_CENTER, new PointF(9998, -77));
            Assert.AreEqual(0, r.Left);
            Assert.AreEqual(-77, r.Top);
            Assert.AreEqual(10, r.Width);
            Assert.AreEqual(97, r.Height);

            r = new RectangleF(10, 20, 10, 20);
            ScaleHelper.RationalScale(ref r, Gripper.POSITION_TOP_LEFT, new PointF(0, 0));
            Assert.AreEqual(0, r.Left);
            Assert.AreEqual(0, r.Top);
            Assert.AreEqual(20, r.Width);
            Assert.AreEqual(40, r.Height);
        }