public void PrintBitmapBaseMap()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\Lincoln Park.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();

            coursePrintSettings.CropLargePrintArea = true;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id <Course>[] { CourseId(1) };
            CoursePrintingTest("courseprinting\\bitmapbase", coursePrintSettings, new CourseAppearance());
        }
        public void PrintAreasAndPageSizes()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\Lincoln Park PrintAreas 2.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();

            coursePrintSettings.CropLargePrintArea = false;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id <Course>[] { CourseId(0), CourseId(1), CourseId(2), CourseId(3), CourseId(4) };
            CoursePrintingTest("courseprinting\\areas", coursePrintSettings, new CourseAppearance());
        }
        public void PrintTemplatedBaseMap()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\Template.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();

            coursePrintSettings.CropLargePrintArea = true;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id <Course>[] { CourseId(1) };
            CoursePrintingTest("courseprinting\\templatebase", coursePrintSettings, new CourseAppearance(), 200);
        }
        public void PrintCourses4()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\marymoor_graphics.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();

            coursePrintSettings.CropLargePrintArea = true;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id <Course>[] { CourseId(2) };
            CoursePrintingTest("courseprinting\\test4", coursePrintSettings, new CourseAppearance());
        }
        private void CoursePrintingTest(string basename, CoursePrintSettings coursePrintSettings, CourseAppearance appearance, float dpi = 200)
        {
            GC.Collect();

            // Get the map display
            MapDisplay mapDisplay = new MapDisplay();

            mapDisplay.MapIntensity = 0.6F;
            mapDisplay.AntiAlias    = true;
            mapDisplay.SetMapFile(controller.MapType, controller.MapFileName);
            if (controller.MapType == MapType.Bitmap)
            {
                mapDisplay.Dpi = controller.MapDpi;
            }
            mapDisplay.OcadOverprintEffect = appearance.useOcadOverprint;

            // Get the pages of the printing.
            CoursePrinting coursePrinter = new CoursePrinting(controller.GetEventDB(), ui.symbolDB, controller, mapDisplay.CloneToFullIntensity(), coursePrintSettings, appearance);

            Bitmap[] bitmaps = coursePrinter.PrintBitmaps();

            // Check all the pages against the baseline.
            for (int page = 0; page < bitmaps.Length; ++page)
            {
                Bitmap bm           = bitmaps[page];
                string baseFileName = basename + "_page" + (page + 1).ToString();
                TestUtil.CheckBitmapsBase(bm, baseFileName);
                bm.Dispose();
            }

#if XPS_PRINTING
            // Only OCAD maps can be printed in XPS mode.
            if (controller.MapType == MapType.OCAD)
            {
                // Get the pages of the printing in XPS/WPF mode
                System.Windows.Media.Imaging.BitmapSource[] xpsBitmaps = coursePrinter.PrintXpsBitmaps(dpi);

                // Check all the pages against the baseline.
                for (int page = 0; page < xpsBitmaps.Length; ++page)
                {
                    var    bm           = xpsBitmaps[page];
                    string baseFileName = basename + "_xps_page" + (page + 1).ToString();
                    string newFileName  = TestUtil.GetTestFile(basename + "_xps_page" + (page + 1).ToString() + "_new");
                    WritePng(bm, newFileName);
                    Bitmap newBitmap = (Bitmap)Image.FromFile(newFileName);

                    // For some reason, the XPS anti-aliasing varies slightly. Allow pixel difference to account.
                    TestUtil.CheckBitmapsBase(newBitmap, baseFileName, 25);
                }
            }
#endif // XPS_PRINTING
        }
        public void PrintCoursesNoBlend()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\marymoor.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();

            coursePrintSettings.CropLargePrintArea = false;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            CourseAppearance appearance = new CourseAppearance();

            appearance.purpleColorBlend = false;

            coursePrintSettings.CourseIds = new Id <Course>[] { CourseId(1), CourseId(2), CourseId(0) };
            CoursePrintingTest("courseprinting\\noblend", coursePrintSettings, appearance);
        }
        public void PrintOverprint()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\Overprint test.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();

            coursePrintSettings.CropLargePrintArea = true;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id <Course>[] { CourseId(1) };

            CourseAppearance appearance = new CourseAppearance();

            appearance.purpleColorBlend = true;
            appearance.useOcadOverprint = true;

            CoursePrintingTest("courseprinting\\overprint", coursePrintSettings, appearance, 200);
        }
        public void PrintingException()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\marymoor.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();

            coursePrintSettings.CourseIds = new Id <Course>[] { CourseId(1), CourseId(2), CourseId(3) };
            coursePrintSettings.PageSettings.PrinterSettings.PrinterName = "foobar";

            bool success = controller.PrintCourses(coursePrintSettings, false);

            Assert.IsFalse(success);
            string expected =
                @"ERROR: 'Cannot print 'Marymoor WIOL 2' for the following reason:

Settings to access printer 'foobar' are not valid.'
";

            Assert.AreEqual(expected, ui.output.ToString());
        }
        public void PrintCourses2()
        {
            CourseAppearance appearance = new CourseAppearance();

            appearance.controlCircleSize = 0.75F; //smaller circles
            appearance.lineWidth         = 3F;    // thin lines
            appearance.numberHeight      = 0.5F;  // small numbers.
            appearance.numberBold        = true;  // bold numbers.
            appearance.useDefaultPurple  = false;
            appearance.autoLegGapSize    = 0.0F;
            appearance.purpleC           = 0.32F;
            appearance.purpleY           = 1.00F;
            appearance.purpleM           = 0;
            appearance.purpleK           = 0.30F;

            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\marymoor.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();

            coursePrintSettings.CropLargePrintArea = false;
            coursePrintSettings.PrintingColorModel = ColorModel.RGB;

            coursePrintSettings.CourseIds = new Id <Course>[] { CourseId(1), CourseId(2), CourseId(0) };
            CoursePrintingTest("courseprinting\\test2", coursePrintSettings, appearance);
        }
        public void PrintOverprint()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\Overprint test.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();
            coursePrintSettings.CropLargePrintArea = true;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id<Course>[] { CourseId(1) };

            CourseAppearance appearance = new CourseAppearance();
            appearance.purpleColorBlend = true;
            appearance.useOcadOverprint = true;

            CoursePrintingTest("courseprinting\\overprint", coursePrintSettings, appearance, 200);
        }
        public void PrintingException()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\marymoor.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();

            coursePrintSettings.CourseIds = new Id<Course>[] { CourseId(1), CourseId(2), CourseId(3) };
            coursePrintSettings.PageSettings.PrinterSettings.PrinterName = "foobar";

            bool success = controller.PrintCourses(coursePrintSettings, false);

            Assert.IsFalse(success);
            string expected =
            @"ERROR: 'Cannot print 'Marymoor WIOL 2' for the following reason:

            Settings to access printer 'foobar' are not valid.'
            ";

            Assert.AreEqual(expected, ui.output.ToString());
        }
        public void PrintCoursesNoBlend()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\marymoor.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();
            coursePrintSettings.CropLargePrintArea = false;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            CourseAppearance appearance = new CourseAppearance();
            appearance.purpleColorBlend = false;

            coursePrintSettings.CourseIds = new Id<Course>[] { CourseId(1), CourseId(2), CourseId(0) };
            CoursePrintingTest("courseprinting\\noblend", coursePrintSettings, appearance);
        }
        public void PrintCourses4()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\marymoor_graphics.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();
            coursePrintSettings.CropLargePrintArea = true;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id<Course>[] {CourseId(2) };
            CoursePrintingTest("courseprinting\\test4", coursePrintSettings, new CourseAppearance());
        }
        public void PrintCourses2()
        {
            CourseAppearance appearance = new CourseAppearance();
            appearance.controlCircleSize = 0.75F;  //smaller circles
            appearance.lineWidth = 3F; // thin lines
            appearance.numberHeight = 0.5F; // small numbers.
            appearance.numberBold = true; // bold numbers.
            appearance.useDefaultPurple = false;
            appearance.autoLegGapSize = 0.0F;
            appearance.purpleC = 0.32F;
            appearance.purpleY = 1.00F;
            appearance.purpleM = 0;
            appearance.purpleK = 0.30F;

            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\marymoor.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();
            coursePrintSettings.CropLargePrintArea = false;
            coursePrintSettings.PrintingColorModel = ColorModel.RGB;

            coursePrintSettings.CourseIds = new Id<Course>[] { CourseId(1), CourseId(2), CourseId(0) };
            CoursePrintingTest("courseprinting\\test2", coursePrintSettings, appearance);
        }
        public void PrintBitmapBaseMap()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\Lincoln Park.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();
            coursePrintSettings.CropLargePrintArea = true;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id<Course>[] { CourseId(1) };
            CoursePrintingTest("courseprinting\\bitmapbase", coursePrintSettings, new CourseAppearance());
        }
        public void PrintTemplatedBaseMap()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\Template.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();
            coursePrintSettings.CropLargePrintArea = true;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id<Course>[] { CourseId(1) };
            CoursePrintingTest("courseprinting\\templatebase", coursePrintSettings, new CourseAppearance(), 200);
        }
        private void CoursePrintingTest(string basename, CoursePrintSettings coursePrintSettings, CourseAppearance appearance, float dpi = 200)
        {
            GC.Collect();

            // Get the map display
            MapDisplay mapDisplay = new MapDisplay();
            mapDisplay.MapIntensity = 0.6F;
            mapDisplay.AntiAlias = true;
            mapDisplay.SetMapFile(controller.MapType, controller.MapFileName);
            if (controller.MapType == MapType.Bitmap)
                mapDisplay.Dpi = controller.MapDpi;
            mapDisplay.OcadOverprintEffect = appearance.useOcadOverprint;

            // Get the pages of the printing.
            CoursePrinting coursePrinter = new CoursePrinting(controller.GetEventDB(), ui.symbolDB, controller, mapDisplay.CloneToFullIntensity(), coursePrintSettings, appearance);
            Bitmap[] bitmaps = coursePrinter.PrintBitmaps();

            // Check all the pages against the baseline.
            for (int page = 0; page < bitmaps.Length; ++page) {
                Bitmap bm = bitmaps[page];
                string baseFileName = basename + "_page" + (page + 1).ToString();
                TestUtil.CheckBitmapsBase(bm, baseFileName);
                bm.Dispose();
            }

            // Only OCAD maps can be printed in XPS mode.
            if (controller.MapType == MapType.OCAD) {
                // Get the pages of the printing in XPS/WPF mode
                System.Windows.Media.Imaging.BitmapSource[] xpsBitmaps = coursePrinter.PrintXpsBitmaps(dpi);

                // Check all the pages against the baseline.
                for (int page = 0; page < xpsBitmaps.Length; ++page) {
                    var bm = xpsBitmaps[page];
                    string baseFileName = basename + "_xps_page" + (page + 1).ToString();
                    string newFileName = TestUtil.GetTestFile(basename + "_xps_page" + (page + 1).ToString() + "_new");
                    WritePng(bm, newFileName);
                    Bitmap newBitmap = (Bitmap)Image.FromFile(newFileName);

                    // For some reason, the XPS anti-aliasing varies slightly. Allow pixel difference to account.
                    TestUtil.CheckBitmapsBase(newBitmap, baseFileName, 19);
                }
            }
        }
        public void PrintAreasAndPageSizes()
        {
            controller.LoadInitialFile(TestUtil.GetTestFile("courseprinting\\Lincoln Park PrintAreas 2.ppen"), true);
            CoursePrintSettings coursePrintSettings = new CoursePrintSettings();
            coursePrintSettings.CropLargePrintArea = false;
            coursePrintSettings.PrintingColorModel = ColorModel.CMYK;

            coursePrintSettings.CourseIds = new Id<Course>[] { CourseId(0), CourseId(1), CourseId(2), CourseId(3), CourseId(4) };
            CoursePrintingTest("courseprinting\\areas", coursePrintSettings, new CourseAppearance());
        }