예제 #1
0
        public void GenerateFromYaml(string yamlPath)
        {
            // Set global variables after starting with a clean slate
            A3Environment.Clean();
            A3Environment.ALLOW_INFER_FROM_SLIDE         = true;
            A3Environment.ALLOW_DEFAULT_INFER_FROM_SLIDE = true;

            // Setup logging
            A3Log log = new A3Log(A3Log.Operations.GenerateFromYaml);

            // Ingest the yaml file
            A3Yaml yaml = new A3Yaml(yamlPath);

            // Lint the YAML file before attempting to deserialize the outline and exit early if the user cancels the operation
            yaml.Lint(log);
            if (A3Environment.QUIT_FROM_CURRENT_LOOP)
            {
                A3Environment.Clean();
                return;
            }

            // Create the outline from the YAML file and exit early if the user cancels the operation
            A3Outline outline = yaml.Deserialize(log);

            if (A3Environment.QUIT_FROM_CURRENT_LOOP)
            {
                A3Environment.Clean();
                return;
            }

            // Open a copy of the model PowerPoint in the current PowerPoint context
            A3Presentation presentation = new A3Presentation(Globals.ThisAddIn.Application.Presentations.Open(A3Environment.MODEL_POWERPOINT, 0, 0, Microsoft.Office.Core.MsoTriState.msoTrue));

            // Save the presentation to a unqiue location
            presentation.SavePresentationAs(outline.Course);

            // Generate the Presentation
            presentation.WriteFromOutline(outline);

            // Cleanup the initial slides
            for (int i = 0; i < 6; i++)
            {
                presentation.Presentation.Slides[1].Delete();
            }

            // Save the generated presentation and handoff control back to the user
            presentation.Presentation.Save();
            MessageBox.Show(A3Yaml.AlertMessages[A3Yaml.Alerts.YamlGenSuccess].Replace("{}", Path), "POWERPOINT GENERATION COMPLETE!", MessageBoxButtons.OK);
            A3Environment.Clean();
        }