Пример #1
0
 public ViewReckoner(
     int cx1, int cx2,
     int cy1, int cy2,
     double vx1, double vx2,
     double vy1, double vy2)
 {
     _x = new CoordReckoner(cx1, cx2, vx1, vx2);
     _y = new CoordReckoner(cy1, cy2, vy1, vy2);
 }
Пример #2
0
        public static bool Test()
        {
            CoordReckoner cr = new CoordReckoner(100, 200, 400.0, 600.0);

            Logger.Assert(cr.C1 == 100, "1. C1 invalid");
            Logger.Assert(cr.C2 == 200, "2. C2 invalid");
            Logger.Assert(cr.V1 == 400.0, "3. V1 invalid");
            Logger.Assert(cr.V2 == 600.0, "4. V2 invalid");
            Logger.Assert(cr.Scale == 2.0, "5. Scale invalid");

            Logger.Assert(cr.VToC(400.0) == 100, "6. VToC(400.0) failed");
            Logger.Assert(cr.VToC(600.0) == 200, "7. VToC(600.0) failed");
            Logger.Assert(cr.VToC(500.0) == 150, "8. VToC(500.0) failed");
            Logger.Assert(cr.CToV(100) == 400.0, "9. CToV(100) failed");
            Logger.Assert(cr.CToV(200) == 600.0, "10. CToV(200) failed");
            Logger.Assert(cr.CToV(150) == 500.0, "11. CToV(150) failed");

            Logger.Assert(cr.VLenToC(20.0) == 10, "12. VLenToC(20.0)");
            Logger.Assert(cr.CLenToV(40) == 80.0, "13. CLenToV(40)");

            Logger.Assert(cr.VSize == 200.0, "14. VSize failed");
            Logger.Assert(cr.CSize == 100, "15. CSize failed");

            cr.Zoom(450.0, 550.0);
            Logger.Assert(cr.VSize == 100.0, "16. VSize failed");
            Logger.Assert(cr.CSize == 100, "17. CSize failed");
            Logger.Assert(cr.C1 == 100, "18. C1 invalid");
            Logger.Assert(cr.C2 == 200, "19. C2 invalid");
            Logger.Assert(cr.V1 == 450.0, "20. V1 invalid");
            Logger.Assert(cr.V2 == 550.0, "21. V2 invalid");
            Logger.Assert(cr.Scale == 1.0, "22. Scale invalid");

            Logger.Assert(cr.VToC(450.0) == 100, "23. VToC(450.0) failed");
            Logger.Assert(cr.VToC(550.0) == 200, "24. VToC(550.0) failed");
            Logger.Assert(cr.VToC(500.0) == 150, "25. VToC(500.0) failed");
            Logger.Assert(cr.CToV(100) == 450.0, "26. CToV(100) failed");
            Logger.Assert(cr.CToV(200) == 550.0, "27. CToV(200) failed");
            Logger.Assert(cr.CToV(150) == 500.0, "28. CToV(150) failed");

            CoordReckoner cr1 = new CoordReckoner(100, 200, 20.0, 40.0);

            Logger.Assert(cr1.VSize == 20.0, "29. VSize failed");
            Logger.Assert(cr1.CSize == 100, "30. CSize failed");
            cr1.ZoomAt(25.0, 0.5);
            Logger.Assert(cr1.VSize == 10.0, "40. VSize failed");
            Logger.Assert(cr1.CSize == 100, "41. CSize failed");
            Logger.Assert(cr1.C1 == 100, "42. C1 invalid");
            Logger.Assert(cr1.C2 == 200, "43. C2 invalid");
            Logger.Assert(cr1.V1 == 22.5, "44. V1 invalid");
            Logger.Assert(cr1.V2 == 32.5, "45. V2 invalid");
            Logger.Assert(cr1.Scale == 0.1, "46. Scale invalid");

            // y axis, inversion
            CoordReckoner cr2 = new CoordReckoner(200, 100, 20.0, 40.0);

            Logger.Assert(cr2.VToC(20.0) == 200, "47. VToC(450.0) failed");
            Logger.Assert(cr2.VToC(40.0) == 100, "48. VToC(550.0) failed");
            Logger.Assert(cr2.VToC(30.0) == 150, "49. VToC(500.0) failed");
            Logger.Assert(cr2.CToV(200) == 20.0, "50. CToV(100) failed");
            Logger.Assert(cr2.CToV(100) == 40.0, "51. CToV(200) failed");
            Logger.Assert(cr2.CToV(150) == 30.0, "52. CToV(150) failed");

            return(false);
        }