Exemplo n.º 1
0
        private void createOcadFilesMenu_Click(object sender, EventArgs e)
        {
            MapFileFormatKind restrictToKind;  // restrict to outputting this kind of map.
            if (mapDisplay.MapType == MapType.OCAD) {
                restrictToKind = mapDisplay.MapVersion.kind;
            }
            else {
                restrictToKind = MapFileFormatKind.None;
            }

            // Get the settings for the dialog. If we've previously show the dialog, then
            // use the previous settings. Note that the previous settings are wiped out when a new map file
            // is loaded.

            OcadCreationSettings settings;
            if (ocadCreationSettingsPrevious != null)
            {
                settings = ocadCreationSettingsPrevious.Clone();
                if (restrictToKind != MapFileFormatKind.None & restrictToKind != ocadCreationSettingsPrevious.fileFormat.kind) {
                    settings.fileFormat = mapDisplay.MapVersion;
                }
            }
            else {
                // Default settings: creating in file directory, use format of the current map file.
                settings = new OcadCreationSettings();

                settings.fileDirectory = true;
                settings.mapDirectory = false;
                settings.outputDirectory = Path.GetDirectoryName(controller.FileName);
                if (mapDisplay.MapType == MapType.OCAD) {
                    settings.fileFormat = mapDisplay.MapVersion;
                }
                else {
                    settings.fileFormat = new MapFileFormat(MapFileFormatKind.OCAD, 8);  // TODO: Maybe change the default to OpenMapper?
                }
            }

            // Get the correct purple color to use.
            FindPurple.GetPurpleColor(mapDisplay, controller.GetCourseAppearance(), out settings.colorOcadId, out settings.cyan, out settings.magenta, out settings.yellow, out settings.black, out settings.purpleOverprint);

            // Initialize the dialog.
            // CONSIDER: shouldn't have GetEventDB here! Do something different.
            CreateOcadFiles createOcadFilesDialog = new CreateOcadFiles(controller.GetEventDB(), restrictToKind, controller.CreateOcadFilesText(false));
            createOcadFilesDialog.OcadCreationSettings = settings;

            // show the dialog; on success, create the files.
            while (createOcadFilesDialog.ShowDialog(this) == DialogResult.OK) {
                List<string> overwritingFiles = controller.OverwritingOcadFiles(createOcadFilesDialog.OcadCreationSettings);
                if (overwritingFiles.Count > 0) {
                    OverwritingOcadFilesDialog overwriteDialog = new OverwritingOcadFilesDialog();
                    overwriteDialog.Filenames = overwritingFiles;
                    if (overwriteDialog.ShowDialog(this) == DialogResult.Cancel)
                        continue;
                }

                // Save settings persisted between invocations of this dialog.
                ocadCreationSettingsPrevious = createOcadFilesDialog.OcadCreationSettings;
                controller.CreateOcadFiles(createOcadFilesDialog.OcadCreationSettings);

                // PP keeps bitmaps in memory and locks them. Tell the user to close PP.
                if (mapDisplay.MapType == MapType.Bitmap)
                    InfoMessage(MiscText.ClosePPBeforeLoadingOCAD);

                break;
            }

            // And the dialog is done.
            createOcadFilesDialog.Dispose();
        }
Exemplo n.º 2
0
        private void createRouteGadgetFilesMenu_Click(object sender, EventArgs e)
        {
            // Get the settings for the dialog. If we've previously show the dialog, then
            // use the previous settings. Note that the previous settings are wiped out when a new map file
            // is loaded.
            RouteGadgetCreationSettings settings;
            if (routeGadgetCreationSettingsPrevious != null)
                settings = routeGadgetCreationSettingsPrevious.Clone();
            else {
                // Default settings: creating in file directory, use format of the current map file.
                settings = new RouteGadgetCreationSettings();

                settings.fileDirectory = true;
                settings.mapDirectory = false;
                settings.outputDirectory = Path.GetDirectoryName(controller.FileName);
                settings.fileBaseName = Path.GetFileNameWithoutExtension(controller.FileName);
            }

            // Initialize the dialog.
            // CONSIDER: shouldn't have GetEventDB here! Do something different.
            CreateRouteGadgetFiles createRouteGadgetFilesDialog = new CreateRouteGadgetFiles(controller.GetEventDB());
            createRouteGadgetFilesDialog.RouteGadgetCreationSettings = settings;

            // show the dialog; on success, create the files.
            while (createRouteGadgetFilesDialog.ShowDialog(this) == DialogResult.OK) {
                List<string> overwritingFiles = controller.OverwritingRouteGadgetFiles(createRouteGadgetFilesDialog.RouteGadgetCreationSettings);
                if (overwritingFiles.Count > 0) {
                    OverwritingOcadFilesDialog overwriteDialog = new OverwritingOcadFilesDialog();
                    overwriteDialog.Filenames = overwritingFiles;
                    if (overwriteDialog.ShowDialog(this) == DialogResult.Cancel)
                        continue;
                }

                // Save settings persisted between invocations of this dialog.
                routeGadgetCreationSettingsPrevious = createRouteGadgetFilesDialog.RouteGadgetCreationSettings;
                controller.CreateRouteGadgetFiles(createRouteGadgetFilesDialog.RouteGadgetCreationSettings);

                break;
            }

            // And the dialog is done.
            createRouteGadgetFilesDialog.Dispose();
        }
Exemplo n.º 3
0
        private void createCoursePdfMenu_Click(object sender, EventArgs e)
        {
            if (! CheckForNonRenderableObjects(false, true))
                return;

            bool isPdfMap = controller.MapType == MapType.PDF;

            CoursePdfSettings settings;
            if (coursePdfSettings != null)
                settings = coursePdfSettings.Clone();
            else {
                // Default settings: creating in file directory
                settings = new CoursePdfSettings();

                settings.fileDirectory = true;
                settings.mapDirectory = false;
                settings.outputDirectory = Path.GetDirectoryName(controller.FileName);
            }

            if (isPdfMap) {
                // If the map file is a PDF, then created PDF must use that paper size, zero margins, and crop courses to that size.
                settings.CropLargePrintArea = true;
                RectangleF bounds = controller.MapDisplay.MapBounds;
            }

            // Initialize dialog
            CreatePdfCourses createPdfDialog = new CreatePdfCourses(controller.GetEventDB(), controller.AnyMultipart());
            createPdfDialog.controller = controller;
            createPdfDialog.PdfSettings = settings;
            if (isPdfMap) {
                createPdfDialog.EnableChangeCropping = false;
            }

            // show the dialog, on success, print.
            while (createPdfDialog.ShowDialog(this) == DialogResult.OK) {
                List<string> overwritingFiles = controller.OverwritingPdfFiles(createPdfDialog.PdfSettings);
                if (overwritingFiles.Count > 0) {
                    OverwritingOcadFilesDialog overwriteDialog = new OverwritingOcadFilesDialog();
                    overwriteDialog.Filenames = overwritingFiles;
                    if (overwriteDialog.ShowDialog(this) == DialogResult.Cancel)
                        continue;
                }

                // Save the settings for the next invocation of the dialog.
                coursePdfSettings = createPdfDialog.PdfSettings;
                controller.CreateCoursePdfs(coursePdfSettings);

                break;
            }

            // And the dialog is done.
            createPdfDialog.Dispose();
        }