Exemplo n.º 1
0
        // Create a single PDF file
        void CreateOneBitmap(string fileName, CourseDesignator courseDesignator)
        {
            RectangleF mapRectangle = controller.GetCurrentPrintAreaRectangle(courseDesignator);

            // Get the course view for the course we are printing.
            CourseView courseView = CourseView.CreatePrintingCourseView(eventDB, courseDesignator);

            // Get the correct purple color to print the course in.
            short ocadId;
            float purpleC, purpleM, purpleY, purpleK;
            bool  purpleOverprint;

            FindPurple.GetPurpleColor(mapDisplay, appearance, out ocadId, out purpleC, out purpleM, out purpleY, out purpleK, out purpleOverprint);

            // Create a course layout from the view.
            CourseLayout layout = new CourseLayout();

            layout.SetLayerColor(CourseLayer.Descriptions, NormalCourseAppearance.blackColorOcadId, NormalCourseAppearance.blackColorName, NormalCourseAppearance.blackColorC, NormalCourseAppearance.blackColorM, NormalCourseAppearance.blackColorY, NormalCourseAppearance.blackColorK, false);
            layout.SetLayerColor(CourseLayer.MainCourse, ocadId, NormalCourseAppearance.courseColorName, purpleC, purpleM, purpleY, purpleK, purpleOverprint);
            CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, layout, CourseLayer.MainCourse);

            // Set the course layout into the map display
            mapDisplay.SetCourse(layout);
            mapDisplay.SetPrintArea(null);

            ExportBitmap exportBitmap = new ExportBitmap(mapDisplay);

            exportBitmap.CreateBitmap(fileName, mapRectangle, GetImageFormat(), bitmapCreationSettings.Dpi,
                                      bitmapCreationSettings.WorldFile ? mapDisplay.CoordinateMapper : null);
        }
Exemplo n.º 2
0
        CourseLayout CreateCourseLayout(CourseView courseView)
        {
            // Create the CourseLayout.
            CourseLayout courseLayout = new CourseLayout();

            courseLayout.SetLayerColor(CourseLayer.Descriptions, NormalCourseAppearance.blackColorOcadId, NormalCourseAppearance.blackColorName, NormalCourseAppearance.blackColorC, NormalCourseAppearance.blackColorM, NormalCourseAppearance.blackColorY, NormalCourseAppearance.blackColorK, false);
            courseLayout.SetLayerColor(CourseLayer.MainCourse, NormalCourseAppearance.courseOcadId, NormalCourseAppearance.courseColorName,
                                       creationSettings.cyan, creationSettings.magenta, creationSettings.yellow, creationSettings.black, creationSettings.purpleOverprint);
            CourseFormatter.FormatCourseToLayout(symbolDB, courseView, courseAppearance, courseLayout, CourseLayer.MainCourse);

            return(courseLayout);
        }
Exemplo n.º 3
0
 // Update the topology
 void UpdateTopology()
 {
     if (topologyCourseView == null) {
         activeTopologyCourseLayout = null;
     }
     else {
         // Place the active course in the layout.
         activeTopologyCourseLayout = new CourseLayout();
         activeTopologyCourseLayout.SetLayerColor(CourseLayer.AllVariations, 1, NormalCourseAppearance.blackColorName, 0, 0, 0, 0.55F, false);
         activeTopologyCourseLayout.SetLayerColor(CourseLayer.MainCourse, NormalCourseAppearance.blackColorOcadId, NormalCourseAppearance.blackColorName, NormalCourseAppearance.blackColorC, NormalCourseAppearance.blackColorM, NormalCourseAppearance.blackColorY, NormalCourseAppearance.blackColorK, false);
         activeTopologyCourseLayout.SetLayerColor(CourseLayer.InvisibleObjects, 2, "DropTargets", 0, 0, 0, 0, false);
         TopologyFormatter formatter = new TopologyFormatter();
         formatter.FormatCourseToLayout(symbolDB, topologyCourseView, activeCourseView, activeTopologyCourseLayout, selectedCourseControl, selectedCourseControl2, CourseLayer.AllVariations, CourseLayer.MainCourse);
     }
 }
Exemplo n.º 4
0
        // The core printing routine.
        void DrawPage(IGraphicsTarget graphicsTarget, CoursePage page)
        {
            // Get the course view for the course we are printing.
            CourseView courseView = CourseView.CreatePrintingCourseView(eventDB, page.courseDesignator);

            // Get the correct purple color to print the course in.
            short ocadId;
            float purpleC, purpleM, purpleY, purpleK;
            bool  purpleOverprint;

            FindPurple.GetPurpleColor(mapDisplay, appearance, out ocadId, out purpleC, out purpleM, out purpleY, out purpleK, out purpleOverprint);

            // Create a course layout from the view.
            CourseLayout layout = new CourseLayout();

            layout.SetLayerColor(CourseLayer.Descriptions, NormalCourseAppearance.blackColorOcadId, NormalCourseAppearance.blackColorName, NormalCourseAppearance.blackColorC, NormalCourseAppearance.blackColorM, NormalCourseAppearance.blackColorY, NormalCourseAppearance.blackColorK, false);
            layout.SetLayerColor(CourseLayer.MainCourse, ocadId, NormalCourseAppearance.courseColorName, purpleC, purpleM, purpleY, purpleK, purpleOverprint);
            CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, layout, CourseLayer.MainCourse);

            // Set the course layout into the map display
            mapDisplay.SetCourse(layout);
            mapDisplay.SetPrintArea(null);

            // Set the transform, and the clip.
            Matrix transform = Geometry.CreateInvertedRectangleTransform(page.mapRectangle, page.printRectangle);

            PushRectangleClip(graphicsTarget, page.printRectangle);
            graphicsTarget.PushTransform(transform);
            // Determine the resolution in map coordinates.
            Matrix inverseTransform = transform.Clone();

            inverseTransform.Invert();
            float minResolutionPage = 100F / 2400F;  // Assume 2400 DPI as the base resolution, to get very accurate print.
            float minResolutionMap  = Geometry.TransformDistance(minResolutionPage, inverseTransform);

            // And draw.
            mapDisplay.Draw(graphicsTarget, page.mapRectangle, minResolutionMap);

            graphicsTarget.PopTransform();
            graphicsTarget.PopClip();
        }
Exemplo n.º 5
0
        // Update the course
        void UpdateCourse()
        {
            CourseAppearance appearance = controller.GetCourseAppearance();

            // Get purple color.
            short purpleOcadId;
            float purpleC, purpleM, purpleY, purpleK;
            bool purpleOverprint;
            controller.GetPurpleColor(out purpleOcadId, out purpleC, out purpleM, out purpleY, out purpleK, out purpleOverprint);

            // Place the active course in the layout.
            activeCourse = new CourseLayout();
            activeCourse.SetLayerColor(CourseLayer.Descriptions, NormalCourseAppearance.blackColorOcadId, NormalCourseAppearance.blackColorName, NormalCourseAppearance.blackColorC, NormalCourseAppearance.blackColorM, NormalCourseAppearance.blackColorY, NormalCourseAppearance.blackColorK, false);
            activeCourse.SetLayerColor(CourseLayer.MainCourse, NormalCourseAppearance.courseOcadId, NormalCourseAppearance.courseColorName, purpleC, purpleM, purpleY, purpleK, 
                                       (purpleOverprint && (extraCourses == null || extraCourses.Count == 0))); 
            CourseFormatter.FormatCourseToLayout(symbolDB, activeCourseView, appearance, activeCourse, CourseLayer.MainCourse);

            if (showAllControls && !activeCourseDesignator.IsAllControls) {
                // Create the all controls view.
                CourseView allControlsView = CourseView.CreateFilteredAllControlsView(eventDB, new CourseDesignator[] { activeCourseDesignator }, allControlsFilter, 
                    new CourseViewOptions() { showNonDescriptionSpecials = false, showDescriptionSpecials = false });

                // Add it to the CourseLayout.
                activeCourse.SetLayerColor(CourseLayer.AllControls, NormalCourseAppearance.allControlsOcadId, NormalCourseAppearance.allControlsColorName,
                    NormalCourseAppearance.allControlsColorC, NormalCourseAppearance.allControlsColorM, NormalCourseAppearance.allControlsColorY, NormalCourseAppearance.allControlsColorK, purpleOverprint);
                CourseFormatter.FormatCourseToLayout(symbolDB, allControlsView, appearance, activeCourse, CourseLayer.AllControls);
            }

            if (extraCourses != null && extraCourses.Count > 0) {
                for (int i = 0; i < extraCourses.Count; ++i) {
                    Id<Course> courseId = extraCourses[i];
                    if (eventDB.IsCoursePresent(courseId)) {
                        AddExtraCourseToLayout(activeCourse, courseId, i % CourseLayout.EXTRACOURSECOUNT);
                    }
                }
            }
        }
Exemplo n.º 6
0
        // extraCourseIndex indicates the color/layer.
        private void AddExtraCourseToLayout(CourseLayout courseLayout, Id<Course> courseId, int extraCourseIndex)
        {
            if (extraCourseIndex >= CourseLayout.EXTRACOURSECOUNT)
                return;

            CourseAppearance appearance = controller.GetCourseAppearance();
            CourseLayer layer = CourseLayer.OtherCourse1 + extraCourseIndex;

            // Create the course view.
            CourseView courseView = CourseView.CreateCourseView(eventDB, new CourseDesignator(courseId),
                new CourseViewOptions() { showNonDescriptionSpecials = false, showDescriptionSpecials = false, showControlNumbers = false });

            // Add it to the CourseLayout.
            courseLayout.SetLayerColor(layer, (short) (NormalCourseAppearance.extraCourseOcadId + extraCourseIndex), 
                                              string.Format(NormalCourseAppearance.allControlsColorName, extraCourseIndex + 1),
                                              NormalCourseAppearance.extraCourseC[extraCourseIndex],
                                              NormalCourseAppearance.extraCourseM[extraCourseIndex],
                                              NormalCourseAppearance.extraCourseY[extraCourseIndex],
                                              NormalCourseAppearance.extraCourseK[extraCourseIndex],
                                              false);

            CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, courseLayout, layer,
                new CourseFormatterOptions() { showControlNumbers = false });
        }
Exemplo n.º 7
0
        // The core printing routine. The origin of the graphics is the upper-left of the margins,
        // and the printArea in the size to draw into (in hundreths of an inch).
        protected override void DrawPage(IGraphicsTarget graphicsTarget, int pageNumber, SizeF printArea, float dpi)
        {
            CoursePage page = pages[pageNumber];

            // Get the course view for the course we are printing.
            CourseView courseView = CourseView.CreatePrintingCourseView(eventDB, page.courseDesignator);

            // Get the correct purple color to print the course in.
            short ocadId;
            float purpleC, purpleM, purpleY, purpleK;
            bool  purpleOverprint;

            FindPurple.GetPurpleColor(mapDisplay, appearance, out ocadId, out purpleC, out purpleM, out purpleY, out purpleK, out purpleOverprint);

            // Create a course layout from the view.
            CourseLayout layout = new CourseLayout();

            layout.SetLayerColor(CourseLayer.Descriptions, NormalCourseAppearance.blackColorOcadId, NormalCourseAppearance.blackColorName, NormalCourseAppearance.blackColorC, NormalCourseAppearance.blackColorM, NormalCourseAppearance.blackColorY, NormalCourseAppearance.blackColorK, false);
            layout.SetLayerColor(CourseLayer.MainCourse, ocadId, NormalCourseAppearance.courseColorName, purpleC, purpleM, purpleY, purpleK, purpleOverprint);
            CourseFormatter.FormatCourseToLayout(symbolDB, courseView, appearance, layout, CourseLayer.MainCourse);

            // Set the course layout into the map display
            mapDisplay.SetCourse(layout);
            this.mapDisplay.SetPrintArea(null);

            // Collecting garbage should make out of memory less common.
            GC.Collect();

            if (graphicsTarget is GDIPlus_GraphicsTarget)
            {
                // We print to intermediate bands of bitmaps. This is the only way to get purple blending correct.
                // Other code ensure that if purple blending is on, we always take this code path.

                GDIPlus_GraphicsTarget gdiGraphicsTarget = ((GDIPlus_GraphicsTarget)graphicsTarget);
                Graphics g = gdiGraphicsTarget.Graphics;
                // Save and restore state so we can mess with stuff.
                GraphicsState graphicsState = g.Save();

                // Printing via a bitmap. Works best with some print drivers.
                dpi = AdjustDpi(dpi);

                const long        MAX_PIXELS_PER_BAND = 20000000; // 20M pixels = 60M bytes (3 bytes per pixel).
                List <CoursePage> bands = BandPageToLimitBitmapSize(page, dpi, MAX_PIXELS_PER_BAND);

                // Create the bitmap. Can do this once because each band is the same size.
                int    bitmapWidth  = (int)Math.Round(bands[0].printRectangle.Width * dpi / 100F);
                int    bitmapHeight = (int)Math.Round(bands[0].printRectangle.Height * dpi / 100F);
                Bitmap bitmap       = new Bitmap(bitmapWidth, bitmapHeight, System.Drawing.Imaging.PixelFormat.Format24bppRgb);

                foreach (CoursePage band in bands)
                {
                    // Set the transform
                    Matrix transform = Geometry.CreateInvertedRectangleTransform(band.mapRectangle, new RectangleF(0, 0, bitmapWidth, bitmapHeight));
                    mapDisplay.Draw(bitmap, transform);

                    try {
                        // Draw the bitmap on the printer.
                        g.DrawImage(bitmap, band.printRectangle);
                    }
                    catch (Exception) { }
                }

                // restore state.
                g.Restore(graphicsState);
                bitmap.Dispose();
            }
            else
            {
                // Print directly. Used only when prerasterization is off.
                // Set the transform, and the clip.
                Matrix transform = Geometry.CreateInvertedRectangleTransform(page.mapRectangle, page.printRectangle);
                PushRectangleClip(graphicsTarget, page.printRectangle);
                graphicsTarget.PushTransform(transform);
                // Determine the resolution in map coordinates.
                Matrix inverseTransform = transform.Clone();
                inverseTransform.Invert();
                float minResolutionPage = 100F / dpi;
                float minResolutionMap  = Geometry.TransformDistance(minResolutionPage, inverseTransform);

                // And draw.
                mapDisplay.Draw(graphicsTarget, page.mapRectangle, minResolutionMap);

                graphicsTarget.PopTransform();
                graphicsTarget.PopClip();
            }
        }