示例#1
0
        public void Lint(A3Log log)
        {
            ConvertIncomingYamlKeys(log);
            string tempFile = System.IO.Path.GetTempFileName();

            File.WriteAllText(tempFile, Text);
            A3Yaml yaml = new A3Yaml(tempFile);

            bool returnedError = yaml.RunSyntaxLinter(log);

            if (returnedError)
            {
                Process.Start(log.Path);
                Process.Start(Path);

                // check to see if the user wants to retry
                DialogResult dialogResult = MessageBox.Show(AlertMessages[Alerts.SyntaxError], "YAML SYNTAX ERROR!", MessageBoxButtons.RetryCancel);
                if (dialogResult == DialogResult.Retry)
                {
                    Lint(log);
                }
                else
                {
                    A3Environment.QUIT_FROM_CURRENT_LOOP = true;
                }
                return;
            }
            return;
        }
示例#2
0
        public A3Outline Deserialize(A3Log log)
        {
            IDeserializer deserializer = new DeserializerBuilder().WithNamingConvention(new CamelCaseNamingConvention()).Build();
            A3Outline     outline      = new A3Outline();

            try
            {
                outline = deserializer.Deserialize <A3Outline>(Text);
                return(outline);
            }
            catch (Exception ex)
            {
                log.Write(A3Log.Level.Error, ex.Message);
                Process.Start(log.Path);
                Process.Start(Path);
                DialogResult dialogResult = MessageBox.Show(AlertMessages[Alerts.DeserializationError].Replace("{}", ex.Message), "DESERIALIZATION ERROR!", MessageBoxButtons.RetryCancel);
                if (dialogResult == DialogResult.Retry)
                {
                    A3Yaml a3Yaml = new A3Yaml(Path);
                    a3Yaml.Lint(log);
                    return(Deserialize(log));
                }
                A3Environment.QUIT_FROM_CURRENT_LOOP = true;
                return(outline);
            }
        }
示例#3
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();
        }