// Set the courses being displayed. public void SetCourse(CourseLayout newCourse) { if (!object.Equals(course, newCourse)) { course = newCourse; if (course == null) { courseMap = null; } else { courseMap = course.RenderToMap(new CourseLayout.MapRenderOptions()); } RaiseChanged(null); } }
// Write a map to the given file name. void ExportMap(CourseView courseView, string outputFilename) { // Create the CourseLayout. CourseLayout courseLayout = CreateCourseLayout(courseView); // OCAD 6-10 cannot handle images in the layout layer, and OOM doesn't have a layout layer. CourseLayout.MapRenderOptions mapRenderOptions = new CourseLayout.MapRenderOptions(); if ((creationSettings.fileFormat.kind == MapFileFormatKind.OCAD && creationSettings.fileFormat.version <= 10) || creationSettings.fileFormat.kind == MapFileFormatKind.OpenMapper) { mapRenderOptions.RenderImagesAsTemplates = true; } else { mapRenderOptions.RenderImagesAsTemplates = false; } // Create the map and write it out. Map map = courseLayout.RenderToMap(mapRenderOptions); using (map.Write()) { map.MapScale = courseView.MapScale; map.PrintScale = courseView.PrintScale; map.PrintArea = controller.GetCurrentPrintAreaRectangle(courseView.CourseDesignator); switch (controller.MapType) { case MapType.OCAD: // Set OCAD map as template. // OCAD 6 doesn't support another OCAD file as a template. if (!(creationSettings.fileFormat.kind == MapFileFormatKind.OCAD && creationSettings.fileFormat.version <= 6)) { AddTemplateToMap(map, new TemplateInfo(controller.MapFileName, new PointF(0, 0), 0, 0, true)); } // Use same real world coordinates as underlying map (nicer, but also works around bug in OCAD 11 // where background maps with real world coordinates aren't displayed if the map map doesn't have same real // world coordinates). map.RealWorldCoords = controller.MapRealWorldCoords; break; case MapType.Bitmap: case MapType.PDF: // Set bitmap as template. PointF centerPoint = Geometry.RectCenter(controller.MapDisplay.MapBounds); ImageFormat imageFormat; string mapFileName; float dpi; if (CreateBitmapFile()) { // Write a copy of the bitmap map. mapFileName = CreateBitmapFileName(out imageFormat); controller.MapDisplay.WriteBitmapMap(mapFileName, imageFormat, out dpi); } else { // Use existing map file. mapFileName = controller.MapFileName; dpi = controller.MapDpi; } AddTemplateToMap(map, new TemplateInfo(mapFileName, centerPoint, dpi, 0, true)); break; case MapType.None: break; default: Debug.Fail("Unexpected map type"); break; } } WriteImageBitmaps(map); InputOutput.WriteFile(outputFilename, map, creationSettings.fileFormat); }