Exemple #1
0
        public void GetDefaultPageSizeMetric()
        {
            int         pageWidth, pageHeight, pageMargins;
            bool        landscape;
            CultureInfo currentCulture;

            currentCulture = Thread.CurrentThread.CurrentCulture;
            try {
                CultureInfo.CurrentCulture.ClearCachedData();
                Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("de-DE");

                Assert.IsTrue(RegionInfo.CurrentRegion.IsMetric);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 350, 210), 1.0F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(1169, pageWidth);
                Assert.AreEqual(1654, pageHeight);
                Assert.AreEqual(28, pageMargins);
                Assert.IsTrue(landscape);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 290, 210), 1.0F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(827, pageWidth);
                Assert.AreEqual(1169, pageHeight);
                Assert.AreEqual(0, pageMargins);
                Assert.IsTrue(landscape);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 190, 270), 1.0F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(827, pageWidth);
                Assert.AreEqual(1169, pageHeight);
                Assert.AreEqual(28, pageMargins);
                Assert.IsFalse(landscape);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 1350, 2210), 1.0F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(827, pageWidth);
                Assert.AreEqual(1169, pageHeight);
                Assert.AreEqual(0, pageMargins);
                Assert.IsFalse(landscape);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 210, 296), 0.5F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(1654, pageWidth);
                Assert.AreEqual(2339, pageHeight);
                Assert.AreEqual(0, pageMargins);
                Assert.IsFalse(landscape);
            }
            finally {
                CultureInfo.CurrentCulture.ClearCachedData();
                Thread.CurrentThread.CurrentCulture = currentCulture;
            }
        }
Exemple #2
0
        public void GetDefaultPageSizeEnglish()
        {
            int         pageWidth, pageHeight, pageMargins;
            bool        landscape;
            CultureInfo currentCulture;

            currentCulture = Thread.CurrentThread.CurrentCulture;
            try {
                CultureInfo.CurrentCulture.ClearCachedData();
                Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US");
                Assert.IsFalse(RegionInfo.CurrentRegion.IsMetric);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 350, 210), 1.0F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(850, pageWidth);
                Assert.AreEqual(1400, pageHeight);
                Assert.AreEqual(0, pageMargins);
                Assert.IsTrue(landscape);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 260, 190), 1.0F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(850, pageWidth);
                Assert.AreEqual(1100, pageHeight);
                Assert.AreEqual(25, pageMargins);
                Assert.IsTrue(landscape);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 200, 270), 1.0F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(850, pageWidth);
                Assert.AreEqual(1100, pageHeight);
                Assert.AreEqual(0, pageMargins);
                Assert.IsFalse(landscape);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 1350, 2210), 1.0F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(850, pageWidth);
                Assert.AreEqual(1100, pageHeight);
                Assert.AreEqual(0, pageMargins);
                Assert.IsFalse(landscape);

                MapUtil.GetDefaultPageSize(new RectangleF(30, 50, 125, 200), 0.5F, out pageWidth, out pageHeight, out pageMargins, out landscape);
                Assert.AreEqual(1100, pageWidth);
                Assert.AreEqual(1700, pageHeight);
                Assert.AreEqual(25, pageMargins);
                Assert.IsFalse(landscape);
            }
            finally {
                Thread.CurrentThread.CurrentCulture = currentCulture;
            }
        }