Exemple #1
0
        /// <summary>
        /// Exports the mission briefing to an HTML or image file.
        /// </summary>
        /// <param name="fileFormat">The file format to export to.</param>
        private void ExportBriefing(BriefingExportFileFormat fileFormat)
        {
            if (Mission == null)
            {
                return;                  // No mission has been generated, nothing to export.
            }
            string defaultFileName = HQTools.RemoveInvalidFileNameCharacters(Mission.BriefingName ?? "");

            if (string.IsNullOrEmpty(defaultFileName))
            {
                defaultFileName = "NewMission";
            }

            string briefingFilePath = GUITools.ShowSaveFileDialog(
                fileFormat.ToString().ToLowerInvariant(), HQTools.GetDCSMissionPath(),
                defaultFileName, $"{fileFormat.ToString().ToUpperInvariant()} files");

            if (briefingFilePath == null)
            {
                return;
            }

            bool result;

            using (HTMLExporter briefingExporter = new HTMLExporter())
            {
                switch (fileFormat)
                {
                default: return;

                case BriefingExportFileFormat.Html: result = briefingExporter.ExportToHTML(briefingFilePath, Mission.BriefingHTML); break;

                case BriefingExportFileFormat.Jpg: result = briefingExporter.ExportToJPEG(briefingFilePath, Mission.BriefingHTML); break;

                case BriefingExportFileFormat.Png: result = briefingExporter.ExportToPNG(briefingFilePath, Mission.BriefingHTML); break;
                }
            }

            if (!result)
            {
                MessageBox.Show("Failed to export briefing", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }