Beispiel #1
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);
            }
        }
        private void btnPublish_Click(object sender, EventArgs e)
        {
            A3Environment.StartUp();

            A3Log log = new A3Log(A3Log.Operations.Publish);

            A3Presentation presentation = new A3Presentation(Globals.ThisAddIn.Application.ActivePresentation);
            A3Outline      outline      = presentation.GenerateOutline(log);

            if (chkPNG.Checked)
            {
                presentation.PublishPNGs();
            }
            if (chkMarkdown.Checked)
            {
                presentation.PublishMarkdown();
            }
            if (chkPDF.Checked)
            {
                presentation.PublishPDF();
            }
            if (chkYAML.Checked)
            {
                presentation.PublishYaml();
            }

            Dispose();
        }
 public void WriteFromOutline(A3Outline outline)
 {
     GenerateCourseSlide(outline.Course, outline.Filename, outline.HasLabs, outline.HasSlides, outline.HasVideos, outline.Weburl);
     GenerateTOCSlide(outline.Course);
     Presentation.SectionProperties.AddBeforeSlide(1, outline.Course);
     GenerateChapterSlides(outline.Chapters);
     GenerateEndOfDeckSlide(outline.Course);
     GenerateQuizSlide();
 }
        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();
        }
        public A3Outline GenerateOutline(A3Log log)
        {
            // Set Enviornment
            A3Environment.Clean();

            // Create new blank outline
            A3Outline outline = new A3Outline();

            // Get the course info
            (outline.Course, outline.Filename, outline.HasLabs, outline.HasSlides, outline.HasVideos, outline.Weburl) = GetCourseInfo(log);

            // Retrieve each of the chapters contents. Each chapter will recurse its own internal tree to collect all the related content ie(subchapters and their content as well. ).
            outline.Chapters = GetChapters(log);

            // Return the outline
            return(outline);
        }